1
1
import { Redirect , useLocation } from "@docusaurus/router" ;
2
2
import useDocusaurusContext from "@docusaurus/useDocusaurusContext" ;
3
3
import { urls } from "@site/src/constants" ;
4
+ import Admonition from "@theme/Admonition" ;
4
5
import Layout from "@theme/Layout" ;
5
6
import React , { useEffect , useState } from "react" ;
6
7
import SVG from 'react-inlinesvg' ;
@@ -70,6 +71,7 @@ export default function MigrationDetails() {
70
71
const url = urls . migrations . details . replace ( "<NAME>" , state . name ) ;
71
72
const details = await ( await fetch ( url ) ) . json ( ) ;
72
73
details . progress = measureProgress ( details ) ;
74
+ details . paused_or_closed = await checkPausedOrClosed ( name ) ;
73
75
setState ( ( prev ) => ( { ...prev , details, view : view || prev . view } ) ) ;
74
76
} catch ( error ) {
75
77
console . warn ( `error loading migration: ${ state . name } ` , error ) ;
@@ -95,10 +97,15 @@ export default function MigrationDetails() {
95
97
< div style = { { clear : "both" } } > </ div >
96
98
</ div >
97
99
< div className = "card__body" style = { { overflow : "auto" } } >
98
- { details && < Bar details = { details } /> }
100
+ { ( details && details . paused_or_closed === "paused" ) ?
101
+ < Admonition type = "note" > This migration is currently paused.</ Admonition > : null }
102
+ { ( details && details . paused_or_closed === "closed" ) ?
103
+ < Admonition type = "note" > This migration has been closed recently.</ Admonition > : null }
104
+ { details && < Bar details = { details } /> || null }
99
105
{ view === "graph" ?
100
106
< Graph > { name } </ Graph > :
101
- ( details && < Table details = { details } /> ) }
107
+ ( details && < Table details = { details } /> )
108
+ }
102
109
</ div >
103
110
</ div >
104
111
</ main >
@@ -114,20 +121,29 @@ function Bar({ details }) {
114
121
< div className = { styles . migration_details_bar } >
115
122
{ ORDERED . filter ( ( [ key ] ) => details [ key ] ?. length ) . map ( ( [ key ] , index ) => (
116
123
< >
117
- < a
118
- id = { `migration-bar-element-${ key } ` }
119
- className = { styles [ `${ prefix } ${ key . replace ( "-" , "_" ) } ` ] }
120
- style = { { flex : details [ key ] . length } }
121
- key = { index }
122
- alt = { TITLES [ key ] + " " + parseFloat ( details [ key ] . length * 100 / measureProgress ( details ) . total ) . toFixed ( 1 ) + "% (" + details [ key ] . length + " PRs over " + measureProgress ( details ) . total + ")" }
123
- > </ a >
124
- < Tooltip
125
- anchorSelect = { `#migration-bar-element-${ key } ` }
126
- place = "top"
127
- className = { styles . migration_details_bar_tooltip }
128
- >
129
- < div > { TITLES [ key ] } </ div >
130
- </ Tooltip >
124
+ < a
125
+ id = { `migration-bar-element-${ key } ` }
126
+ className = { styles [ `${ prefix } ${ key . replace ( "-" , "_" ) } ` ] }
127
+ style = { { flex : details [ key ] . length } }
128
+ key = { `migration-bar-element-href-${ key } ` }
129
+ alt = {
130
+ TITLES [ key ]
131
+ + " "
132
+ + parseFloat ( details [ key ] . length * 100 / measureProgress ( details ) . total ) . toFixed ( 1 )
133
+ + "% (" + details [ key ] . length
134
+ + " PRs over "
135
+ + measureProgress ( details ) . total
136
+ + ")"
137
+ }
138
+ > </ a >
139
+ < Tooltip
140
+ anchorSelect = { `#migration-bar-element-${ key } ` }
141
+ place = "top"
142
+ key = { `migration-bar-element-tooltip-${ key } ` }
143
+ className = { styles . migration_details_bar_tooltip }
144
+ >
145
+ < div > { TITLES [ key ] } </ div >
146
+ </ Tooltip >
131
147
</ >
132
148
) ) }
133
149
</ div >
@@ -300,3 +316,15 @@ function Row({ children }) {
300
316
</ tr > ) }
301
317
</ > ) ;
302
318
}
319
+
320
+ async function checkPausedOrClosed ( name ) {
321
+ for ( const status of [ "paused" , "closed" ] ) {
322
+ try {
323
+ const response = await fetch ( urls . migrations . status [ status ] ) ;
324
+ const data = await response . json ( ) ;
325
+ if ( name in data ) return status ;
326
+ } catch ( error ) {
327
+ console . warn ( `error checking status for ${ name } :` , error ) ;
328
+ }
329
+ }
330
+ }
0 commit comments