Skip to content

Commit fa65bb5

Browse files
giuseppe-stedutomdonadoni
authored andcommitted
refactor(workflow-badges): centralise list and details components (#394)
Closes #151 Closes #395
1 parent 7f4f1ac commit fa65bb5

19 files changed

+170
-357
lines changed
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
import styles from "./WorkflowBadges.module.scss";
2+
import { Label } from "semantic-ui-react";
3+
import { JupyterNotebookIcon } from "~/components";
4+
import { INTERACTIVE_SESSION_URL } from "~/client";
5+
import { LauncherLabel } from "~/components";
6+
import { getReanaToken } from "~/selectors";
7+
import { useSelector } from "react-redux";
8+
import { statusMapping } from "~/util";
9+
10+
export default function WorkflowBadges({ workflow }) {
11+
const reanaToken = useSelector(getReanaToken);
12+
const {
13+
id,
14+
size,
15+
launcherURL,
16+
session_uri: sessionUri,
17+
session_status: sessionStatus,
18+
} = workflow;
19+
const hasDiskUsage = size.raw > 0;
20+
const isSessionOpen = sessionStatus === "created";
21+
22+
return (
23+
<>
24+
<div className={styles.badgesContainer}>
25+
{workflow.duration && (
26+
<Label
27+
size="tiny"
28+
content={workflow.duration}
29+
icon="clock"
30+
rel="noopener noreferrer"
31+
color={statusMapping[workflow.status].color}
32+
onClick={(e) => e.stopPropagation()}
33+
/>
34+
)}
35+
{hasDiskUsage && (
36+
<Label
37+
size="tiny"
38+
content={size.human_readable}
39+
icon="hdd"
40+
as="a"
41+
href={"/details/" + id}
42+
target="_blank"
43+
rel="noopener noreferrer"
44+
onClick={(e) => e.stopPropagation()}
45+
/>
46+
)}
47+
{isSessionOpen && (
48+
<Label
49+
size="tiny"
50+
content={"Notebook"}
51+
icon={<JupyterNotebookIcon size={12} />}
52+
as="a"
53+
href={INTERACTIVE_SESSION_URL(sessionUri, reanaToken)}
54+
target="_blank"
55+
rel="noopener noreferrer"
56+
onClick={(e) => e.stopPropagation()}
57+
/>
58+
)}
59+
<LauncherLabel url={launcherURL} />
60+
</div>
61+
</>
62+
);
63+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
-*- coding: utf-8 -*-
3+
4+
This file is part of REANA.
5+
Copyright (C) 2023 CERN.
6+
7+
REANA is free software; you can redistribute it and/or modify it
8+
under the terms of the MIT License; see LICENSE file for more details.
9+
*/
10+
11+
.badgesContainer {
12+
display: flex;
13+
14+
a:global(.label) {
15+
margin-left: 15px;
16+
gap: 10px;
17+
18+
&:hover {
19+
cursor: pointer;
20+
filter: opacity(0.8);
21+
}
22+
}
23+
}

reana-ui/src/pages/workflowList/components/WorkflowDetails.js renamed to reana-ui/src/components/WorkflowInfo.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
-*- coding: utf-8 -*-
33
44
This file is part of REANA.
5-
Copyright (C) 2023 CERN.
5+
Copyright (C) 2023, 2024 CERN.
66
77
REANA is free software; you can redistribute it and/or modify it
88
under the terms of the MIT License; see LICENSE file for more details.
@@ -13,10 +13,10 @@ import PropTypes from "prop-types";
1313

1414
import { statusMapping } from "~/util";
1515

16-
import styles from "./WorkflowDetails.module.scss";
17-
import WorkflowProgressCircleBar from "~/pages/workflowList/components/WorkflowProgressCircleBar";
16+
import styles from "./WorkflowInfo.module.scss";
17+
import { WorkflowProgressCircleBar } from "~/components";
1818

19-
export default function WorkflowDetails({ workflow }) {
19+
export default function WorkflowInfo({ workflow }) {
2020
const {
2121
name,
2222
run,
@@ -87,6 +87,6 @@ export default function WorkflowDetails({ workflow }) {
8787
);
8888
}
8989

90-
WorkflowDetails.propTypes = {
90+
WorkflowInfo.propTypes = {
9191
workflow: PropTypes.object.isRequired,
9292
};

reana-ui/src/pages/workflowList/components/WorkflowDetails.module.scss renamed to reana-ui/src/components/WorkflowInfo.module.scss

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,7 @@
1717

1818
.workflow {
1919
color: $raven;
20-
21-
/**FIXME visibility on hover is missing!*/
22-
&.hover {
23-
.actions {
24-
visibility: visible !important;
25-
}
26-
}
20+
font-size: 1.15rem;
2721

2822
&.deleted {
2923
opacity: 0.5;
@@ -47,16 +41,6 @@
4741
.run {
4842
padding-left: 0.8em;
4943
}
50-
51-
.size {
52-
color: $light-gray;
53-
font-size: 0.75em;
54-
margin-right: 0.75em;
55-
56-
&.highlight {
57-
color: $sui-red;
58-
}
59-
}
6044
}
6145

6246
.name,
@@ -73,17 +57,12 @@
7357
width: 210px;
7458
flex-shrink: 0;
7559
display: flex;
76-
justify-content: end;
60+
justify-content: flex-end;
7761
text-align: right;
7862
}
7963

8064
.progressbar-container {
8165
width: 80px;
82-
padding: 10px;
83-
padding-top: 0;
84-
}
85-
86-
.notebook {
87-
font-size: 0.85em;
66+
padding: 0 10px;
8867
}
8968
}

reana-ui/src/pages/workflowList/components/WorkflowProgressCircleBar.js renamed to reana-ui/src/components/WorkflowProgressCircleBar.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export default function WorkflowProgressCircleBar({ workflow }) {
1616

1717
const size = 80;
1818
const strokeWidth = 10;
19-
const radius = size / 2 - strokeWidth;
19+
const radius = (size - strokeWidth) / 2;
2020
const circumference = 2 * Math.PI * radius;
2121

2222
let lengthFinishedArc = (completed / total) * circumference;

reana-ui/src/pages/workflowDetails/components/__tests__/LauncherLabel.test.js renamed to reana-ui/src/components/__tests__/LauncherLabel.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
This file is part of REANA.
3-
Copyright (C) 2022 CERN.
3+
Copyright (C) 2022, 2023, 2024 CERN.
44
55
REANA is free software; you can redistribute it and/or modify it
66
under the terms of the MIT License; see LICENSE file for more details.

reana-ui/src/components/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,14 @@ export { default as Pagination } from "./Pagination";
1616
export { default as Title } from "./Title";
1717
export { default as TopHeader } from "./TopHeader";
1818
export { default as TooltipIfTruncated } from "./TooltipIfTruncated";
19+
export { default as LauncherLabel } from "./LauncherLabel";
1920
export { default as JupyterNotebookIcon } from "./JupyterNotebookIcon";
2021
export { default as WorkflowDeleteModal } from "./WorkflowDeleteModal";
22+
export { default as WorkflowInfo } from "./WorkflowInfo";
23+
export { default as WorkflowBadges } from "./WorkflowBadges";
2124
export { default as WorkflowStopModal } from "./WorkflowStopModal";
2225
export { default as WorkflowActionsPopup } from "./WorkflowActionsPopup";
26+
export { default as WorkflowProgressCircleBar } from "./WorkflowProgressCircleBar";
2327
export { default as PieChart } from "./PieChart";
2428
export { default as Search } from "./Search";
2529
export { default as Box } from "./Box";

reana-ui/src/pages/workflowDetails/WorkflowDetails.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,18 @@ import BasePage from "../BasePage";
2525
import {
2626
InteractiveSessionModal,
2727
Notification,
28+
WorkflowInfo,
29+
WorkflowActionsPopup,
30+
WorkflowBadges,
2831
WorkflowDeleteModal,
2932
WorkflowStopModal,
3033
} from "~/components";
3134
import {
32-
WorkflowInfo,
3335
WorkflowLogs,
3436
WorkflowFiles,
3537
WorkflowSpecification,
3638
} from "./components";
39+
import styles from "./WorkflowDetails.module.scss";
3740

3841
const FINISHED_STATUSES = ["finished", "failed", "stopped", "deleted"];
3942

@@ -140,8 +143,14 @@ export default function WorkflowDetails() {
140143

141144
return (
142145
<BasePage title={pageTitle}>
143-
<Container>
146+
<Container className={styles["workflow-details-container"]}>
144147
<WorkflowInfo workflow={workflow} />
148+
<div className={styles["badges-and-actions"]}>
149+
<WorkflowBadges workflow={workflow} withDivider={false} />
150+
<div className={styles.actionsContainer}>
151+
<WorkflowActionsPopup workflow={workflow} />
152+
</div>
153+
</div>
145154
<Tab
146155
menu={{ secondary: true, pointing: true }}
147156
panes={panes}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
.workflow-details-container {
2+
padding-top: 2rem;
3+
}
4+
5+
.badges-and-actions {
6+
display: flex;
7+
justify-content: space-between;
8+
width: 100%;
9+
padding: 0 0.75rem 1rem 1rem;
10+
}

reana-ui/src/pages/workflowDetails/components/WorkflowInfo.js

Lines changed: 0 additions & 119 deletions
This file was deleted.

0 commit comments

Comments
 (0)