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

Conversation

wangdan-fit2cloud
Copy link
Contributor

…ication name on the layout page was not updated(#2799)

What this PR does / why we need it?

Summary of your change

Please indicate you've done the following:

  • Made sure tests are passing and test coverage is added if needed.
  • Made sure commit message follow the rule of Conventional Commits specification.
  • Considered the docs impact and opened a new docs issue or PR with docs changes if needed.

…ication name on the layout page was not updated(#2799)
Copy link

f2c-ci-robot bot commented Apr 8, 2025

Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Copy link

f2c-ci-robot bot commented Apr 8, 2025

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@@ -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.

@wangdan-fit2cloud wangdan-fit2cloud merged commit 7a3a975 into main Apr 8, 2025
4 of 5 checks passed
@wangdan-fit2cloud wangdan-fit2cloud deleted the pr@main/perf-workflow-publish branch April 8, 2025 08:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants