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
Original file line number Diff line number Diff line change
Expand Up @@ -305,13 +305,17 @@ export const ProjectTree: React.FC<Props> = ({
isActive={doesLinkMatch(link, selectedLink)}
link={link}
menu={[
{
label: formatMessage('Remove this dialog'),
icon: 'Delete',
onClick: (link) => {
onDeleteDialog(link.dialogId ?? '');
},
},
...(!dialog.isRoot
? [
{
label: formatMessage('Remove this dialog'),
icon: 'Delete',
onClick: (link) => {
onDeleteDialog(link.dialogId ?? '');
},
},
]
: []),
...(showEditSchema
? [
{
Expand Down
16 changes: 13 additions & 3 deletions Composer/packages/server/src/controllers/formDialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,19 @@ const deleteDialog = async (req: Request, res: Response) => {

const currentProject = await BotProjectService.getProjectById(projectId, user);
if (currentProject !== undefined) {
await currentProject.deleteFormDialog(dialogId);
const updatedProject = await BotProjectService.getProjectById(projectId, user);
res.status(200).json({ id: projectId, ...updatedProject.getProject() });
try {
const rootDialogId = currentProject.rootDialogId;
if (rootDialogId === dialogId) {
throw new Error('root dialog is not allowed to delete');
}
await currentProject.deleteFormDialog(dialogId);
const updatedProject = await BotProjectService.getProjectById(projectId, user);
res.status(200).json({ id: projectId, ...updatedProject.getProject() });
} catch (e) {
res.status(400).json({
message: e.message,
});
}
} else {
res.status(404).json({
message: `Could not delete form dialog. Project ${projectId} not found.`,
Expand Down