mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-13 05:29:04 +08:00
fix: restricted column long value to 3 line and line clamped (#6056)
* fix: restricted column long value to 3 line and line clamped * fix: added tooltip prop as prop for generic component and passed style from consumer * fix: comment resolved * fix: refactored styles * fix: updated snapshot * fix: removed console log
This commit is contained in:
parent
794d6fc0ca
commit
5a0a7c2c60
@ -0,0 +1,5 @@
|
|||||||
|
.long-text-tooltip {
|
||||||
|
max-width: 500px;
|
||||||
|
max-height: 500px;
|
||||||
|
overflow-y: auto;
|
||||||
|
}
|
@ -1,3 +1,5 @@
|
|||||||
|
import './GridTableComponent.styles.scss';
|
||||||
|
|
||||||
import { ExclamationCircleFilled } from '@ant-design/icons';
|
import { ExclamationCircleFilled } from '@ant-design/icons';
|
||||||
import { Space, Tooltip } from 'antd';
|
import { Space, Tooltip } from 'antd';
|
||||||
import { getYAxisFormattedValue } from 'components/Graph/yAxisConfig';
|
import { getYAxisFormattedValue } from 'components/Graph/yAxisConfig';
|
||||||
@ -5,6 +7,7 @@ import { Events } from 'constants/events';
|
|||||||
import { QueryTable } from 'container/QueryTable';
|
import { QueryTable } from 'container/QueryTable';
|
||||||
import { RowData } from 'lib/query/createTableColumnsFromQuery';
|
import { RowData } from 'lib/query/createTableColumnsFromQuery';
|
||||||
import { cloneDeep, get, isEmpty } from 'lodash-es';
|
import { cloneDeep, get, isEmpty } from 'lodash-es';
|
||||||
|
import LineClampedText from 'periscope/components/LineClampedText/LineClampedText';
|
||||||
import { memo, ReactNode, useCallback, useEffect, useMemo } from 'react';
|
import { memo, ReactNode, useCallback, useEffect, useMemo } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { eventEmitter } from 'utils/getEventEmitter';
|
import { eventEmitter } from 'utils/getEventEmitter';
|
||||||
@ -116,7 +119,16 @@ function GridTableComponent({
|
|||||||
}
|
}
|
||||||
>
|
>
|
||||||
<Space>
|
<Space>
|
||||||
{text}
|
<LineClampedText
|
||||||
|
text={text}
|
||||||
|
lines={3}
|
||||||
|
tooltipProps={{
|
||||||
|
placement: 'right',
|
||||||
|
autoAdjustOverflow: true,
|
||||||
|
overlayClassName: 'long-text-tooltip',
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
|
||||||
{hasMultipleMatches && (
|
{hasMultipleMatches && (
|
||||||
<Tooltip title={t('this_value_satisfies_multiple_thresholds')}>
|
<Tooltip title={t('this_value_satisfies_multiple_thresholds')}>
|
||||||
<ExclamationCircleFilled className="value-graph-icon" />
|
<ExclamationCircleFilled className="value-graph-icon" />
|
||||||
@ -127,7 +139,19 @@ function GridTableComponent({
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return <div>{text}</div>;
|
return (
|
||||||
|
<div>
|
||||||
|
<LineClampedText
|
||||||
|
text={text}
|
||||||
|
lines={3}
|
||||||
|
tooltipProps={{
|
||||||
|
placement: 'right',
|
||||||
|
autoAdjustOverflow: true,
|
||||||
|
overlayClassName: 'long-text-tooltip',
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
},
|
},
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
@ -63,8 +63,7 @@
|
|||||||
height: 40px;
|
height: 40px;
|
||||||
justify-content: end;
|
justify-content: end;
|
||||||
padding: 0 8px;
|
padding: 0 8px;
|
||||||
margin-top: 12px;
|
margin: 12px 0 2px;
|
||||||
margin-bottom: 2px;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -266,14 +266,22 @@ exports[`Table panel wrappper tests table should render fine with the query resp
|
|||||||
class="ant-table-cell"
|
class="ant-table-cell"
|
||||||
>
|
>
|
||||||
<div>
|
<div>
|
||||||
demo-app
|
<div
|
||||||
|
class="line-clamped-text"
|
||||||
|
>
|
||||||
|
demo-app
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td
|
<td
|
||||||
class="ant-table-cell"
|
class="ant-table-cell"
|
||||||
>
|
>
|
||||||
<div>
|
<div>
|
||||||
4.35 s
|
<div
|
||||||
|
class="line-clamped-text"
|
||||||
|
>
|
||||||
|
4.35 s
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@ -284,14 +292,22 @@ exports[`Table panel wrappper tests table should render fine with the query resp
|
|||||||
class="ant-table-cell"
|
class="ant-table-cell"
|
||||||
>
|
>
|
||||||
<div>
|
<div>
|
||||||
customer
|
<div
|
||||||
|
class="line-clamped-text"
|
||||||
|
>
|
||||||
|
customer
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td
|
<td
|
||||||
class="ant-table-cell"
|
class="ant-table-cell"
|
||||||
>
|
>
|
||||||
<div>
|
<div>
|
||||||
431 ms
|
<div
|
||||||
|
class="line-clamped-text"
|
||||||
|
>
|
||||||
|
431 ms
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@ -302,14 +318,22 @@ exports[`Table panel wrappper tests table should render fine with the query resp
|
|||||||
class="ant-table-cell"
|
class="ant-table-cell"
|
||||||
>
|
>
|
||||||
<div>
|
<div>
|
||||||
mysql
|
<div
|
||||||
|
class="line-clamped-text"
|
||||||
|
>
|
||||||
|
mysql
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td
|
<td
|
||||||
class="ant-table-cell"
|
class="ant-table-cell"
|
||||||
>
|
>
|
||||||
<div>
|
<div>
|
||||||
431 ms
|
<div
|
||||||
|
class="line-clamped-text"
|
||||||
|
>
|
||||||
|
431 ms
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@ -320,14 +344,22 @@ exports[`Table panel wrappper tests table should render fine with the query resp
|
|||||||
class="ant-table-cell"
|
class="ant-table-cell"
|
||||||
>
|
>
|
||||||
<div>
|
<div>
|
||||||
frontend
|
<div
|
||||||
|
class="line-clamped-text"
|
||||||
|
>
|
||||||
|
frontend
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td
|
<td
|
||||||
class="ant-table-cell"
|
class="ant-table-cell"
|
||||||
>
|
>
|
||||||
<div>
|
<div>
|
||||||
287 ms
|
<div
|
||||||
|
class="line-clamped-text"
|
||||||
|
>
|
||||||
|
287 ms
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@ -338,14 +370,22 @@ exports[`Table panel wrappper tests table should render fine with the query resp
|
|||||||
class="ant-table-cell"
|
class="ant-table-cell"
|
||||||
>
|
>
|
||||||
<div>
|
<div>
|
||||||
driver
|
<div
|
||||||
|
class="line-clamped-text"
|
||||||
|
>
|
||||||
|
driver
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td
|
<td
|
||||||
class="ant-table-cell"
|
class="ant-table-cell"
|
||||||
>
|
>
|
||||||
<div>
|
<div>
|
||||||
230 ms
|
<div
|
||||||
|
class="line-clamped-text"
|
||||||
|
>
|
||||||
|
230 ms
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@ -356,14 +396,22 @@ exports[`Table panel wrappper tests table should render fine with the query resp
|
|||||||
class="ant-table-cell"
|
class="ant-table-cell"
|
||||||
>
|
>
|
||||||
<div>
|
<div>
|
||||||
route
|
<div
|
||||||
|
class="line-clamped-text"
|
||||||
|
>
|
||||||
|
route
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td
|
<td
|
||||||
class="ant-table-cell"
|
class="ant-table-cell"
|
||||||
>
|
>
|
||||||
<div>
|
<div>
|
||||||
66.4 ms
|
<div
|
||||||
|
class="line-clamped-text"
|
||||||
|
>
|
||||||
|
66.4 ms
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@ -374,14 +422,22 @@ exports[`Table panel wrappper tests table should render fine with the query resp
|
|||||||
class="ant-table-cell"
|
class="ant-table-cell"
|
||||||
>
|
>
|
||||||
<div>
|
<div>
|
||||||
redis
|
<div
|
||||||
|
class="line-clamped-text"
|
||||||
|
>
|
||||||
|
redis
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td
|
<td
|
||||||
class="ant-table-cell"
|
class="ant-table-cell"
|
||||||
>
|
>
|
||||||
<div>
|
<div>
|
||||||
31.3 ms
|
<div
|
||||||
|
class="line-clamped-text"
|
||||||
|
>
|
||||||
|
31.3 ms
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -52,8 +52,7 @@
|
|||||||
height: 40px;
|
height: 40px;
|
||||||
justify-content: end;
|
justify-content: end;
|
||||||
padding: 0 8px;
|
padding: 0 8px;
|
||||||
margin-top: 12px;
|
margin: 12px 0 2px;
|
||||||
margin-bottom: 2px;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,14 +1,16 @@
|
|||||||
import './LineClampedText.styles.scss';
|
import './LineClampedText.styles.scss';
|
||||||
|
|
||||||
import { Tooltip } from 'antd';
|
import { Tooltip, TooltipProps } from 'antd';
|
||||||
import { useEffect, useRef, useState } from 'react';
|
import { useEffect, useRef, useState } from 'react';
|
||||||
|
|
||||||
function LineClampedText({
|
function LineClampedText({
|
||||||
text,
|
text,
|
||||||
lines,
|
lines,
|
||||||
|
tooltipProps,
|
||||||
}: {
|
}: {
|
||||||
text: string;
|
text: string;
|
||||||
lines?: number;
|
lines?: number;
|
||||||
|
tooltipProps?: TooltipProps;
|
||||||
}): JSX.Element {
|
}): JSX.Element {
|
||||||
const [isOverflowing, setIsOverflowing] = useState(false);
|
const [isOverflowing, setIsOverflowing] = useState(false);
|
||||||
const textRef = useRef<HTMLDivElement>(null);
|
const textRef = useRef<HTMLDivElement>(null);
|
||||||
@ -42,11 +44,22 @@ function LineClampedText({
|
|||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
||||||
return isOverflowing ? <Tooltip title={text}>{content}</Tooltip> : content;
|
return isOverflowing ? (
|
||||||
|
<Tooltip
|
||||||
|
title={text}
|
||||||
|
// eslint-disable-next-line react/jsx-props-no-spreading
|
||||||
|
{...tooltipProps}
|
||||||
|
>
|
||||||
|
{content}
|
||||||
|
</Tooltip>
|
||||||
|
) : (
|
||||||
|
content
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
LineClampedText.defaultProps = {
|
LineClampedText.defaultProps = {
|
||||||
lines: 1,
|
lines: 1,
|
||||||
|
tooltipProps: {},
|
||||||
};
|
};
|
||||||
|
|
||||||
export default LineClampedText;
|
export default LineClampedText;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user