function columns()

in tools/awps-tunnel/client/src/components/LiveTraceSection.tsx [22:49]


  function columns(items: Record<string, string>): TableColumnDefinition<LogDataViewModel>[] {
    return Object.entries(items).map(([key, value]) =>
      createTableColumn<LogDataViewModel>({
        columnId: key,
        compare: (a, b) => {
          return (a.columns[key] ?? "").localeCompare(b.columns[key] ?? "");
        },
        renderHeaderCell: () => {
          return value;
        },
        renderCell: (item) => {
          const content = item.columns[key];
          // showing tooltip if content is long
          return (
            <TableCellLayout truncate>
              {content?.length > 18 ? (
                <Tooltip positioning="above-start" content={content} relationship="description">
                  <span>{content}</span>
                </Tooltip>
              ) : (
                <>{content}</>
              )}
            </TableCellLayout>
          );
        },
      }),
    );
  }