From 4566b04ccdd044d3f9c8d49c39a4998264229105 Mon Sep 17 00:00:00 2001 From: Akansha Sakhre Date: Fri, 15 Nov 2024 11:12:55 +0530 Subject: [PATCH 1/5] changed name to blank --- src/containers/Flow/Flow.test.tsx | 19 +++++++++++++++++-- src/containers/Flow/Flow.tsx | 9 +++------ 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/src/containers/Flow/Flow.test.tsx b/src/containers/Flow/Flow.test.tsx index fb8503702..4dc722b97 100644 --- a/src/containers/Flow/Flow.test.tsx +++ b/src/containers/Flow/Flow.test.tsx @@ -83,6 +83,17 @@ const mocks = [ addRoleIds: [], deleteRoleIds: [], }), + copyFlowQuery({ + isActive: true, + isPinned: false, + isBackground: false, + name: 'Help flow', + keywords: ['help'], + description: '', + ignoreKeywords: false, + addRoleIds: [], + deleteRoleIds: [], + }), ]; const mockUseLocationValue: any = { @@ -361,12 +372,16 @@ it('should create copy of a template flow', async () => { const { container, getByTestId } = render(copyFlow()); await waitFor(() => { - const inputElement = container.querySelector('input[name="name"]') as HTMLInputElement; - expect(inputElement?.value).toBe('Copy of Help'); + expect(screen.getByText('Template flow copy')).toBeInTheDocument(); }); const button = getByTestId('submitActionButton'); fireEvent.click(button); + + const inputs = screen.getAllByRole('textbox'); + fireEvent.change(inputs[0], { target: { value: 'Help flow' } }); + fireEvent.change(inputs[1], { target: { value: 'help' } }); + await waitFor(() => {}); }); diff --git a/src/containers/Flow/Flow.tsx b/src/containers/Flow/Flow.tsx index 150767345..1ddc5eaa1 100644 --- a/src/containers/Flow/Flow.tsx +++ b/src/containers/Flow/Flow.tsx @@ -105,7 +105,7 @@ export const Flow = () => { fieldName = `Copy of ${nameValue}`; fieldKeywords = ''; } else if (location.state === 'copyTemplate') { - fieldName = `Copy of ${nameValue}`; + fieldName = ''; description = ''; tags = null; fieldKeywords = ''; @@ -140,8 +140,7 @@ export const Flow = () => { } }; - const regex = - /^\s*[^-!$%^&*()+|~=`{}[\]:";'<>?,./]+\s*(,\s*[^-!$%^&*()+|~=`{}[\]:";'<>?,./]+\s*)*$/g; + const regex = /^\s*[^-!$%^&*()+|~=`{}[\]:";'<>?,./]+\s*(,\s*[^-!$%^&*()+|~=`{}[\]:";'<>?,./]+\s*)*$/g; const FormSchema = Yup.object().shape({ name: Yup.string().required(t('Name is required.')), @@ -215,9 +214,7 @@ export const Flow = () => { name: 'ignoreKeywords', title: t('Ignore Keywords'), info: { - title: t( - 'If activated, users will not be able to change this flow by entering keyword for any other flow.' - ), + title: t('If activated, users will not be able to change this flow by entering keyword for any other flow.'), }, darkCheckbox: true, className: styles.Checkbox, From 1728c3b31728ef6c25c0d4b5dc078b6478e214f7 Mon Sep 17 00:00:00 2001 From: Akansha Sakhre Date: Fri, 15 Nov 2024 11:52:58 +0530 Subject: [PATCH 2/5] updated regex --- src/containers/Flow/Flow.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/containers/Flow/Flow.tsx b/src/containers/Flow/Flow.tsx index 1ddc5eaa1..41bfcf4a4 100644 --- a/src/containers/Flow/Flow.tsx +++ b/src/containers/Flow/Flow.tsx @@ -140,7 +140,7 @@ export const Flow = () => { } }; - const regex = /^\s*[^-!$%^&*()+|~=`{}[\]:";'<>?,./]+\s*(,\s*[^-!$%^&*()+|~=`{}[\]:";'<>?,./]+\s*)*$/g; + const regex = /^\s*[^-!$%^&*()+|~=`{}[\]:";'<>?,./\s]+\s*(,\s*[^-!$%^&*()+|~=`{}[\]:";'<>?,./\s]+\s*)*$/g; const FormSchema = Yup.object().shape({ name: Yup.string().required(t('Name is required.')), From a20d27205640d2bc4a392dbb68a254025fd36786 Mon Sep 17 00:00:00 2001 From: Kurund Jalmi Date: Tue, 19 Nov 2024 20:46:52 +0000 Subject: [PATCH 3/5] tweak the copy title --- src/containers/Flow/Flow.tsx | 12 ++++++++++-- src/i18n/en/en.json | 3 +-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/containers/Flow/Flow.tsx b/src/containers/Flow/Flow.tsx index 41bfcf4a4..952f379c0 100644 --- a/src/containers/Flow/Flow.tsx +++ b/src/containers/Flow/Flow.tsx @@ -43,6 +43,8 @@ export const Flow = () => { const [roles, setRoles] = useState>([]); const [isBackground, setIsBackground] = useState(false); const [ignoreKeywords, setIgnoreKeywords] = useState(false); + const [copyFlowTitle, setCopyFlowTitle] = useState(''); + const { t } = useTranslation(); let isTemplate = false; @@ -104,11 +106,13 @@ export const Flow = () => { if (location.state === 'copy') { fieldName = `Copy of ${nameValue}`; fieldKeywords = ''; + setCopyFlowTitle(nameValue); } else if (location.state === 'copyTemplate') { fieldName = ''; description = ''; tags = null; fieldKeywords = ''; + setCopyFlowTitle(nameValue); } const { organization: { @@ -277,12 +281,12 @@ export const Flow = () => { if (location.state === 'copy') { queries.updateItemQuery = CREATE_FLOW_COPY; - title = t('Copy flow'); + title = t('Copy of'); type = 'copy'; copyNotification = t('Copy of the flow has been created!'); } else if (location.state === 'copyTemplate') { queries.updateItemQuery = CREATE_FLOW_COPY; - title = t('Template flow copy'); + title = t('Copy of'); type = 'copy'; copyNotification = t('Flow created successfully from template!'); } else if (location.state === 'template') { @@ -291,6 +295,10 @@ export const Flow = () => { queries.updateItemQuery = UPDATE_FLOW; } + if (copyFlowTitle) { + title = `${title} ${copyFlowTitle}`; + } + const customHandler = (data: any) => { let dataCopy = data; if (data[0].key === 'keywords') { diff --git a/src/i18n/en/en.json b/src/i18n/en/en.json index a05addfc7..3507332f5 100644 --- a/src/i18n/en/en.json +++ b/src/i18n/en/en.json @@ -182,7 +182,7 @@ "If activated, users will not be able to change this flow by entering keyword for any other flow.": "If activated, users will not be able to change this flow by entering keyword for any other flow.", "Is pinned?": "Is pinned?", "Run this flow in the background": "Run this flow in the background", - "Copy flow": "Copy flow", + "Copy of": "Copy of", "Sorry! An error occurred!": "Sorry! An error occurred!", "Copy of the flow has been created!": "Copy of the flow has been created!", "Import flow": "Import flow", @@ -511,7 +511,6 @@ "Import the csv with translations for interactive message.": "Import the csv with translations for interactive message.", "Template Flows": "Template Flows", "Template Flow": "Template Flow", - "Template flow copy": "Template flow copy", "Flow created successfully from template!": "Flow created successfully from template!", "Select/Create an assistant": "Select/Create an assistant", "Create Assistant": "Create Assistant", From 52ec95e75a24bd40c1bbb8a67790c543f8d808f4 Mon Sep 17 00:00:00 2001 From: Kurund Jalmi Date: Tue, 19 Nov 2024 20:49:34 +0000 Subject: [PATCH 4/5] test fixes --- src/containers/Flow/Flow.test.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/containers/Flow/Flow.test.tsx b/src/containers/Flow/Flow.test.tsx index 4dc722b97..221f7bf59 100644 --- a/src/containers/Flow/Flow.test.tsx +++ b/src/containers/Flow/Flow.test.tsx @@ -372,7 +372,7 @@ it('should create copy of a template flow', async () => { const { container, getByTestId } = render(copyFlow()); await waitFor(() => { - expect(screen.getByText('Template flow copy')).toBeInTheDocument(); + expect(screen.getByText('Copy of Help')).toBeInTheDocument(); }); const button = getByTestId('submitActionButton'); From c450524b4c3b8c06973c87a4a68636e46446b18b Mon Sep 17 00:00:00 2001 From: Kurund Jalmi Date: Tue, 19 Nov 2024 20:55:01 +0000 Subject: [PATCH 5/5] set description during copy action --- src/containers/Flow/Flow.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/containers/Flow/Flow.tsx b/src/containers/Flow/Flow.tsx index 952f379c0..b11205a3b 100644 --- a/src/containers/Flow/Flow.tsx +++ b/src/containers/Flow/Flow.tsx @@ -106,10 +106,11 @@ export const Flow = () => { if (location.state === 'copy') { fieldName = `Copy of ${nameValue}`; fieldKeywords = ''; + description = `Copy of ${nameValue}`; setCopyFlowTitle(nameValue); } else if (location.state === 'copyTemplate') { fieldName = ''; - description = ''; + description = `Copy of ${nameValue}`; tags = null; fieldKeywords = ''; setCopyFlowTitle(nameValue);