Skip to content

Commit ec849bb

Browse files
Support setting multiple workflow statuses in Domain Workflows page (#844)
* Modify Domain Page query params to change "statuses" to a multi-value page query param * Update useListWorkflows to read and pass multiple statuses * Update filters to use ListFilterMulti component
1 parent f3806cc commit ec849bb

File tree

11 files changed

+48
-37
lines changed

11 files changed

+48
-37
lines changed

src/views/domain-page/__fixtures__/domain-page-query-params.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import type domainPageQueryParamsConfig from '@/views/domain-page/config/domain-
44
export const mockDomainPageQueryParamsValues = {
55
inputType: 'search',
66
search: '',
7-
status: undefined,
7+
statuses: undefined,
88
timeRangeStart: undefined,
99
timeRangeEnd: undefined,
1010
sortColumn: 'startTime',
@@ -15,7 +15,7 @@ export const mockDomainPageQueryParamsValues = {
1515
statusBasic: undefined,
1616
inputTypeArchival: 'search',
1717
searchArchival: '',
18-
statusArchival: undefined,
18+
statusesArchival: undefined,
1919
timeRangeStartArchival: undefined,
2020
timeRangeEndArchival: undefined,
2121
sortColumnArchival: 'startTime',

src/views/domain-page/config/domain-page-query-params.config.ts

+23-11
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
import { type PageQueryParam } from '@/hooks/use-page-query-params/use-page-query-params.types';
1+
import {
2+
type PageQueryParamMultiValue,
3+
type PageQueryParam,
4+
} from '@/hooks/use-page-query-params/use-page-query-params.types';
25
import parseDateQueryParam from '@/utils/datetime/parse-date-query-param';
36
import { type SortOrder } from '@/utils/sort-by';
47
import { type WorkflowStatusClosed } from '@/views/domain-workflows-archival/domain-workflows-archival-header/domain-workflows-archival-header.types';
@@ -12,7 +15,7 @@ const domainPageQueryParamsConfig: [
1215
PageQueryParam<'inputType', WorkflowsHeaderInputType>,
1316
// Search input
1417
PageQueryParam<'search', string>,
15-
PageQueryParam<'status', WorkflowStatus | undefined>,
18+
PageQueryParamMultiValue<'statuses', Array<WorkflowStatus> | undefined>,
1619
PageQueryParam<'timeRangeStart', Date | undefined>,
1720
PageQueryParam<'timeRangeEnd', Date | undefined>,
1821
PageQueryParam<'sortColumn', string>,
@@ -26,7 +29,10 @@ const domainPageQueryParamsConfig: [
2629
// Archival inputs
2730
PageQueryParam<'inputTypeArchival', WorkflowsHeaderInputType>,
2831
PageQueryParam<'searchArchival', string>,
29-
PageQueryParam<'statusArchival', WorkflowStatusClosed | undefined>,
32+
PageQueryParamMultiValue<
33+
'statusesArchival',
34+
Array<WorkflowStatusClosed> | undefined
35+
>,
3036
PageQueryParam<'timeRangeStartArchival', Date | undefined>,
3137
PageQueryParam<'timeRangeEndArchival', Date | undefined>,
3238
PageQueryParam<'sortColumnArchival', string>,
@@ -44,9 +50,11 @@ const domainPageQueryParamsConfig: [
4450
defaultValue: '',
4551
},
4652
{
47-
key: 'status',
48-
parseValue: (value: string) =>
49-
isWorkflowStatus(value) ? value : undefined,
53+
key: 'statuses',
54+
queryParamKey: 'status',
55+
isMultiValue: true,
56+
parseValue: (value: Array<string>) =>
57+
value.every(isWorkflowStatus) ? value : undefined,
5058
},
5159
{
5260
key: 'timeRangeStart',
@@ -99,12 +107,16 @@ const domainPageQueryParamsConfig: [
99107
defaultValue: '',
100108
},
101109
{
102-
key: 'statusArchival',
110+
key: 'statusesArchival',
103111
queryParamKey: 'astatus',
104-
parseValue: (value: string) =>
105-
isWorkflowStatus(value) &&
106-
value !== 'WORKFLOW_EXECUTION_CLOSE_STATUS_INVALID'
107-
? value
112+
isMultiValue: true,
113+
parseValue: (value: Array<string>) =>
114+
value.every(
115+
(status) =>
116+
isWorkflowStatus(status) &&
117+
status !== 'WORKFLOW_EXECUTION_CLOSE_STATUS_INVALID'
118+
)
119+
? (value as Array<WorkflowStatusClosed>)
108120
: undefined,
109121
},
110122
{

src/views/domain-workflows-archival/config/domain-workflows-archival-filters.config.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { createElement } from 'react';
33
import { omit } from 'lodash';
44

55
import DateFilter from '@/components/date-filter/date-filter';
6-
import ListFilter from '@/components/list-filter/list-filter';
6+
import ListFilterMulti from '@/components/list-filter-multi/list-filter-multi';
77
import { type PageFilterConfig } from '@/components/page-filters/page-filters.types';
88
import type domainPageQueryParamsConfig from '@/views/domain-page/config/domain-page-query-params.config';
99
import { WORKFLOW_STATUS_NAMES } from '@/views/shared/workflow-status-tag/workflow-status-tag.constants';
@@ -13,7 +13,7 @@ import { type WorkflowStatusClosed } from '../domain-workflows-archival-header/d
1313
const domainWorkflowsArchivalFiltersConfig: [
1414
PageFilterConfig<
1515
typeof domainPageQueryParamsConfig,
16-
{ statusArchival: WorkflowStatusClosed | undefined }
16+
{ statusesArchival: Array<WorkflowStatusClosed> | undefined }
1717
>,
1818
PageFilterConfig<
1919
typeof domainPageQueryParamsConfig,
@@ -24,15 +24,15 @@ const domainWorkflowsArchivalFiltersConfig: [
2424
>,
2525
] = [
2626
{
27-
id: 'status',
27+
id: 'statuses',
2828
getValue: (v) => v,
2929
formatValue: (v) => v,
3030
component: ({ value, setValue }) =>
31-
createElement(ListFilter<WorkflowStatusClosed>, {
31+
createElement(ListFilterMulti<WorkflowStatusClosed>, {
3232
label: 'Status',
3333
placeholder: 'Show all statuses',
34-
value: value.statusArchival,
35-
onChangeValue: (v) => setValue({ statusArchival: v }),
34+
values: value.statusesArchival,
35+
onChangeValues: (v) => setValue({ statusesArchival: v }),
3636
labelMap: omit(
3737
WORKFLOW_STATUS_NAMES,
3838
'WORKFLOW_EXECUTION_CLOSE_STATUS_INVALID'

src/views/domain-workflows-archival/domain-workflows-archival-header/domain-workflows-archival-header.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export default function DomainWorkflowsArchivalHeader({
2828
listType: 'archived',
2929
inputType: queryParams.inputTypeArchival,
3030
search: queryParams.searchArchival,
31-
status: queryParams.statusArchival,
31+
statuses: queryParams.statusesArchival,
3232
timeRangeStart: queryParams.timeRangeStartArchival,
3333
timeRangeEnd: queryParams.timeRangeEndArchival,
3434
sortColumn: queryParams.sortColumnArchival,

src/views/domain-workflows-archival/domain-workflows-archival-table/domain-workflows-archival-table.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export default function DomainWorkflowsArchivalTable({
3838
pageSize: DOMAIN_WORKFLOWS_ARCHIVAL_PAGE_SIZE,
3939
inputType: queryParams.inputTypeArchival,
4040
search: queryParams.searchArchival,
41-
status: queryParams.statusArchival,
41+
statuses: queryParams.statusesArchival,
4242
timeRangeStart: queryParams.timeRangeStartArchival,
4343
timeRangeEnd: queryParams.timeRangeEndArchival,
4444
sortColumn: queryParams.sortColumnArchival,

src/views/domain-workflows/config/domain-workflows-filters.config.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { createElement } from 'react';
22

33
import DateFilter from '@/components/date-filter/date-filter';
4-
import ListFilter from '@/components/list-filter/list-filter';
4+
import ListFilterMulti from '@/components/list-filter-multi/list-filter-multi';
55
import { type PageFilterConfig } from '@/components/page-filters/page-filters.types';
66
import type domainPageQueryParamsConfig from '@/views/domain-page/config/domain-page-query-params.config';
77
import { WORKFLOW_STATUS_NAMES } from '@/views/shared/workflow-status-tag/workflow-status-tag.constants';
@@ -10,23 +10,23 @@ import { type WorkflowStatus } from '@/views/shared/workflow-status-tag/workflow
1010
const domainWorkflowsFiltersConfig: [
1111
PageFilterConfig<
1212
typeof domainPageQueryParamsConfig,
13-
{ status: WorkflowStatus | undefined }
13+
{ statuses: Array<WorkflowStatus> | undefined }
1414
>,
1515
PageFilterConfig<
1616
typeof domainPageQueryParamsConfig,
1717
{ timeRangeStart: Date | undefined; timeRangeEnd: Date | undefined }
1818
>,
1919
] = [
2020
{
21-
id: 'status',
22-
getValue: (v) => ({ status: v.status }),
21+
id: 'statuses',
22+
getValue: (v) => ({ statuses: v.statuses }),
2323
formatValue: (v) => v,
2424
component: ({ value, setValue }) =>
25-
createElement(ListFilter<WorkflowStatus>, {
25+
createElement(ListFilterMulti<WorkflowStatus>, {
2626
label: 'Status',
2727
placeholder: 'Show all statuses',
28-
value: value.status,
29-
onChangeValue: (v) => setValue({ status: v }),
28+
values: value.statuses,
29+
onChangeValues: (v) => setValue({ statuses: v }),
3030
labelMap: WORKFLOW_STATUS_NAMES,
3131
}),
3232
},

src/views/domain-workflows/domain-workflows-header/domain-workflows-header.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export default function DomainWorkflowsHeader({ domain, cluster }: Props) {
1919
pageSize: DOMAIN_WORKFLOWS_PAGE_SIZE,
2020
inputType: queryParams.inputType,
2121
search: queryParams.search,
22-
status: queryParams.status,
22+
statuses: queryParams.statuses,
2323
timeRangeStart: queryParams.timeRangeStart,
2424
timeRangeEnd: queryParams.timeRangeEnd,
2525
sortColumn: queryParams.sortColumn,

src/views/domain-workflows/domain-workflows-table/domain-workflows-table.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export default function DomainWorkflowsTable({ domain, cluster }: Props) {
3535
pageSize: DOMAIN_WORKFLOWS_PAGE_SIZE,
3636
inputType: queryParams.inputType,
3737
search: queryParams.search,
38-
status: queryParams.status,
38+
statuses: queryParams.statuses,
3939
timeRangeStart: queryParams.timeRangeStart,
4040
timeRangeEnd: queryParams.timeRangeEnd,
4141
sortColumn: queryParams.sortColumn,
@@ -53,7 +53,7 @@ export default function DomainWorkflowsTable({ domain, cluster }: Props) {
5353
error,
5454
areSearchParamsAbsent:
5555
!queryParams.search &&
56-
!queryParams.status &&
56+
!queryParams.statuses &&
5757
!queryParams.timeRangeStart &&
5858
!queryParams.timeRangeEnd,
5959
});

src/views/shared/hooks/use-list-workflows.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export default function useListWorkflows({
2323
const {
2424
inputType,
2525
search,
26-
status,
26+
statuses,
2727
timeRangeStart,
2828
timeRangeEnd,
2929
sortColumn,
@@ -39,8 +39,7 @@ export default function useListWorkflows({
3939
}
4040
: {
4141
search,
42-
// Temporary change, this will be removed in a follow-up
43-
statuses: status ? [status] : [],
42+
statuses,
4443
sortColumn,
4544
sortOrder,
4645
timeRangeStart: timeRangeStart?.toISOString(),

src/views/shared/hooks/use-list-workflows.types.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export type UseListWorkflowsParams = ListWorkflowsRouteParams & {
1414
inputType: WorkflowsHeaderInputType;
1515
listType: ListType;
1616
search?: string;
17-
status?: WorkflowStatus;
17+
statuses?: Array<WorkflowStatus>;
1818
timeRangeStart?: Date;
1919
timeRangeEnd?: Date;
2020
sortColumn?: string;

src/views/shared/workflows-header/__tests__/workflows-header.test.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ import WorkflowsHeader from '../workflows-header';
1212
const mockFiltersConfig: [
1313
PageFilterConfig<
1414
typeof domainPageQueryParamsConfig,
15-
{ status: WorkflowStatus | undefined }
15+
{ statuses: Array<WorkflowStatus> | undefined }
1616
>,
1717
] = [
1818
{
1919
id: 'filter1',
20-
getValue: (queryParams) => ({ status: queryParams.status }),
20+
getValue: (queryParams) => ({ statuses: queryParams.statuses }),
2121
formatValue: (v) => v,
2222
component: () => <div>filter</div>,
2323
},

0 commit comments

Comments
 (0)