mirror of
https://github.com/SigNoz/signoz.git
synced 2026-03-16 18:02:09 +00:00
Some checks failed
build-staging / prepare (push) Has been cancelled
build-staging / js-build (push) Has been cancelled
build-staging / go-build (push) Has been cancelled
build-staging / staging (push) Has been cancelled
Release Drafter / update_release_draft (push) Has been cancelled
57 lines
1.2 KiB
TypeScript
57 lines
1.2 KiB
TypeScript
import type {
|
|
TableColumnsType as ColumnsType,
|
|
TableColumnType as ColumnType,
|
|
} from 'antd';
|
|
|
|
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;
|
|
};
|
|
|
|
export const getLabelAndValueContent = (
|
|
label: string,
|
|
value?: string,
|
|
): string => {
|
|
if (value) {
|
|
return `${label}: ${value}`;
|
|
}
|
|
return `${label}`;
|
|
};
|
|
|
|
interface GeneratorResizeTableColumnsProp<T> {
|
|
baseColumnOptions: ColumnsType<T>;
|
|
dynamicColumnOption: { key: string; columnOption: ColumnType<T> }[];
|
|
}
|