Skip to content

Commit 089853f

Browse files
DaanRosendaltiborsimko
authored andcommitted
feat(ui): make details available for shared workflows (#375)
Closes reanahub/reana-server#651
1 parent 7722ff3 commit 089853f

File tree

4 files changed

+75
-35
lines changed

4 files changed

+75
-35
lines changed

reana-ui/src/actions.js

+7-3
Original file line numberDiff line numberDiff line change
@@ -293,11 +293,13 @@ export function fetchWorkflows({
293293
sort,
294294
showLoader = true,
295295
workflowIdOrName,
296+
includeShared = false,
296297
}) {
297298
return async (dispatch) => {
298299
if (showLoader) {
299300
dispatch({ type: WORKFLOWS_FETCH });
300301
}
302+
301303
return await client
302304
.getWorkflows({
303305
pagination,
@@ -307,15 +309,16 @@ export function fetchWorkflows({
307309
sharedWith,
308310
sort,
309311
workflowIdOrName,
312+
includeShared,
310313
})
311-
.then((resp) =>
314+
.then((resp) => {
312315
dispatch({
313316
type: WORKFLOWS_RECEIVED,
314317
workflows: parseWorkflows(resp.data.items),
315318
total: resp.data.total,
316319
userHasWorkflows: resp.data.user_has_workflows,
317-
}),
318-
)
320+
});
321+
})
319322
.catch((err) => {
320323
dispatch(errorActionCreator(err, USER_INFO_URL));
321324
dispatch({ type: WORKFLOWS_FETCH_ERROR });
@@ -335,6 +338,7 @@ export function fetchWorkflow(id, { refetch = false, showLoader = true } = {}) {
335338
fetchWorkflows({
336339
workflowIdOrName: id,
337340
showLoader,
341+
includeShared: true,
338342
}),
339343
);
340344
}

reana-ui/src/client.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -131,14 +131,16 @@ class Client {
131131
sharedWith,
132132
sort,
133133
workflowIdOrName,
134+
includeShared = false,
134135
} = {}) {
135136
let shared = false;
136-
if (ownedBy === "anybody") {
137+
if (ownedBy === "anybody" || includeShared) {
137138
ownedBy = undefined;
138139
shared = true;
139140
} else if (ownedBy === "you") {
140141
ownedBy = undefined;
141142
}
143+
142144
return this._request(
143145
WORKFLOWS_URL({
144146
...(pagination ?? {}),

reana-ui/src/components/WorkflowActionsPopup.js

+17-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,11 @@ import styles from "./WorkflowActionsPopup.module.scss";
2929

3030
const JupyterIcon = <JupyterNotebookIcon className={styles["jupyter-icon"]} />;
3131

32-
export default function WorkflowActionsPopup({ workflow, className }) {
32+
export default function WorkflowActionsPopup({
33+
workflow,
34+
className,
35+
insideClickableElement,
36+
}) {
3337
const dispatch = useDispatch();
3438
const [open, setOpen] = useState(false);
3539
const { id, size, status, session_status: sessionStatus } = workflow;
@@ -111,6 +115,17 @@ export default function WorkflowActionsPopup({ workflow, className }) {
111115
});
112116
}
113117

118+
if (workflow.owner_email !== "-") {
119+
return (
120+
<div
121+
className={className || styles.container}
122+
style={
123+
insideClickableElement ? { cursor: "pointer" } : { cursor: "default" }
124+
}
125+
/>
126+
);
127+
}
128+
114129
return (
115130
<div className={className}>
116131
{menuItems.length > 0 && (
@@ -145,4 +160,5 @@ WorkflowActionsPopup.defaultProps = {
145160
WorkflowActionsPopup.propTypes = {
146161
workflow: workflowShape.isRequired,
147162
className: PropTypes.string,
163+
insideClickableElement: PropTypes.bool,
148164
};

reana-ui/src/components/WorkflowBadges.js

+48-30
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*/
1010

1111
import styles from "./WorkflowBadges.module.scss";
12-
import { Label } from "semantic-ui-react";
12+
import { Icon, Label, Popup } from "semantic-ui-react";
1313
import { JupyterNotebookIcon } from "~/components";
1414
import { INTERACTIVE_SESSION_URL } from "~/client";
1515
import { LauncherLabel } from "~/components";
@@ -29,36 +29,54 @@ export default function WorkflowBadges({ workflow }) {
2929

3030
return (
3131
<div className={styles.badgesContainer}>
32-
{workflow.duration && (
33-
<Label
34-
basic
35-
size="tiny"
36-
content={`CPU ${workflow.duration}`}
37-
icon="clock"
38-
/>
39-
)}
40-
{hasDiskUsage && (
41-
<Label
42-
basic
43-
size="tiny"
44-
content={`Disk ${size.human_readable}`}
45-
icon="hdd"
46-
/>
47-
)}
48-
<LauncherLabel url={launcherURL} />
49-
{isSessionOpen && (
50-
<Label
51-
size="tiny"
52-
content={"Notebook"}
53-
icon={
54-
<i className="icon">
55-
<JupyterNotebookIcon size={12} />
56-
</i>
32+
{workflow.owner_email === "-" ? (
33+
<>
34+
{workflow.duration && (
35+
<Label
36+
basic
37+
size="tiny"
38+
content={`CPU ${workflow.duration}`}
39+
icon="clock"
40+
/>
41+
)}
42+
{hasDiskUsage && (
43+
<Label
44+
basic
45+
size="tiny"
46+
content={`Disk ${size.human_readable}`}
47+
icon="hdd"
48+
/>
49+
)}
50+
<LauncherLabel url={launcherURL} />
51+
{isSessionOpen && (
52+
<Label
53+
size="tiny"
54+
content={"Notebook"}
55+
icon={
56+
<i className="icon">
57+
<JupyterNotebookIcon size={12} />
58+
</i>
59+
}
60+
as="a"
61+
href={INTERACTIVE_SESSION_URL(sessionUri, reanaToken)}
62+
target="_blank"
63+
rel="noopener noreferrer"
64+
/>
65+
)}
66+
</>
67+
) : (
68+
<Popup
69+
trigger={
70+
<span className={styles.owner}>
71+
<Icon name="eye" style={{ marginTop: "-3px" }} />
72+
{workflow.owner_email}
73+
</span>
74+
}
75+
position="top center"
76+
content={
77+
"This workflow is read-only shared with you by " +
78+
workflow.owner_email
5779
}
58-
as="a"
59-
href={INTERACTIVE_SESSION_URL(sessionUri, reanaToken)}
60-
target="_blank"
61-
rel="noopener noreferrer"
6280
/>
6381
)}
6482
</div>

0 commit comments

Comments
 (0)