From 54c7d2ad29b3199ba30c9dfe69eb83d96d8f9797 Mon Sep 17 00:00:00 2001 From: aliaksandrryzhou Date: Wed, 17 Jan 2024 09:52:20 +0300 Subject: [PATCH 1/5] fix(pkg): User 1000 instead of root --- libs/embed/Dockerfile | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/libs/embed/Dockerfile b/libs/embed/Dockerfile index fa9ef210533..9eba7e56534 100644 --- a/libs/embed/Dockerfile +++ b/libs/embed/Dockerfile @@ -1,26 +1,27 @@ FROM nikolaik/python-nodejs:python3.10-nodejs20-alpine -WORKDIR /usr/src/app - RUN npm install -g pnpm@8.9.0 --loglevel notice --force -COPY .npmrc . -COPY package.json . +USER 1000 +WORKDIR /usr/src/app + +COPY --chown=1000:1000 .npmrc . +COPY --chown=1000:1000 package.json . -COPY libs/testing ./libs/testing -COPY libs/dal ./libs/dal -COPY libs/shared ./libs/shared -COPY packages/client ./packages/client -COPY packages/node ./packages/node -COPY libs/embed ./libs/embed -COPY packages/notification-center ./packages/notification-center +COPY --chown=1000:1000 libs/testing ./libs/testing +COPY --chown=1000:1000 libs/dal ./libs/dal +COPY --chown=1000:1000 libs/shared ./libs/shared +COPY --chown=1000:1000 packages/client ./packages/client +COPY --chown=1000:1000 packages/node ./packages/node +COPY --chown=1000:1000 libs/embed ./libs/embed +COPY --chown=1000:1000 packages/notification-center ./packages/notification-center -COPY tsconfig.json . -COPY tsconfig.base.json . +COPY --chown=1000:1000 tsconfig.json . +COPY --chown=1000:1000 tsconfig.base.json . -COPY nx.json . -COPY pnpm-workspace.yaml . -COPY pnpm-lock.yaml . +COPY --chown=1000:1000 nx.json . +COPY --chown=1000:1000 pnpm-workspace.yaml . +COPY --chown=1000:1000 pnpm-lock.yaml . RUN pnpm install --reporter=silent RUN pnpm build From 01f88ecfd82d7f6044c3d5a1f3ee7db124fbf78d Mon Sep 17 00:00:00 2001 From: Joel Anton Date: Thu, 11 Jan 2024 13:48:45 -0800 Subject: [PATCH 2/5] test: demonstrate broken empty conditions in variants --- .../notification-editor/variants.spec.ts | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/apps/web/cypress/tests/notification-editor/variants.spec.ts b/apps/web/cypress/tests/notification-editor/variants.spec.ts index 408eaecf7d2..bb9e47632a2 100644 --- a/apps/web/cypress/tests/notification-editor/variants.spec.ts +++ b/apps/web/cypress/tests/notification-editor/variants.spec.ts @@ -841,6 +841,37 @@ describe('Workflow Editor - Variants', function () { cy.wait('@getWorkflow'); cy.getByTestId('variants-count').should('not.exist'); }); + + it('should not allow removing all conditions from a variant', function () { + createWorkflow('Test Removing All Conditions'); + + dragAndDrop('inApp'); + editChannel('inApp'); + fillEditorContent('inApp'); + goBack(); + + showStepActions('inApp'); + addVariantActionClick('inApp'); + addConditions(); + + cy.getByTestId('notification-template-submit-btn').click(); + cy.wait('@updateWorkflow'); + + cy.reload(); + cy.wait('@getWorkflow'); + + // edit the variant condition + cy.getByTestId('editor-sidebar-edit-conditions').click(); + + // open conditions row menu + cy.getByTestId('conditions-row-btn').click(); + + // delete the condition + cy.contains('Delete').click(); + + // submit ("Apply conditions") should be disabled + cy.getByTestId('apply-conditions-btn').should('be.disabled'); + }); }); describe('Variants List Errors', function () { From bc28991567ec1767196a4f89ddc9f669fe3bccf8 Mon Sep 17 00:00:00 2001 From: Joel Anton Date: Thu, 11 Jan 2024 13:54:47 -0800 Subject: [PATCH 3/5] fix: disable submit btn when removing all variant conditions --- .../src/components/conditions/Conditions.tsx | 51 ++++++++++++------- .../components/EditorSidebarHeaderActions.tsx | 1 + .../templates/components/VariantItemCard.tsx | 1 + 3 files changed, 35 insertions(+), 18 deletions(-) diff --git a/apps/web/src/components/conditions/Conditions.tsx b/apps/web/src/components/conditions/Conditions.tsx index 7d88fe7fc51..40dc68f3aa7 100644 --- a/apps/web/src/components/conditions/Conditions.tsx +++ b/apps/web/src/components/conditions/Conditions.tsx @@ -26,6 +26,19 @@ import { OnlineConditionRow } from './OnlineConditionRow'; import { DefaultGroupOperatorData, DefaultOperatorData } from './constants'; import { PreviousStepsConditionRow } from './PreviousStepsConditionRow'; +export interface IConditionsComponentProps { + isOpened: boolean; + isReadonly?: boolean; + onClose: () => void; + updateConditions: (data: IConditions[]) => void; + conditions?: IConditions[]; + name: string; + label?: string; + filterPartsList: IFilterTypeList[]; + defaultFilter?: FilterPartTypeEnum; + shouldDisallowEmptyConditions?: boolean; +} + export function Conditions({ isOpened, isReadonly = false, @@ -36,17 +49,8 @@ export function Conditions({ label = '', filterPartsList, defaultFilter, -}: { - isOpened: boolean; - isReadonly?: boolean; - onClose: () => void; - updateConditions: (data: IConditions[]) => void; - conditions?: IConditions[]; - name: string; - label?: string; - filterPartsList: IFilterTypeList[]; - defaultFilter?: FilterPartTypeEnum; -}) { + shouldDisallowEmptyConditions, +}: IConditionsComponentProps) { const { colorScheme } = useMantineTheme(); const { @@ -95,9 +99,17 @@ export function Conditions({ remove(index); } + /** Flag for determining if conditions are empty but expected not to be */ + const hasDisallowedEmptyConditions = Boolean( + shouldDisallowEmptyConditions && getValues().conditions?.some(({ children }) => !children?.[0]) + ); + + const isSubmitDisabled = + !isDirty || isReadonly || (conditions?.length === 0 && fields?.length === 0) || hasDisallowedEmptyConditions; + const onApplyConditions = async () => { await trigger('conditions'); - if (!errors.conditions) { + if (!errors.conditions && !isSubmitDisabled) { updateConditions(getValues('conditions')); onClose(); } @@ -121,13 +133,16 @@ export function Conditions({ - +
-
diff --git a/apps/web/src/pages/templates/components/EditorSidebarHeaderActions.tsx b/apps/web/src/pages/templates/components/EditorSidebarHeaderActions.tsx index 0954bf86b9f..88992755b0b 100644 --- a/apps/web/src/pages/templates/components/EditorSidebarHeaderActions.tsx +++ b/apps/web/src/pages/templates/components/EditorSidebarHeaderActions.tsx @@ -166,6 +166,7 @@ export const EditorSidebarHeaderActions = () => { conditions={conditions} filterPartsList={filterPartsList} defaultFilter={FilterPartTypeEnum.PAYLOAD} + shouldDisallowEmptyConditions /> )} diff --git a/apps/web/src/pages/templates/components/VariantItemCard.tsx b/apps/web/src/pages/templates/components/VariantItemCard.tsx index fe8a7c50725..9542a451f0f 100644 --- a/apps/web/src/pages/templates/components/VariantItemCard.tsx +++ b/apps/web/src/pages/templates/components/VariantItemCard.tsx @@ -264,6 +264,7 @@ export const VariantItemCard = ({ conditions={conditions} filterPartsList={filterPartsList} defaultFilter={FilterPartTypeEnum.PAYLOAD} + shouldDisallowEmptyConditions /> )} Date: Thu, 11 Jan 2024 13:55:20 -0800 Subject: [PATCH 4/5] test: update test with tooltip validation --- apps/web/cypress/tests/notification-editor/variants.spec.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/apps/web/cypress/tests/notification-editor/variants.spec.ts b/apps/web/cypress/tests/notification-editor/variants.spec.ts index bb9e47632a2..821a822a0c3 100644 --- a/apps/web/cypress/tests/notification-editor/variants.spec.ts +++ b/apps/web/cypress/tests/notification-editor/variants.spec.ts @@ -870,7 +870,10 @@ describe('Workflow Editor - Variants', function () { cy.contains('Delete').click(); // submit ("Apply conditions") should be disabled - cy.getByTestId('apply-conditions-btn').should('be.disabled'); + cy.getByTestId('apply-conditions-btn').should('be.disabled').click({ force: true }); + + // tooltip should warn the user + cy.get('div[role="tooltip"]').contains('At least one condition is required'); }); }); From 6825a58bf7e7bcbd87e21db01d679014c2c6aacb Mon Sep 17 00:00:00 2001 From: Joel Anton Date: Fri, 12 Jan 2024 11:50:39 -0800 Subject: [PATCH 5/5] fix: only disable button for variants --- .../pages/templates/components/EditorSidebarHeaderActions.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/web/src/pages/templates/components/EditorSidebarHeaderActions.tsx b/apps/web/src/pages/templates/components/EditorSidebarHeaderActions.tsx index 88992755b0b..ec7bbd971d3 100644 --- a/apps/web/src/pages/templates/components/EditorSidebarHeaderActions.tsx +++ b/apps/web/src/pages/templates/components/EditorSidebarHeaderActions.tsx @@ -166,7 +166,7 @@ export const EditorSidebarHeaderActions = () => { conditions={conditions} filterPartsList={filterPartsList} defaultFilter={FilterPartTypeEnum.PAYLOAD} - shouldDisallowEmptyConditions + shouldDisallowEmptyConditions={isUnderVariantPath} /> )}