1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Fix linter errors

Signed-off-by: alexfront <alex.andreev.email@gmail.com>
This commit is contained in:
alexfront 2022-09-08 16:04:57 +03:00
parent d951f3a017
commit 2d69bbcfd8
5 changed files with 41 additions and 25 deletions

View File

@ -1,3 +1,7 @@
/**
* 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 { getInjectable } from "@ogre-tools/injectable";
import moment from "moment"; import moment from "moment";
import userStoreInjectable from "../../../../common/user-store/user-store.injectable"; import userStoreInjectable from "../../../../common/user-store/user-store.injectable";
@ -13,7 +17,7 @@ const getVisibleLogsInjectable = getInjectable({
return (tabId: TabId) => { return (tabId: TabId) => {
const getLogTabData = di.inject(getLogTabDataInjectable); const getLogTabData = di.inject(getLogTabDataInjectable);
const getTimestampSplitLogs = di.inject(getTimestampSplitLogsInjectable); const getTimestampSplitLogs = di.inject(getTimestampSplitLogsInjectable);
const userStore = di.inject(userStoreInjectable) const userStore = di.inject(userStoreInjectable);
const logTabData = getLogTabData(tabId); const logTabData = getLogTabData(tabId);
if (!logTabData) { if (!logTabData) {
@ -31,8 +35,8 @@ const getVisibleLogsInjectable = getInjectable({
return getTimestampSplitLogs(tabId).map(([logTimestamp, log]) => ( return getTimestampSplitLogs(tabId).map(([logTimestamp, log]) => (
`${logTimestamp && moment.tz(logTimestamp, userStore.localeTimezone).format()}${log}` `${logTimestamp && moment.tz(logTimestamp, userStore.localeTimezone).format()}${log}`
)); ));
} };
} },
}); });
export default getVisibleLogsInjectable; export default getVisibleLogsInjectable;

View File

@ -5,12 +5,12 @@
import styles from "./log-list.module.scss"; import styles from "./log-list.module.scss";
import { useVirtualizer } from '@tanstack/react-virtual'; import { useVirtualizer } from "@tanstack/react-virtual";
import { observer } from 'mobx-react'; import { observer } from "mobx-react";
import React, { useRef } from 'react'; import React, { useRef } from "react";
import { cssNames } from "../../../utils"; import { cssNames } from "../../../utils";
import { LogRow } from "./log-row"; import { LogRow } from "./log-row";
import type { LogTabViewModel } from './logs-view-model'; import type { LogTabViewModel } from "./logs-view-model";
import { ToBottom } from "./to-bottom"; import { ToBottom } from "./to-bottom";
import { useInitialScrollToBottom } from "./use-initial-scroll-to-bottom"; import { useInitialScrollToBottom } from "./use-initial-scroll-to-bottom";
import { useOnScrollTop } from "./use-on-scroll-top"; import { useOnScrollTop } from "./use-on-scroll-top";
@ -38,12 +38,12 @@ export const LogList = observer(({ model }: LogListProps) => {
}); });
const scrollTo = (index: number) => { const scrollTo = (index: number) => {
rowVirtualizer.scrollToIndex(index, { align: 'start', smoothScroll: false }); rowVirtualizer.scrollToIndex(index, { align: "start", smoothScroll: false });
} };
const scrollToBottom = () => { const scrollToBottom = () => {
scrollTo(visibleLogs.get().length - 1); scrollTo(visibleLogs.get().length - 1);
} };
const onScroll = () => { const onScroll = () => {
if (!parentRef.current) return; if (!parentRef.current) return;
@ -94,6 +94,6 @@ export const LogList = observer(({ model }: LogListProps) => {
<ToBottom onClick={scrollToBottom} /> <ToBottom onClick={scrollToBottom} />
)} )}
</div> </div>
) );
}); });

View File

@ -1,11 +1,15 @@
/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import styles from "./log-row.module.scss"; import styles from "./log-row.module.scss";
import AnsiUp from 'ansi_up'; import AnsiUp from "ansi_up";
import DOMPurify from 'dompurify'; import DOMPurify from "dompurify";
import React from 'react'; import React from "react";
import { SearchStore } from '../../../search-store/search-store'; import { SearchStore } from "../../../search-store/search-store";
import { cssNames } from '../../../utils'; import { cssNames } from "../../../utils";
import type { LogTabViewModel } from './logs-view-model'; import type { LogTabViewModel } from "./logs-view-model";
const colorConverter = new AnsiUp(); const colorConverter = new AnsiUp();
@ -54,4 +58,4 @@ export function LogRow({ rowIndex, model }: { rowIndex: number; model: LogTabVie
<br /> <br />
</div> </div>
); );
} }

View File

@ -1,3 +1,7 @@
/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import { useEffect } from "react"; import { useEffect } from "react";
import type { LogTabViewModel } from "./logs-view-model"; import type { LogTabViewModel } from "./logs-view-model";
@ -5,6 +9,6 @@ export function useInitialScrollToBottom(model: LogTabViewModel, callback: () =>
useEffect(() => { useEffect(() => {
setTimeout(() => { setTimeout(() => {
callback(); callback();
}, 300) // Giving some time virtual library to render its rows }, 300); // Giving some time virtual library to render its rows
}, [model.logTabData.get()?.selectedPodId]) }, [model.logTabData.get()?.selectedPodId]);
} }

View File

@ -1,4 +1,8 @@
import { useState } from 'react'; /**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import { useState } from "react";
export function useJumpToBottomButton(scrolledParent: HTMLDivElement | null): [isVisible: boolean, setVisibility: () => void] { export function useJumpToBottomButton(scrolledParent: HTMLDivElement | null): [isVisible: boolean, setVisibility: () => void] {
const [isVisible, setToBottomVisible] = useState(false); const [isVisible, setToBottomVisible] = useState(false);
@ -13,7 +17,7 @@ export function useJumpToBottomButton(scrolledParent: HTMLDivElement | null): [i
} else { } else {
setToBottomVisible(false); setToBottomVisible(false);
} }
} };
return [isVisible, setVisibility]; return [isVisible, setVisibility];
} }