mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Fix: create/edit resource tab Save & Close button behavior (#7124)
* Close dock tab only if submit() resolved Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com> * Close dock tab only if all resources successfully created Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com> * Simpler error throw Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com> --------- Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
1 parent
0719293b11
commit
c9d43ffdba
5 files changed
+190
-11
No files matched your search
@@ -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 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() {
|
||||
|
||||
+2
@@ -174,5 +174,7 @@ export class EditResourceModel {
|
||||
runInAction(() => {
|
||||
this.editingResource.firstDraft = currentValue;
|
||||
});
|
||||
|
||||
return result.response.toString();
|
||||
};
|
||||
}
|
||||
@@ -93,18 +93,25 @@ class NonInjectedInfoPanel extends Component<InfoPanelProps & Dependencies> {
|
||||
if (showNotifications && result) {
|
||||
this.props.showSuccessNotification(result);
|
||||
}
|
||||
|
||||
return result;
|
||||
} catch (error) {
|
||||
if (showNotifications) {
|
||||
this.props.showCheckedErrorNotification(error, "Unknown error while submitting");
|
||||
}
|
||||
|
||||
return false;
|
||||
} finally {
|
||||
this.waiting = false;
|
||||
}
|
||||
};
|
||||
|
||||
submitAndClose = async () => {
|
||||
await this.submit();
|
||||
this.close();
|
||||
const result = await this.submit();
|
||||
|
||||
if (result) {
|
||||
this.close();
|
||||
}
|
||||
};
|
||||
|
||||
close = () => {
|
||||
|
||||
Reference in new issue
Block a user