Skip to content

Commit 0f3132c

Browse files
feat: Add filters to History Page V2 (cadence-workflow#1088)
* Add Filters menu to History Page V2, in a popover menu * Add colour codes for various event filtering types Signed-off-by: Adhitya Mamallan <adhitya.mamallan@uber.com>
1 parent dba0b79 commit 0f3132c

13 files changed

+555
-38
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import { type WorkflowHistoryEventFilteringType } from '@/views/workflow-history/workflow-history-filters-type/workflow-history-filters-type.types';
2+
3+
import { type WorkflowHistoryEventFilteringTypeColors } from '../workflow-history-v2.types';
4+
5+
const workflowHistoryEventFilteringTypeColorsConfig = {
6+
ACTIVITY: {
7+
content: '#068BEE',
8+
background: '#EFF4FE',
9+
backgroundHighlighted: '#DEE9FE',
10+
},
11+
DECISION: {
12+
content: '#FFB48C',
13+
background: '#FFF0E9',
14+
backgroundHighlighted: '#FEE2D4',
15+
},
16+
SIGNAL: {
17+
content: '#C490F9',
18+
background: '#F9F1FF',
19+
backgroundHighlighted: '#F2E3FF',
20+
},
21+
TIMER: {
22+
content: '#F877D2',
23+
background: '#FEEFF9',
24+
backgroundHighlighted: '#FEDFF3',
25+
},
26+
CHILDWORKFLOW: {
27+
content: '#77D5E3',
28+
background: '#E2F8FB',
29+
backgroundHighlighted: '#CDEEF3',
30+
},
31+
WORKFLOW: {
32+
content: '#77B71C',
33+
background: '#EEF6E3',
34+
backgroundHighlighted: '#DEEEC6',
35+
},
36+
} as const satisfies Record<
37+
WorkflowHistoryEventFilteringType,
38+
WorkflowHistoryEventFilteringTypeColors
39+
>;
40+
41+
export default workflowHistoryEventFilteringTypeColorsConfig;
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { createElement } from 'react';
2+
3+
import { Spinner } from 'baseui/icon';
4+
import { MdCancel, MdCheckCircle, MdReport } from 'react-icons/md';
5+
6+
import { type TagFilterOptionConfig } from '@/components/tag-filter/tag-filter.types';
7+
import { type HistoryEventFilterStatus } from '@/views/workflow-history/workflow-history-filters-status/workflow-history-filters-status.types';
8+
9+
const workflowHistoryFiltersStatusOptionsConfig = {
10+
PENDING: {
11+
label: 'Pending',
12+
startEnhancer: ({ theme }) =>
13+
createElement(Spinner, { color: theme.colors.contentAccent }),
14+
},
15+
CANCELED: {
16+
label: 'Canceled',
17+
startEnhancer: ({ theme }) =>
18+
createElement(MdCancel, { color: theme.colors.backgroundWarning }),
19+
},
20+
FAILED: {
21+
label: 'Failed',
22+
startEnhancer: ({ theme }) =>
23+
createElement(MdReport, { color: theme.colors.contentNegative }),
24+
},
25+
COMPLETED: {
26+
label: 'Completed',
27+
startEnhancer: ({ theme }) =>
28+
createElement(MdCheckCircle, { color: theme.colors.contentPositive }),
29+
},
30+
} as const satisfies Record<HistoryEventFilterStatus, TagFilterOptionConfig>;
31+
32+
export default workflowHistoryFiltersStatusOptionsConfig;
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
import { createElement } from 'react';
2+
3+
import { MdCircle } from 'react-icons/md';
4+
5+
import { type TagFilterOptionConfig } from '@/components/tag-filter/tag-filter.types';
6+
import { type WorkflowHistoryEventFilteringType } from '@/views/workflow-history/workflow-history-filters-type/workflow-history-filters-type.types';
7+
8+
import workflowHistoryEventFilteringTypeColorsConfig from './workflow-history-event-filtering-type-colors.config';
9+
10+
const workflowHistoryFiltersTypeOptionsConfig = {
11+
ACTIVITY: {
12+
label: 'Activity',
13+
startEnhancer: () =>
14+
createElement(MdCircle, {
15+
color: workflowHistoryEventFilteringTypeColorsConfig.ACTIVITY.content,
16+
}),
17+
},
18+
DECISION: {
19+
label: 'Decision',
20+
startEnhancer: () =>
21+
createElement(MdCircle, {
22+
color: workflowHistoryEventFilteringTypeColorsConfig.DECISION.content,
23+
}),
24+
},
25+
SIGNAL: {
26+
label: 'Signal',
27+
startEnhancer: () =>
28+
createElement(MdCircle, {
29+
color: workflowHistoryEventFilteringTypeColorsConfig.SIGNAL.content,
30+
}),
31+
},
32+
TIMER: {
33+
label: 'Timer',
34+
startEnhancer: () =>
35+
createElement(MdCircle, {
36+
color: workflowHistoryEventFilteringTypeColorsConfig.TIMER.content,
37+
}),
38+
},
39+
CHILDWORKFLOW: {
40+
label: 'Child Workflow',
41+
startEnhancer: () =>
42+
createElement(MdCircle, {
43+
color:
44+
workflowHistoryEventFilteringTypeColorsConfig.CHILDWORKFLOW.content,
45+
}),
46+
},
47+
WORKFLOW: {
48+
label: 'Other',
49+
startEnhancer: () =>
50+
createElement(MdCircle, {
51+
color: workflowHistoryEventFilteringTypeColorsConfig.WORKFLOW.content,
52+
}),
53+
},
54+
} as const satisfies Record<
55+
WorkflowHistoryEventFilteringType,
56+
TagFilterOptionConfig
57+
>;
58+
59+
export default workflowHistoryFiltersTypeOptionsConfig;
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import { createElement } from 'react';
2+
3+
import TagFilter from '@/components/tag-filter/tag-filter';
4+
import filterGroupsByGroupStatus from '@/views/workflow-history/workflow-history-filters-status/helpers/filter-groups-by-group-status';
5+
import {
6+
type HistoryEventFilterStatus,
7+
type WorkflowHistoryFiltersStatusValue,
8+
} from '@/views/workflow-history/workflow-history-filters-status/workflow-history-filters-status.types';
9+
import filterGroupsByGroupType from '@/views/workflow-history/workflow-history-filters-type/helpers/filter-groups-by-group-type';
10+
import {
11+
type WorkflowHistoryEventFilteringType,
12+
type WorkflowHistoryFiltersTypeValue,
13+
} from '@/views/workflow-history/workflow-history-filters-type/workflow-history-filters-type.types';
14+
import { type WorkflowHistoryFilterConfig } from '@/views/workflow-history/workflow-history.types';
15+
16+
import workflowHistoryFiltersStatusOptionsConfig from './workflow-history-filters-status-options.config';
17+
import workflowHistoryFiltersTypeOptionsConfig from './workflow-history-filters-type-options.config';
18+
19+
const workflowHistoryFiltersConfig: [
20+
WorkflowHistoryFilterConfig<WorkflowHistoryFiltersTypeValue>,
21+
WorkflowHistoryFilterConfig<WorkflowHistoryFiltersStatusValue>,
22+
] = [
23+
{
24+
id: 'historyEventTypes',
25+
getValue: (v) => ({ historyEventTypes: v.historyEventTypes }),
26+
formatValue: (v) => v,
27+
component: ({ value, setValue }) =>
28+
createElement(TagFilter<WorkflowHistoryEventFilteringType>, {
29+
label: 'Type',
30+
values: value.historyEventTypes ?? [],
31+
onChangeValues: (newValues) =>
32+
setValue({
33+
historyEventTypes: newValues.length > 0 ? newValues : undefined,
34+
}),
35+
optionsConfig: workflowHistoryFiltersTypeOptionsConfig,
36+
}),
37+
filterFunc: filterGroupsByGroupType,
38+
},
39+
{
40+
id: 'historyEventStatuses',
41+
getValue: (v) => ({ historyEventStatuses: v.historyEventStatuses }),
42+
formatValue: (v) => v,
43+
component: ({ value, setValue }) =>
44+
createElement(TagFilter<HistoryEventFilterStatus>, {
45+
label: 'Status',
46+
values: value.historyEventStatuses ?? [],
47+
onChangeValues: (newValues) =>
48+
setValue({
49+
historyEventStatuses: newValues.length > 0 ? newValues : undefined,
50+
}),
51+
optionsConfig: workflowHistoryFiltersStatusOptionsConfig,
52+
}),
53+
filterFunc: filterGroupsByGroupStatus,
54+
},
55+
] as const;
56+
57+
export default workflowHistoryFiltersConfig;

0 commit comments

Comments
 (0)