mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-14 23:15:53 +08:00
fix: [SIG-532]: Copy Log Link Functionality for new designs (#4644)
* fix: [SIG-532]: timeRange not updating correctly for copy log link * fix: [SIG-532]: use virtuoso props to scroll to some intiial position rather than API hit * fix: added styles for highlighted colors * fix: handle colors for copy log link * fix: update colors for copy log lines
This commit is contained in:
parent
6618b47123
commit
0c14145ef9
@ -9,6 +9,7 @@ import dayjs from 'dayjs';
|
|||||||
import dompurify from 'dompurify';
|
import dompurify from 'dompurify';
|
||||||
import { useActiveLog } from 'hooks/logs/useActiveLog';
|
import { useActiveLog } from 'hooks/logs/useActiveLog';
|
||||||
import { useCopyLogLink } from 'hooks/logs/useCopyLogLink';
|
import { useCopyLogLink } from 'hooks/logs/useCopyLogLink';
|
||||||
|
import { useIsDarkMode } from 'hooks/useDarkMode';
|
||||||
// utils
|
// utils
|
||||||
import { FlatLogData } from 'lib/logs/flatLogData';
|
import { FlatLogData } from 'lib/logs/flatLogData';
|
||||||
import { useCallback, useMemo, useState } from 'react';
|
import { useCallback, useMemo, useState } from 'react';
|
||||||
@ -114,6 +115,8 @@ function ListLogView({
|
|||||||
onClearActiveLog: handleClearActiveContextLog,
|
onClearActiveLog: handleClearActiveContextLog,
|
||||||
} = useActiveLog();
|
} = useActiveLog();
|
||||||
|
|
||||||
|
const isDarkMode = useIsDarkMode();
|
||||||
|
|
||||||
const handlerClearActiveContextLog = useCallback(
|
const handlerClearActiveContextLog = useCallback(
|
||||||
(event: React.MouseEvent | React.KeyboardEvent) => {
|
(event: React.MouseEvent | React.KeyboardEvent) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
@ -163,6 +166,7 @@ function ListLogView({
|
|||||||
<>
|
<>
|
||||||
<Container
|
<Container
|
||||||
$isActiveLog={isHighlighted}
|
$isActiveLog={isHighlighted}
|
||||||
|
$isDarkMode={isDarkMode}
|
||||||
onMouseEnter={handleMouseEnter}
|
onMouseEnter={handleMouseEnter}
|
||||||
onMouseLeave={handleMouseLeave}
|
onMouseLeave={handleMouseLeave}
|
||||||
onClick={handleDetailedView}
|
onClick={handleDetailedView}
|
||||||
|
@ -1,18 +1,24 @@
|
|||||||
|
import { Color } from '@signozhq/design-tokens';
|
||||||
import { Card, Typography } from 'antd';
|
import { Card, Typography } from 'antd';
|
||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
import { getActiveLogBackground } from 'utils/logs';
|
|
||||||
|
|
||||||
export const Container = styled(Card)<{
|
export const Container = styled(Card)<{
|
||||||
$isActiveLog: boolean;
|
$isActiveLog: boolean;
|
||||||
|
$isDarkMode: boolean;
|
||||||
}>`
|
}>`
|
||||||
width: 100% !important;
|
width: 100% !important;
|
||||||
margin-bottom: 0.3rem;
|
margin-bottom: 0.3rem;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
.ant-card-body {
|
.ant-card-body {
|
||||||
padding: 0.3rem 0.6rem;
|
padding: 0.3rem 0.6rem;
|
||||||
}
|
|
||||||
|
|
||||||
${({ $isActiveLog }): string => getActiveLogBackground($isActiveLog)}
|
${({ $isActiveLog, $isDarkMode }): string =>
|
||||||
|
$isActiveLog
|
||||||
|
? `background-color: ${
|
||||||
|
$isDarkMode ? Color.BG_SLATE_500 : Color.BG_VANILLA_300
|
||||||
|
} !important`
|
||||||
|
: ''}
|
||||||
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
export const Text = styled(Typography.Text)`
|
export const Text = styled(Typography.Text)`
|
||||||
|
@ -30,6 +30,14 @@ export const RawLogViewContainer = styled(Row)<{
|
|||||||
$isActiveLog
|
$isActiveLog
|
||||||
? getActiveLogBackground($isActiveLog, $isDarkMode)
|
? getActiveLogBackground($isActiveLog, $isDarkMode)
|
||||||
: getDefaultLogBackground($isReadOnly, $isDarkMode)}
|
: getDefaultLogBackground($isReadOnly, $isDarkMode)}
|
||||||
|
|
||||||
|
${({ $isHightlightedLog, $isDarkMode }): string =>
|
||||||
|
$isHightlightedLog
|
||||||
|
? `background-color: ${
|
||||||
|
$isDarkMode ? Color.BG_SLATE_500 : Color.BG_VANILLA_300
|
||||||
|
};
|
||||||
|
transition: background-color 2s ease-in;`
|
||||||
|
: ''}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
export const ExpandIconWrapper = styled(Col)`
|
export const ExpandIconWrapper = styled(Col)`
|
||||||
|
@ -23,6 +23,7 @@ export type UseTableViewProps = {
|
|||||||
onOpenLogsContext?: (log: ILog) => void;
|
onOpenLogsContext?: (log: ILog) => void;
|
||||||
onClickExpand?: (log: ILog) => void;
|
onClickExpand?: (log: ILog) => void;
|
||||||
activeLog?: ILog | null;
|
activeLog?: ILog | null;
|
||||||
|
activeLogIndex?: number;
|
||||||
activeContextLog?: ILog | null;
|
activeContextLog?: ILog | null;
|
||||||
isListViewPanel?: boolean;
|
isListViewPanel?: boolean;
|
||||||
} & LogsTableViewProps;
|
} & LogsTableViewProps;
|
||||||
|
@ -122,12 +122,14 @@ function LiveLogsList({ logs }: LiveLogsListProps): JSX.Element {
|
|||||||
fields: selectedFields,
|
fields: selectedFields,
|
||||||
linesPerRow: options.maxLines,
|
linesPerRow: options.maxLines,
|
||||||
appendTo: 'end',
|
appendTo: 'end',
|
||||||
|
activeLogIndex,
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<Card style={{ width: '100%' }} bodyStyle={CARD_BODY_STYLE}>
|
<Card style={{ width: '100%' }} bodyStyle={CARD_BODY_STYLE}>
|
||||||
<Virtuoso
|
<Virtuoso
|
||||||
ref={ref}
|
ref={ref}
|
||||||
|
initialTopMostItemIndex={activeLogIndex !== -1 ? activeLogIndex : 0}
|
||||||
data={logs}
|
data={logs}
|
||||||
totalCount={logs.length}
|
totalCount={logs.length}
|
||||||
itemContent={getItemContent}
|
itemContent={getItemContent}
|
||||||
|
@ -134,6 +134,9 @@ const InfinityTable = forwardRef<TableVirtuosoHandle, InfinityTableProps>(
|
|||||||
<>
|
<>
|
||||||
<TableVirtuoso
|
<TableVirtuoso
|
||||||
ref={ref}
|
ref={ref}
|
||||||
|
initialTopMostItemIndex={
|
||||||
|
tableViewProps.activeLogIndex !== -1 ? tableViewProps.activeLogIndex : 0
|
||||||
|
}
|
||||||
style={infinityDefaultStyles}
|
style={infinityDefaultStyles}
|
||||||
data={dataSource}
|
data={dataSource}
|
||||||
components={{
|
components={{
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import { Color } from '@signozhq/design-tokens';
|
||||||
import { themeColors } from 'constants/theme';
|
import { themeColors } from 'constants/theme';
|
||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
import { getActiveLogBackground } from 'utils/logs';
|
import { getActiveLogBackground } from 'utils/logs';
|
||||||
@ -27,7 +28,12 @@ export const TableRowStyled = styled.tr<{
|
|||||||
$isDarkMode: boolean;
|
$isDarkMode: boolean;
|
||||||
}>`
|
}>`
|
||||||
td {
|
td {
|
||||||
${({ $isActiveLog }): string => getActiveLogBackground($isActiveLog)}
|
${({ $isActiveLog, $isDarkMode }): string =>
|
||||||
|
$isActiveLog
|
||||||
|
? `background-color: ${
|
||||||
|
$isDarkMode ? Color.BG_SLATE_500 : Color.BG_VANILLA_300
|
||||||
|
} !important`
|
||||||
|
: ''}
|
||||||
}
|
}
|
||||||
|
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
@ -16,7 +16,7 @@ import { useOptionsMenu } from 'container/OptionsMenu';
|
|||||||
import { useActiveLog } from 'hooks/logs/useActiveLog';
|
import { useActiveLog } from 'hooks/logs/useActiveLog';
|
||||||
import { useCopyLogLink } from 'hooks/logs/useCopyLogLink';
|
import { useCopyLogLink } from 'hooks/logs/useCopyLogLink';
|
||||||
import { useQueryBuilder } from 'hooks/queryBuilder/useQueryBuilder';
|
import { useQueryBuilder } from 'hooks/queryBuilder/useQueryBuilder';
|
||||||
import { memo, useCallback, useEffect, useMemo, useRef } from 'react';
|
import { memo, useCallback, useMemo, useRef } from 'react';
|
||||||
import { Virtuoso, VirtuosoHandle } from 'react-virtuoso';
|
import { Virtuoso, VirtuosoHandle } from 'react-virtuoso';
|
||||||
// interfaces
|
// interfaces
|
||||||
import { ILog } from 'types/api/logs/log';
|
import { ILog } from 'types/api/logs/log';
|
||||||
@ -103,16 +103,6 @@ function LogsExplorerList({
|
|||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (!activeLogId || activeLogIndex < 0) return;
|
|
||||||
|
|
||||||
ref?.current?.scrollToIndex({
|
|
||||||
index: activeLogIndex,
|
|
||||||
align: 'start',
|
|
||||||
behavior: 'smooth',
|
|
||||||
});
|
|
||||||
}, [activeLogId, activeLogIndex]);
|
|
||||||
|
|
||||||
const renderContent = useMemo(() => {
|
const renderContent = useMemo(() => {
|
||||||
const components = isLoading
|
const components = isLoading
|
||||||
? {
|
? {
|
||||||
@ -130,6 +120,7 @@ function LogsExplorerList({
|
|||||||
fields: selectedFields,
|
fields: selectedFields,
|
||||||
linesPerRow: options.maxLines,
|
linesPerRow: options.maxLines,
|
||||||
appendTo: 'end',
|
appendTo: 'end',
|
||||||
|
activeLogIndex,
|
||||||
}}
|
}}
|
||||||
infitiyTableProps={{ onEndReached }}
|
infitiyTableProps={{ onEndReached }}
|
||||||
/>
|
/>
|
||||||
@ -143,6 +134,7 @@ function LogsExplorerList({
|
|||||||
>
|
>
|
||||||
<Virtuoso
|
<Virtuoso
|
||||||
ref={ref}
|
ref={ref}
|
||||||
|
initialTopMostItemIndex={activeLogIndex !== -1 ? activeLogIndex : 0}
|
||||||
data={logs}
|
data={logs}
|
||||||
endReached={onEndReached}
|
endReached={onEndReached}
|
||||||
totalCount={logs.length}
|
totalCount={logs.length}
|
||||||
@ -151,7 +143,16 @@ function LogsExplorerList({
|
|||||||
/>
|
/>
|
||||||
</Card>
|
</Card>
|
||||||
);
|
);
|
||||||
}, [isLoading, options, logs, onEndReached, getItemContent, selectedFields]);
|
}, [
|
||||||
|
isLoading,
|
||||||
|
options.format,
|
||||||
|
options.maxLines,
|
||||||
|
activeLogIndex,
|
||||||
|
logs,
|
||||||
|
onEndReached,
|
||||||
|
getItemContent,
|
||||||
|
selectedFields,
|
||||||
|
]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="logs-list-view-container">
|
<div className="logs-list-view-container">
|
||||||
|
@ -11,11 +11,8 @@ import {
|
|||||||
useMemo,
|
useMemo,
|
||||||
useState,
|
useState,
|
||||||
} from 'react';
|
} from 'react';
|
||||||
import { useSelector } from 'react-redux';
|
|
||||||
import { useLocation } from 'react-router-dom';
|
import { useLocation } from 'react-router-dom';
|
||||||
import { useCopyToClipboard } from 'react-use';
|
import { useCopyToClipboard } from 'react-use';
|
||||||
import { AppState } from 'store/reducers';
|
|
||||||
import { GlobalReducer } from 'types/reducer/globalTime';
|
|
||||||
|
|
||||||
import { HIGHLIGHTED_DELAY } from './configs';
|
import { HIGHLIGHTED_DELAY } from './configs';
|
||||||
import { LogTimeRange, UseCopyLogLink } from './types';
|
import { LogTimeRange, UseCopyLogLink } from './types';
|
||||||
@ -25,9 +22,6 @@ export const useCopyLogLink = (logId?: string): UseCopyLogLink => {
|
|||||||
const { pathname } = useLocation();
|
const { pathname } = useLocation();
|
||||||
const [, setCopy] = useCopyToClipboard();
|
const [, setCopy] = useCopyToClipboard();
|
||||||
const { notifications } = useNotifications();
|
const { notifications } = useNotifications();
|
||||||
const { maxTime, minTime } = useSelector<AppState, GlobalReducer>(
|
|
||||||
(state) => state.globalTime,
|
|
||||||
);
|
|
||||||
|
|
||||||
const { queryData: timeRange } = useUrlQueryData<LogTimeRange | null>(
|
const { queryData: timeRange } = useUrlQueryData<LogTimeRange | null>(
|
||||||
QueryParams.timeRange,
|
QueryParams.timeRange,
|
||||||
@ -70,8 +64,8 @@ export const useCopyLogLink = (logId?: string): UseCopyLogLink => {
|
|||||||
urlQuery.delete(QueryParams.timeRange);
|
urlQuery.delete(QueryParams.timeRange);
|
||||||
urlQuery.set(QueryParams.activeLogId, `"${logId}"`);
|
urlQuery.set(QueryParams.activeLogId, `"${logId}"`);
|
||||||
urlQuery.set(QueryParams.timeRange, range);
|
urlQuery.set(QueryParams.timeRange, range);
|
||||||
urlQuery.set(QueryParams.startTime, minTime.toString());
|
urlQuery.set(QueryParams.startTime, timeRange?.start.toString() || '');
|
||||||
urlQuery.set(QueryParams.endTime, maxTime.toString());
|
urlQuery.set(QueryParams.endTime, timeRange?.end.toString() || '');
|
||||||
|
|
||||||
const link = `${window.location.origin}${pathname}?${urlQuery.toString()}`;
|
const link = `${window.location.origin}${pathname}?${urlQuery.toString()}`;
|
||||||
|
|
||||||
@ -80,16 +74,7 @@ export const useCopyLogLink = (logId?: string): UseCopyLogLink => {
|
|||||||
message: 'Copied to clipboard',
|
message: 'Copied to clipboard',
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
[
|
[logId, timeRange, urlQuery, pathname, setCopy, notifications],
|
||||||
logId,
|
|
||||||
timeRange,
|
|
||||||
urlQuery,
|
|
||||||
minTime,
|
|
||||||
maxTime,
|
|
||||||
pathname,
|
|
||||||
setCopy,
|
|
||||||
notifications,
|
|
||||||
],
|
|
||||||
);
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user