From 8e5d650be4940b3f27baae76e8e1b9d81fbd70ab Mon Sep 17 00:00:00 2001 From: Felipe Trost Date: Fri, 13 Dec 2024 12:49:18 +0100 Subject: [PATCH 1/6] fix(ms2/process-page): throw UnauthorizedError -> correct error message --- .../(dashboard)/[environmentId]/processes/[processId]/page.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/management-system-v2/app/(dashboard)/[environmentId]/processes/[processId]/page.tsx b/src/management-system-v2/app/(dashboard)/[environmentId]/processes/[processId]/page.tsx index bfe3d8e02..1ae4b8f4e 100644 --- a/src/management-system-v2/app/(dashboard)/[environmentId]/processes/[processId]/page.tsx +++ b/src/management-system-v2/app/(dashboard)/[environmentId]/processes/[processId]/page.tsx @@ -6,6 +6,7 @@ import { toCaslResource } from '@/lib/ability/caslAbility'; import AddUserControls from '@/components/add-user-controls'; import { getProcess, getProcesses } from '@/lib/data/DTOs'; import { getProcessBPMN } from '@/lib/data/processes'; +import { UnauthorizedError } from '@/lib/ability/abilityHelper'; type ProcessProps = { params: { processId: string; environmentId: string }; @@ -25,7 +26,7 @@ const Process = async ({ params: { processId, environmentId }, searchParams }: P const processes = await getProcesses(userId, ability, false); if (!ability.can('view', toCaslResource('Process', process))) { - throw new Error('Forbidden.'); + throw new UnauthorizedError(); } const selectedVersionBpmn = selectedVersionId From 17993ad4486d5b8f4a5566f113224c4245451317 Mon Sep 17 00:00:00 2001 From: Felipe Trost Date: Sun, 15 Dec 2024 03:41:13 +0100 Subject: [PATCH 2/6] feat(ms2/share-modal): select version of process in share modal --- ...modeler-share-modal-option-public-link.tsx | 182 ++++++++++-------- .../[processId]/modeler-share-modal.tsx | 8 +- .../processes/[processId]/modeler-toolbar.tsx | 1 + 3 files changed, 105 insertions(+), 86 deletions(-) diff --git a/src/management-system-v2/app/(dashboard)/[environmentId]/processes/[processId]/modeler-share-modal-option-public-link.tsx b/src/management-system-v2/app/(dashboard)/[environmentId]/processes/[processId]/modeler-share-modal-option-public-link.tsx index 9d37f3740..8f8e90303 100644 --- a/src/management-system-v2/app/(dashboard)/[environmentId]/processes/[processId]/modeler-share-modal-option-public-link.tsx +++ b/src/management-system-v2/app/(dashboard)/[environmentId]/processes/[processId]/modeler-share-modal-option-public-link.tsx @@ -1,5 +1,5 @@ 'use client'; -import { App, Button, Checkbox, Col, Flex, Input, QRCode, Row } from 'antd'; +import { App, Button, Checkbox, Col, Flex, Input, QRCode, Row, Select, Space } from 'antd'; import { DownloadOutlined, CopyOutlined } from '@ant-design/icons'; import { useEffect, useRef, useState } from 'react'; import { useParams, useSearchParams } from 'next/navigation'; @@ -10,21 +10,24 @@ import { import { useEnvironment } from '@/components/auth-can'; import styles from './modeler-share-modal-option-public-link.module.scss'; +import { Process } from '@/lib/data/process-schema'; type ModelerShareModalOptionPublicLinkProps = { sharedAs: 'public' | 'protected'; shareTimestamp: number; refresh: () => void; + processVersions: Process['versions']; }; const ModelerShareModalOptionPublicLink = ({ sharedAs, shareTimestamp, refresh, + processVersions, }: ModelerShareModalOptionPublicLinkProps) => { const { processId } = useParams(); const query = useSearchParams(); - const selectedVersionId = query.get('version'); + const [selectedVersionId, setSelectedVersionId] = useState(query.get('version')); const environment = useEnvironment(); const [shareLink, setShareLink] = useState(''); @@ -185,95 +188,104 @@ const ModelerShareModalOptionPublicLink = ({ }; return ( - <> -
+ + + + + - - - - {isShareLinkChecked && ( -
- -
- )} -
- - - - - - - - - - -
- + Visible only for registered user + + + + + + + + + {isShareLinkChecked && ( +
+ +
+ )} +
+ + + + + + + + + + + ); }; diff --git a/src/management-system-v2/app/(dashboard)/[environmentId]/processes/[processId]/modeler-share-modal.tsx b/src/management-system-v2/app/(dashboard)/[environmentId]/processes/[processId]/modeler-share-modal.tsx index daafe5c69..26d405cc9 100644 --- a/src/management-system-v2/app/(dashboard)/[environmentId]/processes/[processId]/modeler-share-modal.tsx +++ b/src/management-system-v2/app/(dashboard)/[environmentId]/processes/[processId]/modeler-share-modal.tsx @@ -32,10 +32,15 @@ import { set } from 'zod'; type ShareModalProps = { onExport: () => void; onExportMobile: (type: ProcessExportOptions['type']) => void; + versions: Process['versions']; }; type SharedAsType = 'public' | 'protected'; -const ModelerShareModalButton: FC = ({ onExport, onExportMobile }) => { +const ModelerShareModalButton: FC = ({ + onExport, + onExportMobile, + versions: processVersions, +}) => { const { processId } = useParams(); const environment = useEnvironment(); const [isOpen, setIsOpen] = useState(false); @@ -276,6 +281,7 @@ const ModelerShareModalButton: FC = ({ onExport, onExportMobile sharedAs={sharedAs as SharedAsType} shareTimestamp={shareTimestamp} refresh={checkIfProcessShared} + processVersions={processVersions} /> ), }, diff --git a/src/management-system-v2/app/(dashboard)/[environmentId]/processes/[processId]/modeler-toolbar.tsx b/src/management-system-v2/app/(dashboard)/[environmentId]/processes/[processId]/modeler-toolbar.tsx index 890de3423..74f66e565 100644 --- a/src/management-system-v2/app/(dashboard)/[environmentId]/processes/[processId]/modeler-toolbar.tsx +++ b/src/management-system-v2/app/(dashboard)/[environmentId]/processes/[processId]/modeler-toolbar.tsx @@ -317,6 +317,7 @@ const ModelerToolbar = ({