mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Fixing ts compilation errors
Signed-off-by: alexfront <alex.andreev.email@gmail.com>
This commit is contained in:
parent
1898a4d68e
commit
d37ae1bffe
@ -56,6 +56,7 @@ describe("download logs options in pod logs dock tab", () => {
|
||||
namespace: "default",
|
||||
showPrevious: true,
|
||||
showTimestamps: false,
|
||||
wrap: false,
|
||||
}));
|
||||
windowDi.override(setLogTabDataInjectable, () => jest.fn());
|
||||
windowDi.override(loadLogsInjectable, () => jest.fn());
|
||||
|
||||
@ -46,6 +46,7 @@ function mockLogTabViewModel(tabId: TabId, deps: Partial<LogTabViewModelDependen
|
||||
return new LogTabViewModel(tabId, {
|
||||
getLogs: jest.fn(),
|
||||
getLogsWithoutTimestamps: jest.fn(),
|
||||
getVisibleLogs: jest.fn(),
|
||||
getTimestampSplitLogs: jest.fn(),
|
||||
getLogTabData: jest.fn(),
|
||||
setLogTabData: jest.fn(),
|
||||
@ -73,6 +74,7 @@ function getOnePodViewModel(tabId: TabId, deps: Partial<LogTabViewModelDependenc
|
||||
namespace: selectedPod.getNs(),
|
||||
showPrevious: false,
|
||||
showTimestamps: false,
|
||||
wrap: false,
|
||||
}),
|
||||
getPodById: (id) => {
|
||||
if (id === selectedPod.getId()) {
|
||||
@ -101,6 +103,7 @@ const getFewPodsTabData = (tabId: TabId, deps: Partial<LogTabViewModelDependenci
|
||||
namespace: selectedPod.getNs(),
|
||||
showPrevious: false,
|
||||
showTimestamps: false,
|
||||
wrap: false,
|
||||
}),
|
||||
getPodById: (id) => {
|
||||
if (id === selectedPod.getId()) {
|
||||
|
||||
@ -20,6 +20,7 @@ function mockLogTabViewModel(tabId: TabId, deps: Partial<LogTabViewModelDependen
|
||||
return new LogTabViewModel(tabId, {
|
||||
getLogs: jest.fn(),
|
||||
getLogsWithoutTimestamps: jest.fn(),
|
||||
getVisibleLogs: jest.fn(),
|
||||
getTimestampSplitLogs: jest.fn(),
|
||||
getLogTabData: jest.fn(),
|
||||
setLogTabData: jest.fn(),
|
||||
@ -47,6 +48,7 @@ const getOnePodViewModel = (tabId: TabId, deps: Partial<LogTabViewModelDependenc
|
||||
namespace: selectedPod.getNs(),
|
||||
showPrevious: false,
|
||||
showTimestamps: false,
|
||||
wrap: false,
|
||||
}),
|
||||
getPodById: (id) => {
|
||||
if (id === selectedPod.getId()) {
|
||||
@ -71,10 +73,7 @@ describe("LogSearch tests", () => {
|
||||
it("renders w/o errors", () => {
|
||||
const model = getOnePodViewModel("foobar");
|
||||
const { container } = render(
|
||||
<LogSearch
|
||||
model={model}
|
||||
scrollToOverlay={jest.fn()}
|
||||
/>,
|
||||
<LogSearch model={model}/>,
|
||||
);
|
||||
|
||||
expect(container).toBeInstanceOf(HTMLElement);
|
||||
@ -90,10 +89,7 @@ describe("LogSearch tests", () => {
|
||||
});
|
||||
|
||||
render(
|
||||
<LogSearch
|
||||
model={model}
|
||||
scrollToOverlay={scrollToOverlay}
|
||||
/>,
|
||||
<LogSearch model={model}/>,
|
||||
);
|
||||
|
||||
userEvent.click(await screen.findByPlaceholderText("Search..."));
|
||||
@ -112,10 +108,7 @@ describe("LogSearch tests", () => {
|
||||
});
|
||||
|
||||
render(
|
||||
<LogSearch
|
||||
model={model}
|
||||
scrollToOverlay={scrollToOverlay}
|
||||
/>,
|
||||
<LogSearch model={model}/>,
|
||||
);
|
||||
|
||||
userEvent.click(await screen.findByPlaceholderText("Search..."));
|
||||
@ -134,10 +127,7 @@ describe("LogSearch tests", () => {
|
||||
});
|
||||
|
||||
render(
|
||||
<LogSearch
|
||||
model={model}
|
||||
scrollToOverlay={scrollToOverlay}
|
||||
/>,
|
||||
<LogSearch model={model}/>,
|
||||
);
|
||||
|
||||
userEvent.click(await screen.findByText("keyboard_arrow_down"));
|
||||
|
||||
@ -31,6 +31,7 @@ const createLogsTab = ({ createDockTab, setLogTabData, getRandomId }: Dependenci
|
||||
setLogTabData(id, {
|
||||
showTimestamps: false,
|
||||
showPrevious: false,
|
||||
wrap: false,
|
||||
...data,
|
||||
});
|
||||
});
|
||||
|
||||
@ -1,5 +1,11 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
|
||||
import styles from "./log-list.module.scss";
|
||||
|
||||
import throttle from "lodash/throttle";
|
||||
import { useVirtualizer } from '@tanstack/react-virtual';
|
||||
import { observer } from 'mobx-react';
|
||||
import React, { useEffect, useRef } from 'react';
|
||||
@ -16,7 +22,7 @@ export interface LogListProps {
|
||||
}
|
||||
|
||||
export const LogList = observer(({ model }: LogListProps) => {
|
||||
const [lastLineVisible, setLastLineVisible] = React.useState(true);
|
||||
// const [lastLineVisible, setLastLineVisible] = React.useState(true);
|
||||
const [rowKeySuffix, setRowKeySuffix] = React.useState(getRandomId());
|
||||
|
||||
const { visibleLogs } = model;
|
||||
@ -37,22 +43,22 @@ export const LogList = observer(({ model }: LogListProps) => {
|
||||
scrollTo(visibleLogs.get().length - 1);
|
||||
}
|
||||
|
||||
const onScroll = (event: React.UIEvent<HTMLDivElement>) => {
|
||||
const onScroll = throttle(() => {
|
||||
if (!parentRef.current) return;
|
||||
|
||||
setButtonVisibility();
|
||||
setLastLineVisibility();
|
||||
onScrollToTop();
|
||||
}
|
||||
}, 1_000, { trailing: true, leading: true });
|
||||
|
||||
const setLastLineVisibility = () => {
|
||||
const { scrollTop, scrollHeight } = parentRef.current as HTMLDivElement;
|
||||
// const { scrollTop, scrollHeight } = parentRef.current as HTMLDivElement;
|
||||
|
||||
if (scrollHeight - scrollTop < 4000) {
|
||||
setLastLineVisible(true);
|
||||
} else {
|
||||
setLastLineVisible(false);
|
||||
}
|
||||
// if (scrollHeight - scrollTop < 4000) {
|
||||
// setLastLineVisible(true);
|
||||
// } else {
|
||||
// setLastLineVisible(false);
|
||||
// }
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Loading…
Reference in New Issue
Block a user