Skip to content

Commit 55a2f55

Browse files
Add a table for the paused migrators category (#2262)
* Add a table for the paused migrations. * Add a table for the paused migrations. * Update src/components/StatusDashboard/current_migrations.jsx Co-authored-by: jaimergp <[email protected]> * Address review comment. * Add a condition to explicitly display a zero when there is no paused migrations. * Revert previous condition on paused to take [] case into account. * Update src/components/StatusDashboard/current_migrations.jsx Co-authored-by: jaimergp <[email protected]> * Add logics to detect if fetching is finished and display either the number of migrations or 3 periods depending on the result. --------- Co-authored-by: jaimergp <[email protected]>
1 parent 6267a80 commit 55a2f55

File tree

2 files changed

+32
-10
lines changed

2 files changed

+32
-10
lines changed

src/components/StatusDashboard/current_migrations.jsx

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,15 @@ const SORT_KEY = "migration-sort";
1111
export default function CurrentMigrations({ onLoad }) {
1212
const [state, setState] = useState({
1313
closed: [],
14-
collapsed: { closed: true, longterm: true, regular: true },
14+
collapsed: { closed: true, longterm: true, paused: true, regular: true},
1515
longterm: [],
16+
paused: [],
1617
regular: [],
1718
sort: {
1819
closed: { by: "name", order: "ascending" },
1920
longterm: { by: "name", order: "ascending" },
20-
regular: { by: "name", order: "ascending" }
21+
paused: { by: "name", order: "ascending" },
22+
regular: { by: "name", order: "ascending" },
2123
}
2224
});
2325
const resort = (group) => {
@@ -59,9 +61,10 @@ export default function CurrentMigrations({ onLoad }) {
5961
return { ...prev, collapsed: updated };
6062
});
6163
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 (
6568
<div className="card" style={{ overflow: 'auto' }}>
6669
<div className="card__header">
6770
<h3>
@@ -78,6 +81,7 @@ export default function CurrentMigrations({ onLoad }) {
7881
rows={longterm}
7982
select={() => select("longterm")}
8083
sort={state.sort.longterm}
84+
fetched={fetched}
8185
/>
8286
</table>
8387
<table className={styles.migrations_table}>
@@ -88,6 +92,7 @@ export default function CurrentMigrations({ onLoad }) {
8892
rows={regular}
8993
select={() => select("regular")}
9094
sort={state.sort.regular}
95+
fetched={fetched}
9196
/>
9297
</table>
9398
<table className={styles.migrations_table}>
@@ -98,14 +103,26 @@ export default function CurrentMigrations({ onLoad }) {
98103
rows={closed}
99104
select={() => select("closed")}
100105
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}
101118
/>
102119
</table>
103120
</div>
104121
</div>
105122
);
106123
}
107124

108-
function TableContent({ collapsed, name, resort, rows, select, sort }) {
125+
function TableContent({ collapsed, name, resort, rows, select, sort, fetched }) {
109126
const [redirect, setState] = useState('');
110127
if (redirect) return (<Redirect to={redirect} replace={false} push={true} />);
111128
return (
@@ -114,7 +131,7 @@ function TableContent({ collapsed, name, resort, rows, select, sort }) {
114131
<tr onClick={select}>
115132
<th colSpan={8} className={collapsed ? styles.collapsed : undefined}>
116133
{name}{" "}
117-
<span className="badge badge--secondary">{rows.length || "…"}</span>
134+
<span className="badge badge--secondary">{fetched ? rows.length : "…" }</span>
118135
</th>
119136
</tr>
120137
<tr className={collapsed ? styles.collapsed : undefined}>
@@ -234,10 +251,11 @@ function fetchContent(onLoad, setState) {
234251
const sort = {
235252
closed: window.localStorage.getItem(`${SORT_KEY}-closed`),
236253
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`)
238256
};
239257
if (collapsed) local.collapsed = JSON.parse(collapsed);
240-
["closed", "longterm", "regular"].forEach(group => {
258+
["closed", "longterm", "regular", "paused"].forEach(group => {
241259
if (!sort[group]) return;
242260
local.sort = local.sort || {};
243261
local.sort[group] = JSON.parse(sort[group])
@@ -280,7 +298,8 @@ function fetchContent(onLoad, setState) {
280298
const sort = {
281299
closed: patch.sort?.closed || prev.sort.closed,
282300
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
284303
};
285304
const result = {
286305
...prev,
@@ -289,6 +308,7 @@ function fetchContent(onLoad, setState) {
289308
closed: fetched.closed.sort(compare(sort.closed.by, sort.closed.order)),
290309
longterm: fetched.longterm.sort(compare(sort.longterm.by, sort.longterm.order)),
291310
regular: fetched.regular.sort(compare(sort.regular.by, sort.regular.order)),
311+
paused: fetched.paused.sort(compare(sort.paused.by, sort.paused.order)),
292312
};
293313
return result;
294314
});

src/constants.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ export const urls = {
8585
"https://raw.githubusercontent.com/regro/cf-graph-countyfair/master/status/closed_status.json",
8686
longterm:
8787
"https://raw.githubusercontent.com/regro/cf-graph-countyfair/master/status/longterm_status.json",
88+
paused:
89+
"https://raw.githubusercontent.com/regro/cf-graph-countyfair/master/status/paused_status.json",
8890
regular:
8991
"https://raw.githubusercontent.com/regro/cf-graph-countyfair/master/status/regular_status.json",
9092
},

0 commit comments

Comments
 (0)