Skip to content

Commit

Permalink
Merge branch 'master' into filesearch-feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
kurund authored Nov 19, 2024
2 parents b792b9d + 852f39d commit fc23434
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 13 deletions.
19 changes: 17 additions & 2 deletions src/containers/Flow/Flow.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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('Copy of Help')).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(() => {});
});

Expand Down
24 changes: 15 additions & 9 deletions src/containers/Flow/Flow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ export const Flow = () => {
const [roles, setRoles] = useState<Array<any>>([]);
const [isBackground, setIsBackground] = useState(false);
const [ignoreKeywords, setIgnoreKeywords] = useState(false);
const [copyFlowTitle, setCopyFlowTitle] = useState('');

const { t } = useTranslation();

let isTemplate = false;
Expand Down Expand Up @@ -104,11 +106,14 @@ export const Flow = () => {
if (location.state === 'copy') {
fieldName = `Copy of ${nameValue}`;
fieldKeywords = '';
description = `Copy of ${nameValue}`;
setCopyFlowTitle(nameValue);
} else if (location.state === 'copyTemplate') {
fieldName = `Copy of ${nameValue}`;
description = '';
fieldName = '';
description = `Copy of ${nameValue}`;
tags = null;
fieldKeywords = '';
setCopyFlowTitle(nameValue);
}
const {
organization: {
Expand Down Expand Up @@ -140,8 +145,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.')),
Expand Down Expand Up @@ -215,9 +219,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,
Expand Down Expand Up @@ -280,12 +282,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') {
Expand All @@ -294,6 +296,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') {
Expand Down
3 changes: 1 addition & 2 deletions src/i18n/en/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit fc23434

Please sign in to comment.