-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Conversation
…ication name on the layout page was not updated(#2799)
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. |
[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 |
@@ -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) => { |
There was a problem hiding this comment.
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:
-
Use of
loading
param: Theapplication.asyncPutApplication
method is being called with an extra parameterloading
, which might not be necessary if you're handling loading state separately. -
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. -
Suggested modifications:
- Remove unnecessary
loading
parameter fromasyncPutApplication
. - Add specific error handling for both async operations.
- Ensure proper formatting consistency throughout the code.
- Remove unnecessary
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 fromasyncPutApplication
. - 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.
…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: