-
Notifications
You must be signed in to change notification settings - Fork 580
UN-3217 [FEAT] Show specific pipeline/API names in workflow deletion error message #1784
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -146,37 +146,60 @@ function Workflows() { | |
| }); | ||
| } | ||
|
|
||
| const canDeleteProject = async (id) => { | ||
| let status = false; | ||
| await projectApiService.canUpdate(id).then((res) => { | ||
| status = res?.data?.can_update || false; | ||
| }); | ||
| return status; | ||
| const checkWorkflowUsage = async (id) => { | ||
| const res = await projectApiService.canUpdate(id); | ||
| return { | ||
| can_update: res?.data?.can_update || false, | ||
| pipeline_names: res?.data?.pipeline_names || [], | ||
| api_names: res?.data?.api_names || [], | ||
| }; | ||
| }; | ||
|
|
||
| const getUsageMessage = (workflowName, pipelineNames, apiNames) => { | ||
| const allNames = [...apiNames, ...pipelineNames]; | ||
| const total = allNames.length; | ||
| if (total === 0) return ""; | ||
| const firstName = `"${allNames[0]}"`; | ||
| if (total === 1) { | ||
| return `Cannot delete "${workflowName}" as it is used in ${firstName}.`; | ||
| } | ||
| const remaining = total - 1; | ||
| const pipelineLabel = remaining === 1 ? "pipeline" : "pipelines"; | ||
| return `Cannot delete "${workflowName}" as it is used in ${firstName} and ${remaining} other API/ETL/Task ${pipelineLabel}.`; | ||
| }; | ||
|
Comment on lines
+158
to
169
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Empty error toast if If the backend returns Suggested fix const total = allNames.length;
- if (total === 0) return "";
+ if (total === 0)
+ return `Cannot delete "${workflowName}" as it is currently in use.`;
const firstName = `"${allNames[0]}"`;🤖 Prompt for AI Agents |
||
|
|
||
| const deleteProject = async (_evt, project) => { | ||
| const canDelete = await canDeleteProject(project.id); | ||
| if (canDelete) { | ||
| projectApiService | ||
| .deleteProject(project.id) | ||
| .then(() => { | ||
| getProjectList(); | ||
| setAlertDetails({ | ||
| type: "success", | ||
| content: "Workflow deleted successfully", | ||
| try { | ||
| const usage = await checkWorkflowUsage(project.id); | ||
| if (usage.can_update) { | ||
| projectApiService | ||
| .deleteProject(project.id) | ||
| .then(() => { | ||
| getProjectList(); | ||
| setAlertDetails({ | ||
| type: "success", | ||
| content: "Workflow deleted successfully", | ||
| }); | ||
| }) | ||
| .catch((err) => { | ||
| setAlertDetails( | ||
| handleException(err, `Unable to delete workflow ${project.id}`) | ||
| ); | ||
| }); | ||
| }) | ||
| .catch((err) => { | ||
| setAlertDetails( | ||
| handleException(err, `Unable to delete workflow ${project.id}`) | ||
| ); | ||
| } else { | ||
| setAlertDetails({ | ||
| type: "error", | ||
| content: getUsageMessage( | ||
| project.workflow_name, | ||
| usage.pipeline_names, | ||
| usage.api_names | ||
| ), | ||
| }); | ||
| } else { | ||
| setAlertDetails({ | ||
| type: "error", | ||
| content: | ||
| "Cannot delete this Workflow, since it is used in one or many of the API/ETL/Task pipelines", | ||
| }); | ||
| } | ||
| } catch (err) { | ||
| setAlertDetails( | ||
| handleException(err, `Unable to delete workflow ${project.id}`) | ||
| ); | ||
| } | ||
| }; | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.