mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Replace usage of callForAllLogs with
simple callForLogs Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
parent
f19c1565e4
commit
3eb129efcb
@ -15,7 +15,7 @@ import type { ApplicationBuilder } from "../../../test-utils/get-application-bui
|
|||||||
import { getApplicationBuilder } from "../../../test-utils/get-application-builder";
|
import { getApplicationBuilder } from "../../../test-utils/get-application-builder";
|
||||||
import dockStoreInjectable from "../../dock/store.injectable";
|
import dockStoreInjectable from "../../dock/store.injectable";
|
||||||
import areLogsPresentInjectable from "../are-logs-present.injectable";
|
import areLogsPresentInjectable from "../are-logs-present.injectable";
|
||||||
import callForAllLogsInjectable from "../call-for-all-logs.injectable";
|
import callForLogsInjectable from "../call-for-logs.injectable";
|
||||||
import createPodLogsTabInjectable from "../create-pod-logs-tab.injectable";
|
import createPodLogsTabInjectable from "../create-pod-logs-tab.injectable";
|
||||||
import getLogTabDataInjectable from "../get-log-tab-data.injectable";
|
import getLogTabDataInjectable from "../get-log-tab-data.injectable";
|
||||||
import getLogsWithoutTimestampsInjectable from "../get-logs-without-timestamps.injectable";
|
import getLogsWithoutTimestampsInjectable from "../get-logs-without-timestamps.injectable";
|
||||||
@ -41,7 +41,7 @@ describe("download logs options in pod logs dock tab", () => {
|
|||||||
builder.setEnvironmentToClusterFrame();
|
builder.setEnvironmentToClusterFrame();
|
||||||
|
|
||||||
builder.beforeApplicationStart(({ rendererDi }) => {
|
builder.beforeApplicationStart(({ rendererDi }) => {
|
||||||
rendererDi.override(callForAllLogsInjectable, () => () => Promise.resolve("all-logs"));
|
rendererDi.override(callForLogsInjectable, () => () => Promise.resolve("all-logs"));
|
||||||
|
|
||||||
// Overriding internals of logsViewModelInjectable
|
// Overriding internals of logsViewModelInjectable
|
||||||
rendererDi.override(getLogsInjectable, () => () => ["some-logs"]);
|
rendererDi.override(getLogsInjectable, () => () => ["some-logs"]);
|
||||||
|
|||||||
@ -1,25 +0,0 @@
|
|||||||
/**
|
|
||||||
* 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 { Pod, PodLogsQuery } from "../../../../common/k8s-api/endpoints";
|
|
||||||
import callForLogsInjectable from "./call-for-logs.injectable";
|
|
||||||
|
|
||||||
const callForAllLogsInjectable = getInjectable({
|
|
||||||
id: "call-for-all-logs",
|
|
||||||
|
|
||||||
instantiate: (di) => {
|
|
||||||
const callForLogs = di.inject(callForLogsInjectable);
|
|
||||||
|
|
||||||
return async (pod: Pod, query?: PodLogsQuery) => {
|
|
||||||
const namespace = pod.getNs();
|
|
||||||
const name = pod.getName();
|
|
||||||
const logs = await callForLogs({ name, namespace }, query);
|
|
||||||
|
|
||||||
return logs;
|
|
||||||
};
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
export default callForAllLogsInjectable;
|
|
||||||
@ -13,9 +13,8 @@ import { Checkbox } from "../../checkbox";
|
|||||||
import type { LogTabViewModel } from "./logs-view-model";
|
import type { LogTabViewModel } from "./logs-view-model";
|
||||||
import { withInjectables } from "@ogre-tools/injectable-react";
|
import { withInjectables } from "@ogre-tools/injectable-react";
|
||||||
import openSaveFileDialogInjectable from "../../../utils/save-file.injectable";
|
import openSaveFileDialogInjectable from "../../../utils/save-file.injectable";
|
||||||
import callForAllLogsInjectable from "./call-for-all-logs.injectable";
|
|
||||||
import { DownloadLogsDropdown } from "./download-logs-dropdown";
|
import { DownloadLogsDropdown } from "./download-logs-dropdown";
|
||||||
import type { Pod, PodLogsQuery } from "../../../../common/k8s-api/endpoints";
|
import callForLogsInjectable, { CallForLogs } from "./call-for-logs.injectable";
|
||||||
|
|
||||||
export interface LogControlsProps {
|
export interface LogControlsProps {
|
||||||
model: LogTabViewModel;
|
model: LogTabViewModel;
|
||||||
@ -23,10 +22,10 @@ export interface LogControlsProps {
|
|||||||
|
|
||||||
interface Dependencies {
|
interface Dependencies {
|
||||||
openSaveFileDialog: (filename: string, contents: BlobPart | BlobPart[], type: string) => void;
|
openSaveFileDialog: (filename: string, contents: BlobPart | BlobPart[], type: string) => void;
|
||||||
callForAllLogs: (pod: Pod, query?: PodLogsQuery) => Promise<string>;
|
callForLogs: CallForLogs;
|
||||||
}
|
}
|
||||||
|
|
||||||
const NonInjectedLogControls = observer(({ openSaveFileDialog, model, callForAllLogs }: Dependencies & LogControlsProps) => {
|
const NonInjectedLogControls = observer(({ openSaveFileDialog, model, callForLogs }: Dependencies & LogControlsProps) => {
|
||||||
const tabData = model.logTabData.get();
|
const tabData = model.logTabData.get();
|
||||||
const pod = model.pod.get();
|
const pod = model.pod.get();
|
||||||
|
|
||||||
@ -51,7 +50,10 @@ const NonInjectedLogControls = observer(({ openSaveFileDialog, model, callForAll
|
|||||||
const pod = model.pod.get();
|
const pod = model.pod.get();
|
||||||
|
|
||||||
if (pod) {
|
if (pod) {
|
||||||
const logs = await callForAllLogs(pod, { timestamps: showTimestamps, previous });
|
const logs = await callForLogs(
|
||||||
|
{ name: pod.getName(), namespace: pod.getNs() },
|
||||||
|
{ timestamps: showTimestamps, previous }
|
||||||
|
)
|
||||||
|
|
||||||
openSaveFileDialog(`${pod.getName()}.log`, logs, "text/plain");
|
openSaveFileDialog(`${pod.getName()}.log`, logs, "text/plain");
|
||||||
}
|
}
|
||||||
@ -106,7 +108,7 @@ const NonInjectedLogControls = observer(({ openSaveFileDialog, model, callForAll
|
|||||||
export const LogControls = withInjectables<Dependencies, LogControlsProps>(NonInjectedLogControls, {
|
export const LogControls = withInjectables<Dependencies, LogControlsProps>(NonInjectedLogControls, {
|
||||||
getProps: (di, props) => ({
|
getProps: (di, props) => ({
|
||||||
openSaveFileDialog: di.inject(openSaveFileDialogInjectable),
|
openSaveFileDialog: di.inject(openSaveFileDialogInjectable),
|
||||||
callForAllLogs: di.inject(callForAllLogsInjectable),
|
callForLogs: di.inject(callForLogsInjectable),
|
||||||
...props,
|
...props,
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user