From 675c776a5a6bff743cdcb7969aa7b8dc14ab65e9 Mon Sep 17 00:00:00 2001 From: jasquat Date: Thu, 8 Dec 2022 12:28:23 -0500 Subject: [PATCH] added new notification component that allows links based on carbons w/ burnettk cullerton --- .../src/spiffworkflow_backend/api.yml | 2 +- .../services/git_service.py | 4 +- .../integration/test_process_api.py | 2 +- .../src/components/Notification.tsx | 48 ++++++++++++++ .../components/ProcessInstanceListTable.tsx | 16 ++--- .../src/hooks/UriListForPermissions.tsx | 1 + spiffworkflow-frontend/src/index.css | 11 +++- .../src/routes/ProcessModelShow.tsx | 65 ++++++++++--------- 8 files changed, 105 insertions(+), 44 deletions(-) create mode 100644 spiffworkflow-frontend/src/components/Notification.tsx diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/api.yml b/spiffworkflow-backend/src/spiffworkflow_backend/api.yml index 3dc700612..d4ed3755d 100755 --- a/spiffworkflow-backend/src/spiffworkflow_backend/api.yml +++ b/spiffworkflow-backend/src/spiffworkflow_backend/api.yml @@ -459,7 +459,7 @@ paths: description: the name of the branch we want to merge into schema: type: string - put: + post: operationId: spiffworkflow_backend.routes.process_api_blueprint.process_model_publish summary: Merge changes from this model to another branch. tags: diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/services/git_service.py b/spiffworkflow-backend/src/spiffworkflow_backend/services/git_service.py index b5c451b45..27d940259 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/services/git_service.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/services/git_service.py @@ -96,8 +96,8 @@ class GitService: os.system("git push") # build url for github page to open PR - output = os.popen("git remote -v").read() - remote_url = output.strip().split("\n")[0].split("\t")[1].split(" ")[0].replace(".git", "") + output = os.popen("git config --get remote.origin.url").read() + remote_url = output.strip().replace(".git", "") pr_url = f"{remote_url}/compare/{publish_branch}?expand=1" # try to clean up diff --git a/spiffworkflow-backend/tests/spiffworkflow_backend/integration/test_process_api.py b/spiffworkflow-backend/tests/spiffworkflow_backend/integration/test_process_api.py index 8f9933027..495dbfc72 100644 --- a/spiffworkflow-backend/tests/spiffworkflow_backend/integration/test_process_api.py +++ b/spiffworkflow-backend/tests/spiffworkflow_backend/integration/test_process_api.py @@ -2665,7 +2665,7 @@ class TestProcessApi(BaseTest): assert "new_file.txt" in listing modified_process_model_id = process_model_identifier.replace("/", ":") - # response = client.put( + # response = client.post( # f"/v1.0/process-models/{modified_process_model_id}/publish?branch_to_update=staging", # headers=self.logged_in_headers(with_super_admin_user), # ) diff --git a/spiffworkflow-frontend/src/components/Notification.tsx b/spiffworkflow-frontend/src/components/Notification.tsx new file mode 100644 index 000000000..a3a200779 --- /dev/null +++ b/spiffworkflow-frontend/src/components/Notification.tsx @@ -0,0 +1,48 @@ +import React, { useState } from 'react'; +// @ts-ignore +import { Close, CheckmarkFilled } from '@carbon/icons-react'; +// @ts-ignore +import { Button } from '@carbon/react'; + +type OwnProps = { + title: string; + children: React.ReactNode; + onClose: (..._args: any[]) => any; + type?: string; +}; + +export function Notification({ + title, + children, + onClose, + type = 'success', +}: OwnProps) { + let iconClassName = 'green-icon'; + if (type === 'error') { + iconClassName = 'red-icon'; + } + return ( +
+
+
+ +
{title}
+
{children}
+
+
+
+ ); +} diff --git a/spiffworkflow-frontend/src/components/ProcessInstanceListTable.tsx b/spiffworkflow-frontend/src/components/ProcessInstanceListTable.tsx index eee5a2736..51d20d64b 100644 --- a/spiffworkflow-frontend/src/components/ProcessInstanceListTable.tsx +++ b/spiffworkflow-frontend/src/components/ProcessInstanceListTable.tsx @@ -7,7 +7,7 @@ import { } from 'react-router-dom'; // @ts-ignore -import { Filter, Close, AddAlt } from '@carbon/icons-react'; +import { Filter, Close, AddAlt, CheckmarkFilled } from '@carbon/icons-react'; import { Button, ButtonSet, @@ -65,6 +65,7 @@ import ProcessModelSearch from './ProcessModelSearch'; import ProcessInstanceReportSearch from './ProcessInstanceReportSearch'; import ProcessInstanceListSaveAsReport from './ProcessInstanceListSaveAsReport'; import { FormatProcessModelDisplayName } from './MiniComponents'; +import { Notification } from './Notification'; const REFRESH_INTERVAL = 5; const REFRESH_TIMEOUT = 600; @@ -372,18 +373,13 @@ export default function ProcessInstanceListTable({ titleOperation = 'Created'; } return ( - <> - setProcessInstanceReportJustSaved(null)}> + {`'${ processInstanceReportSelection ? processInstanceReportSelection.identifier : '' - }'`} - kind="success" - /> -
- + }'`}
+ ); } return null; diff --git a/spiffworkflow-frontend/src/hooks/UriListForPermissions.tsx b/spiffworkflow-frontend/src/hooks/UriListForPermissions.tsx index eff30a828..f84465c82 100644 --- a/spiffworkflow-frontend/src/hooks/UriListForPermissions.tsx +++ b/spiffworkflow-frontend/src/hooks/UriListForPermissions.tsx @@ -18,6 +18,7 @@ export const useUriListForPermissions = () => { processModelCreatePath: `/v1.0/process-models/${params.process_group_id}`, processModelFileCreatePath: `/v1.0/process-models/${params.process_model_id}/files`, processModelFileShowPath: `/v1.0/process-models/${params.process_model_id}/files/${params.file_name}`, + processModelPublishPath: `/v1.0/process-models/${params.process_model_id}/publish`, processModelShowPath: `/v1.0/process-models/${params.process_model_id}`, secretListPath: `/v1.0/secrets`, }; diff --git a/spiffworkflow-frontend/src/index.css b/spiffworkflow-frontend/src/index.css index f40947858..5701a4f1d 100644 --- a/spiffworkflow-frontend/src/index.css +++ b/spiffworkflow-frontend/src/index.css @@ -332,6 +332,14 @@ td.actions-cell { fill: red; } +svg.green-icon { + fill: #198038; +} + +svg.notification-icon { + margin-right: 1rem; +} + .failure-string { color: red; } @@ -358,7 +366,8 @@ td.actions-cell { } +/* lime green */ .tag-type-green:hover { - background-color: #00FF00; + background-color: #80ee90; } diff --git a/spiffworkflow-frontend/src/routes/ProcessModelShow.tsx b/spiffworkflow-frontend/src/routes/ProcessModelShow.tsx index ecd6cada7..24abd1409 100644 --- a/spiffworkflow-frontend/src/routes/ProcessModelShow.tsx +++ b/spiffworkflow-frontend/src/routes/ProcessModelShow.tsx @@ -49,6 +49,7 @@ import ProcessInstanceListTable from '../components/ProcessInstanceListTable'; import { usePermissionFetcher } from '../hooks/PermissionService'; import { useUriListForPermissions } from '../hooks/UriListForPermissions'; import ProcessInstanceRun from '../components/ProcessInstanceRun'; +import { Notification } from '../components/Notification'; export default function ProcessModelShow() { const params = useParams(); @@ -62,11 +63,13 @@ export default function ProcessModelShow() { const [showFileUploadModal, setShowFileUploadModal] = useState(false); const [processModelPublished, setProcessModelPublished] = useState(null); + const [publishDisabled, setPublishDisabled] = useState(false); const navigate = useNavigate(); const { targetUris } = useUriListForPermissions(); const permissionRequestData: PermissionsToCheck = { [targetUris.processModelShowPath]: ['PUT', 'DELETE'], + [targetUris.processModelPublishPath]: ['POST'], [targetUris.processInstanceListPath]: ['GET'], [targetUris.processInstanceCreatePath]: ['POST'], [targetUris.processModelFileCreatePath]: ['POST', 'PUT', 'GET', 'DELETE'], @@ -93,19 +96,17 @@ export default function ProcessModelShow() { const processInstanceRunResultTag = () => { if (processInstance) { return ( -
-

- Process Instance {processInstance.id} kicked off ( - - view - - ). -

-
-
+ setProcessInstance(null)} + > + + view + + ); } return null; @@ -206,15 +207,17 @@ export default function ProcessModelShow() { }; const postPublish = (value: any) => { + setPublishDisabled(false); setProcessModelPublished(value); }; const publishProcessModel = () => { + setPublishDisabled(true); setProcessModelPublished(null); HttpService.makeCallToBackend({ path: `/process-models/${modifiedProcessModelId}/publish`, successCallback: postPublish, - httpMethod: 'PUT', + httpMethod: 'POST', }); }; @@ -529,16 +532,14 @@ export default function ProcessModelShow() { if (processModelPublished) { const prUrl: string = processModelPublished.pr_url; return ( - <> - -
- + setProcessModelPublished(false)} + > + + view the changes and create a Pull Request + + ); } return null; @@ -548,7 +549,6 @@ export default function ProcessModelShow() { return ( <> {fileUploadModal()} - {processModelPublishMessage()} + {processModelPublishMessage()} + {processInstanceRunResultTag()}

Process Model: {processModel.display_name} @@ -603,11 +605,16 @@ export default function ProcessModelShow() {
-
- -
+ + + - {processInstanceRunResultTag()} {processModelFilesSection()} {processInstanceListTableButton()}