diff --git a/apps/meteor/client/views/admin/ABAC/ABACAttributesTab/AttributesContextualBar.tsx b/apps/meteor/client/views/admin/ABAC/ABACAttributesTab/AttributesContextualBar.tsx index a41e7b6b87ca2..a1f22fd11a1dd 100644 --- a/apps/meteor/client/views/admin/ABAC/ABACAttributesTab/AttributesContextualBar.tsx +++ b/apps/meteor/client/views/admin/ABAC/ABACAttributesTab/AttributesContextualBar.tsx @@ -75,7 +75,7 @@ const AttributesContextualBar = ({ attributeData, onClose }: AttributesContextua dispatchToastMessage({ type: 'error', message: error }); }, onSettled: () => { - queryClient.invalidateQueries({ queryKey: ABACQueryKeys.roomAttributes.list() }); + queryClient.invalidateQueries({ queryKey: ABACQueryKeys.roomAttributes.list({}) }); }, }); diff --git a/apps/meteor/client/views/admin/ABAC/ABACAttributesTab/AttributesForm.tsx b/apps/meteor/client/views/admin/ABAC/ABACAttributesTab/AttributesForm.tsx index 9e899452914fd..a9b067e52fe61 100644 --- a/apps/meteor/client/views/admin/ABAC/ABACAttributesTab/AttributesForm.tsx +++ b/apps/meteor/client/views/admin/ABAC/ABACAttributesTab/AttributesForm.tsx @@ -102,92 +102,112 @@ const AttributesForm = ({ onSave, onCancel, description }: AttributesFormProps) return ( <> - - - {description} - - - {t('Name')} - - - - - {errors.name && {errors.name.message}} - - - - {t('Values')} - - {lockedAttributesFields.map((field, index) => ( - - - validateRepeatedValues(value), - })} - /> - {index !== 0 && ( - removeLockedAttribute(index)} /> - )} - - {errors.lockedAttributes?.[index]?.value && {errors.lockedAttributes?.[index]?.value?.message}} - {showDisclaimer.includes(index) && ( - - { - e.preventDefault(); - viewRoomsAction(getValues('name')); - }} - > - {t('ABAC_View_rooms')} - - ), - }} - /> - + + {description} + + + {t('Name')} + + + + + {errors.name && ( + + {errors.name.message} + + )} + + + + {t('Values')} + + {lockedAttributesFields.map((field, index) => ( + + + validateRepeatedValues(value), + })} + /> + {index !== 0 && ( + removeLockedAttribute(index)} /> )} - - ))} - {fields.map((field, index) => ( - - - validateRepeatedValues(value), - })} + + {errors.lockedAttributes?.[index]?.value && ( + + {errors.lockedAttributes?.[index]?.value?.message} + + )} + {showDisclaimer.includes(index) && ( + + { + e.preventDefault(); + viewRoomsAction(getValues('name')); + }} + > + {t('ABAC_View_rooms')} + + ), + }} /> - {(index !== 0 || lockedAttributesFields.length > 0) && ( - remove(index)} /> - )} - - {errors.attributeValues?.[index]?.value && {errors.attributeValues[index].value.message}} - - ))} - - - + + )} + + ))} + {fields.map((field, index) => ( + + + validateRepeatedValues(value), + })} + /> + {(index !== 0 || lockedAttributesFields.length > 0) && ( + remove(index)} /> + )} + + {errors.attributeValues?.[index]?.value && ( + + {errors.attributeValues[index].value.message} + + )} + + ))} + + diff --git a/apps/meteor/client/views/admin/ABAC/ABACAttributesTab/AttributesPage.tsx b/apps/meteor/client/views/admin/ABAC/ABACAttributesTab/AttributesPage.tsx index d77f9b083cf0c..23401eb150b61 100644 --- a/apps/meteor/client/views/admin/ABAC/ABACAttributesTab/AttributesPage.tsx +++ b/apps/meteor/client/views/admin/ABAC/ABACAttributesTab/AttributesPage.tsx @@ -25,7 +25,7 @@ const AttributesPage = () => { const searchTerm = useSearchParameter('searchTerm'); const [text, setText] = useState(searchTerm ?? ''); - 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(); diff --git a/apps/meteor/client/views/admin/ABAC/ABACAttributesTab/__snapshots__/AttributesForm.spec.tsx.snap b/apps/meteor/client/views/admin/ABAC/ABACAttributesTab/__snapshots__/AttributesForm.spec.tsx.snap index 3e914b776d6e3..17b7c700a50b5 100644 --- a/apps/meteor/client/views/admin/ABAC/ABACAttributesTab/__snapshots__/AttributesForm.spec.tsx.snap +++ b/apps/meteor/client/views/admin/ABAC/ABACAttributesTab/__snapshots__/AttributesForm.spec.tsx.snap @@ -26,85 +26,85 @@ exports[`AttributesForm renders NewAttribute without crashing 1`] = ` style="margin-right: 0px; margin-bottom: 0px; margin-left: 0px; top: 0px; left: 0px; width: calc(100% + 0px); padding: 0px 0px 0px 0px;" tabindex="-1" > -
-
-
- Create an attribute that can later be assigned to rooms. -
-
+
+
-
+ - + + +
+
+
- -
+ Add Value + + +
+
-
-
-
- Attribute values cannot be edited, but can be added or deleted. -
-
+
+
-
+ - - - - + + +
+
+
- -
+ + +
+
- - - - - {t('ABAC_Room_to_be_managed')} - - - {roomInfo ? ( - - ) : ( - ( - { - field.onChange(value); - setSelectedRoomLabel(label); - }} - /> - )} - /> - )} - - {errors.room && {errors.room.message}} - - - - + + + + {t('ABAC_Room_to_be_managed')} + + + {roomInfo ? ( + + ) : ( + ( + { + field.onChange(value); + setSelectedRoomLabel(label); + }} + /> + )} + /> + )} + + {errors.room && ( + + {errors.room.message} + + )} + + + diff --git a/apps/meteor/client/views/admin/ABAC/ABACRoomsTab/RoomFormAttributeField.tsx b/apps/meteor/client/views/admin/ABAC/ABACRoomsTab/RoomFormAttributeField.tsx index d9a4247c3db55..21a54fd8539f5 100644 --- a/apps/meteor/client/views/admin/ABAC/ABACRoomsTab/RoomFormAttributeField.tsx +++ b/apps/meteor/client/views/admin/ABAC/ABACRoomsTab/RoomFormAttributeField.tsx @@ -7,12 +7,14 @@ import { useTranslation } from 'react-i18next'; import type { RoomFormData } from './RoomForm'; type ABACAttributeAutocompleteProps = { + labelId: string; onRemove: () => void; index: number; attributeList: { value: string; label: string; attributeValues: string[] }[]; + required?: boolean; }; -const RoomFormAttributeField = ({ onRemove, index, attributeList }: ABACAttributeAutocompleteProps) => { +const RoomFormAttributeField = ({ labelId, onRemove, index, attributeList, required = false }: ABACAttributeAutocompleteProps) => { const { t } = useTranslation(); const { control, getValues, resetField } = useFormContext(); @@ -60,6 +62,11 @@ const RoomFormAttributeField = ({ onRemove, index, attributeList }: ABACAttribut - {keyFieldState.error && {keyFieldState.error.message}} - + {keyFieldState.error && ( + + {keyFieldState.error.message} + + )} - {valuesFieldState.error && {valuesFieldState.error.message}} - - + {valuesFieldState.error && ( + + {valuesFieldState.error.message} + + )} + {index !== 0 && ( + + )} ); }; diff --git a/apps/meteor/client/views/admin/ABAC/ABACRoomsTab/RoomFormAttributeFields.tsx b/apps/meteor/client/views/admin/ABAC/ABACRoomsTab/RoomFormAttributeFields.tsx index bfcdf21464b28..49555685329a8 100644 --- a/apps/meteor/client/views/admin/ABAC/ABACRoomsTab/RoomFormAttributeFields.tsx +++ b/apps/meteor/client/views/admin/ABAC/ABACRoomsTab/RoomFormAttributeFields.tsx @@ -19,12 +19,14 @@ const RoomFormAttributeFields = ({ fields, remove }: RoomFormAttributeFieldsProp } return fields.map((field, index) => ( - - + + {t('Attribute')} { remove(index); }} diff --git a/apps/meteor/client/views/admin/ABAC/ABACRoomsTab/__snapshots__/RoomFormAttributeField.spec.tsx.snap b/apps/meteor/client/views/admin/ABAC/ABACRoomsTab/__snapshots__/RoomFormAttributeField.spec.tsx.snap index 999e90812d4e5..988f9bd936828 100644 --- a/apps/meteor/client/views/admin/ABAC/ABACRoomsTab/__snapshots__/RoomFormAttributeField.spec.tsx.snap +++ b/apps/meteor/client/views/admin/ABAC/ABACRoomsTab/__snapshots__/RoomFormAttributeField.spec.tsx.snap @@ -13,6 +13,8 @@ exports[`RoomFormAttributeField renders Default without crashing 1`] = ` class="rcx-box rcx-box--full rcx-field__row" >
@@ -46,6 +48,8 @@ exports[`RoomFormAttributeField renders Default without crashing 1`] = ` class="rcx-box rcx-box--full rcx-field__row" >
@@ -77,17 +81,6 @@ exports[`RoomFormAttributeField renders Default without crashing 1`] = `
-
diff --git a/apps/meteor/client/views/admin/ABAC/AdminABACPage.tsx b/apps/meteor/client/views/admin/ABAC/AdminABACPage.tsx index ae7b2062887a4..a4fdde032fb89 100644 --- a/apps/meteor/client/views/admin/ABAC/AdminABACPage.tsx +++ b/apps/meteor/client/views/admin/ABAC/AdminABACPage.tsx @@ -76,22 +76,18 @@ const AdminABACPage = ({ shouldShowWarning }: AdminABACPageProps) => { {tab === 'logs' && } - {tab !== undefined && context !== undefined && ( + {isABACAvailable === true && tab !== undefined && context !== undefined && ( handleCloseContextualbar()}> {tab === 'room-attributes' && ( <> - {context === 'new' && isABACAvailable === true && handleCloseContextualbar()} />} - {context === 'edit' && _id && isABACAvailable === true && ( - handleCloseContextualbar()} /> - )} + {context === 'new' && handleCloseContextualbar()} />} + {context === 'edit' && _id && handleCloseContextualbar()} />} )} {tab === 'rooms' && ( <> - {context === 'new' && isABACAvailable === true && handleCloseContextualbar()} />} - {context === 'edit' && _id && isABACAvailable === true && ( - handleCloseContextualbar()} /> - )} + {context === 'new' && handleCloseContextualbar()} />} + {context === 'edit' && _id && handleCloseContextualbar()} />} )}