Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion Composer/packages/client/src/recoilModel/dispatchers/dialogs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
showCreateDialogModalState,
dialogState,
} from '../atoms/botState';
import { dispatcherState } from '../DispatcherWrapper';

import { createLgFileState, removeLgFileState } from './lg';
import { createLuFileState, removeLuFileState } from './lu';
Expand All @@ -24,7 +25,16 @@ import { removeDialogSchema } from './dialogSchema';
export const dialogsDispatcher = () => {
const removeDialog = useRecoilCallback(
(callbackHelpers: CallbackInterface) => async (id: string, projectId: string) => {
const { set, reset } = callbackHelpers;
const { set, reset, snapshot } = callbackHelpers;

const dialog = await snapshot.getPromise(dialogState({ projectId, dialogId: id }));

// If the dialog is a generated form dialog, delete using form dialog dispatcher
if (dialog.content?.$schema) {
const { removeFormDialog } = await snapshot.getPromise(dispatcherState);
await removeFormDialog({ projectId, dialogId: id });
return;
}

reset(dialogState({ projectId, dialogId: id }));
set(dialogIdsState(projectId), (previousDialogIds) => previousDialogIds.filter((dialogId) => dialogId !== id));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
formDialogGenerationProgressingState,
formDialogLibraryTemplatesState,
} from '../atoms/appState';
import { formDialogSchemaIdsState, formDialogSchemaState } from '../atoms/botState';
import { dialogState, formDialogSchemaIdsState, formDialogSchemaState } from '../atoms/botState';
import { dispatcherState } from '../DispatcherWrapper';

export const formDialogsDispatcher = () => {
Expand Down Expand Up @@ -79,14 +79,37 @@ export const formDialogsDispatcher = () => {
} catch (error) {
set(applicationErrorState, {
message: error.message,
summary: formatMessage('Generating form dialog using ${schemaId} schema failed.', { schemaId }),
summary: formatMessage('Generating form dialog using "{ schemaId }" schema failed.', { schemaId }),
});
} finally {
set(formDialogGenerationProgressingState, false);
}
}
);

const removeFormDialog = useRecoilCallback(
(callbackHelpers: CallbackInterface) => async ({ projectId, dialogId }) => {
const { set, snapshot } = callbackHelpers;

const dialog = await snapshot.getPromise(dialogState({ projectId, dialogId }));
const { reloadProject } = await snapshot.getPromise(dispatcherState);

try {
if (!dialog) {
return;
}

const response = await httpClient.delete(`/formDialogs/${projectId}/${dialogId}`);
await reloadProject(callbackHelpers, response);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to do anything with the file state to prevent the delete from causing that issue with reloading (that thing you previously saw during generation)?

} catch (error) {
set(applicationErrorState, {
message: error.message,
summary: formatMessage('Deleting "{ dialogId }" failed.', { dialogId }),
});
}
}
);

const navigateToGeneratedDialog = ({ projectId, schemaId }) => {
navigate(`/bot/${projectId}/dialogs/${schemaId}`);
};
Expand All @@ -103,5 +126,6 @@ export const formDialogsDispatcher = () => {
generateFormDialog,
navigateToGeneratedDialog,
navigateToFormDialogSchema,
removeFormDialog,
};
};
13 changes: 8 additions & 5 deletions Composer/packages/server/src/locales/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -611,9 +611,6 @@
"could_not_connect_to_storage_50411de0": {
"message": "Could not connect to storage."
},
"could_not_init_plugin_1f1c29cd": {
"message": "Could not init plugin"
},
"couldn_t_complete_the_update_a337a359": {
"message": "Couldn''t complete the update:"
},
Expand Down Expand Up @@ -812,6 +809,9 @@
"delete_property_b3786fa0": {
"message": "Delete Property"
},
"deleting_dialogid_failed_1d7cc05a": {
"message": "Deleting \"{ dialogId }\" failed."
},
"describe_your_skill_88554792": {
"message": "Describe your skill"
},
Expand Down Expand Up @@ -1163,6 +1163,9 @@
"form_title_baf85c7e": {
"message": "form title"
},
"form_wide_operations_1c1a73eb": {
"message": "form-wide operations"
},
"forms_380ab2ae": {
"message": "Forms"
},
Expand All @@ -1181,8 +1184,8 @@
"generate_dialog_b80a85b2": {
"message": "Generate dialog"
},
"generating_form_dialog_using_schemaid_schema_faile_8062f953": {
"message": "Generating form dialog using ${ schemaId } schema failed."
"generating_form_dialog_using_schemaid_schema_faile_82ebdd72": {
"message": "Generating form dialog using \"{ schemaId }\" schema failed."
},
"get_a_new_copy_of_the_runtime_code_84970bf": {
"message": "Get a new copy of the runtime code"
Expand Down