Skip to content

Commit 8399abe

Browse files
Check if the migration is paused or closed, and report it in the details page (#2274)
* check if the migration is paused or closed, and report it * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 55a2f55 commit 8399abe

File tree

1 file changed

+44
-16
lines changed

1 file changed

+44
-16
lines changed

src/pages/status/migration/index.jsx

Lines changed: 44 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Redirect, useLocation } from "@docusaurus/router";
22
import useDocusaurusContext from "@docusaurus/useDocusaurusContext";
33
import { urls } from "@site/src/constants";
4+
import Admonition from "@theme/Admonition";
45
import Layout from "@theme/Layout";
56
import React, { useEffect, useState } from "react";
67
import SVG from 'react-inlinesvg';
@@ -70,6 +71,7 @@ export default function MigrationDetails() {
7071
const url = urls.migrations.details.replace("<NAME>", state.name);
7172
const details = await (await fetch(url)).json();
7273
details.progress = measureProgress(details);
74+
details.paused_or_closed = await checkPausedOrClosed(name);
7375
setState((prev) => ({ ...prev, details, view: view || prev.view }));
7476
} catch (error) {
7577
console.warn(`error loading migration: ${state.name}`, error);
@@ -95,10 +97,15 @@ export default function MigrationDetails() {
9597
<div style={{ clear: "both" }}></div>
9698
</div>
9799
<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}
99105
{view === "graph" ?
100106
<Graph>{name}</Graph> :
101-
(details && <Table details={details} />)}
107+
(details && <Table details={details} />)
108+
}
102109
</div>
103110
</div>
104111
</main>
@@ -114,20 +121,29 @@ function Bar({ details }) {
114121
<div className={styles.migration_details_bar}>
115122
{ORDERED.filter(([key]) => details[key]?.length).map(([key], index) => (
116123
<>
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>
131147
</>
132148
))}
133149
</div>
@@ -300,3 +316,15 @@ function Row({ children }) {
300316
</tr>)}
301317
</>);
302318
}
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

Comments
 (0)