Skip to content

Commit 04abb2c

Browse files
added filter on all run screens.
1 parent fe61059 commit 04abb2c

File tree

16 files changed

+274
-33
lines changed

16 files changed

+274
-33
lines changed

src/ui/components/Filters/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,12 +210,12 @@ export const getInitialFilterStateForRuns = () => {
210210
type: 'string',
211211
},
212212
{
213-
value: 'name',
213+
value: 'pipelineName',
214214
label: 'Pipeline Name',
215215
type: 'string',
216216
},
217217
{
218-
value: 'name',
218+
value: 'stackName',
219219
label: 'Stack Name',
220220
type: 'string',
221221
},

src/ui/layouts/pipelines/PipelineDetail/Runs/index.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,18 @@ import { translate } from '../translate';
33
import { RunsTable } from '../../RunsTable';
44
import { useService } from './useService';
55

6-
export const Runs: React.FC<{ pipelineId: TId }> = ({ pipelineId }) => {
6+
export const Runs: React.FC<{ pipelineId: TId; filter: any }> = ({
7+
pipelineId,
8+
filter,
9+
}) => {
710
const { fetching, runIds } = useService({ pipelineId });
811

912
return (
1013
<RunsTable
1114
fetching={fetching}
1215
emptyStateText={translate('emptyState.text')}
1316
runIds={runIds}
17+
filter={filter}
1418
/>
1519
);
1620
};

src/ui/layouts/pipelines/PipelineDetail/index.tsx

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from 'react';
1+
import React, { useState } from 'react';
22

33
import { Box, Paragraph, icons } from '../../../components';
44
import { iconColors, iconSizes } from '../../../../constants';
@@ -9,7 +9,43 @@ import { Configuration } from './Configuration';
99
import { Runs } from './Runs';
1010
import { BasePage } from '../BasePage';
1111
import { useService } from './useService';
12+
import FilterComponent, {
13+
getInitialFilterStateForRuns,
14+
} from '../../../components/Filters';
15+
import { useLocationPath } from '../../../hooks';
1216

17+
interface Props {
18+
pipelineId: TId;
19+
}
20+
const FilterWrapperForRun = () => {
21+
const locationPath = useLocationPath();
22+
// debugger;
23+
24+
// TODO: Dev please note: getInitialFilterState is for stack inital filter value for any other component you need to modify it
25+
const [filters, setFilter] = useState([getInitialFilterStateForRuns()]);
26+
function getFilter(values: any) {
27+
const filterValuesMap = values.map((v: any) => {
28+
return {
29+
column: v.column.selectedValue,
30+
type: v.contains.selectedValue,
31+
value: v.filterValue,
32+
};
33+
});
34+
return filterValuesMap;
35+
}
36+
return (
37+
<FilterComponent
38+
getInitials={getInitialFilterStateForRuns}
39+
filters={filters}
40+
setFilter={setFilter}
41+
>
42+
<Runs
43+
filter={getFilter(filters)}
44+
pipelineId={locationPath.split('/')[2]}
45+
/>
46+
</FilterComponent>
47+
);
48+
};
1349
const getTabPages = (pipelineId: TId): TabPage[] => {
1450
return [
1551
{
@@ -19,7 +55,8 @@ const getTabPages = (pipelineId: TId): TabPage[] => {
1955
},
2056
{
2157
text: translate('tabs.runs.text'),
22-
Component: () => <Runs pipelineId={pipelineId} />,
58+
Component: FilterWrapperForRun,
59+
2360
path: routePaths.pipeline.runs(pipelineId),
2461
},
2562
];
@@ -121,7 +158,6 @@ export const PipelineDetail: React.FC = () => {
121158
</Paragraph>
122159
</Box>
123160
</Box>
124-
125161
</BasePage>
126162
);
127163
};

src/ui/layouts/pipelines/Pipelines/AllRuns/index.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@ import { getTranslateByScope } from '../../../../../services';
88

99
export const translate = getTranslateByScope('ui.layouts.AllRuns');
1010

11-
export const AllRuns: React.FC = () => {
11+
interface Props {
12+
filter: any;
13+
}
14+
15+
export const AllRuns: React.FC<Props> = ({ filter }: Props) => {
1216
const { fetching, runIds } = useService();
1317

1418
return (
@@ -17,6 +21,7 @@ export const AllRuns: React.FC = () => {
1721
emptyStateText={translate('emptyState.text')}
1822
runIds={runIds}
1923
fromAllruns={true}
24+
filter={filter}
2025
/>
2126
);
2227
};

src/ui/layouts/pipelines/Pipelines/index.tsx

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { useService } from './useService';
99
import { useLocationPath } from '../../../hooks';
1010
import FilterComponent, {
1111
getInitialFilterStateForPipeline,
12+
getInitialFilterStateForRuns,
1213
} from '../../../components/Filters';
1314

1415
const FilterWrapper = () => {
@@ -34,6 +35,29 @@ const FilterWrapper = () => {
3435
</FilterComponent>
3536
);
3637
};
38+
const FilterWrapperForRun = () => {
39+
// TODO: Dev please note: getInitialFilterState is for stack inital filter value for any other component you need to modify it
40+
const [filters, setFilter] = useState([getInitialFilterStateForRuns()]);
41+
function getFilter(values: any) {
42+
const filterValuesMap = values.map((v: any) => {
43+
return {
44+
column: v.column.selectedValue,
45+
type: v.contains.selectedValue,
46+
value: v.filterValue,
47+
};
48+
});
49+
return filterValuesMap;
50+
}
51+
return (
52+
<FilterComponent
53+
getInitials={getInitialFilterStateForRuns}
54+
filters={filters}
55+
setFilter={setFilter}
56+
>
57+
<AllRuns filter={getFilter(filters)} />
58+
</FilterComponent>
59+
);
60+
};
3761
const PAGES = [
3862
{
3963
text: translate('tabs.pipelines.text'),
@@ -42,7 +66,7 @@ const PAGES = [
4266
},
4367
{
4468
text: translate('tabs.allRuns.text'),
45-
Component: AllRuns,
69+
Component: FilterWrapperForRun,
4670
path: routePaths.pipelines.allRuns,
4771
},
4872
];

src/ui/layouts/pipelines/RunsTable/index.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,25 @@ import { Table } from '../../common/Table';
77
import { useHeaderCols } from './HeaderCols';
88
import { useService } from './useService';
99

10+
interface Props {
11+
filter: any;
12+
}
1013
export const RunsTable: React.FC<{
1114
runIds: TId[];
1215
pagination?: boolean;
1316
emptyStateText: string;
1417
fetching: boolean;
1518
pipelineRuns?: any;
1619
fromAllruns?: boolean;
20+
filter?: any;
1721
}> = ({
1822
runIds,
1923
pagination = true,
2024
emptyStateText,
2125
fetching,
2226
pipelineRuns,
2327
fromAllruns,
28+
filter,
2429
}) => {
2530
const history = useHistory();
2631

@@ -32,7 +37,7 @@ export const RunsTable: React.FC<{
3237
activeSortingDirection,
3338
setActiveSortingDirection,
3439
setSelectedRunIds,
35-
} = useService({ pipelineRuns, runIds });
40+
} = useService({ pipelineRuns, runIds, filter });
3641

3742
const openDetailPage = (run: TRun) => {
3843
setSelectedRunIds([]);

src/ui/layouts/pipelines/RunsTable/useService.ts

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { Sorting, SortingDirection } from './types';
77
import { pipelinePagesActions } from '../../../../redux/actions';
88
import { useDispatch, useSelector } from '../../../hooks';
99
import { runSelectors } from '../../../../redux/selectors';
10+
import { getFilteredDataForTable } from '../../../../utils/tableFilters';
1011

1112
interface ServiceInterface {
1213
sortedRuns: TRun[];
@@ -17,13 +18,24 @@ interface ServiceInterface {
1718
setActiveSortingDirection: (arg: SortingDirection | null) => void;
1819
setSelectedRunIds: (ids: TId[]) => void;
1920
}
21+
interface filterValue {
22+
label: string;
23+
type: string;
24+
value: string;
25+
}
2026

2127
export const useService = ({
2228
pipelineRuns,
2329
runIds,
30+
filter,
2431
}: {
2532
pipelineRuns: any;
2633
runIds: TId[];
34+
filter: {
35+
column: filterValue;
36+
type: filterValue;
37+
value: string;
38+
}[];
2739
}): ServiceInterface => {
2840
const dispatch = useDispatch();
2941
const [activeSorting, setActiveSorting] = React.useState<Sorting | null>(
@@ -40,12 +52,17 @@ export const useService = ({
4052
: useSelector(runSelectors.forRunIds(runIds));
4153

4254
useEffect(() => {
43-
const orderedRuns = _.sortBy(runs, (run: TRun) =>
55+
let orderedRuns = _.sortBy(runs, (run: TRun) =>
4456
new Date(run.kubeflowStartTime).getTime(),
4557
).reverse();
4658

59+
const isValidFilter = filter.map((f) => f.value).join('');
60+
if (isValidFilter) {
61+
orderedRuns = getFilteredDataForTable(orderedRuns, filter);
62+
}
63+
4764
setSortedRuns(orderedRuns);
48-
}, []);
65+
}, [filter]);
4966

5067
const setSelectedRunIds = (runIds: TId[]) => {
5168
dispatch(pipelinePagesActions.setSelectedRunIds({ runIds }));

src/ui/layouts/stackComponents/RunsTable/index.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ export const RunsTable: React.FC<{
1212
pagination?: boolean;
1313
emptyStateText: string;
1414
fetching: boolean;
15-
}> = ({ runIds, pagination = true, emptyStateText, fetching }) => {
15+
filter?: any;
16+
}> = ({ runIds, pagination = true, emptyStateText, fetching, filter }) => {
1617
const history = useHistory();
1718

1819
const {
@@ -23,7 +24,7 @@ export const RunsTable: React.FC<{
2324
activeSortingDirection,
2425
setActiveSortingDirection,
2526
setSelectedRunIds,
26-
} = useService({ runIds });
27+
} = useService({ runIds, filter });
2728

2829
const openDetailPage = (run: TRun) => {
2930
// debugger;

src/ui/layouts/stackComponents/RunsTable/useService.ts

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { Sorting, SortingDirection } from './types';
77
import { stackPagesActions } from '../../../../redux/actions';
88
import { useDispatch, useSelector } from '../../../hooks';
99
import { runSelectors } from '../../../../redux/selectors';
10+
import { getFilteredDataForTable } from '../../../../utils/tableFilters';
1011

1112
interface ServiceInterface {
1213
sortedRuns: TRun[];
@@ -17,8 +18,23 @@ interface ServiceInterface {
1718
setActiveSortingDirection: (arg: SortingDirection | null) => void;
1819
setSelectedRunIds: (ids: TId[]) => void;
1920
}
21+
interface filterValue {
22+
label: string;
23+
type: string;
24+
value: string;
25+
}
2026

21-
export const useService = ({ runIds }: { runIds: TId[] }): ServiceInterface => {
27+
export const useService = ({
28+
runIds,
29+
filter,
30+
}: {
31+
runIds: TId[];
32+
filter: {
33+
column: filterValue;
34+
type: filterValue;
35+
value: string;
36+
}[];
37+
}): ServiceInterface => {
2238
const dispatch = useDispatch();
2339
const [activeSorting, setActiveSorting] = React.useState<Sorting | null>(
2440
'createdAt',
@@ -32,12 +48,16 @@ export const useService = ({ runIds }: { runIds: TId[] }): ServiceInterface => {
3248
const runs = useSelector(runSelectors.forRunIds(runIds));
3349

3450
useEffect(() => {
35-
const orderedRuns = _.sortBy(runs, (run: TRun) =>
51+
let orderedRuns = _.sortBy(runs, (run: TRun) =>
3652
new Date(run.kubeflowStartTime).getTime(),
3753
).reverse();
3854

55+
const isValidFilter = filter.map((f) => f.value).join('');
56+
if (isValidFilter) {
57+
orderedRuns = getFilteredDataForTable(orderedRuns, filter);
58+
}
3959
setSortedRuns(orderedRuns);
40-
}, []);
60+
}, [filter]);
4161

4262
const setSelectedRunIds = (runIds: TId[]) => {
4363
dispatch(stackPagesActions.setSelectedRunIds({ runIds }));

src/ui/layouts/stackComponents/StackDetail/Runs/index.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ import { translate } from '../translate';
33
import { RunsTable } from '../../RunsTable';
44
import { useService } from './useService';
55

6-
export const Runs: React.FC<{ stackComponentId: TId }> = ({
6+
export const Runs: React.FC<{ stackComponentId: TId; filter?: any }> = ({
77
stackComponentId,
8+
filter,
89
}) => {
910
const { fetching, runIds } = useService({ stackComponentId });
1011
// debugger;
@@ -14,6 +15,7 @@ export const Runs: React.FC<{ stackComponentId: TId }> = ({
1415
fetching={fetching}
1516
emptyStateText={translate('emptyState.text')}
1617
runIds={runIds}
18+
filter={filter}
1719
/>
1820
);
1921
};

0 commit comments

Comments
 (0)