Skip to content

Commit

Permalink
Add href support to detection column data. Closes #642.
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelBurgess committed Jan 13, 2025
1 parent d0b6684 commit 418f39d
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions ui/dashboard/src/components/dashboards/Table/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ const getData = (columns: TableColumnInfo[], rows: LeafNodeDataRow[]) => {
};

type CellValueProps = {
panel: PanelDefinition;
panel: TableProps;
column: TableColumnInfo;
rowIndex: number;
rowTemplateData: RowRenderResult[];
Expand Down Expand Up @@ -216,6 +216,10 @@ const CellValue = ({
const [showCellControls, setShowCellControls] = useState<boolean>(false);

useEffect(() => {
if (panel.isDetectionTable) {
return;
}

const renderedTemplateObj = rowTemplateData[rowIndex];

if (!renderedTemplateObj) {
Expand All @@ -241,7 +245,24 @@ const CellValue = ({
setHref(null);
setError(renderedTemplateForColumn.error);
}
}, [column, rowIndex, rowTemplateData, searchPathPrefix]);
}, [
panel.isDetectionTable,
column,
rowIndex,
rowTemplateData,
searchPathPrefix,
]);

useEffect(() => {
if (!panel.isDetectionTable || value === undefined || value === null) {
return;
}
const isLink = /(http(s?)):\/\//i.test(value);
if (!isLink) {
return;
}
setHref(value);
}, [panel.isDetectionTable, value]);

let cellContent;
if (value === null || value === undefined) {
Expand Down

0 comments on commit 418f39d

Please sign in to comment.