1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Close dock tab only if all resources successfully created

Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
Alex Andreev 2023-02-08 13:53:59 +03:00
parent 2674f42f54
commit 07cf71edbb
2 changed files with 11 additions and 3 deletions

View File

@ -76,7 +76,7 @@ class NonInjectedCreateResource extends React.Component<CreateResourceProps & De
this.error = error.toString();
};
create = async (): Promise<void> => {
create = async (): Promise<string | void> => {
const { apiManager, getDetailsUrl, navigate, requestKubeObjectCreation } = this.props;
if (this.error || !this.data?.trim()) {
@ -98,7 +98,7 @@ class NonInjectedCreateResource extends React.Component<CreateResourceProps & De
this.props.logger.warn("Failed to create resource", { resource }, result.error);
this.props.showCheckedErrorNotification(result.error, "Unknown error occured while creating resources");
return;
throw Error(result.error);
}
const { kind, apiVersion, metadata: { name, namespace }} = result.response;
@ -122,7 +122,13 @@ class NonInjectedCreateResource extends React.Component<CreateResourceProps & De
));
});
await Promise.allSettled(creatingResources);
const results = await Promise.allSettled(creatingResources);
if (results.some(result => result.status === "rejected")) {
return;
}
return "All resources have been successfully created";
};
renderControls() {

View File

@ -174,5 +174,7 @@ export class EditResourceModel {
runInAction(() => {
this.editingResource.firstDraft = currentValue;
});
return result.response.toString();
};
}