Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ const AttributesContextualBar = ({ attributeData, onClose }: AttributesContextua
dispatchToastMessage({ type: 'error', message: error });
},
onSettled: () => {
queryClient.invalidateQueries({ queryKey: ABACQueryKeys.roomAttributes.list() });
console.log('onSettled');
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated
queryClient.invalidateQueries({ queryKey: ABACQueryKeys.roomAttributes.list({}) });
},
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,72 +81,86 @@ const AttributesForm = ({ onSave, onCancel, description }: AttributesFormProps)

return (
<>
<ContextualbarScrollableContent>
<Box is='form' onSubmit={handleSubmit(onSave)} id={formId}>
<Box>{description}</Box>
<Field mb={16}>
<FieldLabel htmlFor={nameField} required>
{t('Name')}
</FieldLabel>
<FieldRow>
<TextInput
error={errors.name?.message}
id={nameField}
{...register('name', { required: t('Required_field', { field: t('Name') }) })}
/>
</FieldRow>
{errors.name && <FieldError>{errors.name.message}</FieldError>}
</Field>
<Field mb={16}>
<FieldLabel required id={valuesField}>
{t('Values')}
</FieldLabel>
{lockedAttributesFields.map((field, index) => (
<Fragment key={field.id}>
<FieldRow key={field.id}>
<TextInput
disabled
aria-labelledby={valuesField}
error={errors.lockedAttributes?.[index]?.value?.message || ''}
{...register(`lockedAttributes.${index}.value`, {
required: t('Required_field', { field: t('Values') }),
validate: (value: string) => validateRepeatedValues(value),
})}
/>
{index !== 0 && (
<IconButton title={t('ABAC_Remove_attribute')} icon='trash' onClick={() => removeLockedAttribute(index)} />
)}
</FieldRow>
{errors.lockedAttributes?.[index]?.value && <FieldError>{errors.lockedAttributes?.[index]?.value?.message}</FieldError>}
</Fragment>
))}
{fields.map((field, index) => (
<Fragment key={field.id}>
<FieldRow>
<TextInput
aria-labelledby={valuesField}
error={errors.attributeValues?.[index]?.value?.message || ''}
{...register(`attributeValues.${index}.value`, {
required: t('Required_field', { field: t('Values') }),
validate: (value: string) => validateRepeatedValues(value),
})}
/>
{(index !== 0 || lockedAttributesFields.length > 0) && (
<IconButton title={t('ABAC_Remove_attribute')} icon='trash' onClick={() => remove(index)} />
)}
</FieldRow>
{errors.attributeValues?.[index]?.value && <FieldError>{errors.attributeValues[index].value.message}</FieldError>}
</Fragment>
))}
<Button
onClick={() => append({ value: '' })}
// Checking for values since rhf does consider the newly added field as dirty after an append() call
disabled={!!getAttributeValuesError() || attributeValues?.some((value: { value: string }) => value?.value === '')}
>
{t('Add_Value')}
</Button>
</Field>
</Box>
<ContextualbarScrollableContent is='form' onSubmit={handleSubmit(onSave)} id={formId}>
<Box>{description}</Box>
<Field>
<FieldLabel htmlFor={nameField} required>
{t('Name')}
</FieldLabel>
<FieldRow>
<TextInput
error={errors.name?.message}
id={nameField}
aria-required='true'
{...register('name', { required: t('Required_field', { field: t('Name') }) })}
aria-invalid={errors.name ? 'true' : 'false'}
aria-describedby={`${nameField}-error`}
/>
</FieldRow>
{errors.name && (
<FieldError id={`${nameField}-error`} role='alert'>
{errors.name.message}
</FieldError>
)}
Comment thread
coderabbitai[bot] marked this conversation as resolved.
</Field>
<Field>
<FieldLabel required id={valuesField}>
{t('Values')}
</FieldLabel>
{lockedAttributesFields.map((field, index) => (
<Fragment key={field.id}>
<FieldRow key={field.id}>
<TextInput
disabled
aria-labelledby={valuesField}
error={errors.lockedAttributes?.[index]?.value?.message || ''}
{...register(`lockedAttributes.${index}.value`, {
required: t('Required_field', { field: t('Values') }),
validate: (value: string) => validateRepeatedValues(value),
})}
/>
{index !== 0 && (
<IconButton mis={8} small title={t('ABAC_Remove_attribute')} icon='trash' onClick={() => removeLockedAttribute(index)} />
)}
</FieldRow>
{errors.lockedAttributes?.[index]?.value && (
<FieldError id={`${valuesField + index}-error`} role='alert'>
{errors.lockedAttributes?.[index]?.value?.message}
</FieldError>
)}
</Fragment>
))}
Comment thread
coderabbitai[bot] marked this conversation as resolved.
{fields.map((field, index) => (
<Fragment key={field.id}>
<FieldRow>
<TextInput
aria-labelledby={valuesField}
error={errors.attributeValues?.[index]?.value?.message || ''}
{...register(`attributeValues.${index}.value`, {
required: t('Required_field', { field: t('Values') }),
validate: (value: string) => validateRepeatedValues(value),
})}
/>
{(index !== 0 || lockedAttributesFields.length > 0) && (
<IconButton mis={8} small title={t('ABAC_Remove_attribute')} icon='trash' onClick={() => remove(index)} />
)}
</FieldRow>
{errors.attributeValues?.[index]?.value && (
<FieldError id={`${valuesField + index}-error`} role='alert'>
{errors.attributeValues[index].value.message}
</FieldError>
)}
</Fragment>
))}
Comment thread
coderabbitai[bot] marked this conversation as resolved.
<Button
mb={8}
onClick={() => append({ value: '' })}
// Checking for values since rhf does consider the newly added field as dirty after an append() call
disabled={!!getAttributeValuesError() || attributeValues?.some((value: { value: string }) => value?.value === '')}
>
{t('Add_Value')}
</Button>
</Field>
</ContextualbarScrollableContent>
<ContextualbarFooter>
<ButtonGroup stretch>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const AttributesPage = () => {
const { t } = useTranslation();

const [text, setText] = useState('');
const debouncedText = useDebouncedValue(text, 200);
const debouncedText = useDebouncedValue(text, 400);
const { current, itemsPerPage, setItemsPerPage, setCurrent, ...paginationProps } = usePagination();
const getAttributes = useEndpoint('GET', '/v1/abac/attributes');
const isABACAvailable = useIsABACAvailable();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ exports[`AttributesForm renders NewAttribute without crashing 1`] = `
/>
</span>
<button
class="rcx-box rcx-box--full rcx-button"
class="rcx-box rcx-box--full rcx-button rcx-css-cnkcl9"
disabled=""
type="button"
>
Expand Down Expand Up @@ -272,13 +272,13 @@ exports[`AttributesForm renders WithLockedAttributes without crashing 1`] = `
type="text"
/>
<button
class="rcx-box rcx-box--full rcx-button--large-square rcx-button--square rcx-button--icon rcx-button"
class="rcx-box rcx-box--full rcx-button--small-square rcx-button--square rcx-button--icon rcx-button rcx-css-rxhtwq rcx-css-nc7kyx"
title="ABAC_Remove_attribute"
type="button"
>
<i
aria-hidden="true"
class="rcx-box rcx-box--full rcx-icon--name-trash rcx-icon rcx-css-1x2l7ts"
class="rcx-box rcx-box--full rcx-icon--name-trash rcx-icon rcx-css-4pvxx3"
>
</i>
Expand All @@ -296,20 +296,20 @@ exports[`AttributesForm renders WithLockedAttributes without crashing 1`] = `
type="text"
/>
<button
class="rcx-box rcx-box--full rcx-button--large-square rcx-button--square rcx-button--icon rcx-button"
class="rcx-box rcx-box--full rcx-button--small-square rcx-button--square rcx-button--icon rcx-button rcx-css-rxhtwq rcx-css-nc7kyx"
title="ABAC_Remove_attribute"
type="button"
>
<i
aria-hidden="true"
class="rcx-box rcx-box--full rcx-icon--name-trash rcx-icon rcx-css-1x2l7ts"
class="rcx-box rcx-box--full rcx-icon--name-trash rcx-icon rcx-css-4pvxx3"
>
</i>
</button>
</span>
<button
class="rcx-box rcx-box--full rcx-button"
class="rcx-box rcx-box--full rcx-button rcx-css-cnkcl9"
type="button"
>
<span
Expand Down
Loading