mirror of
https://github.com/sartography/spiff-arena.git
synced 2025-01-12 02:24:15 +00:00
TaskShow had a useEffect that depended on params, that dependency caused an infinite request cycle when an error occured.
The same issue was happening on the ProcessInstanceListTable, and there it was being managed by a "SafelySetErrorMessage" function in one case, but would not be addressed in all possible cases. Reworked error handling into a context provider (APIErrorProvider) and hook (UseApiError) and removed the "(useContext as any)(ErrorContext)[1];" that felt a little off but that never was an actual problem.
This commit is contained in:
parent
809c4b055a
commit
c35ba85605
@ -20,8 +20,10 @@ services:
|
|||||||
retries: 10
|
retries: 10
|
||||||
|
|
||||||
spiffworkflow-backend:
|
spiffworkflow-backend:
|
||||||
container_name: spiffworkflow-backend
|
# container_name: spiffworkflow-backend
|
||||||
image: ghcr.io/sartography/spiffworkflow-backend:latest
|
build: ./spiffworkflow-backend/.
|
||||||
|
# dockerfile: Dockerfile
|
||||||
|
# image: ghcr.io/sartography/spiffworkflow-backend:latest
|
||||||
depends_on:
|
depends_on:
|
||||||
spiffworkflow-db:
|
spiffworkflow-db:
|
||||||
condition: service_healthy
|
condition: service_healthy
|
||||||
|
1854
spiffworkflow-frontend/package-lock.json
generated
1854
spiffworkflow-frontend/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -49,6 +49,7 @@
|
|||||||
"react-bootstrap": "^2.5.0",
|
"react-bootstrap": "^2.5.0",
|
||||||
"react-bootstrap-typeahead": "^6.0.0",
|
"react-bootstrap-typeahead": "^6.0.0",
|
||||||
"react-datepicker": "^4.8.0",
|
"react-datepicker": "^4.8.0",
|
||||||
|
"react-devtools": "^4.27.1",
|
||||||
"react-dom": "^18.2.0",
|
"react-dom": "^18.2.0",
|
||||||
"react-icons": "^4.4.0",
|
"react-icons": "^4.4.0",
|
||||||
"react-jsonschema-form": "^1.8.1",
|
"react-jsonschema-form": "^1.8.1",
|
||||||
|
@ -1,29 +1,20 @@
|
|||||||
import { useMemo, useState } from 'react';
|
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
import { Content } from '@carbon/react';
|
import { Content } from '@carbon/react';
|
||||||
|
|
||||||
import { BrowserRouter, Routes, Route } from 'react-router-dom';
|
import { BrowserRouter, Routes, Route } from 'react-router-dom';
|
||||||
import { defineAbility } from '@casl/ability';
|
import { defineAbility } from '@casl/ability';
|
||||||
import ErrorContext from './contexts/ErrorContext';
|
|
||||||
import NavigationBar from './components/NavigationBar';
|
import NavigationBar from './components/NavigationBar';
|
||||||
|
|
||||||
import HomePageRoutes from './routes/HomePageRoutes';
|
import HomePageRoutes from './routes/HomePageRoutes';
|
||||||
import ErrorBoundary from './components/ErrorBoundary';
|
import ErrorBoundary from './components/ErrorBoundary';
|
||||||
import AdminRoutes from './routes/AdminRoutes';
|
import AdminRoutes from './routes/AdminRoutes';
|
||||||
import { ErrorForDisplay } from './interfaces';
|
|
||||||
|
|
||||||
import { AbilityContext } from './contexts/Can';
|
import { AbilityContext } from './contexts/Can';
|
||||||
import UserService from './services/UserService';
|
import UserService from './services/UserService';
|
||||||
import ErrorDisplay from './components/ErrorDisplay';
|
import ErrorDisplay from './components/ErrorDisplay';
|
||||||
|
import APIErrorProvider from './contexts/APIErrorContext';
|
||||||
|
|
||||||
export default function App() {
|
export default function App() {
|
||||||
const [errorObject, setErrorObject] = useState<ErrorForDisplay | null>(null);
|
|
||||||
|
|
||||||
const errorContextValueArray = useMemo(
|
|
||||||
() => [errorObject, setErrorObject],
|
|
||||||
[errorObject]
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!UserService.isLoggedIn()) {
|
if (!UserService.isLoggedIn()) {
|
||||||
UserService.doLogin();
|
UserService.doLogin();
|
||||||
return null;
|
return null;
|
||||||
@ -35,7 +26,7 @@ export default function App() {
|
|||||||
<div className="cds--white">
|
<div className="cds--white">
|
||||||
{/* @ts-ignore */}
|
{/* @ts-ignore */}
|
||||||
<AbilityContext.Provider value={ability}>
|
<AbilityContext.Provider value={ability}>
|
||||||
<ErrorContext.Provider value={errorContextValueArray}>
|
<APIErrorProvider>
|
||||||
<BrowserRouter>
|
<BrowserRouter>
|
||||||
<NavigationBar />
|
<NavigationBar />
|
||||||
<Content>
|
<Content>
|
||||||
@ -49,7 +40,7 @@ export default function App() {
|
|||||||
</ErrorBoundary>
|
</ErrorBoundary>
|
||||||
</Content>
|
</Content>
|
||||||
</BrowserRouter>
|
</BrowserRouter>
|
||||||
</ErrorContext.Provider>
|
</APIErrorProvider>
|
||||||
</AbilityContext.Provider>
|
</AbilityContext.Provider>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import { useContext } from 'react';
|
|
||||||
import ErrorContext from '../contexts/ErrorContext';
|
|
||||||
import { Notification } from './Notification';
|
import { Notification } from './Notification';
|
||||||
|
import useAPIError from '../hooks/UseApiError';
|
||||||
|
|
||||||
function errorDetailDisplay(
|
function errorDetailDisplay(
|
||||||
errorObject: any,
|
errorObject: any,
|
||||||
@ -20,8 +19,8 @@ function errorDetailDisplay(
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default function ErrorDisplay() {
|
export default function ErrorDisplay() {
|
||||||
const [errorObject, setErrorObject] = (useContext as any)(ErrorContext);
|
const errorObject = useAPIError().error;
|
||||||
|
const { removeError } = useAPIError()
|
||||||
let errorTag = null;
|
let errorTag = null;
|
||||||
if (errorObject) {
|
if (errorObject) {
|
||||||
let sentryLinkTag = null;
|
let sentryLinkTag = null;
|
||||||
@ -50,7 +49,7 @@ export default function ErrorDisplay() {
|
|||||||
);
|
);
|
||||||
const errorLine = errorDetailDisplay(errorObject, 'error_line', 'Context');
|
const errorLine = errorDetailDisplay(errorObject, 'error_line', 'Context');
|
||||||
let taskTrace = null;
|
let taskTrace = null;
|
||||||
if ('task_trace' in errorObject && errorObject.task_trace.length > 1) {
|
if (errorObject.task_trace && errorObject.task_trace.length > 1) {
|
||||||
taskTrace = (
|
taskTrace = (
|
||||||
<div className="error_info">
|
<div className="error_info">
|
||||||
<span className="error_title">Call Activity Trace:</span>
|
<span className="error_title">Call Activity Trace:</span>
|
||||||
@ -62,7 +61,7 @@ export default function ErrorDisplay() {
|
|||||||
errorTag = (
|
errorTag = (
|
||||||
<Notification
|
<Notification
|
||||||
title={title}
|
title={title}
|
||||||
onClose={() => setErrorObject(null)}
|
onClose={() => (removeError())}
|
||||||
type="error"
|
type="error"
|
||||||
>
|
>
|
||||||
{message}
|
{message}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { useContext, useEffect, useMemo, useRef, useState } from 'react';
|
import { useEffect, useMemo, useRef, useState } from 'react';
|
||||||
import {
|
import {
|
||||||
Link,
|
Link,
|
||||||
useNavigate,
|
useNavigate,
|
||||||
@ -40,13 +40,11 @@ import {
|
|||||||
getProcessModelFullIdentifierFromSearchParams,
|
getProcessModelFullIdentifierFromSearchParams,
|
||||||
modifyProcessIdentifierForPathParam,
|
modifyProcessIdentifierForPathParam,
|
||||||
refreshAtInterval,
|
refreshAtInterval,
|
||||||
setErrorMessageSafely,
|
|
||||||
} from '../helpers';
|
} from '../helpers';
|
||||||
|
|
||||||
import PaginationForTable from './PaginationForTable';
|
import PaginationForTable from './PaginationForTable';
|
||||||
import 'react-datepicker/dist/react-datepicker.css';
|
import 'react-datepicker/dist/react-datepicker.css';
|
||||||
|
|
||||||
import ErrorContext from '../contexts/ErrorContext';
|
|
||||||
import HttpService from '../services/HttpService';
|
import HttpService from '../services/HttpService';
|
||||||
|
|
||||||
import 'react-bootstrap-typeahead/css/Typeahead.css';
|
import 'react-bootstrap-typeahead/css/Typeahead.css';
|
||||||
@ -61,6 +59,7 @@ import {
|
|||||||
ReportMetadata,
|
ReportMetadata,
|
||||||
ReportFilter,
|
ReportFilter,
|
||||||
User,
|
User,
|
||||||
|
ErrorForDisplay,
|
||||||
} from '../interfaces';
|
} from '../interfaces';
|
||||||
import ProcessModelSearch from './ProcessModelSearch';
|
import ProcessModelSearch from './ProcessModelSearch';
|
||||||
import ProcessInstanceReportSearch from './ProcessInstanceReportSearch';
|
import ProcessInstanceReportSearch from './ProcessInstanceReportSearch';
|
||||||
@ -68,6 +67,7 @@ import ProcessInstanceListDeleteReport from './ProcessInstanceListDeleteReport';
|
|||||||
import ProcessInstanceListSaveAsReport from './ProcessInstanceListSaveAsReport';
|
import ProcessInstanceListSaveAsReport from './ProcessInstanceListSaveAsReport';
|
||||||
import { FormatProcessModelDisplayName } from './MiniComponents';
|
import { FormatProcessModelDisplayName } from './MiniComponents';
|
||||||
import { Notification } from './Notification';
|
import { Notification } from './Notification';
|
||||||
|
import useAPIError from '../hooks/UseApiError';
|
||||||
|
|
||||||
const REFRESH_INTERVAL = 5;
|
const REFRESH_INTERVAL = 5;
|
||||||
const REFRESH_TIMEOUT = 600;
|
const REFRESH_TIMEOUT = 600;
|
||||||
@ -110,6 +110,7 @@ export default function ProcessInstanceListTable({
|
|||||||
const params = useParams();
|
const params = useParams();
|
||||||
const [searchParams] = useSearchParams();
|
const [searchParams] = useSearchParams();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
const { addError, removeError } = useAPIError();
|
||||||
|
|
||||||
const [processInstances, setProcessInstances] = useState([]);
|
const [processInstances, setProcessInstances] = useState([]);
|
||||||
const [reportMetadata, setReportMetadata] = useState<ReportMetadata | null>();
|
const [reportMetadata, setReportMetadata] = useState<ReportMetadata | null>();
|
||||||
@ -133,8 +134,6 @@ export default function ProcessInstanceListTable({
|
|||||||
const [endFromTimeInvalid, setEndFromTimeInvalid] = useState<boolean>(false);
|
const [endFromTimeInvalid, setEndFromTimeInvalid] = useState<boolean>(false);
|
||||||
const [endToTimeInvalid, setEndToTimeInvalid] = useState<boolean>(false);
|
const [endToTimeInvalid, setEndToTimeInvalid] = useState<boolean>(false);
|
||||||
|
|
||||||
const [errorObject, setErrorObject] = (useContext as any)(ErrorContext);
|
|
||||||
|
|
||||||
const processInstanceListPathPrefix =
|
const processInstanceListPathPrefix =
|
||||||
variant === 'all'
|
variant === 'all'
|
||||||
? '/admin/process-instances/all'
|
? '/admin/process-instances/all'
|
||||||
@ -517,7 +516,7 @@ export default function ProcessInstanceListTable({
|
|||||||
}
|
}
|
||||||
if (message !== '') {
|
if (message !== '') {
|
||||||
valid = false;
|
valid = false;
|
||||||
setErrorMessageSafely(message, errorObject, setErrorObject);
|
addError({ message } as ErrorForDisplay);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -579,7 +578,7 @@ export default function ProcessInstanceListTable({
|
|||||||
queryParamString += `&process_initiator_username=${processInitiatorSelection.username}`;
|
queryParamString += `&process_initiator_username=${processInitiatorSelection.username}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
setErrorObject(null);
|
removeError();
|
||||||
setProcessInstanceReportJustSaved(null);
|
setProcessInstanceReportJustSaved(null);
|
||||||
setProcessInstanceFilters({});
|
setProcessInstanceFilters({});
|
||||||
navigate(`${processInstanceListPathPrefix}?${queryParamString}`);
|
navigate(`${processInstanceListPathPrefix}?${queryParamString}`);
|
||||||
@ -679,7 +678,7 @@ export default function ProcessInstanceListTable({
|
|||||||
queryParamString = `?report_id=${selectedReport.id}`;
|
queryParamString = `?report_id=${selectedReport.id}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
setErrorObject(null);
|
removeError();
|
||||||
setProcessInstanceReportJustSaved(mode || null);
|
setProcessInstanceReportJustSaved(mode || null);
|
||||||
navigate(`${processInstanceListPathPrefix}${queryParamString}`);
|
navigate(`${processInstanceListPathPrefix}${queryParamString}`);
|
||||||
};
|
};
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
import { useContext } from 'react';
|
|
||||||
import { useNavigate } from 'react-router-dom';
|
import { useNavigate } from 'react-router-dom';
|
||||||
import {
|
import {
|
||||||
Button,
|
Button,
|
||||||
@ -11,9 +10,9 @@ import {
|
|||||||
RecentProcessModel,
|
RecentProcessModel,
|
||||||
} from '../interfaces';
|
} from '../interfaces';
|
||||||
import HttpService from '../services/HttpService';
|
import HttpService from '../services/HttpService';
|
||||||
import ErrorContext from '../contexts/ErrorContext';
|
|
||||||
import { modifyProcessIdentifierForPathParam } from '../helpers';
|
import { modifyProcessIdentifierForPathParam } from '../helpers';
|
||||||
import { usePermissionFetcher } from '../hooks/PermissionService';
|
import { usePermissionFetcher } from '../hooks/PermissionService';
|
||||||
|
import useAPIError from '../hooks/UseApiError';
|
||||||
|
|
||||||
const storeRecentProcessModelInLocalStorage = (
|
const storeRecentProcessModelInLocalStorage = (
|
||||||
processModelForStorage: ProcessModel
|
processModelForStorage: ProcessModel
|
||||||
@ -78,7 +77,7 @@ export default function ProcessInstanceRun({
|
|||||||
checkPermissions = true,
|
checkPermissions = true,
|
||||||
}: OwnProps) {
|
}: OwnProps) {
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const setErrorObject = (useContext as any)(ErrorContext)[1];
|
const { addError, removeError } = useAPIError();
|
||||||
const modifiedProcessModelId = modifyProcessIdentifierForPathParam(
|
const modifiedProcessModelId = modifyProcessIdentifierForPathParam(
|
||||||
processModel.id
|
processModel.id
|
||||||
);
|
);
|
||||||
@ -105,12 +104,12 @@ export default function ProcessInstanceRun({
|
|||||||
};
|
};
|
||||||
|
|
||||||
const processModelRun = (processInstance: any) => {
|
const processModelRun = (processInstance: any) => {
|
||||||
setErrorObject(null);
|
removeError();
|
||||||
storeRecentProcessModelInLocalStorage(processModel);
|
storeRecentProcessModelInLocalStorage(processModel);
|
||||||
HttpService.makeCallToBackend({
|
HttpService.makeCallToBackend({
|
||||||
path: `/process-instances/${modifiedProcessModelId}/${processInstance.id}/run`,
|
path: `/process-instances/${modifiedProcessModelId}/${processInstance.id}/run`,
|
||||||
successCallback: onProcessInstanceRun,
|
successCallback: onProcessInstanceRun,
|
||||||
failureCallback: setErrorObject,
|
failureCallback: addError,
|
||||||
httpMethod: 'POST',
|
httpMethod: 'POST',
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -6,7 +6,7 @@ import BpmnViewer from 'bpmn-js/lib/Viewer';
|
|||||||
import {
|
import {
|
||||||
BpmnPropertiesPanelModule,
|
BpmnPropertiesPanelModule,
|
||||||
BpmnPropertiesProviderModule,
|
BpmnPropertiesProviderModule,
|
||||||
// @ts-expect-error TS(7016) FIXME: Could not find a declaration file for module 'bpmn... Remove this comment to see the full error message
|
// @ts-expect-error TS(7016) FIXME: Could not find a declaration file for module 'bpmn... RemoFve this comment to see the full error message
|
||||||
} from 'bpmn-js-properties-panel';
|
} from 'bpmn-js-properties-panel';
|
||||||
|
|
||||||
// @ts-expect-error TS(7016) FIXME: Could not find a declaration file for module 'dmn-... Remove this comment to see the full error message
|
// @ts-expect-error TS(7016) FIXME: Could not find a declaration file for module 'dmn-... Remove this comment to see the full error message
|
||||||
|
40
spiffworkflow-frontend/src/contexts/APIErrorContext.tsx
Normal file
40
spiffworkflow-frontend/src/contexts/APIErrorContext.tsx
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
import React, { createContext, useState, useCallback } from 'react';
|
||||||
|
import { ErrorForDisplay } from '../interfaces';
|
||||||
|
|
||||||
|
type ErrorContextType = {
|
||||||
|
error: null | ErrorForDisplay;
|
||||||
|
addError: Function;
|
||||||
|
removeError: Function;
|
||||||
|
};
|
||||||
|
export const APIErrorContext = createContext<ErrorContextType>({
|
||||||
|
error: null,
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
addError: () => {},
|
||||||
|
removeError: () => {},
|
||||||
|
});
|
||||||
|
|
||||||
|
// @ts-ignore
|
||||||
|
// eslint-disable-next-line react/prop-types
|
||||||
|
export default function APIErrorProvider({ children }) {
|
||||||
|
const [error, setError] = useState<ErrorForDisplay | null>(null);
|
||||||
|
const addError = (errorForDisplay: ErrorForDisplay | null) => {
|
||||||
|
setError(errorForDisplay);
|
||||||
|
console.log('Adding an error.', errorForDisplay);
|
||||||
|
}
|
||||||
|
const removeError = () => setError(null);
|
||||||
|
|
||||||
|
const contextValue = {
|
||||||
|
error,
|
||||||
|
addError: useCallback(
|
||||||
|
(newError: ErrorForDisplay | null) => addError(newError),
|
||||||
|
[]
|
||||||
|
),
|
||||||
|
removeError: useCallback(() => removeError(), []),
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<APIErrorContext.Provider value={contextValue}>
|
||||||
|
{children}
|
||||||
|
</APIErrorContext.Provider>
|
||||||
|
);
|
||||||
|
}
|
@ -1,5 +0,0 @@
|
|||||||
import { createContext } from 'react';
|
|
||||||
|
|
||||||
// @ts-expect-error TS(2554) FIXME: Expected 1 arguments, but got 0.
|
|
||||||
const ErrorContext = createContext();
|
|
||||||
export default ErrorContext;
|
|
@ -258,20 +258,6 @@ export const getBpmnProcessIdentifiers = (rootBpmnElement: any) => {
|
|||||||
return childProcesses;
|
return childProcesses;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Setting the error message state to the same string is still considered a change
|
|
||||||
// and re-renders the page so check the message first to avoid that.
|
|
||||||
export const setErrorMessageSafely = (
|
|
||||||
newErrorMessageString: string,
|
|
||||||
oldErrorMessage: ErrorForDisplay,
|
|
||||||
errorMessageSetter: any
|
|
||||||
) => {
|
|
||||||
if (oldErrorMessage && oldErrorMessage.message === newErrorMessageString) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
errorMessageSetter({ message: newErrorMessageString });
|
|
||||||
return null;
|
|
||||||
};
|
|
||||||
|
|
||||||
export const isInteger = (str: string | number) => {
|
export const isInteger = (str: string | number) => {
|
||||||
return /^\d+$/.test(str.toString());
|
return /^\d+$/.test(str.toString());
|
||||||
};
|
};
|
||||||
|
10
spiffworkflow-frontend/src/hooks/UseApiError.tsx
Normal file
10
spiffworkflow-frontend/src/hooks/UseApiError.tsx
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
// src/common/hooks/useAPIError/index.js
|
||||||
|
import { useContext } from 'react';
|
||||||
|
import { APIErrorContext } from '../contexts/APIErrorContext';
|
||||||
|
|
||||||
|
function useAPIError() {
|
||||||
|
const { error, addError, removeError } = useContext(APIErrorContext);
|
||||||
|
return { error, addError, removeError };
|
||||||
|
}
|
||||||
|
|
||||||
|
export default useAPIError;
|
@ -182,6 +182,7 @@ export interface ErrorForDisplay {
|
|||||||
task_id?: string;
|
task_id?: string;
|
||||||
line_number?: number;
|
line_number?: number;
|
||||||
file_name?: string;
|
file_name?: string;
|
||||||
|
task_trace?: [string];
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface AuthenticationParam {
|
export interface AuthenticationParam {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { Routes, Route, useLocation } from 'react-router-dom';
|
import { Routes, Route, useLocation } from 'react-router-dom';
|
||||||
|
|
||||||
import { useContext, useEffect } from 'react';
|
import { useEffect } from 'react';
|
||||||
import ProcessGroupList from './ProcessGroupList';
|
import ProcessGroupList from './ProcessGroupList';
|
||||||
import ProcessGroupShow from './ProcessGroupShow';
|
import ProcessGroupShow from './ProcessGroupShow';
|
||||||
import ProcessGroupNew from './ProcessGroupNew';
|
import ProcessGroupNew from './ProcessGroupNew';
|
||||||
@ -17,21 +17,21 @@ import ProcessInstanceReportList from './ProcessInstanceReportList';
|
|||||||
import ProcessInstanceReportNew from './ProcessInstanceReportNew';
|
import ProcessInstanceReportNew from './ProcessInstanceReportNew';
|
||||||
import ProcessInstanceReportEdit from './ProcessInstanceReportEdit';
|
import ProcessInstanceReportEdit from './ProcessInstanceReportEdit';
|
||||||
import ReactFormEditor from './ReactFormEditor';
|
import ReactFormEditor from './ReactFormEditor';
|
||||||
import ErrorContext from '../contexts/ErrorContext';
|
|
||||||
import ProcessInstanceLogList from './ProcessInstanceLogList';
|
import ProcessInstanceLogList from './ProcessInstanceLogList';
|
||||||
import MessageInstanceList from './MessageInstanceList';
|
import MessageInstanceList from './MessageInstanceList';
|
||||||
import Configuration from './Configuration';
|
import Configuration from './Configuration';
|
||||||
import JsonSchemaFormBuilder from './JsonSchemaFormBuilder';
|
import JsonSchemaFormBuilder from './JsonSchemaFormBuilder';
|
||||||
import ProcessModelNewExperimental from './ProcessModelNewExperimental';
|
import ProcessModelNewExperimental from './ProcessModelNewExperimental';
|
||||||
import ProcessInstanceFindById from './ProcessInstanceFindById';
|
import ProcessInstanceFindById from './ProcessInstanceFindById';
|
||||||
|
import useAPIError from '../hooks/UseApiError';
|
||||||
|
|
||||||
export default function AdminRoutes() {
|
export default function AdminRoutes() {
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
const setErrorObject = (useContext as any)(ErrorContext)[1];
|
const { removeError } = useAPIError();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setErrorObject(null);
|
removeError();
|
||||||
}, [location, setErrorObject]);
|
}, [location, removeError]);
|
||||||
|
|
||||||
if (UserService.hasRole(['admin'])) {
|
if (UserService.hasRole(['admin'])) {
|
||||||
return (
|
return (
|
||||||
|
@ -1,14 +1,13 @@
|
|||||||
import { useContext, useEffect, useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
import { Table } from '@carbon/react';
|
import { Table } from '@carbon/react';
|
||||||
import ErrorContext from '../contexts/ErrorContext';
|
import useAPIError from '../hooks/UseApiError';
|
||||||
import { AuthenticationItem } from '../interfaces';
|
import { AuthenticationItem } from '../interfaces';
|
||||||
import HttpService from '../services/HttpService';
|
import HttpService from '../services/HttpService';
|
||||||
import UserService from '../services/UserService';
|
import UserService from '../services/UserService';
|
||||||
|
|
||||||
export default function AuthenticationList() {
|
export default function AuthenticationList() {
|
||||||
const setErrorObject = (useContext as any)(ErrorContext)[1];
|
const { addError } = useAPIError();
|
||||||
|
|
||||||
const [authenticationList, setAuthenticationList] = useState<
|
const [authenticationList, setAuthenticationList] = useState<
|
||||||
AuthenticationItem[] | null
|
AuthenticationItem[] | null
|
||||||
>(null);
|
>(null);
|
||||||
@ -26,9 +25,9 @@ export default function AuthenticationList() {
|
|||||||
HttpService.makeCallToBackend({
|
HttpService.makeCallToBackend({
|
||||||
path: `/authentications`,
|
path: `/authentications`,
|
||||||
successCallback: processResult,
|
successCallback: processResult,
|
||||||
failureCallback: setErrorObject,
|
failureCallback: addError,
|
||||||
});
|
});
|
||||||
}, [setErrorObject]);
|
}, [addError]);
|
||||||
|
|
||||||
const buildTable = () => {
|
const buildTable = () => {
|
||||||
if (authenticationList) {
|
if (authenticationList) {
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
import { useContext, useEffect, useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
import { Route, Routes, useLocation, useNavigate } from 'react-router-dom';
|
import { Route, Routes, useLocation, useNavigate } from 'react-router-dom';
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
import { Tabs, TabList, Tab } from '@carbon/react';
|
import { Tabs, TabList, Tab } from '@carbon/react';
|
||||||
import { Can } from '@casl/react';
|
import { Can } from '@casl/react';
|
||||||
import ErrorContext from '../contexts/ErrorContext';
|
import useAPIError from '../hooks/UseApiError';
|
||||||
import SecretList from './SecretList';
|
import SecretList from './SecretList';
|
||||||
import SecretNew from './SecretNew';
|
import SecretNew from './SecretNew';
|
||||||
import SecretShow from './SecretShow';
|
import SecretShow from './SecretShow';
|
||||||
@ -14,7 +14,7 @@ import { usePermissionFetcher } from '../hooks/PermissionService';
|
|||||||
|
|
||||||
export default function Configuration() {
|
export default function Configuration() {
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
const setErrorObject = (useContext as any)(ErrorContext)[1];
|
const { removeError } = useAPIError();
|
||||||
const [selectedTabIndex, setSelectedTabIndex] = useState<number>(0);
|
const [selectedTabIndex, setSelectedTabIndex] = useState<number>(0);
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
|
||||||
@ -26,13 +26,13 @@ export default function Configuration() {
|
|||||||
const { ability } = usePermissionFetcher(permissionRequestData);
|
const { ability } = usePermissionFetcher(permissionRequestData);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setErrorObject(null);
|
removeError();
|
||||||
let newSelectedTabIndex = 0;
|
let newSelectedTabIndex = 0;
|
||||||
if (location.pathname.match(/^\/admin\/configuration\/authentications\b/)) {
|
if (location.pathname.match(/^\/admin\/configuration\/authentications\b/)) {
|
||||||
newSelectedTabIndex = 1;
|
newSelectedTabIndex = 1;
|
||||||
}
|
}
|
||||||
setSelectedTabIndex(newSelectedTabIndex);
|
setSelectedTabIndex(newSelectedTabIndex);
|
||||||
}, [location, setErrorObject]);
|
}, [location, removeError]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
import { useContext, useEffect, useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
import { Route, Routes, useLocation, useNavigate } from 'react-router-dom';
|
import { Route, Routes, useLocation, useNavigate } from 'react-router-dom';
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
import { Tabs, TabList, Tab } from '@carbon/react';
|
import { Tabs, TabList, Tab } from '@carbon/react';
|
||||||
import TaskShow from './TaskShow';
|
import TaskShow from './TaskShow';
|
||||||
import ErrorContext from '../contexts/ErrorContext';
|
import useAPIError from '../hooks/UseApiError';
|
||||||
import MyTasks from './MyTasks';
|
import MyTasks from './MyTasks';
|
||||||
import GroupedTasks from './GroupedTasks';
|
import GroupedTasks from './GroupedTasks';
|
||||||
import CompletedInstances from './CompletedInstances';
|
import CompletedInstances from './CompletedInstances';
|
||||||
@ -11,12 +11,12 @@ import CreateNewInstance from './CreateNewInstance';
|
|||||||
|
|
||||||
export default function HomePageRoutes() {
|
export default function HomePageRoutes() {
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
const setErrorObject = (useContext as any)(ErrorContext)[1];
|
const { removeError } = useAPIError();
|
||||||
const [selectedTabIndex, setSelectedTabIndex] = useState<number>(0);
|
const [selectedTabIndex, setSelectedTabIndex] = useState<number>(0);
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setErrorObject(null);
|
removeError();
|
||||||
let newSelectedTabIndex = 0;
|
let newSelectedTabIndex = 0;
|
||||||
if (location.pathname.match(/^\/tasks\/completed-instances\b/)) {
|
if (location.pathname.match(/^\/tasks\/completed-instances\b/)) {
|
||||||
newSelectedTabIndex = 1;
|
newSelectedTabIndex = 1;
|
||||||
@ -24,7 +24,7 @@ export default function HomePageRoutes() {
|
|||||||
newSelectedTabIndex = 2;
|
newSelectedTabIndex = 2;
|
||||||
}
|
}
|
||||||
setSelectedTabIndex(newSelectedTabIndex);
|
setSelectedTabIndex(newSelectedTabIndex);
|
||||||
}, [location, setErrorObject]);
|
}, [location, removeError]);
|
||||||
|
|
||||||
const renderTabs = () => {
|
const renderTabs = () => {
|
||||||
if (location.pathname.match(/^\/tasks\/\d+\/\b/)) {
|
if (location.pathname.match(/^\/tasks\/\d+\/\b/)) {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { useContext, useEffect, useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
import Editor from '@monaco-editor/react';
|
import Editor from '@monaco-editor/react';
|
||||||
import {
|
import {
|
||||||
useParams,
|
useParams,
|
||||||
@ -38,7 +38,6 @@ import {
|
|||||||
unModifyProcessIdentifierForPathParam,
|
unModifyProcessIdentifierForPathParam,
|
||||||
} from '../helpers';
|
} from '../helpers';
|
||||||
import ButtonWithConfirmation from '../components/ButtonWithConfirmation';
|
import ButtonWithConfirmation from '../components/ButtonWithConfirmation';
|
||||||
import ErrorContext from '../contexts/ErrorContext';
|
|
||||||
import { useUriListForPermissions } from '../hooks/UriListForPermissions';
|
import { useUriListForPermissions } from '../hooks/UriListForPermissions';
|
||||||
import {
|
import {
|
||||||
PermissionsToCheck,
|
PermissionsToCheck,
|
||||||
@ -49,6 +48,7 @@ import {
|
|||||||
import { usePermissionFetcher } from '../hooks/PermissionService';
|
import { usePermissionFetcher } from '../hooks/PermissionService';
|
||||||
import ProcessInstanceClass from '../classes/ProcessInstanceClass';
|
import ProcessInstanceClass from '../classes/ProcessInstanceClass';
|
||||||
import TaskListTable from '../components/TaskListTable';
|
import TaskListTable from '../components/TaskListTable';
|
||||||
|
import useAPIError from '../hooks/UseApiError';
|
||||||
|
|
||||||
type OwnProps = {
|
type OwnProps = {
|
||||||
variant: string;
|
variant: string;
|
||||||
@ -75,8 +75,7 @@ export default function ProcessInstanceShow({ variant }: OwnProps) {
|
|||||||
useState<boolean>(false);
|
useState<boolean>(false);
|
||||||
const [displayDetails, setDisplayDetails] = useState<boolean>(false);
|
const [displayDetails, setDisplayDetails] = useState<boolean>(false);
|
||||||
|
|
||||||
const setErrorObject = (useContext as any)(ErrorContext)[1];
|
const { addError, removeError } = useAPIError();
|
||||||
|
|
||||||
const unModifiedProcessModelId = unModifyProcessIdentifierForPathParam(
|
const unModifiedProcessModelId = unModifyProcessIdentifierForPathParam(
|
||||||
`${params.process_model_id}`
|
`${params.process_model_id}`
|
||||||
);
|
);
|
||||||
@ -151,11 +150,11 @@ export default function ProcessInstanceShow({ variant }: OwnProps) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, [
|
}, [
|
||||||
params,
|
// targetUris,
|
||||||
|
// params,
|
||||||
modifiedProcessModelId,
|
modifiedProcessModelId,
|
||||||
permissionsLoaded,
|
permissionsLoaded,
|
||||||
ability,
|
ability,
|
||||||
targetUris,
|
|
||||||
searchParams,
|
searchParams,
|
||||||
taskListPath,
|
taskListPath,
|
||||||
variant,
|
variant,
|
||||||
@ -684,7 +683,7 @@ export default function ProcessInstanceShow({ variant }: OwnProps) {
|
|||||||
setSelectingEvent(false);
|
setSelectingEvent(false);
|
||||||
initializeTaskDataToDisplay(taskToDisplay);
|
initializeTaskDataToDisplay(taskToDisplay);
|
||||||
setEventPayload('{}');
|
setEventPayload('{}');
|
||||||
setErrorObject(null);
|
removeError();
|
||||||
};
|
};
|
||||||
|
|
||||||
const taskDataStringToObject = (dataString: string) => {
|
const taskDataStringToObject = (dataString: string) => {
|
||||||
@ -699,16 +698,12 @@ export default function ProcessInstanceShow({ variant }: OwnProps) {
|
|||||||
refreshPage();
|
refreshPage();
|
||||||
};
|
};
|
||||||
|
|
||||||
const saveTaskDataFailure = (result: any) => {
|
|
||||||
setErrorObject({ message: result.message });
|
|
||||||
};
|
|
||||||
|
|
||||||
const saveTaskData = () => {
|
const saveTaskData = () => {
|
||||||
if (!taskToDisplay) {
|
if (!taskToDisplay) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
setErrorObject(null);
|
removeError();
|
||||||
|
|
||||||
// taskToUse is copy of taskToDisplay, with taskDataToDisplay in data attribute
|
// taskToUse is copy of taskToDisplay, with taskDataToDisplay in data attribute
|
||||||
const taskToUse: any = { ...taskToDisplay, data: taskDataToDisplay };
|
const taskToUse: any = { ...taskToDisplay, data: taskDataToDisplay };
|
||||||
@ -716,7 +711,7 @@ export default function ProcessInstanceShow({ variant }: OwnProps) {
|
|||||||
path: `${targetUris.processInstanceTaskListDataPath}/${taskToUse.id}`,
|
path: `${targetUris.processInstanceTaskListDataPath}/${taskToUse.id}`,
|
||||||
httpMethod: 'PUT',
|
httpMethod: 'PUT',
|
||||||
successCallback: saveTaskDataResult,
|
successCallback: saveTaskDataResult,
|
||||||
failureCallback: saveTaskDataFailure,
|
failureCallback: addError,
|
||||||
postBody: {
|
postBody: {
|
||||||
new_task_data: taskToUse.data,
|
new_task_data: taskToUse.data,
|
||||||
},
|
},
|
||||||
@ -730,7 +725,7 @@ export default function ProcessInstanceShow({ variant }: OwnProps) {
|
|||||||
path: `/send-event/${modifiedProcessModelId}/${params.process_instance_id}`,
|
path: `/send-event/${modifiedProcessModelId}/${params.process_instance_id}`,
|
||||||
httpMethod: 'POST',
|
httpMethod: 'POST',
|
||||||
successCallback: saveTaskDataResult,
|
successCallback: saveTaskDataResult,
|
||||||
failureCallback: saveTaskDataFailure,
|
failureCallback: addError,
|
||||||
postBody: eventToSend,
|
postBody: eventToSend,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { useContext, useEffect, useRef, useState } from 'react';
|
import { useEffect, useRef, useState } from 'react';
|
||||||
import {
|
import {
|
||||||
generatePath,
|
generatePath,
|
||||||
useNavigate,
|
useNavigate,
|
||||||
@ -25,7 +25,7 @@ import MDEditor from '@uiw/react-md-editor';
|
|||||||
import ReactDiagramEditor from '../components/ReactDiagramEditor';
|
import ReactDiagramEditor from '../components/ReactDiagramEditor';
|
||||||
import ProcessBreadcrumb from '../components/ProcessBreadcrumb';
|
import ProcessBreadcrumb from '../components/ProcessBreadcrumb';
|
||||||
import HttpService from '../services/HttpService';
|
import HttpService from '../services/HttpService';
|
||||||
import ErrorContext from '../contexts/ErrorContext';
|
import useAPIError from '../hooks/UseApiError';
|
||||||
import { makeid, modifyProcessIdentifierForPathParam } from '../helpers';
|
import { makeid, modifyProcessIdentifierForPathParam } from '../helpers';
|
||||||
import {
|
import {
|
||||||
CarbonComboBoxProcessSelection,
|
CarbonComboBoxProcessSelection,
|
||||||
@ -100,7 +100,7 @@ export default function ProcessModelEditDiagram() {
|
|||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const [searchParams] = useSearchParams();
|
const [searchParams] = useSearchParams();
|
||||||
|
|
||||||
const setErrorObject = (useContext as any)(ErrorContext)[1];
|
const { addError, removeError } = useAPIError();
|
||||||
const [processModelFile, setProcessModelFile] = useState<ProcessFile | null>(
|
const [processModelFile, setProcessModelFile] = useState<ProcessFile | null>(
|
||||||
null
|
null
|
||||||
);
|
);
|
||||||
@ -176,7 +176,7 @@ export default function ProcessModelEditDiagram() {
|
|||||||
|
|
||||||
const saveDiagram = (bpmnXML: any, fileName = params.file_name) => {
|
const saveDiagram = (bpmnXML: any, fileName = params.file_name) => {
|
||||||
setDisplaySaveFileMessage(false);
|
setDisplaySaveFileMessage(false);
|
||||||
setErrorObject(null);
|
removeError();
|
||||||
setBpmnXmlForDiagramRendering(bpmnXML);
|
setBpmnXmlForDiagramRendering(bpmnXML);
|
||||||
|
|
||||||
let url = `/process-models/${modifiedProcessModelId}/files`;
|
let url = `/process-models/${modifiedProcessModelId}/files`;
|
||||||
@ -202,7 +202,7 @@ export default function ProcessModelEditDiagram() {
|
|||||||
HttpService.makeCallToBackend({
|
HttpService.makeCallToBackend({
|
||||||
path: url,
|
path: url,
|
||||||
successCallback: navigateToProcessModelFile,
|
successCallback: navigateToProcessModelFile,
|
||||||
failureCallback: setErrorObject,
|
failureCallback: addError,
|
||||||
httpMethod,
|
httpMethod,
|
||||||
postBody: formData,
|
postBody: formData,
|
||||||
});
|
});
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { useContext, useEffect, useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
import { Link, useNavigate, useParams } from 'react-router-dom';
|
import { Link, useNavigate, useParams } from 'react-router-dom';
|
||||||
import {
|
import {
|
||||||
Add,
|
Add,
|
||||||
@ -32,7 +32,8 @@ import {
|
|||||||
import { Can } from '@casl/react';
|
import { Can } from '@casl/react';
|
||||||
import ProcessBreadcrumb from '../components/ProcessBreadcrumb';
|
import ProcessBreadcrumb from '../components/ProcessBreadcrumb';
|
||||||
import HttpService from '../services/HttpService';
|
import HttpService from '../services/HttpService';
|
||||||
import ErrorContext from '../contexts/ErrorContext';
|
import useAPIError from '../hooks/UseApiError';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
getGroupFromModifiedModelId,
|
getGroupFromModifiedModelId,
|
||||||
modifyProcessIdentifierForPathParam,
|
modifyProcessIdentifierForPathParam,
|
||||||
@ -52,7 +53,7 @@ import { Notification } from '../components/Notification';
|
|||||||
|
|
||||||
export default function ProcessModelShow() {
|
export default function ProcessModelShow() {
|
||||||
const params = useParams();
|
const params = useParams();
|
||||||
const setErrorObject = (useContext as any)(ErrorContext)[1];
|
const { addError, removeError } = useAPIError();
|
||||||
|
|
||||||
const [processModel, setProcessModel] = useState<ProcessModel | null>(null);
|
const [processModel, setProcessModel] = useState<ProcessModel | null>(null);
|
||||||
const [processInstance, setProcessInstance] =
|
const [processInstance, setProcessInstance] =
|
||||||
@ -148,7 +149,7 @@ export default function ProcessModelShow() {
|
|||||||
!('file_contents' in processModelFile) ||
|
!('file_contents' in processModelFile) ||
|
||||||
processModelFile.file_contents === undefined
|
processModelFile.file_contents === undefined
|
||||||
) {
|
) {
|
||||||
setErrorObject({
|
addError({
|
||||||
message: `Could not file file contents for file: ${processModelFile.name}`,
|
message: `Could not file file contents for file: ${processModelFile.name}`,
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
@ -169,7 +170,7 @@ export default function ProcessModelShow() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const downloadFile = (fileName: string) => {
|
const downloadFile = (fileName: string) => {
|
||||||
setErrorObject(null);
|
removeError();
|
||||||
const processModelPath = `process-models/${modifiedProcessModelId}`;
|
const processModelPath = `process-models/${modifiedProcessModelId}`;
|
||||||
HttpService.makeCallToBackend({
|
HttpService.makeCallToBackend({
|
||||||
path: `/${processModelPath}/files/${fileName}`,
|
path: `/${processModelPath}/files/${fileName}`,
|
||||||
@ -374,7 +375,7 @@ export default function ProcessModelShow() {
|
|||||||
|
|
||||||
const doFileUpload = (event: any) => {
|
const doFileUpload = (event: any) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
setErrorObject(null);
|
removeError();
|
||||||
const url = `/process-models/${modifiedProcessModelId}/files`;
|
const url = `/process-models/${modifiedProcessModelId}/files`;
|
||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
formData.append('file', filesToUpload[0]);
|
formData.append('file', filesToUpload[0]);
|
||||||
@ -384,7 +385,7 @@ export default function ProcessModelShow() {
|
|||||||
successCallback: onUploadedCallback,
|
successCallback: onUploadedCallback,
|
||||||
httpMethod: 'POST',
|
httpMethod: 'POST',
|
||||||
postBody: formData,
|
postBody: formData,
|
||||||
failureCallback: setErrorObject,
|
failureCallback: addError,
|
||||||
});
|
});
|
||||||
setFilesToUpload(null);
|
setFilesToUpload(null);
|
||||||
};
|
};
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { useContext, useEffect, useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
import Editor from '@monaco-editor/react';
|
import Editor from '@monaco-editor/react';
|
||||||
import { useNavigate, useParams, useSearchParams } from 'react-router-dom';
|
import { useNavigate, useParams, useSearchParams } from 'react-router-dom';
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
@ -8,16 +8,14 @@ import HttpService from '../services/HttpService';
|
|||||||
import ButtonWithConfirmation from '../components/ButtonWithConfirmation';
|
import ButtonWithConfirmation from '../components/ButtonWithConfirmation';
|
||||||
import { modifyProcessIdentifierForPathParam } from '../helpers';
|
import { modifyProcessIdentifierForPathParam } from '../helpers';
|
||||||
import { ProcessFile } from '../interfaces';
|
import { ProcessFile } from '../interfaces';
|
||||||
import ErrorContext from '../contexts/ErrorContext';
|
|
||||||
import { Notification } from '../components/Notification';
|
import { Notification } from '../components/Notification';
|
||||||
|
import useAPIError from '../hooks/UseApiError';
|
||||||
// NOTE: This is mostly the same as ProcessModelEditDiagram and if we go this route could
|
// NOTE: This is mostly the same as ProcessModelEditDiagram and if we go this route could
|
||||||
// possibly be merged into it. I'm leaving as a separate file now in case it does
|
// possibly be merged into it. I'm leaving as a separate file now in case it does
|
||||||
// end up diverging greatly
|
// end up diverging greatly
|
||||||
export default function ReactFormEditor() {
|
export default function ReactFormEditor() {
|
||||||
const params = useParams();
|
const params = useParams();
|
||||||
const setErrorObject = (useContext as any)(ErrorContext)[1];
|
const { addError, removeError } = useAPIError();
|
||||||
|
|
||||||
const [showFileNameEditor, setShowFileNameEditor] = useState(false);
|
const [showFileNameEditor, setShowFileNameEditor] = useState(false);
|
||||||
const [newFileName, setNewFileName] = useState('');
|
const [newFileName, setNewFileName] = useState('');
|
||||||
const searchParams = useSearchParams()[0];
|
const searchParams = useSearchParams()[0];
|
||||||
@ -87,7 +85,7 @@ export default function ReactFormEditor() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const saveFile = () => {
|
const saveFile = () => {
|
||||||
setErrorObject(null);
|
removeError();
|
||||||
setDisplaySaveFileMessage(false);
|
setDisplaySaveFileMessage(false);
|
||||||
|
|
||||||
let url = `/process-models/${modifiedProcessModelId}/files`;
|
let url = `/process-models/${modifiedProcessModelId}/files`;
|
||||||
@ -116,7 +114,7 @@ export default function ReactFormEditor() {
|
|||||||
HttpService.makeCallToBackend({
|
HttpService.makeCallToBackend({
|
||||||
path: url,
|
path: url,
|
||||||
successCallback: navigateToProcessModelFile,
|
successCallback: navigateToProcessModelFile,
|
||||||
failureCallback: setErrorObject,
|
failureCallback: addError,
|
||||||
httpMethod,
|
httpMethod,
|
||||||
postBody: formData,
|
postBody: formData,
|
||||||
});
|
});
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { useContext, useEffect, useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
import { useNavigate, useParams } from 'react-router-dom';
|
import { useNavigate, useParams } from 'react-router-dom';
|
||||||
import validator from '@rjsf/validator-ajv8';
|
import validator from '@rjsf/validator-ajv8';
|
||||||
|
|
||||||
@ -17,7 +17,7 @@ import remarkGfm from 'remark-gfm';
|
|||||||
// eslint-disable-next-line import/no-named-as-default
|
// eslint-disable-next-line import/no-named-as-default
|
||||||
import Form from '../themes/carbon';
|
import Form from '../themes/carbon';
|
||||||
import HttpService from '../services/HttpService';
|
import HttpService from '../services/HttpService';
|
||||||
import ErrorContext from '../contexts/ErrorContext';
|
import useAPIError from '../hooks/UseApiError';
|
||||||
import { modifyProcessIdentifierForPathParam } from '../helpers';
|
import { modifyProcessIdentifierForPathParam } from '../helpers';
|
||||||
import { useUriListForPermissions } from '../hooks/UriListForPermissions';
|
import { useUriListForPermissions } from '../hooks/UriListForPermissions';
|
||||||
import { PermissionsToCheck } from '../interfaces';
|
import { PermissionsToCheck } from '../interfaces';
|
||||||
@ -29,7 +29,7 @@ export default function TaskShow() {
|
|||||||
const params = useParams();
|
const params = useParams();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
|
||||||
const setErrorObject = (useContext as any)(ErrorContext)[1];
|
const { addError, removeError } = useAPIError();
|
||||||
|
|
||||||
const { targetUris } = useUriListForPermissions();
|
const { targetUris } = useUriListForPermissions();
|
||||||
const permissionRequestData: PermissionsToCheck = {
|
const permissionRequestData: PermissionsToCheck = {
|
||||||
@ -39,48 +39,55 @@ export default function TaskShow() {
|
|||||||
permissionRequestData
|
permissionRequestData
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const processResult = (result: any) => {
|
||||||
|
setTask(result);
|
||||||
|
const url = `/task-data/${modifyProcessIdentifierForPathParam(
|
||||||
|
result.process_model_identifier
|
||||||
|
)}/${params.process_instance_id}`;
|
||||||
|
if (
|
||||||
|
result.process_model_identifier &&
|
||||||
|
ability.can('GET', url)
|
||||||
|
// Assure we get a valid process model identifier back
|
||||||
|
) {
|
||||||
|
HttpService.makeCallToBackend({
|
||||||
|
path: url,
|
||||||
|
successCallback: setUserTasks,
|
||||||
|
failureCallback: (error: any) => {
|
||||||
|
addError(error);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (permissionsLoaded) {
|
if (permissionsLoaded) {
|
||||||
const processResult = (result: any) => {
|
|
||||||
setTask(result);
|
|
||||||
if (ability.can('GET', targetUris.processInstanceTaskListDataPath)) {
|
|
||||||
HttpService.makeCallToBackend({
|
|
||||||
path: `/task-data/${modifyProcessIdentifierForPathParam(
|
|
||||||
result.process_model_identifier
|
|
||||||
)}/${params.process_instance_id}`,
|
|
||||||
successCallback: setUserTasks,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
HttpService.makeCallToBackend({
|
HttpService.makeCallToBackend({
|
||||||
path: `/tasks/${params.process_instance_id}/${params.task_id}`,
|
path: `/tasks/${params.process_instance_id}/${params.task_id}`,
|
||||||
successCallback: processResult,
|
successCallback: processResult,
|
||||||
// This causes the page to continuously reload
|
failureCallback: addError,
|
||||||
// failureCallback: setErrorObject,
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}, [params, permissionsLoaded, ability, targetUris]);
|
}, [permissionsLoaded, ability]); // params and targetUris (which deps on params) cause this to re-fire in an infinite loop on error.
|
||||||
|
|
||||||
const processSubmitResult = (result: any) => {
|
const processSubmitResult = (result: any) => {
|
||||||
setErrorObject(null);
|
removeError();
|
||||||
if (result.ok) {
|
if (result.ok) {
|
||||||
navigate(`/tasks`);
|
navigate(`/tasks`);
|
||||||
} else if (result.process_instance_id) {
|
} else if (result.process_instance_id) {
|
||||||
navigate(`/tasks/${result.process_instance_id}/${result.id}`);
|
navigate(`/tasks/${result.process_instance_id}/${result.id}`);
|
||||||
} else {
|
} else {
|
||||||
setErrorObject(`Received unexpected error: ${result.message}`);
|
addError(result);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleFormSubmit = (event: any) => {
|
const handleFormSubmit = (event: any) => {
|
||||||
setErrorObject(null);
|
removeError();
|
||||||
const dataToSubmit = event.formData;
|
const dataToSubmit = event.formData;
|
||||||
delete dataToSubmit.isManualTask;
|
delete dataToSubmit.isManualTask;
|
||||||
HttpService.makeCallToBackend({
|
HttpService.makeCallToBackend({
|
||||||
path: `/tasks/${params.process_instance_id}/${params.task_id}`,
|
path: `/tasks/${params.process_instance_id}/${params.task_id}`,
|
||||||
successCallback: processSubmitResult,
|
successCallback: processSubmitResult,
|
||||||
failureCallback: setErrorObject,
|
failureCallback: addError,
|
||||||
httpMethod: 'PUT',
|
httpMethod: 'PUT',
|
||||||
postBody: dataToSubmit,
|
postBody: dataToSubmit,
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user