Skip to content

Commit ea20030

Browse files
DaanRosendaltiborsimko
authored andcommitted
feat(ui): add dropdowns for filtering shared workflows (#375)
Closes #367
1 parent 660584e commit ea20030

11 files changed

+412
-9
lines changed

AUTHORS.md

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ The list of contributors in alphabetical order:
44

55
- [Alp Tuna](https://orcid.org/0009-0001-1915-3993)
66
- [Audrius Mecionis](https://orcid.org/0000-0002-3759-1663)
7+
- [Daan Rosendal](https://orcid.org/0000-0002-3447-9000)
78
- [Diego Rodriguez](https://orcid.org/0000-0003-0649-2002)
89
- [Dinos Kousidis](https://orcid.org/0000-0002-4914-4289)
910
- [Domenic Gosein](https://orcid.org/0000-0002-1546-0435)

reana-ui/src/actions.js

+55
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,19 @@ export const OPEN_INTERACTIVE_SESSION_MODAL = "Open interactive session modal";
9191
export const CLOSE_INTERACTIVE_SESSION_MODAL =
9292
"Close interactive session modal";
9393

94+
export const USERS_SHARED_WITH_YOU_FETCH =
95+
"Fetch users who shared workflows with you";
96+
export const USERS_SHARED_WITH_YOU_RECEIVED =
97+
"Users who shared workflows with you received";
98+
export const USERS_SHARED_WITH_YOU_FETCH_ERROR =
99+
"Fetch users who shared workflows with you error";
100+
export const USERS_YOU_SHARED_WITH_FETCH =
101+
"Fetch users you shared workflows with";
102+
export const USERS_YOU_SHARED_WITH_RECEIVED =
103+
"Users you shared workflows with received";
104+
export const USERS_YOU_SHARED_WITH_FETCH_ERROR =
105+
"Fetch users you shared workflows with error";
106+
94107
export function errorActionCreator(error, name) {
95108
const { status, data } = error?.response;
96109
const { message } = data;
@@ -262,6 +275,8 @@ export function fetchWorkflows({
262275
pagination,
263276
search,
264277
status,
278+
ownedBy,
279+
sharedWith,
265280
sort,
266281
showLoader = true,
267282
workflowIdOrName,
@@ -275,6 +290,8 @@ export function fetchWorkflows({
275290
pagination,
276291
search: formatSearch(search),
277292
status,
293+
ownedBy,
294+
sharedWith,
278295
sort,
279296
workflowIdOrName,
280297
})
@@ -522,3 +539,41 @@ export function closeInteractiveSession(id) {
522539
});
523540
};
524541
}
542+
543+
export function fetchUsersSharedWithYou() {
544+
return async (dispatch) => {
545+
dispatch({ type: USERS_SHARED_WITH_YOU_FETCH });
546+
547+
return await client
548+
.getUsersSharedWithYou()
549+
.then((resp) => {
550+
dispatch({
551+
type: USERS_SHARED_WITH_YOU_RECEIVED,
552+
users_shared_with_you: resp.data.users_shared_with_you,
553+
});
554+
return resp;
555+
})
556+
.catch((err) => {
557+
dispatch(errorActionCreator(err, USERS_SHARED_WITH_YOU_FETCH_ERROR));
558+
});
559+
};
560+
}
561+
562+
export function fetchUsersYouSharedWith() {
563+
return async (dispatch) => {
564+
dispatch({ type: USERS_YOU_SHARED_WITH_FETCH });
565+
566+
return await client
567+
.getUsersYouSharedWith()
568+
.then((resp) => {
569+
dispatch({
570+
type: USERS_YOU_SHARED_WITH_RECEIVED,
571+
users_you_shared_with: resp.data.users_you_shared_with,
572+
});
573+
return resp;
574+
})
575+
.catch((err) => {
576+
dispatch(errorActionCreator(err, USERS_YOU_SHARED_WITH_FETCH_ERROR));
577+
});
578+
};
579+
}

reana-ui/src/client.js

+29-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ export const USER_SIGNIN_URL = `${api}/api/login`;
2323
export const USER_SIGNOUT_URL = `${api}/api/logout`;
2424
export const USER_REQUEST_TOKEN_URL = `${api}/api/token`;
2525
export const USER_CONFIRM_EMAIL_URL = `${api}/api/confirm-email`;
26+
export const USERS_SHARED_WITH_YOU_URL = `${api}/api/users/shared-with-you`;
27+
export const USERS_YOU_SHARED_WITH_URL = `${api}/api/users/you-shared-with`;
2628
export const CLUSTER_STATUS_URL = `${api}/api/status`;
2729
export const GITLAB_AUTH_URL = `${api}/api/gitlab/connect`;
2830
export const GITLAB_PROJECTS_URL = (params) =>
@@ -116,13 +118,31 @@ class Client {
116118
});
117119
}
118120

119-
getWorkflows({ pagination, search, status, sort, workflowIdOrName } = {}) {
121+
getWorkflows({
122+
pagination,
123+
search,
124+
status,
125+
ownedBy,
126+
sharedWith,
127+
sort,
128+
workflowIdOrName,
129+
} = {}) {
130+
let shared = false;
131+
if (ownedBy === "anybody") {
132+
ownedBy = undefined;
133+
shared = true;
134+
} else if (ownedBy === "you") {
135+
ownedBy = undefined;
136+
}
120137
return this._request(
121138
WORKFLOWS_URL({
122139
...(pagination ?? {}),
123140
workflow_id_or_name: workflowIdOrName,
124141
search,
125142
status,
143+
shared,
144+
shared_by: ownedBy,
145+
shared_with: sharedWith,
126146
sort,
127147
}),
128148
);
@@ -198,6 +218,14 @@ class Client {
198218
method: "post",
199219
});
200220
}
221+
222+
getUsersSharedWithYou() {
223+
return this._request(USERS_SHARED_WITH_YOU_URL);
224+
}
225+
226+
getUsersYouSharedWith() {
227+
return this._request(USERS_YOU_SHARED_WITH_URL);
228+
}
201229
}
202230

203231
const client = new Client();

reana-ui/src/pages/workflowList/WorkflowList.js

+22-2
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) 2020, 2021, 2022 CERN.
5+
Copyright (C) 2020, 2021, 2022, 2023 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.
@@ -51,6 +51,8 @@ function Workflows() {
5151
const [pagination, setPagination] = useState({ page: 1, size: PAGE_SIZE });
5252
const [statusFilter, setStatusFilter] = useState(NON_DELETED_STATUSES);
5353
const [searchFilter, setSearchFilter] = useState();
54+
const [ownedByFilter, setOwnedByFilter] = useState();
55+
const [sharedWithFilter, setSharedWithFilter] = useState();
5456
const [sortDir, setSortDir] = useState("desc");
5557
const dispatch = useDispatch();
5658
const config = useSelector(getConfig);
@@ -76,6 +78,8 @@ function Workflows() {
7678
pagination: { ...pagination },
7779
search: searchFilter,
7880
status: statusFilter,
81+
ownedBy: ownedByFilter,
82+
sharedWith: sharedWithFilter,
7983
sort: sortDir,
8084
}),
8185
);
@@ -88,6 +92,8 @@ function Workflows() {
8892
pagination: { ...pagination },
8993
search: searchFilter,
9094
status: statusFilter,
95+
ownedBy: ownedByFilter,
96+
sharedWith: sharedWithFilter,
9197
sort: sortDir,
9298
showLoader,
9399
}),
@@ -103,6 +109,8 @@ function Workflows() {
103109
reanaToken,
104110
searchFilter,
105111
statusFilter,
112+
ownedByFilter,
113+
sharedWithFilter,
106114
sortDir,
107115
workflowRefresh,
108116
]);
@@ -133,7 +141,7 @@ function Workflows() {
133141

134142
return (
135143
<div className={styles.container}>
136-
<Container text>
144+
<Container id={styles["workflow-list-container"]}>
137145
<Title className={styles.title}>
138146
<span>Your workflows</span>
139147
<span className={styles.refresh}>
@@ -155,6 +163,18 @@ function Workflows() {
155163
pagination,
156164
setPagination,
157165
)}
166+
ownedByFilter={ownedByFilter}
167+
setOwnedByFilter={applyFilter(
168+
setOwnedByFilter,
169+
pagination,
170+
setPagination,
171+
)}
172+
sharedWithFilter={sharedWithFilter}
173+
setSharedWithFilter={applyFilter(
174+
setSharedWithFilter,
175+
pagination,
176+
setPagination,
177+
)}
158178
sortDir={sortDir}
159179
setSortDir={applyFilter(setSortDir, pagination, setPagination)}
160180
/>

reana-ui/src/pages/workflowList/WorkflowList.module.scss

+36-1
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) 2020, 2022 CERN.
5+
Copyright (C) 2020, 2022, 2023 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.
@@ -41,3 +41,38 @@
4141
:global(.ui.pagination.menu).pagination {
4242
margin: 2em;
4343
}
44+
45+
#workflow-list-container {
46+
font-size: 1.14285714rem;
47+
line-height: 1.5;
48+
margin-left: 0;
49+
margin-right: 0;
50+
}
51+
52+
/* Mobile */
53+
@media only screen and (max-width: 767px) {
54+
#workflow-list-container {
55+
width: 500px;
56+
}
57+
}
58+
59+
/* Tablet */
60+
@media only screen and (min-width: 768px) and (max-width: 991px) {
61+
#workflow-list-container {
62+
width: 700px;
63+
}
64+
}
65+
66+
/* Small Monitor */
67+
@media only screen and (min-width: 992px) and (max-width: 1199px) {
68+
#workflow-list-container {
69+
width: 800px;
70+
}
71+
}
72+
73+
/* Large Monitor */
74+
@media only screen and (min-width: 1200px) {
75+
#workflow-list-container {
76+
width: 825px;
77+
}
78+
}

reana-ui/src/pages/workflowList/components/WorkflowFilters.js

+17-2
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) 2020, 2022 CERN.
5+
Copyright (C) 2020, 2022, 2023 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.
@@ -15,12 +15,17 @@ import WorkflowStatusFilter from "./WorkflowStatusFilter";
1515
import WorkflowSorting from "./WorkflowSorting";
1616

1717
import styles from "./WorkflowFilters.module.scss";
18+
import WorkflowSharingFilters from "./WorkflowSharingFilter";
1819

1920
export default function WorkflowFilters({
2021
statusFilter,
2122
setStatusFilter,
2223
sortDir,
2324
setSortDir,
25+
ownedByFilter,
26+
setOwnedByFilter,
27+
sharedWithFilter,
28+
setSharedWithFilter,
2429
}) {
2530
return (
2631
<div className={styles.container}>
@@ -29,7 +34,13 @@ export default function WorkflowFilters({
2934
statusFilter={statusFilter}
3035
filter={setStatusFilter}
3136
/>
32-
<Grid.Column floated="right" width={4}>
37+
<WorkflowSharingFilters
38+
ownedByFilter={ownedByFilter}
39+
setOwnedByFilter={setOwnedByFilter}
40+
sharedWithFilter={sharedWithFilter}
41+
setSharedWithFilter={setSharedWithFilter}
42+
/>
43+
<Grid.Column mobile={16} tablet={4} computer={3} floated="right">
3344
<WorkflowSorting value={sortDir} sort={setSortDir} />
3445
</Grid.Column>
3546
</Grid>
@@ -42,4 +53,8 @@ WorkflowFilters.propTypes = {
4253
setStatusFilter: PropTypes.func.isRequired,
4354
sortDir: PropTypes.string.isRequired,
4455
setSortDir: PropTypes.func.isRequired,
56+
ownedByFilter: PropTypes.string,
57+
setOwnedByFilter: PropTypes.func.isRequired,
58+
sharedWithFilter: PropTypes.string,
59+
setSharedWithFilter: PropTypes.func.isRequired,
4560
};

0 commit comments

Comments
 (0)