reload files on model show page when uploading new ones w/ burnettk

This commit is contained in:
jasquat 2022-07-07 12:50:25 -04:00
parent 88629d1b57
commit 102088800a
3 changed files with 18 additions and 4 deletions

View File

@ -41,7 +41,7 @@
"web-vitals": "^2.1.4" "web-vitals": "^2.1.4"
}, },
"scripts": { "scripts": {
"start": "PORT=7001 craco start", "start": "ESLINT_NO_DEV_ERRORS=true PORT=7001 craco start",
"build": "craco build", "build": "craco build",
"test": "react-scripts test", "test": "react-scripts test",
"eject": "craco eject", "eject": "craco eject",

View File

@ -5,6 +5,7 @@ import { BACKEND_BASE_URL, HOT_AUTH_TOKEN } from '../config';
type Props = { type Props = {
processGroupId: string; processGroupId: string;
processModelId: string; processModelId: string;
onUploadedCallback?: (..._args: any[]) => any;
}; };
export default class FileInput extends React.Component<Props> { export default class FileInput extends React.Component<Props> {
@ -14,12 +15,15 @@ export default class FileInput extends React.Component<Props> {
processModelId: any; processModelId: any;
constructor({ processGroupId, processModelId }: Props) { onUploadedCallback: any;
super({ processGroupId, processModelId });
constructor({ processGroupId, processModelId, onUploadedCallback }: Props) {
super({ processGroupId, processModelId, onUploadedCallback });
this.handleSubmit = this.handleSubmit.bind(this); this.handleSubmit = this.handleSubmit.bind(this);
this.fileInput = React.createRef(); this.fileInput = React.createRef();
this.processGroupId = processGroupId; this.processGroupId = processGroupId;
this.processModelId = processModelId; this.processModelId = processModelId;
this.onUploadedCallback = onUploadedCallback;
} }
handleSubmit(event: any) { handleSubmit(event: any) {
@ -55,6 +59,9 @@ export default class FileInput extends React.Component<Props> {
}; };
axios.post(url, formData, config).then((response) => { axios.post(url, formData, config).then((response) => {
console.log(response.data); console.log(response.data);
if (this.onUploadedCallback) {
this.onUploadedCallback();
}
}); });
} }

View File

@ -10,6 +10,7 @@ export default function ProcessModelShow() {
const [processModel, setProcessModel] = useState(null); const [processModel, setProcessModel] = useState(null);
const [processInstanceResult, setProcessInstanceResult] = useState(null); const [processInstanceResult, setProcessInstanceResult] = useState(null);
const [reloadModel, setReloadModel] = useState(false);
useEffect(() => { useEffect(() => {
fetch( fetch(
@ -24,12 +25,13 @@ export default function ProcessModelShow() {
.then( .then(
(result) => { (result) => {
setProcessModel(result); setProcessModel(result);
setReloadModel(false);
}, },
(error) => { (error) => {
console.log(error); console.log(error);
} }
); );
}, [params]); }, [params, reloadModel]);
const processModelRun = (processInstance: any) => { const processModelRun = (processInstance: any) => {
fetch( fetch(
@ -96,6 +98,10 @@ export default function ProcessModelShow() {
); );
} }
const onUploadedCallback = () => {
setReloadModel(true);
};
if (processModel) { if (processModel) {
const processModelFilesTag = (processModel as any).files.map( const processModelFilesTag = (processModel as any).files.map(
(fileBpmn: any) => { (fileBpmn: any) => {
@ -132,6 +138,7 @@ export default function ProcessModelShow() {
<FileInput <FileInput
processModelId={(processModel as any).id} processModelId={(processModel as any).id}
processGroupId={(processModel as any).process_group_id} processGroupId={(processModel as any).process_group_id}
onUploadedCallback={onUploadedCallback}
/> />
<br /> <br />
<Stack direction="horizontal" gap={3}> <Stack direction="horizontal" gap={3}>