From 820eacde912e41f485818c4bf359b5591b72a868 Mon Sep 17 00:00:00 2001 From: Carlos Valente <34649812+cpvalente@users.noreply.github.com> Date: Mon, 18 Dec 2023 15:07:30 +0100 Subject: [PATCH] refactor: prevent accidental edit in operator view (#659) * refactor: prevent accidental edit in operator view --- .../src/common/components/view-params-editor/constants.ts | 7 +++++++ apps/client/src/features/operator/Operator.tsx | 7 +++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/apps/client/src/common/components/view-params-editor/constants.ts b/apps/client/src/common/components/view-params-editor/constants.ts index 64443ad67..ec1805e75 100644 --- a/apps/client/src/common/components/view-params-editor/constants.ts +++ b/apps/client/src/common/components/view-params-editor/constants.ts @@ -380,5 +380,12 @@ export const getOperatorOptions = (userFields: UserFields, timeFormat: TimeForma user9: userFields.user9 || 'user9', }, }, + { + id: 'shouldEdit', + title: 'Edit user field', + description: 'Allows editing an events user field by long pressing on it. Needs a selected highlighted field', + type: 'boolean', + defaultValue: false, + }, ]; }; diff --git a/apps/client/src/features/operator/Operator.tsx b/apps/client/src/features/operator/Operator.tsx index c00b2d6db..c5ac43ace 100644 --- a/apps/client/src/features/operator/Operator.tsx +++ b/apps/client/src/features/operator/Operator.tsx @@ -123,7 +123,10 @@ export default function Operator() { } // get fields which the user subscribed to + const shouldEdit = searchParams.get('shouldEdit'); const subscribe = searchParams.get('subscribe') as keyof UserFields | null; + const canEdit = shouldEdit && subscribe; + const main = searchParams.get('main') as keyof TitleFields | null; const secondary = searchParams.get('secondary') as keyof TitleFields | null; const subscribedAlias = subscribe ? userFields[subscribe] : ''; @@ -152,7 +155,7 @@ export default function Operator() { lastId={lastEvent?.id} /> - {subscribe && ( + {canEdit && (