From 2674f42f540ead1d22b1b18b10c99af0df3c2414 Mon Sep 17 00:00:00 2001 From: Alex Andreev Date: Wed, 8 Feb 2023 13:53:15 +0300 Subject: [PATCH] Close dock tab only if submit() resolved Signed-off-by: Alex Andreev --- .../edit-namespace-from-new-tab.test.tsx.snap | 173 +++++++++++++++++- .../edit-namespace-from-new-tab.test.tsx | 3 +- .../renderer/components/dock/info-panel.tsx | 11 +- 3 files changed, 179 insertions(+), 8 deletions(-) diff --git a/packages/core/src/features/cluster/namespaces/__snapshots__/edit-namespace-from-new-tab.test.tsx.snap b/packages/core/src/features/cluster/namespaces/__snapshots__/edit-namespace-from-new-tab.test.tsx.snap index 6675611fca..832ee400c8 100644 --- a/packages/core/src/features/cluster/namespaces/__snapshots__/edit-namespace-from-new-tab.test.tsx.snap +++ b/packages/core/src/features/cluster/namespaces/__snapshots__/edit-namespace-from-new-tab.test.tsx.snap @@ -10119,11 +10119,11 @@ exports[`cluster/namespaces - edit namespace from new tab when navigating to nam class="footer" >
+ > + +
+ + + fullscreen + + +
+ Fit to window +
+ + + keyboard_arrow_down + + +
+ Minimize +
+
+
+
+
+
+
+
+ + Kind: + +
+ Namespace +
+ + Name: + +
+ some-name +
+ + Namespace: + +
+ default +
+
+
+
+ + + +
+
diff --git a/packages/core/src/features/cluster/namespaces/edit-namespace-from-new-tab.test.tsx b/packages/core/src/features/cluster/namespaces/edit-namespace-from-new-tab.test.tsx index c6102f3f24..52796fc314 100644 --- a/packages/core/src/features/cluster/namespaces/edit-namespace-from-new-tab.test.tsx +++ b/packages/core/src/features/cluster/namespaces/edit-namespace-from-new-tab.test.tsx @@ -401,8 +401,7 @@ metadata: expect(rendered.baseElement).toMatchSnapshot(); }); - // TODO: Not doable at the moment because info panel controls closing of the tab - xit("does not close the dock tab", () => { + it("does not close the dock tab", () => { expect( rendered.getByTestId("dock-tab-for-some-first-tab-id"), ).toBeInTheDocument(); diff --git a/packages/core/src/renderer/components/dock/info-panel.tsx b/packages/core/src/renderer/components/dock/info-panel.tsx index 48a53a0308..8f1ac32266 100644 --- a/packages/core/src/renderer/components/dock/info-panel.tsx +++ b/packages/core/src/renderer/components/dock/info-panel.tsx @@ -93,18 +93,25 @@ class NonInjectedInfoPanel extends Component { 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 = () => {