mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
* Separate 'download visible' and 'download all' tests Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com> * Add disabled prop to DownloadLogsDropdown Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com> * Test for dropdown if no logs available in the tab Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com> * Fix linter Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com> * Remove unused code statement Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com> * Update snapshots Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com> Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
37 lines
1.4 KiB
TypeScript
37 lines
1.4 KiB
TypeScript
/**
|
|
* Copyright (c) OpenLens Authors. All rights reserved.
|
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
|
*/
|
|
import { getInjectable } from "@ogre-tools/injectable";
|
|
import type { PodLogsQuery } from "../../../../common/k8s-api/endpoints";
|
|
import type { ResourceDescriptor } from "../../../../common/k8s-api/kube-api";
|
|
import loggerInjectable from "../../../../common/logger.injectable";
|
|
import openSaveFileDialogInjectable from "../../../utils/save-file.injectable";
|
|
import showErrorNotificationInjectable from "../../notifications/show-error-notification.injectable";
|
|
import callForLogsInjectable from "./call-for-logs.injectable";
|
|
|
|
const downloadAllLogsInjectable = getInjectable({
|
|
id: "download-all-logs",
|
|
|
|
instantiate: (di) => {
|
|
const callForLogs = di.inject(callForLogsInjectable);
|
|
const openSaveFileDialog = di.inject(openSaveFileDialogInjectable);
|
|
const logger = di.inject(loggerInjectable);
|
|
const showErrorNotification = di.inject(showErrorNotificationInjectable);
|
|
|
|
return async (params: ResourceDescriptor, query: PodLogsQuery) => {
|
|
const logs = await callForLogs(params, query).catch(error => {
|
|
logger.error("Can't download logs: ", error);
|
|
});
|
|
|
|
if (logs) {
|
|
openSaveFileDialog(`${params.name}.log`, logs, "text/plain");
|
|
} else {
|
|
showErrorNotification("No logs to download");
|
|
}
|
|
};
|
|
},
|
|
});
|
|
|
|
export default downloadAllLogsInjectable;
|