diff --git a/changelog/unreleased/enhancement-respect-user-readonly-configuration b/changelog/unreleased/enhancement-respect-user-readonly-configuration new file mode 100644 index 00000000000..f95fc5e769d --- /dev/null +++ b/changelog/unreleased/enhancement-respect-user-readonly-configuration @@ -0,0 +1,8 @@ +Enhancement: Respect user read-only configuration by the server + +The user edit dialog in the user management will respect the server's FRONTEND_READONLY_USER_ATTRIBUTES configuration, +recent fields will be disabled and will have a lock icon to visualize, that those fields are read-only. + +https://github.com/owncloud/web/pull/8868 +https://github.com/owncloud/web/issues/8840 + diff --git a/packages/web-app-admin-settings/src/components/Users/SideBar/EditPanel.vue b/packages/web-app-admin-settings/src/components/Users/SideBar/EditPanel.vue index b49f75cdb25..519745ae525 100644 --- a/packages/web-app-admin-settings/src/components/Users/SideBar/EditPanel.vue +++ b/packages/web-app-admin-settings/src/components/Users/SideBar/EditPanel.vue @@ -10,6 +10,7 @@ :label="$gettext('User name')" :error-message="formData.userName.errorMessage" :fix-message-line="true" + :read-only="isInputFieldReadOnly('user.onPremisesSamAccountName')" @update:model-value="validateUserName" />
@@ -49,6 +53,7 @@ option-label="displayName" :options="translatedRoleOptions" :clearable="false" + :read-only="isInputFieldReadOnly('user.appRoleAssignments')" @update:model-value="onUpdateRole" />
@@ -61,6 +66,7 @@ :label="$gettext('Login')" :options="loginOptions" :clearable="false" + :read-only="isInputFieldReadOnly('user.accountEnabled')" @update:model-value="onUpdateLogin" /> @@ -71,15 +77,16 @@ :key="'quota-select-' + user.id" :disabled="isQuotaInputDisabled" class="oc-mb-s" - :title="$gettext('Personal quota')" + :label="$gettext('Personal quota')" :total-quota="editUser.drive?.quota?.total || 0" :max-quota="maxQuota" :fix-message-line="true" :description-message=" - isQuotaInputDisabled + isQuotaInputDisabled && !isInputFieldReadOnly('drive.quota') ? $gettext('To set an individual quota, the user needs to have logged in once.') : '' " + :read-only="isInputFieldReadOnly('drive.quota')" @selected-option-change="changeSelectedQuotaOption" /> !selectedGroups.some((s) => s.id === g.id) && !g.groupTypes?.includes('ReadOnly') ) }) - const isLoginInputDisabled = computed(() => currentUser.uuid === (props.user as User).id) + const readOnlyUserAttributes = useCapabilityReadOnlyUserAttributes() + const isInputFieldReadOnly = (key) => { + return unref(readOnlyUserAttributes).includes(key) + } return { maxQuota: useCapabilitySpacesMaxQuota(), + isInputFieldReadOnly, isLoginInputDisabled, editUser, formData, diff --git a/packages/web-app-admin-settings/tests/unit/components/Users/SideBar/EditPanel.spec.ts b/packages/web-app-admin-settings/tests/unit/components/Users/SideBar/EditPanel.spec.ts index 7c20fd29518..7d1543ee74a 100644 --- a/packages/web-app-admin-settings/tests/unit/components/Users/SideBar/EditPanel.spec.ts +++ b/packages/web-app-admin-settings/tests/unit/components/Users/SideBar/EditPanel.spec.ts @@ -35,6 +35,18 @@ describe('EditPanel', () => { expect(groupOptions.length).toBe(1) expect(groupOptions[0].id).toEqual(availableGroupOptions[1].id) }) + + describe('method "isInputFieldReadOnly"', () => { + it('should be true if included in capability ReadOnlyUserAttributes list', () => { + const { wrapper } = getWrapper({ readOnlyUserAttributes: ['user.displayName'] }) + expect(wrapper.vm.isInputFieldReadOnly('user.displayName')).toBeTruthy() + }) + it('should be false if not included in capability ReadOnlyUserAttributes list', () => { + const { wrapper } = getWrapper() + expect(wrapper.vm.isInputFieldReadOnly('user.displayName')).toBeFalsy() + }) + }) + describe('method "revertChanges"', () => { it('should revert changes on property editUser', () => { const { wrapper } = getWrapper() @@ -159,9 +171,18 @@ describe('EditPanel', () => { }) }) -function getWrapper({ selectedGroups = [], groups = availableGroupOptions } = {}) { +function getWrapper({ + readOnlyUserAttributes = [], + selectedGroups = [], + groups = availableGroupOptions +} = {}) { const mocks = defaultComponentMocks() const storeOptions = defaultStoreMockOptions + storeOptions.getters.capabilities.mockReturnValue({ + graph: { + read_only_user_attributes: readOnlyUserAttributes + } + }) const store = createStore(storeOptions) return { mocks, diff --git a/packages/web-app-admin-settings/tests/unit/components/Users/SideBar/__snapshots__/EditPanel.spec.ts.snap b/packages/web-app-admin-settings/tests/unit/components/Users/SideBar/__snapshots__/EditPanel.spec.ts.snap index 7561cc87043..b0804cc4c86 100644 --- a/packages/web-app-admin-settings/tests/unit/components/Users/SideBar/__snapshots__/EditPanel.spec.ts.snap +++ b/packages/web-app-admin-settings/tests/unit/components/Users/SideBar/__snapshots__/EditPanel.spec.ts.snap @@ -17,7 +17,7 @@ exports[`EditPanel renders all available inputs 1`] = `
- + diff --git a/packages/web-pkg/src/components/QuotaSelect.vue b/packages/web-pkg/src/components/QuotaSelect.vue index c35b10b3874..36b301fa510 100644 --- a/packages/web-pkg/src/components/QuotaSelect.vue +++ b/packages/web-pkg/src/components/QuotaSelect.vue @@ -4,21 +4,17 @@ ref="select" :model-value="selectedOption" :selectable="optionSelectable" - :disabled="disabled" taggable push-tags :clearable="false" :options="options" :create-option="createOption" option-label="displayValue" - :label="title" - :fix-message-line="fixMessageLine" - :error-message="errorMessage" - :warning-message="warningMessage" - :description-message="descriptionMessage" + v-bind="$attrs" @update:model-value="onUpdate" >