-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into snyk-upgrade-c1ec17a80d627d684bf532dadc6e4fd3
- Loading branch information
Showing
31 changed files
with
1,761 additions
and
217 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"extends": [ | ||
"github>konflux-ci/mintmaker//config/renovate/renovate.json" | ||
], | ||
"schedule": [ | ||
"on Monday after 3am and before 10am" | ||
], | ||
"ignorePaths": [ | ||
".pre-commit-config.yaml" | ||
] | ||
} |
59 changes: 0 additions & 59 deletions
59
src/Components/PresentationalComponents/Filters/CustomFilters/RadioCustomFilter.js
This file was deleted.
Oops, something went wrong.
42 changes: 0 additions & 42 deletions
42
src/Components/PresentationalComponents/Filters/CustomFilters/RadioCustomFilter.test.js
This file was deleted.
Oops, something went wrong.
74 changes: 74 additions & 0 deletions
74
src/Components/PresentationalComponents/Filters/CustomFilters/SelectCustomFilter.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import React, { useState } from 'react'; | ||
import propTypes from 'prop-types'; | ||
import { | ||
MenuToggle, | ||
Select, | ||
SelectList, | ||
SelectOption | ||
} from '@patternfly/react-core'; | ||
|
||
const SelectCustomFilter = ({ filterData, setFilterData, selectProps, options, filterId, filterName }) => { | ||
const [isOpen, setOpen] = useState(false); | ||
|
||
const handleOnRadioChange = (filterId, optionName) => { | ||
const optionValue = options.find(item => item.label === optionName).value; | ||
setFilterData({ ...filterData, [filterId]: optionValue }); | ||
setOpen(false); | ||
}; | ||
|
||
const selectedValue = options.find(item => item.value === filterData[filterId])?.label; | ||
|
||
const toggle = toggleRef => | ||
<MenuToggle | ||
ref={toggleRef} | ||
onClick={() => setOpen(!isOpen)} | ||
isExpanded={isOpen} | ||
style={{ | ||
width: 'auto' | ||
}}> | ||
{ | ||
filterName | ||
? `${filterName}: ${selectedValue}` | ||
: `${selectedValue}` | ||
} | ||
</MenuToggle>; | ||
|
||
return ( | ||
<div className="pf-v5-c-select pf-v5-u-mr-sm pf-v5-u-mb-sm" style={{ width: 'auto' }}> | ||
<Select | ||
aria-label="Select Input" | ||
isOpen={isOpen} | ||
key={filterId} | ||
onSelect={(event, optionName) => handleOnRadioChange(filterId, optionName)} | ||
onOpenChange={(isOpen) => setOpen(isOpen)} | ||
selected={selectedValue} | ||
toggle={toggle} | ||
shouldFocusToggleOnSelect | ||
{... selectProps} | ||
> | ||
<SelectList> | ||
{options.map(item => | ||
<SelectOption | ||
width="100%" | ||
key={filterId + item.label} | ||
value={item.label} | ||
> | ||
{item.label} | ||
</SelectOption> | ||
)} | ||
</SelectList> | ||
</Select> | ||
</div> | ||
); | ||
}; | ||
|
||
SelectCustomFilter.propTypes = { | ||
filterName: propTypes.string, | ||
filterId: propTypes.string, | ||
filterData: propTypes.object, | ||
setFilterData: propTypes.func, | ||
selectProps: propTypes.object, | ||
options: propTypes.array | ||
}; | ||
|
||
export default SelectCustomFilter; |
68 changes: 68 additions & 0 deletions
68
src/Components/PresentationalComponents/Filters/CustomFilters/SelectCustomFilter.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import userEvent from '@testing-library/user-event'; | ||
import SelectCustomFilter from './SelectCustomFilter'; | ||
import { fireEvent, render, screen, waitFor, within } from '@testing-library/react'; | ||
|
||
const selectProps = null | ||
const options = [ | ||
{ value: "op1", label: "option 1" }, | ||
{ value: "op2", label: "option 2" }, | ||
{ value: "op3", label: "option 3" } | ||
] | ||
const filterName = "My filter" | ||
const filterId = "my_filter" | ||
|
||
describe('SelectCustomFilter component', () => { | ||
it('Should have selected first item by default.', async () => { | ||
let filterData = { my_filter: "op1" } | ||
const setFilterData = newData => filterData = newData | ||
|
||
render( | ||
<SelectCustomFilter filterData={filterData} setFilterData={setFilterData} selectProps={selectProps} options={options} filterName={filterName} filterId={filterId} /> | ||
); | ||
|
||
await waitFor(() => userEvent.click(screen.getByRole('button', { | ||
name: /my filter: option 1/i | ||
}))); | ||
|
||
const option1 = screen.getByRole('option', { | ||
name: /option 1/i | ||
}); | ||
const option2 = screen.getByRole('option', { | ||
name: /option 2/i | ||
}); | ||
const option3 = screen.getByRole('option', { | ||
name: /option 3/i | ||
}); | ||
|
||
expect(within(option1).getByRole('img', { | ||
hidden: true | ||
})).toBeTruthy(); | ||
expect(within(option2).queryByRole('img', { | ||
hidden: true | ||
})).toBeFalsy(); | ||
expect(within(option3).queryByRole('img', { | ||
hidden: true | ||
})).toBeFalsy(); | ||
}); | ||
|
||
it('Should update filter data on radio change.', async () => { | ||
let filterData = { my_filter: "op1" } | ||
const setFilterData = newData => filterData = newData | ||
|
||
render( | ||
<SelectCustomFilter filterData={filterData} setFilterData={setFilterData} selectProps={selectProps} options={options} filterName={filterName} filterId={filterId} /> | ||
); | ||
|
||
await waitFor(() => userEvent.click(screen.getByRole('button', { | ||
name: /my filter: option 1/i | ||
}))); | ||
|
||
const option2 = screen.getByRole('option', { | ||
name: /option 2/i | ||
}); | ||
|
||
await waitFor(() => userEvent.click(option2)); | ||
|
||
expect(filterData).toStrictEqual({ my_filter: "op2" }) | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.