@@ -5,7 +5,6 @@ import { persistStore } from './persist-store';
55import { customSearchAttributes } from './search-attributes' ;
66
77export const MAX_PINNED_COLUMNS = 2 ;
8-
98export const WorkflowHeaderLabels = [
109 'Status' ,
1110 'Workflow ID' ,
@@ -107,14 +106,17 @@ export const workflowTableColumns: Readable<State> = derived(
107106 [ namespaces , persistedWorkflowTableColumns ] ,
108107 ( [ $namespaces , $persistedWorkflowTableColumns ] ) => {
109108 const state : State = { } ;
110- return $namespaces . reduce (
111- ( namespaceToColumnsMap , { namespaceInfo : { name } } ) => {
112- return {
113- ...namespaceToColumnsMap ,
114- [ name ] : $persistedWorkflowTableColumns [ name ] ?? getDefaultColumns ( ) ,
115- } ;
116- } ,
117- state ,
109+ return (
110+ $namespaces ?. reduce (
111+ ( namespaceToColumnsMap , { namespaceInfo : { name } } ) => {
112+ return {
113+ ...namespaceToColumnsMap ,
114+ [ name ] :
115+ $persistedWorkflowTableColumns ?. [ name ] ?? getDefaultColumns ( ) ,
116+ } ;
117+ } ,
118+ state ,
119+ ) ?? { }
118120 ) ;
119121 } ,
120122) ;
@@ -129,7 +131,7 @@ export const availableSystemSearchAttributeColumns: (
129131 derived ( workflowTableColumns , ( $workflowTableColumns ) =>
130132 [ ...DEFAULT_COLUMNS , ...DEFAULT_AVAILABLE_COLUMNS ] . filter (
131133 ( header ) =>
132- ! $workflowTableColumns [ namespace ] . some (
134+ ! $workflowTableColumns [ namespace ] ? .some (
133135 ( column ) => column . label === header . label ,
134136 ) ,
135137 ) ,
@@ -144,7 +146,7 @@ export const availableCustomSearchAttributeColumns: (
144146 Object . keys ( $customSearchAttributes )
145147 . filter (
146148 ( searchAttribute ) =>
147- ! $workflowTableColumns [ namespace ] . some (
149+ ! $workflowTableColumns [ namespace ] ? .some (
148150 ( column ) => column . label === searchAttribute ,
149151 ) ,
150152 )
@@ -158,7 +160,7 @@ const reducer = (action: Action, state: State): State => {
158160 switch ( action . type ) {
159161 case 'WORKFLOW_COLUMN.ADD' : {
160162 const { label, namespace } = action . payload ;
161- const columns = state [ namespace ] ?? DEFAULT_COLUMNS ;
163+ const columns = state ?. [ namespace ] ?? DEFAULT_COLUMNS ;
162164
163165 return {
164166 ...state ,
@@ -167,7 +169,7 @@ const reducer = (action: Action, state: State): State => {
167169 }
168170 case 'WORKFLOW_COLUMN.REMOVE' : {
169171 const { label : labelToRemove , namespace } = action . payload ;
170- const columns = state [ namespace ] ?? DEFAULT_COLUMNS ;
172+ const columns = state ?. [ namespace ] ?? DEFAULT_COLUMNS ;
171173
172174 return {
173175 ...state ,
@@ -176,7 +178,7 @@ const reducer = (action: Action, state: State): State => {
176178 }
177179 case 'WORKFLOW_COLUMN.PIN' : {
178180 const { label : labelToPin , namespace } = action . payload ;
179- const columns = state [ namespace ] ?? DEFAULT_COLUMNS ;
181+ const columns = state ?. [ namespace ] ?? DEFAULT_COLUMNS ;
180182 const index = columns . findIndex ( ( { label } ) => label === labelToPin ) ;
181183
182184 const isPinned = columns [ index ] . pinned ;
@@ -205,7 +207,7 @@ const reducer = (action: Action, state: State): State => {
205207 }
206208 case 'WORKFLOW_COLUMN.MOVE' : {
207209 const { from, to, namespace } = action . payload ;
208- const columns = state [ namespace ] ?? DEFAULT_COLUMNS ;
210+ const columns = state ?. [ namespace ] ?? DEFAULT_COLUMNS ;
209211 const isPinned = columns [ from ] . pinned ;
210212
211213 let lastPinned = 0 ;
0 commit comments