Skip to content

Commit

Permalink
js: add POST request to run button
Browse files Browse the repository at this point in the history
  • Loading branch information
carlinmack committed May 29, 2024
1 parent c81abf3 commit f3cf1fb
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ export async function JobRunsHeader(pidValue) {
}

const actions = document.getElementById("actions");
ReactDOM.render(<RunButton config={data.default_args ?? {}} />, actions);
ReactDOM.render(
<RunButton jobId={data.id} config={data.default_args ?? {}} />,
actions
);
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import React, { Component } from "react";
import { UserListItemCompact, toRelativeTime } from "react-invenio-forms";
import { withState } from "react-searchkit";
import { Popup, Table, Button, Icon } from "semantic-ui-react";
import { RunButton } from "./RunButton";
// import { RunButton } from "./RunButton";
import { StatusFormatter } from "./StatusFormatter";
import { http } from "react-invenio-forms";

Expand Down Expand Up @@ -93,11 +93,19 @@ class SearchResultItemComponent extends Component {
: toRelativeTime(result.next_run, i18next.language) ?? "−"}
</Table.Cell>
<Table.Cell collapsing>
<Button icon fluid basic labelPosition="left" onClick={() => {http.post('/api/jobs/' + result.id + '/runs')}}>
<Icon name='play' />
Run
</Button>
{/* <RunButton config={result.default_args ?? {}} /> */}
<Button
icon
fluid
basic
labelPosition="left"
onClick={() => {
http.post("/api/jobs/" + result.id + "/runs");
}}
>
<Icon name="play" />
Run
</Button>
{/* <RunButton jobId={result.id} config={result.default_args ?? {}} /> */}
</Table.Cell>
</Table.Row>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ import {
Form,
FormInput,
} from "semantic-ui-react";
import { http } from "react-invenio-forms";

export const RunButton = ({ config }) => {
export const RunButton = ({ jobId, config }) => {
return (
<Dropdown
text={i18next.t("Run")}
Expand All @@ -29,7 +30,7 @@ export const RunButton = ({ config }) => {
direction="left"
>
<DropdownMenu>
<Form className="p-10" >
<Form className="p-10">
{Object.keys(config).map((key) => (
<FormInput
key={key}
Expand All @@ -38,13 +39,24 @@ export const RunButton = ({ config }) => {
onClick={(e) => e.stopPropagation()}
/>
))}
<Button type="submit" content="Run" />
<Button
type="submit"
content="Run"
onClick={() => {
http.post("/api/jobs/" + jobId + "/runs");
}}
/>
</Form>
</DropdownMenu>
</Dropdown>
);
};

RunButton.propTypes = {
config: PropTypes.object.isRequired,
jobId: PropTypes.string.isRequired,
config: PropTypes.object,
};

RunButton.defaultProps = {
config: {},
};

0 comments on commit f3cf1fb

Please sign in to comment.