mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-13 19:33:55 +03:00
console: automatically select the $eq operator when filtering table rows, close 9970
GITHUB_PR_NUMBER: 9971 GITHUB_PR_URL: https://github.com/hasura/graphql-engine/pull/9971 PR-URL: https://github.com/hasura/graphql-engine-mono/pull/10455 Co-authored-by: Bert Verhelst <1710840+bertyhell@users.noreply.github.com> Co-authored-by: Vijay Prasanna <11921040+vijayprasanna13@users.noreply.github.com> GitOrigin-RevId: 07dd4e46619609178fba982097526b3866d29776
This commit is contained in:
parent
726842a3f8
commit
0a7e211538
@ -26,6 +26,15 @@ export const FilterRow = ({
|
||||
const localOperator = watch(`${name}.operator`);
|
||||
const localValue = watch(`${name}.value`);
|
||||
|
||||
/**
|
||||
* Set operator to first operator if it is empty
|
||||
*/
|
||||
useEffect(() => {
|
||||
if (!localOperator && operatorOptions[0]?.value) {
|
||||
setValue(`${name}.operator`, operatorOptions[0].value);
|
||||
}
|
||||
}, [localOperator, operatorOptions, setValue, name]);
|
||||
|
||||
/**
|
||||
* Set the default value into the input field depending on the operator type
|
||||
*/
|
||||
|
@ -77,7 +77,7 @@ export const Primary: StoryObj<typeof LegacyRunQuery> = {
|
||||
expect(await canvas.findAllByDisplayValue('Select a column')).toHaveLength(
|
||||
2
|
||||
);
|
||||
expect(await canvas.findByDisplayValue('Select an operator')).toBeVisible();
|
||||
expect(await canvas.findByTestId('filters.0.operator')).toBeVisible();
|
||||
expect(await canvas.findByPlaceholderText('-- value --')).toBeVisible();
|
||||
|
||||
// select the value "id" in the "column" select
|
||||
@ -88,7 +88,7 @@ export const Primary: StoryObj<typeof LegacyRunQuery> = {
|
||||
|
||||
// select the value "_eq" in the "operator" select
|
||||
userEvent.selectOptions(
|
||||
await canvas.findByDisplayValue('Select an operator'),
|
||||
await canvas.findByTestId('filters.0.operator'),
|
||||
'_eq'
|
||||
);
|
||||
|
||||
@ -108,8 +108,9 @@ export const Primary: StoryObj<typeof LegacyRunQuery> = {
|
||||
);
|
||||
|
||||
// select the value "_neq" in the second "operator" select
|
||||
|
||||
userEvent.selectOptions(
|
||||
await canvas.findByDisplayValue('Select an operator'),
|
||||
await canvas.findByTestId('filters.1.operator'),
|
||||
'_neq'
|
||||
);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user