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 moment from "moment";
import userStoreInjectable from "../../../../common/user-store/user-store.injectable";
@ -13,7 +17,7 @@ const getVisibleLogsInjectable = getInjectable({
return (tabId: TabId) => {
const getLogTabData = di.inject(getLogTabDataInjectable);
const getTimestampSplitLogs = di.inject(getTimestampSplitLogsInjectable);
const userStore = di.inject(userStoreInjectable)
const userStore = di.inject(userStoreInjectable);
const logTabData = getLogTabData(tabId);
if (!logTabData) {
@ -31,8 +35,8 @@ const getVisibleLogsInjectable = getInjectable({
return getTimestampSplitLogs(tabId).map(([logTimestamp, 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 { useVirtualizer } from '@tanstack/react-virtual';
import { observer } from 'mobx-react';
import React, { useRef } from 'react';
import { useVirtualizer } from "@tanstack/react-virtual";
import { observer } from "mobx-react";
import React, { useRef } from "react";
import { cssNames } from "../../../utils";
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 { useInitialScrollToBottom } from "./use-initial-scroll-to-bottom";
import { useOnScrollTop } from "./use-on-scroll-top";
@ -38,12 +38,12 @@ export const LogList = observer(({ model }: LogListProps) => {
});
const scrollTo = (index: number) => {
rowVirtualizer.scrollToIndex(index, { align: 'start', smoothScroll: false });
}
rowVirtualizer.scrollToIndex(index, { align: "start", smoothScroll: false });
};
const scrollToBottom = () => {
scrollTo(visibleLogs.get().length - 1);
}
};
const onScroll = () => {
if (!parentRef.current) return;
@ -94,6 +94,6 @@ export const LogList = observer(({ model }: LogListProps) => {
<ToBottom onClick={scrollToBottom} />
)}
</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 AnsiUp from 'ansi_up';
import DOMPurify from 'dompurify';
import React from 'react';
import { SearchStore } from '../../../search-store/search-store';
import { cssNames } from '../../../utils';
import type { LogTabViewModel } from './logs-view-model';
import AnsiUp from "ansi_up";
import DOMPurify from "dompurify";
import React from "react";
import { SearchStore } from "../../../search-store/search-store";
import { cssNames } from "../../../utils";
import type { LogTabViewModel } from "./logs-view-model";
const colorConverter = new AnsiUp();
@ -54,4 +58,4 @@ export function LogRow({ rowIndex, model }: { rowIndex: number; model: LogTabVie
<br />
</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 type { LogTabViewModel } from "./logs-view-model";
@ -5,6 +9,6 @@ export function useInitialScrollToBottom(model: LogTabViewModel, callback: () =>
useEffect(() => {
setTimeout(() => {
callback();
}, 300) // Giving some time virtual library to render its rows
}, [model.logTabData.get()?.selectedPodId])
}
}, 300); // Giving some time virtual library to render its rows
}, [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] {
const [isVisible, setToBottomVisible] = useState(false);
@ -13,7 +17,7 @@ export function useJumpToBottomButton(scrolledParent: HTMLDivElement | null): [i
} else {
setToBottomVisible(false);
}
}
};
return [isVisible, setVisibility];
}
}