Skip to content

Commit

Permalink
feat(ui): make details available for shared workflows (#375)
Browse files Browse the repository at this point in the history
  • Loading branch information
DaanRosendal authored and tiborsimko committed Sep 4, 2024
1 parent 7722ff3 commit 089853f
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 35 deletions.
10 changes: 7 additions & 3 deletions reana-ui/src/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -293,11 +293,13 @@ export function fetchWorkflows({
sort,
showLoader = true,
workflowIdOrName,
includeShared = false,
}) {
return async (dispatch) => {
if (showLoader) {
dispatch({ type: WORKFLOWS_FETCH });
}

return await client
.getWorkflows({
pagination,
Expand All @@ -307,15 +309,16 @@ export function fetchWorkflows({
sharedWith,
sort,
workflowIdOrName,
includeShared,
})
.then((resp) =>
.then((resp) => {
dispatch({
type: WORKFLOWS_RECEIVED,
workflows: parseWorkflows(resp.data.items),
total: resp.data.total,
userHasWorkflows: resp.data.user_has_workflows,
}),
)
});
})
.catch((err) => {
dispatch(errorActionCreator(err, USER_INFO_URL));
dispatch({ type: WORKFLOWS_FETCH_ERROR });
Expand All @@ -335,6 +338,7 @@ export function fetchWorkflow(id, { refetch = false, showLoader = true } = {}) {
fetchWorkflows({
workflowIdOrName: id,
showLoader,
includeShared: true,
}),
);
}
Expand Down
4 changes: 3 additions & 1 deletion reana-ui/src/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,14 +131,16 @@ class Client {
sharedWith,
sort,
workflowIdOrName,
includeShared = false,
} = {}) {
let shared = false;
if (ownedBy === "anybody") {
if (ownedBy === "anybody" || includeShared) {
ownedBy = undefined;
shared = true;
} else if (ownedBy === "you") {
ownedBy = undefined;
}

return this._request(
WORKFLOWS_URL({
...(pagination ?? {}),
Expand Down
18 changes: 17 additions & 1 deletion reana-ui/src/components/WorkflowActionsPopup.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ import styles from "./WorkflowActionsPopup.module.scss";

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

export default function WorkflowActionsPopup({ workflow, className }) {
export default function WorkflowActionsPopup({
workflow,
className,
insideClickableElement,
}) {
const dispatch = useDispatch();
const [open, setOpen] = useState(false);
const { id, size, status, session_status: sessionStatus } = workflow;
Expand Down Expand Up @@ -111,6 +115,17 @@ export default function WorkflowActionsPopup({ workflow, className }) {
});
}

if (workflow.owner_email !== "-") {
return (
<div
className={className || styles.container}
style={
insideClickableElement ? { cursor: "pointer" } : { cursor: "default" }
}
/>
);
}

return (
<div className={className}>
{menuItems.length > 0 && (
Expand Down Expand Up @@ -145,4 +160,5 @@ WorkflowActionsPopup.defaultProps = {
WorkflowActionsPopup.propTypes = {
workflow: workflowShape.isRequired,
className: PropTypes.string,
insideClickableElement: PropTypes.bool,
};
78 changes: 48 additions & 30 deletions reana-ui/src/components/WorkflowBadges.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*/

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

return (
<div className={styles.badgesContainer}>
{workflow.duration && (
<Label
basic
size="tiny"
content={`CPU ${workflow.duration}`}
icon="clock"
/>
)}
{hasDiskUsage && (
<Label
basic
size="tiny"
content={`Disk ${size.human_readable}`}
icon="hdd"
/>
)}
<LauncherLabel url={launcherURL} />
{isSessionOpen && (
<Label
size="tiny"
content={"Notebook"}
icon={
<i className="icon">
<JupyterNotebookIcon size={12} />
</i>
{workflow.owner_email === "-" ? (
<>
{workflow.duration && (
<Label
basic
size="tiny"
content={`CPU ${workflow.duration}`}
icon="clock"
/>
)}
{hasDiskUsage && (
<Label
basic
size="tiny"
content={`Disk ${size.human_readable}`}
icon="hdd"
/>
)}
<LauncherLabel url={launcherURL} />
{isSessionOpen && (
<Label
size="tiny"
content={"Notebook"}
icon={
<i className="icon">
<JupyterNotebookIcon size={12} />
</i>
}
as="a"
href={INTERACTIVE_SESSION_URL(sessionUri, reanaToken)}
target="_blank"
rel="noopener noreferrer"
/>
)}
</>
) : (
<Popup
trigger={
<span className={styles.owner}>
<Icon name="eye" style={{ marginTop: "-3px" }} />
{workflow.owner_email}
</span>
}
position="top center"
content={
"This workflow is read-only shared with you by " +
workflow.owner_email
}
as="a"
href={INTERACTIVE_SESSION_URL(sessionUri, reanaToken)}
target="_blank"
rel="noopener noreferrer"
/>
)}
</div>
Expand Down

0 comments on commit 089853f

Please sign in to comment.