Skip to content

Commit

Permalink
Remove duplicated function
Browse files Browse the repository at this point in the history
Signed-off-by: Gavin Reynolds <[email protected]>
  • Loading branch information
gsreynolds committed Jul 16, 2024
1 parent 49bc0ad commit 321b8c5
Showing 1 changed file with 2 additions and 47 deletions.
49 changes: 2 additions & 47 deletions src/config/column-generator.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,6 @@ export const incidentColumn = ({
minWidth,
sortType,
columnType,
expression,
expressionType,
}) => {
const wrappedRenderer = ({
cell, value: cellValue, row,
Expand Down Expand Up @@ -206,8 +204,6 @@ export const incidentColumn = ({
minWidth,
columnType: columnType || 'incident',
Filter: ColumnFilterComponent,
expression,
expressionType,
};

if (id) {
Expand Down Expand Up @@ -796,7 +792,7 @@ export const defaultAlertsColumns = () => [
}),
];

export const computedColumnForSavedColumn = (savedColumn) => {
export const customComputedColumnForSavedColumn = (savedColumn) => {
const {
value,
Header: header,
Expand Down Expand Up @@ -889,47 +885,6 @@ export const customAlertColumnForSavedColumn = (savedColumn) => {
return column;
};

export const customComputedColumnForSavedColumn = (savedColumn) => {
const {
Header: header, accessorPath, width, expression, expressionType,
} = savedColumn;
if (!(header && accessorPath)) {
return null;
}
const accessor = (incident) => {
const path = accessorPath;
let result = null;
try {
result = JSONPath({
path,
json: incident,
});
} catch (e) {
result = null;
}
return result[0];
};

const id = `${header}:${accessorPath}:${expression}`;
const column = incidentColumn({
id,
value: id,
header,
columnType: 'computed',
accessor,
accessorPath,
expression,
expressionType,
minWidth: 100,
renderer: renderPlainTextAlertCell,
});

if (width) {
column.width = width;
}
return column;
};

export const defaultColumns = () => [...defaultIncidentColumns(), ...defaultAlertsColumns()];

export const customAlertColumns = (savedColumns) => {
Expand Down Expand Up @@ -973,7 +928,7 @@ export const columnsForSavedColumns = (savedColumns) => {
return customAlertColumnForSavedColumn(column);
}
if (column.columnType === 'computed') {
return computedColumnForSavedColumn(column);
return customComputedColumnForSavedColumn(column);
}
return null;
})
Expand Down

0 comments on commit 321b8c5

Please sign in to comment.