@@ -11,13 +11,15 @@ const SORT_KEY = "migration-sort";
11
11
export default function CurrentMigrations ( { onLoad } ) {
12
12
const [ state , setState ] = useState ( {
13
13
closed : [ ] ,
14
- collapsed : { closed : true , longterm : true , regular : true } ,
14
+ collapsed : { closed : true , longterm : true , paused : true , regular : true } ,
15
15
longterm : [ ] ,
16
+ paused : [ ] ,
16
17
regular : [ ] ,
17
18
sort : {
18
19
closed : { by : "name" , order : "ascending" } ,
19
20
longterm : { by : "name" , order : "ascending" } ,
20
- regular : { by : "name" , order : "ascending" }
21
+ paused : { by : "name" , order : "ascending" } ,
22
+ regular : { by : "name" , order : "ascending" } ,
21
23
}
22
24
} ) ;
23
25
const resort = ( group ) => {
@@ -59,9 +61,10 @@ export default function CurrentMigrations({ onLoad }) {
59
61
return { ...prev , collapsed : updated } ;
60
62
} ) ;
61
63
useEffect ( fetchContent ( onLoad , setState ) , [ ] ) ;
62
- const { closed, longterm, regular } = state ;
63
- const total = closed . length + longterm . length + regular . length ;
64
- return (
64
+ const { closed, longterm, paused, regular } = state ;
65
+ const total = closed . length + longterm . length + paused . length + regular . length ;
66
+ const fetched = total > 0 ;
67
+ return (
65
68
< div className = "card" style = { { overflow : 'auto' } } >
66
69
< div className = "card__header" >
67
70
< h3 >
@@ -78,6 +81,7 @@ export default function CurrentMigrations({ onLoad }) {
78
81
rows = { longterm }
79
82
select = { ( ) => select ( "longterm" ) }
80
83
sort = { state . sort . longterm }
84
+ fetched = { fetched }
81
85
/>
82
86
</ table >
83
87
< table className = { styles . migrations_table } >
@@ -88,6 +92,7 @@ export default function CurrentMigrations({ onLoad }) {
88
92
rows = { regular }
89
93
select = { ( ) => select ( "regular" ) }
90
94
sort = { state . sort . regular }
95
+ fetched = { fetched }
91
96
/>
92
97
</ table >
93
98
< table className = { styles . migrations_table } >
@@ -98,14 +103,26 @@ export default function CurrentMigrations({ onLoad }) {
98
103
rows = { closed }
99
104
select = { ( ) => select ( "closed" ) }
100
105
sort = { state . sort . closed }
106
+ fetched = { fetched }
107
+ />
108
+ </ table >
109
+ < table className = { styles . migrations_table } >
110
+ < TableContent
111
+ collapsed = { state . collapsed . paused }
112
+ name = "Paused migrations"
113
+ resort = { resort ( "paused" ) }
114
+ rows = { paused }
115
+ select = { ( ) => select ( "paused" ) }
116
+ sort = { state . sort . paused }
117
+ fetched = { fetched }
101
118
/>
102
119
</ table >
103
120
</ div >
104
121
</ div >
105
122
) ;
106
123
}
107
124
108
- function TableContent ( { collapsed, name, resort, rows, select, sort } ) {
125
+ function TableContent ( { collapsed, name, resort, rows, select, sort, fetched } ) {
109
126
const [ redirect , setState ] = useState ( '' ) ;
110
127
if ( redirect ) return ( < Redirect to = { redirect } replace = { false } push = { true } /> ) ;
111
128
return (
@@ -114,7 +131,7 @@ function TableContent({ collapsed, name, resort, rows, select, sort }) {
114
131
< tr onClick = { select } >
115
132
< th colSpan = { 8 } className = { collapsed ? styles . collapsed : undefined } >
116
133
{ name } { " " }
117
- < span className = "badge badge--secondary" > { rows . length || "…" } </ span >
134
+ < span className = "badge badge--secondary" > { fetched ? rows . length : "…" } </ span >
118
135
</ th >
119
136
</ tr >
120
137
< tr className = { collapsed ? styles . collapsed : undefined } >
@@ -234,10 +251,11 @@ function fetchContent(onLoad, setState) {
234
251
const sort = {
235
252
closed : window . localStorage . getItem ( `${ SORT_KEY } -closed` ) ,
236
253
longterm : window . localStorage . getItem ( `${ SORT_KEY } -longterm` ) ,
237
- regular : window . localStorage . getItem ( `${ SORT_KEY } -regular` )
254
+ regular : window . localStorage . getItem ( `${ SORT_KEY } -regular` ) ,
255
+ paused : window . localStorage . getItem ( `${ SORT_KEY } -paused` )
238
256
} ;
239
257
if ( collapsed ) local . collapsed = JSON . parse ( collapsed ) ;
240
- [ "closed" , "longterm" , "regular" ] . forEach ( group => {
258
+ [ "closed" , "longterm" , "regular" , "paused" ] . forEach ( group => {
241
259
if ( ! sort [ group ] ) return ;
242
260
local . sort = local . sort || { } ;
243
261
local . sort [ group ] = JSON . parse ( sort [ group ] )
@@ -280,7 +298,8 @@ function fetchContent(onLoad, setState) {
280
298
const sort = {
281
299
closed : patch . sort ?. closed || prev . sort . closed ,
282
300
longterm : patch . sort ?. longterm || prev . sort . longterm ,
283
- regular : patch . sort ?. regular || prev . sort . regular
301
+ regular : patch . sort ?. regular || prev . sort . regular ,
302
+ paused : patch . sort ?. paused || prev . sort . paused
284
303
} ;
285
304
const result = {
286
305
...prev ,
@@ -289,6 +308,7 @@ function fetchContent(onLoad, setState) {
289
308
closed : fetched . closed . sort ( compare ( sort . closed . by , sort . closed . order ) ) ,
290
309
longterm : fetched . longterm . sort ( compare ( sort . longterm . by , sort . longterm . order ) ) ,
291
310
regular : fetched . regular . sort ( compare ( sort . regular . by , sort . regular . order ) ) ,
311
+ paused : fetched . paused . sort ( compare ( sort . paused . by , sort . paused . order ) ) ,
292
312
} ;
293
313
return result ;
294
314
} ) ;
0 commit comments