From 5795452cc36fe1bcb0f88c881ff5fbcf537206cf Mon Sep 17 00:00:00 2001 From: Alex Andreev Date: Tue, 30 Aug 2022 16:00:11 +0300 Subject: [PATCH] Add option to download all logs from the container (#5970) * Creating callForAllLogsInjectable Signed-off-by: Alex Andreev * Add sketch of Download all logs button Signed-off-by: Alex Andreev * Use randomId while creating pod logs tab Signed-off-by: Alex Andreev * Initial draft of download all logs tests Signed-off-by: Alex Andreev * Introduce download logs dropdown Signed-off-by: Alex Andreev * Cleaning up Controls component Signed-off-by: Alex Andreev * Coloring and styling Download logs button Signed-off-by: Alex Andreev * Drop waiting state on network or other error Signed-off-by: Alex Andreev * After clicking on button test cases Signed-off-by: Alex Andreev * Linter fixes Signed-off-by: Alex Andreev * Removing previous Download icon Signed-off-by: Alex Andreev * Respect timestamps and previous props in callForAllLogsInjectable Signed-off-by: Alex Andreev * Update snapshots Signed-off-by: Alex Andreev * Update snapshots Signed-off-by: Alex Andreev * Remove unused .mockReturnValueOnce Signed-off-by: Alex Andreev * Remove one more unused line Signed-off-by: Alex Andreev * Cleanin up by overriding internals of logsViewModel injectable Signed-off-by: Alex Andreev * Replace usage of callForAllLogs with simple callForLogs Signed-off-by: Alex Andreev * Use css modules for the Controls component Signed-off-by: Alex Andreev * Move downloadAllLogs logic to injectable Signed-off-by: Alex Andreev * Move downloadLogs logic to the model Signed-off-by: Alex Andreev * Remove withInjectables wrapper from LogControls Signed-off-by: Alex Andreev * Move downloadAllLogs to model Signed-off-by: Alex Andreev * Testing resolve/reject options for callForLogsInjectable Signed-off-by: Alex Andreev * Catching call for logs errors Signed-off-by: Alex Andreev * Doesn't show save dialog if no logs received Signed-off-by: Alex Andreev * More descriptive describe statement Signed-off-by: Alex Andreev * Introduce Dropdown component with Menu Signed-off-by: Alex Andreev * Use in Download All Logs dropdown Signed-off-by: Alex Andreev * Fix line-break symbol Signed-off-by: Alex Andreev * Update snapshots Signed-off-by: Alex Andreev * Return a Promise from downloadAllLogs() Signed-off-by: Alex Andreev * Extend LogTabViewModel mocks in other tests Signed-off-by: Alex Andreev * Fix downloadAllLogs prop typings Signed-off-by: Alex Andreev * Fixing linter Signed-off-by: Alex Andreev * Fix linter harder Signed-off-by: Alex Andreev * Fix selectors in integration test Signed-off-by: Alex Andreev * Move tests into /behaviours Signed-off-by: Alex Andreev Signed-off-by: Alex Andreev --- integration/__tests__/cluster-pages.tests.ts | 4 +- .../__snapshots__/download-logs.test.tsx.snap | 864 ++++++++++++++++++ .../pod-logs/download-logs.test.tsx | 269 ++++++ .../__test__/log-resource-selector.test.tsx | 2 + .../dock/logs/__test__/log-search.test.tsx | 2 + .../components/dock/logs/controls.module.scss | 11 + .../components/dock/logs/controls.scss | 11 - .../components/dock/logs/controls.tsx | 43 +- .../dock/logs/create-logs-tab.injectable.ts | 8 +- .../dock/logs/download-all-logs.injectable.ts | 32 + .../logs/download-logs-dropdown.module.scss | 37 + .../dock/logs/download-logs-dropdown.tsx | 53 ++ .../dock/logs/download-logs.injectable.ts | 20 + ...t-random-id-for-pod-logs-tab.injectable.ts | 13 + .../dock/logs/logs-view-model.injectable.ts | 4 + .../components/dock/logs/logs-view-model.ts | 33 +- src/renderer/components/dropdown/dropdown.tsx | 38 + 17 files changed, 1394 insertions(+), 50 deletions(-) create mode 100644 src/behaviours/pod-logs/__snapshots__/download-logs.test.tsx.snap create mode 100644 src/behaviours/pod-logs/download-logs.test.tsx create mode 100644 src/renderer/components/dock/logs/controls.module.scss delete mode 100644 src/renderer/components/dock/logs/controls.scss create mode 100644 src/renderer/components/dock/logs/download-all-logs.injectable.ts create mode 100644 src/renderer/components/dock/logs/download-logs-dropdown.module.scss create mode 100644 src/renderer/components/dock/logs/download-logs-dropdown.tsx create mode 100644 src/renderer/components/dock/logs/download-logs.injectable.ts create mode 100644 src/renderer/components/dock/logs/get-random-id-for-pod-logs-tab.injectable.ts create mode 100644 src/renderer/components/dropdown/dropdown.tsx diff --git a/integration/__tests__/cluster-pages.tests.ts b/integration/__tests__/cluster-pages.tests.ts index b56b999b2b..15e72f0d80 100644 --- a/integration/__tests__/cluster-pages.tests.ts +++ b/integration/__tests__/cluster-pages.tests.ts @@ -113,13 +113,13 @@ utils.describeIf(minikubeReady(TEST_NAMESPACE))("Minikube based tests", () => { await frame.waitForSelector(".LogList .list span.active"); const showTimestampsButton = await frame.waitForSelector( - ".LogControls .show-timestamps", + "[data-testid='log-controls'] .show-timestamps", ); await showTimestampsButton.click(); const showPreviousButton = await frame.waitForSelector( - ".LogControls .show-previous", + "[data-testid='log-controls'] .show-previous", ); await showPreviousButton.click(); diff --git a/src/behaviours/pod-logs/__snapshots__/download-logs.test.tsx.snap b/src/behaviours/pod-logs/__snapshots__/download-logs.test.tsx.snap new file mode 100644 index 0000000000..91daf9e587 --- /dev/null +++ b/src/behaviours/pod-logs/__snapshots__/download-logs.test.tsx.snap @@ -0,0 +1,864 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`download logs options in pod logs dock tab when opening pod logs renders 1`] = ` + +
+
+
+