mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-14 17:02:49 +03:00
console: Support X-Hasura-User-Id for number inputs DSF-162
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8261 Co-authored-by: Julian <843342+okjulian@users.noreply.github.com> GitOrigin-RevId: 118bdb9261f92f6829ea19633de660388ff7db82
This commit is contained in:
parent
cd18fd0762
commit
472fc45239
@ -345,6 +345,49 @@ BooleanArrayTypeRoot.play = async ({ canvasElement }) => {
|
||||
).toBeInTheDocument();
|
||||
};
|
||||
|
||||
export const NumericValue: ComponentStory<
|
||||
typeof RowPermissionsInput
|
||||
> = args => (
|
||||
<RowPermissionsInput
|
||||
onPermissionsChange={action('onPermissionsChange')}
|
||||
table={['Album']}
|
||||
tables={tables}
|
||||
comparators={comparators}
|
||||
permissions={{ id: { _eq: '' } }}
|
||||
/>
|
||||
);
|
||||
|
||||
NumericValue.play = async ({ canvasElement }) => {
|
||||
const canvas = within(canvasElement);
|
||||
expect(
|
||||
canvas.getByTestId('id._eq-value-input-x-hasura-user-id')
|
||||
).toBeInTheDocument();
|
||||
};
|
||||
|
||||
export const NumericIntValue: ComponentStory<
|
||||
typeof RowPermissionsInput
|
||||
> = args => (
|
||||
<RowPermissionsInput
|
||||
onPermissionsChange={action('onPermissionsChange')}
|
||||
table={['Album']}
|
||||
tables={tables}
|
||||
comparators={comparators}
|
||||
permissions={{ id: { _eq: 0 } }}
|
||||
/>
|
||||
);
|
||||
|
||||
export const NumericFloatValue: ComponentStory<
|
||||
typeof RowPermissionsInput
|
||||
> = args => (
|
||||
<RowPermissionsInput
|
||||
onPermissionsChange={action('onPermissionsChange')}
|
||||
table={['Album']}
|
||||
tables={tables}
|
||||
comparators={comparators}
|
||||
permissions={{ id: { _eq: 0.9 } }}
|
||||
/>
|
||||
);
|
||||
|
||||
SetRootLevelPermission.play = async ({ canvasElement }) => {
|
||||
const canvas = within(canvasElement);
|
||||
await userEvent.click(canvas.getByTestId('-operator'));
|
||||
|
@ -70,10 +70,12 @@ export const ValueInput = ({ value, path }: { value: any; path: string[] }) => {
|
||||
value={value}
|
||||
comparatorType={comparator?.type}
|
||||
/>
|
||||
{inputType === 'text' && isComparator(comparatorName) && (
|
||||
{(inputType === 'text' || inputType === 'number') &&
|
||||
isComparator(comparatorName) && (
|
||||
<Button
|
||||
disabled={comparatorName === '_where' && isEmpty(table)}
|
||||
onClick={() => setValue(path, 'X-Hasura-User-Id')}
|
||||
data-testid={`${componentLevelId}-x-hasura-user-id`}
|
||||
mode="default"
|
||||
>
|
||||
[x-hasura-user-id]
|
||||
|
@ -23,9 +23,6 @@ export const ValueInputType = ({
|
||||
const { setValue } = useContext(rowPermissionsContext);
|
||||
const { table } = useContext(tableContext);
|
||||
|
||||
const inputType =
|
||||
jsType === 'boolean' ? 'checkbox' : jsType === 'string' ? 'text' : 'number';
|
||||
|
||||
switch (jsType) {
|
||||
case 'boolean':
|
||||
return (
|
||||
@ -55,7 +52,7 @@ export const ValueInputType = ({
|
||||
data-testid={componentLevelId}
|
||||
disabled={comparatorName === '_where' && isEmpty(table)}
|
||||
className="border border-gray-200 rounded-md p-2 !mr-4"
|
||||
type={inputType}
|
||||
type="text"
|
||||
value={value}
|
||||
onChange={e => {
|
||||
setValue(path, graphQLTypeToJsType(e.target.value, comparatorType));
|
||||
|
@ -120,9 +120,7 @@ export function graphQLTypeToJsType(
|
||||
if (!isScalarType(type)) {
|
||||
return value;
|
||||
}
|
||||
if (type.name === 'Int' || type.name === 'ID' || type.name === 'Float') {
|
||||
return Number(value);
|
||||
} else if (type.name === 'Boolean') {
|
||||
if (type.name === 'Boolean') {
|
||||
return Boolean(value);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user