Skip to content

workspace: add file search #212

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jan 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ Changes
Version 0.8.1 (UNRELEASED)
---------------------------

- Adds support for HTML preview of workspace files.
- Adds search by name in workflow file list page.
- Changes cluster health status page to represent availability instead of usage.

Version 0.8.0 (2021-11-22)
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:12 as react-build
FROM node:16 as react-build
WORKDIR /code
COPY . /code
# hadolint ignore=DL3003
Expand Down
12 changes: 6 additions & 6 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ to review production and historical workflows.
Features
========

- profile page containing REANA access token
- list of personal workflows
- workflow details page containing logs, files, specification
- Profile page containing REANA access token
- List of personal workflows
- Workflow details page containing logs, files, specification
- GitLab integration to load your workflow repositories

Usage
Expand All @@ -45,14 +45,14 @@ Development

$ git clone https://github.com/reanahub/reana-ui.git
$ cd reana-ui/reana-ui
$ npm install
$ npm start # make sure REANA_SERVER_URL env var is set
$ yarn install
$ yarn start # make sure REANA_SERVER_URL env var is set
$ firefox localhost:3000

Useful links
============

- `REANA project home page <http://www.reana.io/>`_
- `REANA project home page <https://www.reana.io/>`_
- `REANA user documentation <https://docs.reana.io>`_
- `REANA user support forum <https://forum.reana.io>`_

Expand Down
4 changes: 2 additions & 2 deletions reana-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
"version": "0.8.0",
"private": true,
"dependencies": {
"axios": "latest",
"axios": "^0.24.0",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice to see this! 👍

"lodash": "^4.17.15",
"mime": "^2.4.4",
"moment": "^2.24.0",
"node-sass": "^4.13.0",
"node-sass": "^6.0.0",
"prop-types": "^15.7.2",
"query-string": "^6.13.4",
"react": "^17.0.2",
Expand Down
11 changes: 5 additions & 6 deletions reana-ui/src/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
-*- coding: utf-8 -*-

This file is part of REANA.
Copyright (C) 2020, 2021 CERN.
Copyright (C) 2020, 2021, 2022 CERN.

REANA is free software; you can redistribute it and/or modify it
under the terms of the MIT License; see LICENSE file for more details.
Expand All @@ -21,7 +21,7 @@ import client, {
INTERACTIVE_SESSIONS_OPEN_URL,
INTERACTIVE_SESSIONS_CLOSE_URL,
} from "~/client";
import { parseWorkflows, parseLogs, parseFiles } from "~/util";
import { parseWorkflows, parseLogs, parseFiles, formatSearch } from "~/util";
import {
getConfig,
getWorkflow,
Expand Down Expand Up @@ -243,9 +243,8 @@ export function fetchWorkflows(
if (showLoader) {
dispatch({ type: WORKFLOWS_FETCH });
}
const nameSearch = search ? JSON.stringify({ name: [search] }) : search;
return await client
.getWorkflows(pagination, nameSearch, status, sort)
.getWorkflows(pagination, formatSearch(search), status, sort)
.then((resp) =>
dispatch({
type: WORKFLOWS_RECEIVED,
Expand Down Expand Up @@ -298,11 +297,11 @@ export function fetchWorkflowLogs(id) {
};
}

export function fetchWorkflowFiles(id, pagination) {
export function fetchWorkflowFiles(id, pagination, search) {
return async (dispatch) => {
dispatch({ type: WORKFLOW_FILES_FETCH });
return await client
.getWorkflowFiles(id, pagination)
.getWorkflowFiles(id, pagination, formatSearch(search))
.then((resp) =>
dispatch({
type: WORKFLOW_FILES_RECEIVED,
Expand Down
10 changes: 5 additions & 5 deletions reana-ui/src/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
-*- coding: utf-8 -*-

This file is part of REANA.
Copyright (C) 2021 CERN.
Copyright (C) 2021, 2022 CERN.

REANA is free software; you can redistribute it and/or modify it
under the terms of the MIT License; see LICENSE file for more details.
Expand Down Expand Up @@ -31,8 +31,8 @@ export const WORKFLOWS_URL = (params) =>
export const WORKFLOW_LOGS_URL = (id) => `${api}/api/workflows/${id}/logs`;
export const WORKFLOW_SPECIFICATION_URL = (id) =>
`${api}/api/workflows/${id}/specification`;
export const WORKFLOW_FILES_URL = (id, pagination) =>
`${api}/api/workflows/${id}/workspace?${stringifyQueryParams(pagination)}`;
export const WORKFLOW_FILES_URL = (id, params) =>
`${api}/api/workflows/${id}/workspace?${stringifyQueryParams(params)}`;
export const WORKFLOW_FILE_URL = (id, filename, preview = true) =>
`${api}/api/workflows/${id}/workspace/${filename}?${stringifyQueryParams(
preview
Expand Down Expand Up @@ -126,8 +126,8 @@ class Client {
return this._request(WORKFLOW_LOGS_URL(id));
}

getWorkflowFiles(id, pagination) {
return this._request(WORKFLOW_FILES_URL(id, pagination));
getWorkflowFiles(id, pagination, search) {
return this._request(WORKFLOW_FILES_URL(id, { ...pagination, search }));
}

getWorkflowFile(id, filename) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,43 @@
-*- coding: utf-8 -*-

This file is part of REANA.
Copyright (C) 2020 CERN.
Copyright (C) 2020, 2021, 2022 CERN.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very minor: copyright year was not updated in most of the other touched files

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated, thanks!

Did you manage to find a nice way to keep this updated in VSCode?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not yet, is seems there are no extensions which would do exactly this task in VSCode unfortunately. However there are extensions like 'Run on Save' which could trigger custom task like this after saving a file, but I haven't tried to implement it.


REANA is free software; you can redistribute it and/or modify it
under the terms of the MIT License; see LICENSE file for more details.
*/

import PropTypes from "prop-types";

import { unstable_batchedUpdates } from "react-dom";
import { Input } from "semantic-ui-react";
import debounce from "lodash/debounce";

import styles from "./Search.module.scss";

const TYPING_DELAY = 1000;

export default function WorkflowSearch({ search }) {
export default function Search({ search }) {
const handleChange = debounce(search, TYPING_DELAY);
return (
<Input
fluid
icon="search"
placeholder="Search..."
className={styles.input}
onChange={(_, data) => handleChange(data.value)}
/>
);
}

WorkflowSearch.propTypes = {
Search.propTypes = {
search: PropTypes.func.isRequired,
};

export const applyFilter = (filter, pagination, setPagination) => (value) => {
// FIXME: refactor once implemented by default in future versions of React
// https://github.com/facebook/react/issues/16387#issuecomment-521623662c
unstable_batchedUpdates(() => {
filter(value);
setPagination({ ...pagination, page: 1 });
});
};
21 changes: 21 additions & 0 deletions reana-ui/src/components/Search.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
-*- coding: utf-8 -*-

This file is part of REANA.
Copyright (C) 2022 CERN.

REANA is free software; you can redistribute it and/or modify it
under the terms of the MIT License; see LICENSE file for more details.
*/

@import "@palette";

:global(.ui.input).input {
:global(input)::placeholder {
color: $gray;
}

:global(input):focus::placeholder {
color: darken($gray, 30%);
}
}
3 changes: 2 additions & 1 deletion reana-ui/src/components/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
-*- coding: utf-8 -*-

This file is part of REANA.
Copyright (C) 2020 CERN.
Copyright (C) 2020, 2021, 2022 CERN.

REANA is free software; you can redistribute it and/or modify it
under the terms of the MIT License; see LICENSE file for more details.
Expand All @@ -20,3 +20,4 @@ export { default as JupyterNotebookIcon } from "./JupyterNotebookIcon";
export { default as WorkflowDeleteModal } from "./WorkflowDeleteModal";
export { default as WorkflowActionsPopup } from "./WorkflowActionsPopup";
export { default as PieChart } from "./PieChart";
export { default as Search } from "./Search";
Loading