Skip to content

Commit

Permalink
UI: fix default queue; don't error on empty args
Browse files Browse the repository at this point in the history
  • Loading branch information
yashlamba committed Jul 19, 2024
1 parent 623bb36 commit 7195d50
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand All @@ -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 (
<>
Expand All @@ -70,7 +71,12 @@ export class JobRunsHeaderComponent extends Component {
</div>
<div className="column ten wide right aligned">
{loading ? null : (
<RunButton jobId={jobId} config={config} onError={this.onError} />
<RunButton
jobId={jobId}
config={config}
onError={this.onError}
queue={queue}
/>
)}
</div>
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
}
Expand All @@ -45,17 +45,21 @@ 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) {
console.log("hehe error");
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)
Expand Down Expand Up @@ -131,6 +135,7 @@ RunButton.propTypes = {
config: PropTypes.object.isRequired,
onError: PropTypes.func.isRequired,
setRun: PropTypes.func,
queue: PropTypes.string.isRequired,
};

RunButton.defaultProps = {
Expand Down

0 comments on commit 7195d50

Please sign in to comment.