From 606c61efa2d8c3cbb6947fa960594d7ac82f84ef Mon Sep 17 00:00:00 2001 From: jasquat Date: Tue, 15 Nov 2022 11:00:52 -0500 Subject: [PATCH] added configuration nav item to help reduce nav items w/ burnettk --- .../routes/process_api_blueprint.py | 2 +- .../src/components/FileInput.tsx | 57 ------------------ .../src/components/NavigationBar.tsx | 18 ++---- .../src/components/SubNavigation.tsx | 59 ------------------- .../src/routes/AdminRoutes.tsx | 6 +- .../src/routes/Configuration.tsx | 52 ++++++++++++++++ spiffworkflow-frontend/src/routes/MyTasks.tsx | 3 +- .../src/routes/ProcessModelShow.tsx | 23 +------- .../src/routes/SecretList.tsx | 6 +- .../src/routes/SecretNew.tsx | 4 +- .../src/routes/SecretShow.tsx | 6 +- 11 files changed, 69 insertions(+), 167 deletions(-) delete mode 100644 spiffworkflow-frontend/src/components/FileInput.tsx delete mode 100644 spiffworkflow-frontend/src/components/SubNavigation.tsx create mode 100644 spiffworkflow-frontend/src/routes/Configuration.tsx diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/routes/process_api_blueprint.py b/spiffworkflow-backend/src/spiffworkflow_backend/routes/process_api_blueprint.py index 1722635cf..6e1cee4d6 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/routes/process_api_blueprint.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/routes/process_api_blueprint.py @@ -1597,7 +1597,7 @@ def add_secret(body: Dict) -> Response: def update_secret(key: str, body: dict) -> Response: """Update secret.""" - SecretService().update_secret(key, body["value"], body["user_id"]) + SecretService().update_secret(key, body["value"], g.user.id) return Response(json.dumps({"ok": True}), status=200, mimetype="application/json") diff --git a/spiffworkflow-frontend/src/components/FileInput.tsx b/spiffworkflow-frontend/src/components/FileInput.tsx deleted file mode 100644 index b86e21111..000000000 --- a/spiffworkflow-frontend/src/components/FileInput.tsx +++ /dev/null @@ -1,57 +0,0 @@ -import React from 'react'; -import HttpService from '../services/HttpService'; -import { modifyProcessModelPath } from '../helpers'; - -type Props = { - processGroupId: string; - processModelId: string; - onUploadedCallback?: (..._args: any[]) => any; -}; - -export default class FileInput extends React.Component { - fileInput: any; - - processGroupId: any; - - processModelId: any; - - onUploadedCallback: any; - - constructor({ processGroupId, processModelId, onUploadedCallback }: Props) { - super({ processGroupId, processModelId, onUploadedCallback }); - this.handleSubmit = this.handleSubmit.bind(this); - this.fileInput = React.createRef(); - this.processGroupId = processGroupId; - this.processModelId = processModelId; - this.onUploadedCallback = onUploadedCallback; - } - - handleSubmit(event: any) { - event.preventDefault(); - const modifiedProcessModelId = modifyProcessModelPath( - `${this.processGroupId}/${this.processModelId}` - ); - const url = `/process-models/${modifiedProcessModelId}/files`; - const formData = new FormData(); - formData.append('file', this.fileInput.current.files[0]); - formData.append('fileName', this.fileInput.current.files[0].name); - HttpService.makeCallToBackend({ - path: url, - successCallback: this.onUploadedCallback, - httpMethod: 'POST', - postBody: formData, - }); - } - - render() { - return ( -
- - -
- ); - } -} diff --git a/spiffworkflow-frontend/src/components/NavigationBar.tsx b/spiffworkflow-frontend/src/components/NavigationBar.tsx index 25ff3582f..6ef62ac83 100644 --- a/spiffworkflow-frontend/src/components/NavigationBar.tsx +++ b/spiffworkflow-frontend/src/components/NavigationBar.tsx @@ -44,10 +44,8 @@ export default function NavigationBar() { newActiveKey = '/admin/process-instances/reports'; } else if (location.pathname.match(/^\/admin\/process-instances\b/)) { newActiveKey = '/admin/process-instances'; - } else if (location.pathname.match(/^\/admin\/secrets\b/)) { - newActiveKey = '/admin/secrets'; - } else if (location.pathname.match(/^\/admin\/authentications\b/)) { - newActiveKey = '/admin/authentications'; + } else if (location.pathname.match(/^\/admin\/configuration\b/)) { + newActiveKey = '/admin/configuration'; } else if (location.pathname === '/') { newActiveKey = '/'; } else if (location.pathname.match(/^\/tasks\b/)) { @@ -112,16 +110,10 @@ export default function NavigationBar() { Messages - Secrets - - - Authentications + Configuration { - let newActiveKey = '/admin/process-groups'; - if (location.pathname.match(/^\/admin\/messages\b/)) { - newActiveKey = '/admin/messages'; - } else if ( - location.pathname.match(/^\/admin\/process-instances\/reports\b/) - ) { - newActiveKey = '/admin/process-instances/reports'; - } else if (location.pathname.match(/^\/admin\/process-instances\b/)) { - newActiveKey = '/admin/process-instances'; - } else if (location.pathname.match(/^\/admin\/secrets\b/)) { - newActiveKey = '/admin/secrets'; - } else if (location.pathname.match(/^\/admin\/authentications\b/)) { - newActiveKey = '/admin/authentications'; - } else if (location.pathname === '/') { - newActiveKey = '/'; - } else if (location.pathname.match(/^\/tasks\b/)) { - newActiveKey = '/'; - } - setActiveKey(newActiveKey); - }, [location]); - - if (activeKey) { - return ( - - ); - } - return null; -} diff --git a/spiffworkflow-frontend/src/routes/AdminRoutes.tsx b/spiffworkflow-frontend/src/routes/AdminRoutes.tsx index 84609d663..eb08e20b9 100644 --- a/spiffworkflow-frontend/src/routes/AdminRoutes.tsx +++ b/spiffworkflow-frontend/src/routes/AdminRoutes.tsx @@ -24,6 +24,7 @@ import SecretList from './SecretList'; import SecretNew from './SecretNew'; import SecretShow from './SecretShow'; import AuthenticationList from './AuthenticationList'; +import Configuration from './Configuration'; export default function AdminRoutes() { const location = useLocation(); @@ -110,10 +111,7 @@ export default function AdminRoutes() { /> } /> } /> - } /> - } /> - } /> - } /> + } /> ); } diff --git a/spiffworkflow-frontend/src/routes/Configuration.tsx b/spiffworkflow-frontend/src/routes/Configuration.tsx new file mode 100644 index 000000000..0390ec906 --- /dev/null +++ b/spiffworkflow-frontend/src/routes/Configuration.tsx @@ -0,0 +1,52 @@ +import { useContext, useEffect, useState } from 'react'; +import { Route, Routes, useLocation, useNavigate } from 'react-router-dom'; +// @ts-ignore +import { Tabs, TabList, Tab } from '@carbon/react'; +import TaskShow from './TaskShow'; +import ErrorContext from '../contexts/ErrorContext'; +import MyTasks from './MyTasks'; +import GroupedTasks from './GroupedTasks'; +import CompletedInstances from './CompletedInstances'; +import SecretList from './SecretList'; +import SecretNew from './SecretNew'; +import SecretShow from './SecretShow'; +import AuthenticationList from './AuthenticationList'; + +export default function Configuration() { + const location = useLocation(); + const setErrorMessage = (useContext as any)(ErrorContext)[1]; + const [selectedTabIndex, setSelectedTabIndex] = useState(0); + const navigate = useNavigate(); + + useEffect(() => { + setErrorMessage(null); + let newSelectedTabIndex = 0; + if (location.pathname.match(/^\/admin\/configuration\/authentications\b/)) { + newSelectedTabIndex = 1; + } + setSelectedTabIndex(newSelectedTabIndex); + }, [location, setErrorMessage]); + + return ( + <> + + + navigate('/admin/configuration/secrets')}> + Secrets + + navigate('/admin/configuration/authentications')}> + Authentications + + + +
+ + } /> + } /> + } /> + } /> + } /> + + + ); +} diff --git a/spiffworkflow-frontend/src/routes/MyTasks.tsx b/spiffworkflow-frontend/src/routes/MyTasks.tsx index a2183dbbf..010f3805d 100644 --- a/spiffworkflow-frontend/src/routes/MyTasks.tsx +++ b/spiffworkflow-frontend/src/routes/MyTasks.tsx @@ -122,7 +122,7 @@ export default function MyTasks() { }); return ( <> -

Processes I can start

+

Recently viewed process models

@@ -169,6 +169,7 @@ export default function MyTasks() { return ( <> {tasksWaitingForMe} +
{relevantProcessModelSection} ); diff --git a/spiffworkflow-frontend/src/routes/ProcessModelShow.tsx b/spiffworkflow-frontend/src/routes/ProcessModelShow.tsx index 9c1fa8cfa..044b787eb 100644 --- a/spiffworkflow-frontend/src/routes/ProcessModelShow.tsx +++ b/spiffworkflow-frontend/src/routes/ProcessModelShow.tsx @@ -30,7 +30,7 @@ import { import ProcessBreadcrumb from '../components/ProcessBreadcrumb'; import HttpService from '../services/HttpService'; import ErrorContext from '../contexts/ErrorContext'; -import { modifyProcessModelPath, unModifyProcessModelPath } from '../helpers'; +import { modifyProcessModelPath } from '../helpers'; import { ProcessFile, ProcessModel, RecentProcessModel } from '../interfaces'; import ButtonWithConfirmation from '../components/ButtonWithConfirmation'; import ProcessInstanceListTable from '../components/ProcessInstanceListTable'; @@ -353,27 +353,6 @@ export default function ProcessModelShow() { ); }; - const processInstancesUl = () => { - const unmodifiedProcessModelId: String = unModifyProcessModelPath( - `${params.process_model_id}` - ); - if (!processModel) { - return null; - } - return ( -
    -
  • - - List - -
  • -
- ); - }; - const handleFileUploadCancel = () => { setShowFileUploadModal(false); }; diff --git a/spiffworkflow-frontend/src/routes/SecretList.tsx b/spiffworkflow-frontend/src/routes/SecretList.tsx index b41792d61..be9e3c1c5 100644 --- a/spiffworkflow-frontend/src/routes/SecretList.tsx +++ b/spiffworkflow-frontend/src/routes/SecretList.tsx @@ -42,12 +42,12 @@ export default function SecretList() { return ( @@ -96,7 +96,7 @@ export default function SecretList() {

Secrets

{SecretsDisplayArea()} - +
); } diff --git a/spiffworkflow-frontend/src/routes/SecretNew.tsx b/spiffworkflow-frontend/src/routes/SecretNew.tsx index 329d7e2f7..02bc88c9a 100644 --- a/spiffworkflow-frontend/src/routes/SecretNew.tsx +++ b/spiffworkflow-frontend/src/routes/SecretNew.tsx @@ -12,11 +12,11 @@ export default function SecretNew() { const navigate = useNavigate(); const navigateToSecret = (_result: any) => { - navigate(`/admin/secrets/${key}`); + navigate(`/admin/configuration/secrets/${key}`); }; const navigateToSecrets = () => { - navigate(`/admin/secrets`); + navigate(`/admin/configuration/secrets`); }; const changeSpacesToDash = (someString: string) => { diff --git a/spiffworkflow-frontend/src/routes/SecretShow.tsx b/spiffworkflow-frontend/src/routes/SecretShow.tsx index 6dd446b0e..4a434d8e4 100644 --- a/spiffworkflow-frontend/src/routes/SecretShow.tsx +++ b/spiffworkflow-frontend/src/routes/SecretShow.tsx @@ -26,10 +26,6 @@ export default function SecretShow() { } }; - // const reloadSecret = (_result: any) => { - // window.location.reload(); - // }; - const updateSecretValue = () => { if (secret && secretValue) { secret.value = secretValue; @@ -48,7 +44,7 @@ export default function SecretShow() { }; const navigateToSecrets = (_result: any) => { - navigate(`/admin/secrets`); + navigate(`/admin/configuration/secrets`); }; const deleteSecret = () => {
- + {(row as any).id} - + {(row as any).key}