Skip to content
This repository has been archived by the owner on Dec 13, 2023. It is now read-only.

Commit

Permalink
Fix validation error handling in workflow editor
Browse files Browse the repository at this point in the history
- Rev version. Keep moment upgrade.
  • Loading branch information
peterlau committed Apr 12, 2022
1 parent 4b5317f commit a5034eb
Show file tree
Hide file tree
Showing 16 changed files with 320 additions and 290 deletions.
4 changes: 2 additions & 2 deletions ui/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "client",
"version": "3.6.1",
"version": "3.7.1",
"dependencies": {
"@material-ui/core": "^4.12.3",
"@material-ui/icons": "^4.11.2",
Expand All @@ -16,7 +16,7 @@
"immutability-helper": "^3.1.1",
"json-bigint-string": "^1.0.0",
"lodash": "^4.17.20",
"moment": "^2.29.1",
"moment": "^2.29.2",
"parse-svg-path": "^0.1.2",
"prop-types": "^15.7.2",
"react": "^16.8.0",
Expand Down
2 changes: 1 addition & 1 deletion ui/src/App.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from "react";

import { Route, Switch } from "react-router-dom";
import { makeStyles } from "@material-ui/core/styles";
import { makeStyles } from "@material-ui/styles";
import { Button, AppBar, Toolbar } from "@material-ui/core";
import AppLogo from "./plugins/AppLogo";
import NavLink from "./components/NavLink";
Expand Down
4 changes: 3 additions & 1 deletion ui/src/components/Dropdown.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Input } from "./";
import Autocomplete from "@material-ui/lab/Autocomplete";
import FormControl from "@material-ui/core/FormControl";
import InputLabel from "@material-ui/core/InputLabel";
import CloseIcon from "@material-ui/icons/Close";

export default function ({
label,
Expand All @@ -18,6 +19,8 @@ export default function ({
<FormControl style={style} className={className}>
{label && <InputLabel error={!!error}>{label}</InputLabel>}
<Autocomplete
{...props}
closeIcon={<CloseIcon />}
renderInput={(params) => (
<Input
{...params}
Expand All @@ -27,7 +30,6 @@ export default function ({
/>
)}
value={value === undefined ? null : value} // convert undefined to null
{...props}
/>
</FormControl>
);
Expand Down
2 changes: 1 addition & 1 deletion ui/src/components/KeyValueTable.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from "react";
import { makeStyles } from "@material-ui/core/styles";
import { makeStyles } from "@material-ui/styles";
import List from "@material-ui/core/List";
import ListItem from "@material-ui/core/ListItem";
import ListItemText from "@material-ui/core/ListItemText";
Expand Down
8 changes: 4 additions & 4 deletions ui/src/components/ReactJson.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const useStyles = makeStyles({
position: "relative",
},
label: {
marginTop: 5,
marginTop: 13,
marginBottom: 10,
flex: 1,
},
Expand Down Expand Up @@ -67,17 +67,17 @@ export default function ReactJson({ className, label, src }) {
</InputLabel>

<Tooltip title="Collapse All">
<IconButton size="small" onClick={handleCollapse}>
<IconButton onClick={handleCollapse}>
<ExpandLessIcon />
</IconButton>
</Tooltip>
<Tooltip title="Expand All">
<IconButton size="small" onClick={handleExpandAll}>
<IconButton onClick={handleExpandAll}>
<ExpandMoreIcon />
</IconButton>
</Tooltip>
<Tooltip title="Copy All">
<IconButton size="small" onClick={handleCopyAll}>
<IconButton onClick={handleCopyAll}>
<FileCopyIcon />
</IconButton>
</Tooltip>
Expand Down
6 changes: 1 addition & 5 deletions ui/src/data/workflow.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,23 +85,19 @@ export function useWorkflowDefs() {
const workflows = useMemo(() => {
if (data) {
const unique = new Map();
const types = new Set();
for (let workflowDef of data) {
if (!unique.has(workflowDef.name)) {
unique.set(workflowDef.name, workflowDef);
} else if (unique.get(workflowDef.name).version < workflowDef.version) {
unique.set(workflowDef.name, workflowDef);
}

for (let task of workflowDef.tasks) {
types.add(task.type);
}
}

return Array.from(unique.values());
}
}, [data]);

console.log(workflows);
return {
data: workflows,
...rest,
Expand Down
5 changes: 4 additions & 1 deletion ui/src/pages/definition/SaveTaskDialog.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,11 @@ export default function SaveTaskDialog({ onSuccess, onCancel, document }) {
},
onError: (err) => {
console.log("onerror", err);
let errStr = _.isString(err.body)
? err.body
: JSON.stringify(err.body, null, 2);
setErrorMsg({
message: `${TASK_SAVE_FAILED} - Error: ${err}`,
message: `${TASK_SAVE_FAILED}: ${errStr}`,
dismissible: true,
});
},
Expand Down
5 changes: 4 additions & 1 deletion ui/src/pages/definition/SaveWorkflowDialog.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,10 @@ export default function SaveWorkflowDialog({ onSuccess, onCancel, document }) {
},
onError: (err) => {
console.log("onerror", err);
setErrorMsg(`${WORKFLOW_SAVE_FAILED} - Error: ${err}`);
let errStr = _.isString(err.body)
? err.body
: JSON.stringify(err.body, null, 2);
setErrorMsg(`${WORKFLOW_SAVE_FAILED}: ${errStr}`);
},
});

Expand Down
2 changes: 1 addition & 1 deletion ui/src/pages/execution/Execution.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
Heading,
} from "../../components";
import { Tooltip } from "@material-ui/core";
import { makeStyles } from "@material-ui/core/styles";
import { makeStyles } from "@material-ui/styles";
import { useRouteMatch } from "react-router-dom";
import TaskDetails from "./TaskDetails";
import ExecutionSummary from "./ExecutionSummary";
Expand Down
1 change: 0 additions & 1 deletion ui/src/pages/executions/TaskSearch.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ export default function TaskSearchPanel() {
setQueryFT(newQuery);

if (oldQuery === newQuery) {
console.log("refetching");
refetch();
}
}
Expand Down
2 changes: 1 addition & 1 deletion ui/src/pages/kitchensink/KitchenSink.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import DataTableDemo from "./DataTableDemo";
import top100Films from "./sampleMovieData";
import Dropdown from "../../components/Dropdown";
import sharedStyles from "../styles";
import { makeStyles } from "@material-ui/core/styles";
import { makeStyles } from "@material-ui/styles";
import clsx from "clsx";
import FormikInput from "../../components/formik/FormikInput";
import FormikJsonInput from "../../components/formik/FormikJsonInput";
Expand Down
2 changes: 0 additions & 2 deletions ui/src/pages/workbench/RunHistory.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,6 @@ const RunHistory = forwardRef((props: RunHistoryProps, ref) => {
return newRun;
},
updateRun: (createTime: number, workflowId: string) => {
console.log("updating run", createTime, workflowId);

const idx = runHistory.findIndex((v) => v.createTime === createTime);
const currRun = runHistory[idx];
const oldRecords = currRun.workflowRecords;
Expand Down
39 changes: 25 additions & 14 deletions ui/src/pages/workbench/WorkbenchForm.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useMemo } from "react";
import { Text, Pill } from "../../components";
import { Toolbar, IconButton } from "@material-ui/core";
import { Toolbar, IconButton, Tooltip } from "@material-ui/core";
import FormikInput from "../../components/formik/FormikInput";
import FormikJsonInput from "../../components/formik/FormikJsonInput";
import FormikDropdown from "../../components/formik/FormikDropdown";
Expand Down Expand Up @@ -146,7 +146,6 @@ function WorkbenchForm(props) {
validateForm().then((errors) => {
if (Object.keys(errors).length === 0) {
const payload = formDataToRunPayload(values);
console.log(payload);
saveRun(payload);
} else {
setTouched(setNestedObjectValues(errors, true));
Expand All @@ -158,18 +157,30 @@ function WorkbenchForm(props) {
<Form className={classes.main}>
<Toolbar className={classes.toolbar}>
<Text className={classes.workflowName}>Workflow Workbench</Text>
<IconButton onClick={handleRun}>
<PlayArrowIcon />
</IconButton>
<IconButton disabled={!dirty} onClick={handleSave}>
<SaveIcon />
</IconButton>
<IconButton
disabled={!values.workflowName}
onClick={triggerPopulateInput}
>
<PlaylistAddIcon />
</IconButton>
<Tooltip title="Execute Workflow">
<IconButton onClick={handleRun}>
<PlayArrowIcon />
</IconButton>
</Tooltip>

<Tooltip title="Save Workflow Trigger">
<div>
<IconButton disabled={!dirty} onClick={handleSave}>
<SaveIcon />
</IconButton>
</div>
</Tooltip>

<Tooltip title="Populate Input Parameters">
<div>
<IconButton
disabled={!values.workflowName}
onClick={triggerPopulateInput}
>
<PlaylistAddIcon />
</IconButton>
</div>
</Tooltip>

{dirty && <Pill label="Modified" />}
{createTime && <Text>Created: {timestampRenderer(createTime)}</Text>}
Expand Down
7 changes: 6 additions & 1 deletion ui/src/plugins/fetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@ export function useFetchContext() {
ready: true,
};
}
export function fetchWithContext(path, context, fetchParams, isJsonResponse) {
export function fetchWithContext(
path,
context,
fetchParams,
isJsonResponse = true
) {
const newParams = { ...fetchParams };

const newPath = `/api/${path}`;
Expand Down
1 change: 0 additions & 1 deletion ui/src/theme/theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,6 @@ const overrides = {
},
clearIndicator: {
fontSize: fontSizes.fontSize5,
color: baseTheme.palette.text.primary,
},
inputRoot: {
padding: "0px !important",
Expand Down
Loading

0 comments on commit a5034eb

Please sign in to comment.