Skip to content

Commit cac6659

Browse files
authored
concord-console2: log segments status filter (#980)
1 parent 65e444a commit cac6659

File tree

2 files changed

+65
-3
lines changed
  • console2/src/components

2 files changed

+65
-3
lines changed

console2/src/components/molecules/ProcessToolbar/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ interface ExternalProps {
3030
const ProcessToolbar = ({ children }: ExternalProps) => {
3131
return (
3232
<Menu borderless={true} secondary={true} className={'processToolbar'}>
33-
<Menu.Item position={'right'}>{children}</Menu.Item>
33+
<Menu.Item style={{width: '100%'}}>{children}</Menu.Item>
3434
</Menu>
3535
);
3636
};

console2/src/components/organisms/ProcessLogActivityV2/index.tsx

Lines changed: 64 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,19 @@ import { ConcordId } from '../../../api/common';
2525
import { isFinal, ProcessStatus } from '../../../api/process';
2626

2727
import './styles.css';
28-
import { listLogSegments as apiListLogSegments, LogSegmentEntry } from '../../../api/process/log';
28+
import {listLogSegments as apiListLogSegments, LogSegmentEntry, SegmentStatus} from '../../../api/process/log';
2929
import { usePolling } from '../../../api/usePolling';
3030
import { RequestErrorActivity } from '../../organisms';
3131
import LogSegmentActivity from './LogSegmentActivity';
3232
import { FormWizardAction, ProcessToolbar } from '../../molecules';
33-
import { Button, Divider, Popup, Radio } from 'semantic-ui-react';
33+
import {
34+
Button,
35+
Divider,
36+
Dropdown,
37+
DropdownProps,
38+
Popup,
39+
Radio,
40+
} from 'semantic-ui-react';
3441
import { LogProcessorOptions } from '../../../state/data/processes/logs/processors';
3542
import { Route } from 'react-router';
3643
import { FormListEntry, list as apiListForms } from '../../../api/process/form';
@@ -47,6 +54,38 @@ const DEFAULT_OPTS: LogOptions = {
4754
segmentOptions: DEFAULT_SEGMENT_OPTS
4855
};
4956

57+
const LOG_SEGMENT_STATUS_OPTS = [
58+
{
59+
key: 'ALL',
60+
text: 'All logs',
61+
value: 'ALL',
62+
},
63+
{
64+
key: SegmentStatus.OK,
65+
text: SegmentStatus.OK,
66+
value: SegmentStatus.OK,
67+
icon: {name: 'circle', color: 'green'},
68+
},
69+
{
70+
key: SegmentStatus.FAILED,
71+
text: SegmentStatus.FAILED,
72+
value: SegmentStatus.FAILED,
73+
icon: {name: 'close', color: 'red'},
74+
},
75+
{
76+
key: SegmentStatus.RUNNING,
77+
text: SegmentStatus.RUNNING,
78+
value: SegmentStatus.RUNNING,
79+
icon: {name: 'spinner', color: 'teal'},
80+
},
81+
{
82+
key: SegmentStatus.SUSPENDED,
83+
text: SegmentStatus.SUSPENDED,
84+
value: SegmentStatus.SUSPENDED,
85+
icon: {name: 'hourglass half', color: 'blue'},
86+
},
87+
]
88+
5089
interface LogOptions {
5190
expandAllSegments: boolean;
5291
showSystemSegment: boolean;
@@ -72,6 +111,12 @@ const ProcessLogActivityV2 = ({
72111
const [logOpts, setLogOptions] = useState<LogOptions>(getStoredOpts());
73112
const [forms, setForms] = useState<FormListEntry[]>([]);
74113

114+
const [logSegmentStatusFilter, setLogSegmentStatusFilter] = useState<string>(LOG_SEGMENT_STATUS_OPTS[0].value);
115+
116+
const handleLogSegmentStatusFilterChange = useCallback((e: React.SyntheticEvent<HTMLElement>, data: DropdownProps) => {
117+
setLogSegmentStatusFilter(data.value as string);
118+
}, []);
119+
75120
const segmentOptsHandler = useCallback((o: LogProcessorOptions) => {
76121
setLogOptions((prev) => {
77122
return { ...prev, segmentOptions: o };
@@ -119,6 +164,20 @@ const ProcessLogActivityV2 = ({
119164
return (
120165
<>
121166
<ProcessToolbar>
167+
<Dropdown
168+
icon='filter'
169+
labeled={true}
170+
button={true}
171+
basic={true}
172+
className='icon'
173+
style={{marginRight: 20, width: 160 }}
174+
options={LOG_SEGMENT_STATUS_OPTS}
175+
onChange={handleLogSegmentStatusFilterChange}
176+
value={logSegmentStatusFilter}
177+
/>
178+
179+
<div style={{flexGrow: 1}}/>
180+
122181
{forms.length > 0 && processStatus === ProcessStatus.SUSPENDED && (
123182
<div style={{ marginRight: 20 }}>
124183
<Route
@@ -213,6 +272,9 @@ const ProcessLogActivityV2 = ({
213272
(value) =>
214273
logOpts.showSystemSegment || (!logOpts.showSystemSegment && value.id !== 0)
215274
)
275+
.filter(
276+
(value) => logSegmentStatusFilter === 'ALL' || value.status === undefined || logSegmentStatusFilter === value.status
277+
)
216278
.map((s) => {
217279
return (
218280
<LogSegmentActivity

0 commit comments

Comments
 (0)