From 49ba424edaea189f53a7c5abe68543748affd4b4 Mon Sep 17 00:00:00 2001 From: yashlamba Date: Fri, 19 Jul 2024 09:06:53 +0200 Subject: [PATCH] UI: fix default queue; don't error on empty args --- .../js/invenio_jobs/administration/JobRunsHeader.js | 10 ++++++++-- .../administration/JobSearchResultItemLayout.js | 1 + .../js/invenio_jobs/administration/RunButton.js | 10 +++++++--- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/invenio_jobs/assets/semantic-ui/js/invenio_jobs/administration/JobRunsHeader.js b/invenio_jobs/assets/semantic-ui/js/invenio_jobs/administration/JobRunsHeader.js index a6154bb..2b7ecf4 100644 --- a/invenio_jobs/assets/semantic-ui/js/invenio_jobs/administration/JobRunsHeader.js +++ b/invenio_jobs/assets/semantic-ui/js/invenio_jobs/administration/JobRunsHeader.js @@ -36,6 +36,7 @@ export class JobRunsHeaderComponent extends Component { ...(data.title && { title: data.title }), ...(data.description && { description: data.description }), ...(data.default_args && { config: data.default_args }), + ...(data.default_queue && { queue: data.default_queue }), }); }) .catch((error) => { @@ -60,7 +61,7 @@ export class JobRunsHeaderComponent extends Component { }; render() { - const { title, description, config, loading } = this.state; + const { title, description, config, loading, queue } = this.state; const { jobId } = this.props; return ( <> @@ -70,7 +71,12 @@ export class JobRunsHeaderComponent extends Component {
{loading ? null : ( - + )}
diff --git a/invenio_jobs/assets/semantic-ui/js/invenio_jobs/administration/JobSearchResultItemLayout.js b/invenio_jobs/assets/semantic-ui/js/invenio_jobs/administration/JobSearchResultItemLayout.js index 22c56c2..590a304 100644 --- a/invenio_jobs/assets/semantic-ui/js/invenio_jobs/administration/JobSearchResultItemLayout.js +++ b/invenio_jobs/assets/semantic-ui/js/invenio_jobs/administration/JobSearchResultItemLayout.js @@ -143,6 +143,7 @@ class SearchResultItemComponent extends Component { jobId={result.id} config={result.default_args ?? {}} onError={this.onError} + queue={result.default_queue} setRun={(status, created) => { this.setState({ lastRunStatus: status, diff --git a/invenio_jobs/assets/semantic-ui/js/invenio_jobs/administration/RunButton.js b/invenio_jobs/assets/semantic-ui/js/invenio_jobs/administration/RunButton.js index a0383c8..3328848 100644 --- a/invenio_jobs/assets/semantic-ui/js/invenio_jobs/administration/RunButton.js +++ b/invenio_jobs/assets/semantic-ui/js/invenio_jobs/administration/RunButton.js @@ -25,7 +25,7 @@ export class RunButton extends Component { this.state = { title: "Manual run", config: JSON.stringify(props.config, null, "\t"), - queue: "low", + queue: props.queue || "celery", loading: false, }; } @@ -45,17 +45,20 @@ export class RunButton extends Component { const { title, config, queue } = this.state; try { - var userConfigJSON = JSON.parse(config); + var userConfigJSON = config === "" ? null : JSON.parse(config); } catch (e) { onError(e); } const runData = { title: title, - args: userConfigJSON, queue: queue, }; + if (userConfigJSON !== null) { + runData.args = userConfigJSON; + } + try { this.cancellableAction = await withCancel( http.post("/api/jobs/" + jobId + "/runs", runData) @@ -131,6 +134,7 @@ RunButton.propTypes = { config: PropTypes.object.isRequired, onError: PropTypes.func.isRequired, setRun: PropTypes.func, + queue: PropTypes.string.isRequired, }; RunButton.defaultProps = {