From e39805484e5e0fb4cdde1ee44954fd5bbfda13ef Mon Sep 17 00:00:00 2001 From: Heather0K Date: Wed, 28 Jun 2023 13:07:03 +0100 Subject: [PATCH 1/2] show error to user if cant submit --- docker-compose.yml | 17 ++-- .../helpers/validate-revision.ts | 2 +- .../new/components/DefaultSubmitButton.tsx | 93 ++++++++++--------- .../shared/hooks/use-viewer-saving.ts | 2 +- services/madoc-ts/translations/en/madoc.json | 1 + 5 files changed, 64 insertions(+), 51 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 4ab52b696..7958e3762 100755 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -99,6 +99,7 @@ services: tasks-api: tty: true image: ghcr.io/digirati-co-uk/tasks-api:latest + platform: linux/amd64 environment: - SERVER_PORT=3000 - DATABASE_HOST=shared-postgres @@ -119,6 +120,7 @@ services: model-api: tty: true image: digirati/capture-models:latest + platform: linux/amd64 environment: - SERVER_PORT=3000 - DATABASE_HOST=shared-postgres @@ -171,6 +173,7 @@ services: config-service: image: digirati/madoc_config_service_django:175410fc5b7dbef4cc259686564fbedeb60c8789 + platform: linux/amd64 environment: - USE_DOCKER=yes - IPYTHONDIR=/app/.ipython @@ -194,6 +197,7 @@ services: storage-api: tty: true image: ghcr.io/digirati-co-uk/storage-api:main + platform: linux/amd64 environment: - GATEWAY_HOST=${GATEWAY_HOST} volumes: @@ -204,9 +208,10 @@ services: search: image: ghcr.io/digirati-co-uk/madoc-search-service:247f854b1258e3971907e6912cef2374a1da8474 -# build: -# context: services/search -# dockerfile: Dockerfile + platform: linux/amd64 + # build: + # context: services/search + # dockerfile: Dockerfile environment: - BROWSABLE=False - USE_DOCKER=yes @@ -225,9 +230,9 @@ services: - DATABASE_URL=postgres://${POSTGRES_SEARCH_API_USER}:${POSTGRES_SEARCH_API_PASSWORD}@shared-postgres:${POSTGRES_PORT}/${POSTGRES_DB} links: - shared-postgres -# volumes: -# - ./services/search/search_service:/app + # volumes: + # - ./services/search/search_service:/app okra: image: digirati/okra:latest - + platform: linux/amd64 diff --git a/services/madoc-ts/src/frontend/shared/capture-models/helpers/validate-revision.ts b/services/madoc-ts/src/frontend/shared/capture-models/helpers/validate-revision.ts index c08e68d80..b905941cb 100644 --- a/services/madoc-ts/src/frontend/shared/capture-models/helpers/validate-revision.ts +++ b/services/madoc-ts/src/frontend/shared/capture-models/helpers/validate-revision.ts @@ -28,7 +28,7 @@ export function validateRevision( const filteredDocument = filterDocumentByRevision(req.document, req.revision, captureModel.revisions); if (!filteredDocument && (req.revision.deletedFields || []).length === 0) { - throw new RequestError('Invalid revision'); + throw new RequestError('Invalid revision: No changes'); } // If the source is `structure` we want to make sure a user was associated. We add this to the revision. diff --git a/services/madoc-ts/src/frontend/shared/capture-models/new/components/DefaultSubmitButton.tsx b/services/madoc-ts/src/frontend/shared/capture-models/new/components/DefaultSubmitButton.tsx index 98cc055f0..75947b7ca 100644 --- a/services/madoc-ts/src/frontend/shared/capture-models/new/components/DefaultSubmitButton.tsx +++ b/services/madoc-ts/src/frontend/shared/capture-models/new/components/DefaultSubmitButton.tsx @@ -9,6 +9,7 @@ import { HrefLink } from '../../../utility/href-link'; import { Revisions } from '../../editor/stores/revisions'; import { useDeselectRevision } from '../hooks/use-deselect-revision'; import { EditorRenderingConfig, useSlotContext } from './EditorSlots'; +import { ErrorMessage } from '../../../callouts/ErrorMessage'; export const DefaultSubmitButton: EditorRenderingConfig['SubmitButton'] = ({ afterSave, canSubmit = true }) => { const { t } = useTranslation(); @@ -38,7 +39,6 @@ export const DefaultSubmitButton: EditorRenderingConfig['SubmitButton'] = ({ aft // Change this to "draft" to save for later. await updateFunction(currentRevision, status); } catch (e) { - console.error(e); throw new Error(t('Unable to save your submission')); } }); @@ -63,49 +63,56 @@ export const DefaultSubmitButton: EditorRenderingConfig['SubmitButton'] = ({ aft }} footerAlignRight renderFooter={({ close }) => { - return isSuccess ? ( - <> - - {projectId ? ( - + ) : null} + - ) : null} - - - - ) : ( - - {!disableSaveForLater ? ( - - ) : null} - - + + ) : ( + + {!disableSaveForLater ? ( + + ) : null} + + + )} + ); }} > diff --git a/services/madoc-ts/src/frontend/shared/hooks/use-viewer-saving.ts b/services/madoc-ts/src/frontend/shared/hooks/use-viewer-saving.ts index bff452989..19281cac1 100644 --- a/services/madoc-ts/src/frontend/shared/hooks/use-viewer-saving.ts +++ b/services/madoc-ts/src/frontend/shared/hooks/use-viewer-saving.ts @@ -1,6 +1,6 @@ import { Revisions } from '../capture-models/editor/stores/revisions/index'; import { RevisionRequest } from '../capture-models/types/revision-request'; -import { useApi, useOptionalApi } from './use-api'; +import { useOptionalApi } from './use-api'; import { useMutation } from 'react-query'; import { createContext, useCallback, useContext } from 'react'; import { useUser } from './use-site'; diff --git a/services/madoc-ts/translations/en/madoc.json b/services/madoc-ts/translations/en/madoc.json index eaf2ee772..4847a6444 100644 --- a/services/madoc-ts/translations/en/madoc.json +++ b/services/madoc-ts/translations/en/madoc.json @@ -314,6 +314,7 @@ "Enter scope": "Enter scope", "Entity from model": "Entity from model", "Entity labelled by property": "Entity labelled by property", + "Error - Unable to save your submission": "Error - Unable to save your submission", "Errored": "Errored", "Errored / Rejected": "Errored / Rejected", "Exit edit mode": "Exit edit mode", From b9396283836930b768cab8659b3fab76bd859c70 Mon Sep 17 00:00:00 2001 From: Heather0K Date: Wed, 28 Jun 2023 13:34:14 +0100 Subject: [PATCH 2/2] fix refresh error on review page --- .../site/pages/tasks/review-listing/single-review.tsx | 8 +++++--- services/madoc-ts/translations/en/madoc.json | 1 + 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/services/madoc-ts/src/frontend/site/pages/tasks/review-listing/single-review.tsx b/services/madoc-ts/src/frontend/site/pages/tasks/review-listing/single-review.tsx index f753b8a8a..df3db7b11 100644 --- a/services/madoc-ts/src/frontend/site/pages/tasks/review-listing/single-review.tsx +++ b/services/madoc-ts/src/frontend/site/pages/tasks/review-listing/single-review.tsx @@ -194,9 +194,11 @@ function ViewSingleReview({ const limitedReviewer = user && user.scope && user.scope.indexOf('models.revision') !== -1 && user.scope.indexOf('models.create') === -1; const reviewer = - (user && user.scope && user.scope.indexOf('models.revision') !== -1) || - user.scope.indexOf('site.admin') || - (-1 && user.scope.indexOf('models.admin')); + user && + user.scope && + (user.scope.indexOf('models.revision') !== -1 || + user.scope.indexOf('site.admin') !== -1 || + user.scope.indexOf('models.admin') !== -1); const canReview = limitedReviewer ? review?.assignee?.id === user.user?.id : reviewer; const isDone = task?.status === 3; diff --git a/services/madoc-ts/translations/en/madoc.json b/services/madoc-ts/translations/en/madoc.json index 4847a6444..9bd08472b 100644 --- a/services/madoc-ts/translations/en/madoc.json +++ b/services/madoc-ts/translations/en/madoc.json @@ -886,6 +886,7 @@ "You can continue working on another canvas.": "You can continue working on another canvas.", "You can view your contribution in the left sidebar.": "You can view your contribution in the left sidebar.", "You cannot edit annotations if you are rotating": "You cannot edit annotations if you are rotating", + "You do not have the correct permissions to review this task": "You do not have the correct permissions to review this task", "You have already completed this item": "You have already completed this item", "You have already completed this manifest": "You have already completed this manifest", "You have been assigned a manifest": "You have been assigned a manifest",