Skip to content

fix: After modifying the application name and publishing it, the appl… #2825

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

Merged
merged 1 commit into from
Apr 8, 2025
Merged
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
3 changes: 2 additions & 1 deletion ui/src/views/application-workflow/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ async function publicHandle() {
const obj = {
work_flow: getGraphData()
}
await application.asyncPutApplication(id, obj)
await application.asyncPutApplication(id, obj, loading)
const workflow = new WorkFlowInstance(obj.work_flow)
try {
workflow.is_valid()
Expand All @@ -280,6 +280,7 @@ async function publicHandle() {
}
applicationApi.putPublishApplication(id as String, obj, loading).then(() => {
MsgSuccess(t('views.applicationWorkflow.tip.publicSuccess'))
getDetail()
})
})
.catch((res: any) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

There appear to be a few potential issues and areas for improvement in the provided code:

  1. Use of loading param: The application.asyncPutApplication method is being called with an extra parameter loading, which might not be necessary if you're handling loading state separately.

  2. Handling errors after put operation fails: It doesn't seem like there are any error handling mechanisms in place following the putPublishApplication call. This could lead to unhandled exceptions if something goes wrong during this step.

  3. Suggested modifications:

    • Remove unnecessary loading parameter from asyncPutApplication.
    • Add specific error handling for both async operations.
    • Ensure proper formatting consistency throughout the code.

Here's a revised version with these improvements:

async function publicHandle() {
  const obj = {
    work_flow: getGraphData()
  };
  
  await application.asyncPutApplication(id, obj);
  
  const workflow = new WorkFlowInstance(obj.work_flow);
  try {
    workflow.is_valid();
    
    // Assuming you have access to a message service (MsgSuccess, t)
    MsgSuccess(t('views.applicationWorkflow.tip.publicSuccess'));
    
    // Call getDetail() here if needed or ensure it's properly defined elsewhere
    getDetail?.(); // Safe navigation operator
    
    // Continue handling publishApplication asynchronously if needed
    applicationApi.putPublishApplication(id as string, obj). catch((err) => {
      console.error("Failed to publish application:", err); // Log errors for debugging
      
      // Handle more granularly based on error type
      switch (err.message) {
        case "Validation Error":
          // Show validation error UI or handle differently
          break;
        default:
          Alert.warning("An unexpected error occurred!");
      }
      
      // Optionally inform user via message or another means
      MsgError(t('common.err.commonMessage'));
    });
  } catch (error) {
    console.error("Work flow instance initialization failed:", error);

    // Provide feedback to the user
    MsgWarning(t('app.workflow.workflowInitFail', { workflow_id }));
  }
}

Key Changes Applied:

  • Removed the loading parameter from asyncPutApplication.
  • Added error handling following the putPublishApplication call.
  • Used safe navigation (?.() ) for optional methods (getDetail) to avoid null/undefined pointer issues.
  • Enhanced logging for better debug information.
  • Provided a basic way to handle different types of errors that might occur during the sequence of operations.

Expand Down