Skip to content

Commit 37e0c70

Browse files
authored
More checks on the namespace workflow columns (#1474)
* More checks on the namespace * Add checks in the workflowTableColumns store * Remove unnecessary ?. check
1 parent 9747274 commit 37e0c70

File tree

3 files changed

+19
-17
lines changed

3 files changed

+19
-17
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@temporalio/ui",
3-
"version": "2.16.8",
3+
"version": "2.16.9",
44
"engines": {
55
"pnpm": ">=8.6.0",
66
"node": ">=18.15.0"

src/lib/components/workflow/workflows-summary-configurable-table/orderable-list.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
1515
export let namespace: string;
1616
17-
$: columnsInUse = $workflowTableColumns[namespace];
17+
$: columnsInUse = $workflowTableColumns?.[namespace] ?? [];
1818
$: availableSystemColumns = availableSystemSearchAttributeColumns(namespace);
1919
$: availableCustomColumns = availableCustomSearchAttributeColumns(namespace);
2020
</script>

src/lib/stores/workflow-table-columns.ts

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { persistStore } from './persist-store';
55
import { customSearchAttributes } from './search-attributes';
66

77
export const MAX_PINNED_COLUMNS = 2;
8-
98
export 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

Comments
 (0)