mirror of
https://github.com/SigNoz/signoz.git
synced 2025-12-26 12:02:19 +00:00
* feat: added dropdown in alert list table * refactor: done with combining actions * feat: done with label and dynamic table * feat: dynamic column in table * chore: show all label on hover * refactor: create to created timestamp - highlighted action * refactor: storing the column data in localstorage
45 lines
1.1 KiB
TypeScript
45 lines
1.1 KiB
TypeScript
import { ColumnType } from 'antd/es/table';
|
|
import { ColumnsType } from 'antd/lib/table';
|
|
|
|
export const generatorResizeTableColumns = <T>({
|
|
baseColumnOptions,
|
|
dynamicColumnOption,
|
|
}: GeneratorResizeTableColumnsProp<T>): ColumnsType<T> =>
|
|
baseColumnOptions.map((config: ColumnType<T>) => {
|
|
const { key } = config;
|
|
const extraConfig = dynamicColumnOption.find(
|
|
(dynamicConfigItem) => dynamicConfigItem.key === key,
|
|
);
|
|
return {
|
|
...config,
|
|
...extraConfig?.columnOption,
|
|
};
|
|
});
|
|
|
|
export const getLabelRenderingValue = (
|
|
label: string,
|
|
value?: string,
|
|
): string => {
|
|
const maxLength = 20;
|
|
|
|
if (label.length > maxLength) {
|
|
return `${label.slice(0, maxLength)}...`;
|
|
}
|
|
|
|
if (value) {
|
|
const remainingSpace = maxLength - label.length;
|
|
let newValue = value;
|
|
if (value.length > remainingSpace) {
|
|
newValue = `${value.slice(0, remainingSpace)}...`;
|
|
}
|
|
return `${label}: ${newValue}`;
|
|
}
|
|
|
|
return label;
|
|
};
|
|
|
|
interface GeneratorResizeTableColumnsProp<T> {
|
|
baseColumnOptions: ColumnsType<T>;
|
|
dynamicColumnOption: { key: string; columnOption: ColumnType<T> }[];
|
|
}
|