Skip to content

Commit e76ad66

Browse files
committed
Variations. branch name filter added
1 parent 01d8aad commit e76ad66

File tree

2 files changed

+42
-1
lines changed

2 files changed

+42
-1
lines changed

src/components/Filters.tsx

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ interface IProps {
1919
browserState: [string, React.Dispatch<React.SetStateAction<string>>];
2020
viewportState: [string, React.Dispatch<React.SetStateAction<string>>];
2121
testStatusState?: [string, React.Dispatch<React.SetStateAction<string>>];
22+
branchNameState?: [string, React.Dispatch<React.SetStateAction<string>>];
2223
}
2324

2425
const Filters: React.FunctionComponent<IProps> = ({
@@ -29,6 +30,7 @@ const Filters: React.FunctionComponent<IProps> = ({
2930
browserState,
3031
viewportState,
3132
testStatusState,
33+
branchNameState,
3234
}) => {
3335
const [query, setQuery] = queryState;
3436
const [os, setOs] = osState;
@@ -38,6 +40,9 @@ const Filters: React.FunctionComponent<IProps> = ({
3840
const [testStatus, setTestStatus] = testStatusState
3941
? testStatusState
4042
: [null, () => {}];
43+
const [branchName, setBranchName] = branchNameState
44+
? branchNameState
45+
: [null, () => {}];
4146

4247
const osList = items
4348
.map((t) => t.os)
@@ -56,11 +61,18 @@ const Filters: React.FunctionComponent<IProps> = ({
5661
.filter((v, i, array) => v && array.indexOf(v) === i);
5762

5863
const testStatusList =
64+
testStatusState &&
5965
items.some((i) => (i as TestRun).status) &&
6066
(items as TestRun[])
6167
.map((t) => t.status)
6268
.filter((v, i, array) => v && array.indexOf(v) === i);
6369

70+
const branchNameList =
71+
branchNameState &&
72+
items
73+
.map((t) => t.branchName)
74+
.filter((v, i, array) => v && array.indexOf(v) === i);
75+
6476
return (
6577
<React.Fragment>
6678
<Grid container spacing={2} alignItems="flex-end">
@@ -197,6 +209,32 @@ const Filters: React.FunctionComponent<IProps> = ({
197209
</FormControl>
198210
</Grid>
199211
)}
212+
{branchNameList && branchNameList.length > 0 && (
213+
<Grid item xs>
214+
<FormControl fullWidth>
215+
<InputLabel shrink id="filter_branchName">
216+
Branch
217+
</InputLabel>
218+
<Select
219+
id="filter_branchName"
220+
value={branchName}
221+
displayEmpty
222+
onChange={(event) =>
223+
setBranchName(event.target.value as string)
224+
}
225+
>
226+
<MenuItem value="">
227+
<em>All</em>
228+
</MenuItem>
229+
{branchNameList.map((item) => (
230+
<MenuItem key={item} value={item}>
231+
{item}
232+
</MenuItem>
233+
))}
234+
</Select>
235+
</FormControl>
236+
</Grid>
237+
)}
200238
<Grid item>
201239
<Button
202240
variant="contained"

src/pages/TestVariationListPage.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ const TestVariationListPage: React.FunctionComponent = () => {
1919
const [device, setDevice] = React.useState("");
2020
const [browser, setBrowser] = React.useState("");
2121
const [viewport, setViewport] = React.useState("");
22+
const [branchName, setBranchName] = React.useState("");
2223
const [filteredItems, setFilteredItems] = React.useState<TestVariation[]>([]);
2324

2425
React.useEffect(() => {
@@ -34,13 +35,14 @@ const TestVariationListPage: React.FunctionComponent = () => {
3435
testVariations.filter(
3536
(t) =>
3637
t.name.includes(query) && // by query
38+
(branchName ? t.branchName === branchName : true) && // by branchName
3739
(os ? t.os === os : true) && // by OS
3840
(device ? t.device === device : true) && // by device
3941
(viewport ? t.viewport === viewport : true) && // by viewport
4042
(browser ? t.browser === browser : true) // by browser
4143
)
4244
);
43-
}, [query, os, device, browser, viewport, testVariations]);
45+
}, [query, branchName, os, device, browser, viewport, testVariations]);
4446

4547
return (
4648
<React.Fragment>
@@ -60,6 +62,7 @@ const TestVariationListPage: React.FunctionComponent = () => {
6062
deviceState={[device, setDevice]}
6163
browserState={[browser, setBrowser]}
6264
viewportState={[viewport, setViewport]}
65+
branchNameState={[branchName, setBranchName]}
6366
/>
6467
</Box>
6568
</Grid>

0 commit comments

Comments
 (0)