Skip to content

Commit

Permalink
Guard against computed or alert column state being undefined
Browse files Browse the repository at this point in the history
Signed-off-by: Gavin Reynolds <[email protected]>
  • Loading branch information
gsreynolds committed Jul 18, 2024
1 parent 38ac483 commit 3f71eab
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/components/ColumnsModal/ColumnsModalComponent.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ import DraggableColumnsModalItem from './subcomponents/DraggableColumnsModalItem

const TableColumnsModalComponent = () => {
const displayColumnsModal = useSelector((state) => state.settings.displayColumnsModal);
const alertCustomDetailFields = useSelector((state) => state.settings.alertCustomDetailFields);
const computedFields = useSelector((state) => state.settings.computedFields);
const alertCustomDetailFields = useSelector((state) => state.settings.alertCustomDetailFields) || [];
const computedFields = useSelector((state) => state.settings.computedFields) || [];
const incidentTableColumns = useSelector((state) => state.incidentTable.incidentTableColumns);
const {
incidentTableState,
Expand Down
6 changes: 6 additions & 0 deletions src/config/column-generator.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -908,6 +908,9 @@ export const customAlertColumns = (savedColumns) => {

export const customComputedColumns = (savedColumns) => {
const allColumns = defaultColumns();
if (!savedColumns) {
return [];
}
return savedColumns.map((column) => {
if (
column.columnType === 'computed'
Expand All @@ -921,6 +924,9 @@ export const customComputedColumns = (savedColumns) => {

export const columnsForSavedColumns = (savedColumns) => {
const allColumns = defaultColumns();
if (!savedColumns) {
return [];
}
const columns = savedColumns
.map((column) => {
const foundColumn = allColumns.find((c) => c.originalHeader === column.Header);
Expand Down

0 comments on commit 3f71eab

Please sign in to comment.