From 6b6254011b42480a16c77913e11ac36a17f451e7 Mon Sep 17 00:00:00 2001 From: Paul Neubauer Date: Mon, 6 Feb 2023 15:07:45 +0100 Subject: [PATCH 01/15] Add batch actions for spaces list --- .../src/views/Spaces.vue | 29 +++++++++++++++++-- .../web-pkg/src/mixins/spaces/editQuota.ts | 6 +--- 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/packages/web-app-admin-settings/src/views/Spaces.vue b/packages/web-app-admin-settings/src/views/Spaces.vue index 23c6ebee1a4..38e56cead24 100644 --- a/packages/web-app-admin-settings/src/views/Spaces.vue +++ b/packages/web-app-admin-settings/src/views/Spaces.vue @@ -38,6 +38,12 @@ @@ -120,6 +126,9 @@ import AppTemplate from '../components/AppTemplate.vue' import { useSideBar } from 'web-pkg/src/composables/sideBar' import ItemFilter from 'web-pkg/src/components/ItemFilter.vue' import AppLoadingSpinner from 'web-pkg/src/components/AppLoadingSpinner.vue' +import EditQuota from 'web-pkg/src/mixins/spaces/editQuota' +import { toRaw } from 'vue' +import { SpaceResource } from 'web-client/src' export default defineComponent({ name: 'UsersView', @@ -132,9 +141,10 @@ export default defineComponent({ ContextActions, ItemFilter }, - mixins: [Delete], + mixins: [Delete, EditQuota], setup() { const instance = getCurrentInstance().proxy as any + const $gettext = instance.$gettext const store = useStore() const accessToken = useAccessToken({ store }) const { graphClient } = useGraphClient() @@ -190,6 +200,7 @@ export default defineComponent({ loadUsersTask.perform(groupIds) } + const selectedPersonalDrives = ref([]) watch( () => unref(selectedUsers).length, async () => { @@ -210,6 +221,19 @@ export default defineComponent({ loadedUser.value = null }) sideBarLoading.value = false + selectedPersonalDrives.value.splice(0, unref(selectedPersonalDrives).length) + unref(selectedUsers).forEach((user) => { + const drive = toRaw(user.drive) + if (drive === undefined || drive.id === undefined) { + return + } + const spaceResource = { + id: drive.id, + name: $gettext(' of %{name}', { name: user.displayName }), + spaceQuota: drive.quota + } as SpaceResource + selectedPersonalDrives.value.push(spaceResource) + }) } ) @@ -218,7 +242,7 @@ export default defineComponent({ } const batchActions = computed(() => { - return [...instance.$_delete_items].filter((item) => + return [...instance.$_delete_items, ...instance.$_editQuota_items].filter((item) => item.isEnabled({ resources: unref(selectedUsers) }) ) }) @@ -246,6 +270,14 @@ export default defineComponent({ eventBus.unsubscribe('app.admin-settings.users.user.updated', userUpdatedEventToken) }) + const quotaModalIsOpen = computed(() => instance.$data.$_editQuota_modalOpen) + const closeQuotaModal = () => { + instance.$_editQuota_closeModal() + } + const spaceQuotaUpdated = (quota) => { + instance.$data.$_editQuota_selectedSpace.spaceQuota = quota + } + return { ...useSideBar(), template, @@ -262,7 +294,11 @@ export default defineComponent({ listHeaderPosition, createUserModalOpen, batchActions, - filterGroups + filterGroups, + quotaModalIsOpen, + closeQuotaModal, + spaceQuotaUpdated, + selectedPersonalDrives } }, computed: { From 5733bcf15d43916a66cfa82ed3e7b77d5744d0ef Mon Sep 17 00:00:00 2001 From: Paul Neubauer Date: Mon, 13 Feb 2023 09:40:01 +0100 Subject: [PATCH 08/15] Add changelog --- .../enhancement-admin-change-spaces-quota-batch-action | 6 ++++++ packages/web-app-admin-settings/src/views/Users.vue | 1 + packages/web-pkg/src/components/Spaces/QuotaModal.vue | 1 - 3 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 changelog/unreleased/enhancement-admin-change-spaces-quota-batch-action diff --git a/changelog/unreleased/enhancement-admin-change-spaces-quota-batch-action b/changelog/unreleased/enhancement-admin-change-spaces-quota-batch-action new file mode 100644 index 00000000000..0ae3da11125 --- /dev/null +++ b/changelog/unreleased/enhancement-admin-change-spaces-quota-batch-action @@ -0,0 +1,6 @@ +Enhancement: Batch edit quota in admin panel + +We've added the batch edit quota functionality to the admin panel for users personal space and in the spaces list + +https://github.com/owncloud/web/pull/8387 +https://github.com/owncloud/web/issues/8417 \ No newline at end of file diff --git a/packages/web-app-admin-settings/src/views/Users.vue b/packages/web-app-admin-settings/src/views/Users.vue index 1d0950a3aad..0a3e7b70c2e 100644 --- a/packages/web-app-admin-settings/src/views/Users.vue +++ b/packages/web-app-admin-settings/src/views/Users.vue @@ -205,6 +205,7 @@ export default defineComponent({ () => unref(selectedUsers).length, async () => { sideBarLoading.value = true + // Load additional user data const requests = [] unref(selectedUsers).forEach((user) => { requests.push(loadAdditionalUserDataTask.perform(user)) diff --git a/packages/web-pkg/src/components/Spaces/QuotaModal.vue b/packages/web-pkg/src/components/Spaces/QuotaModal.vue index 30fad665407..1b3d287b650 100644 --- a/packages/web-pkg/src/components/Spaces/QuotaModal.vue +++ b/packages/web-pkg/src/components/Spaces/QuotaModal.vue @@ -67,7 +67,6 @@ export default defineComponent({ } }, mounted() { - console.log(this.spaces) this.selectedOption = this.spaces[0].spaceQuota.total || 0 }, methods: { From b46da3c3eab5d86c3d1d62f4329e97b54bc03116 Mon Sep 17 00:00:00 2001 From: Paul Neubauer Date: Mon, 13 Feb 2023 12:59:00 +0100 Subject: [PATCH 09/15] Address some PR issues --- .../src/components/Users/ContextActions.vue | 22 +++++++++++++------ .../src/views/Users.vue | 8 +++++-- .../src/components/Spaces/QuotaModal.vue | 5 +++-- 3 files changed, 24 insertions(+), 11 deletions(-) diff --git a/packages/web-app-admin-settings/src/components/Users/ContextActions.vue b/packages/web-app-admin-settings/src/components/Users/ContextActions.vue index 0b40d440130..799e6184117 100644 --- a/packages/web-app-admin-settings/src/components/Users/ContextActions.vue +++ b/packages/web-app-admin-settings/src/components/Users/ContextActions.vue @@ -14,14 +14,22 @@ import ShowDetails from '../../mixins/showDetails' import Delete from '../../mixins/users/delete' import Edit from '../../mixins/users/edit' -import { computed, defineComponent, getCurrentInstance, PropType, unref } from 'vue' +import { + computed, + defineComponent, + getCurrentInstance, + PropType, + unref, + watch, + toRaw, + ref +} from 'vue' import ContextActionMenu from 'web-pkg/src/components/ContextActions/ContextActionMenu.vue' import { User } from 'web-client/src/generated' import QuotaModal from 'web-pkg/src/components/Spaces/QuotaModal.vue' import EditQuota from 'web-pkg/src/mixins/spaces/editQuota' -import { watch, toRaw } from 'vue' import { SpaceResource } from 'web-client/src' -import { reactive } from 'vue' +import { useGettext } from 'vue3-gettext' export default defineComponent({ name: 'ContextActions', @@ -35,13 +43,13 @@ export default defineComponent({ }, setup(props) { const instance = getCurrentInstance().proxy as any - const $gettext = instance.$gettext + const { $gettext } = useGettext() const filterParams = computed(() => ({ resources: props.items })) - const selectedPersonalDrives = reactive([]) + const selectedPersonalDrives = ref([]) watch( () => props.items, async () => { - selectedPersonalDrives.splice(0, selectedPersonalDrives.length) + selectedPersonalDrives.value.splice(0, unref(selectedPersonalDrives).length) props.items.forEach((user) => { const drive = toRaw(user.drive) if (drive === undefined || drive.id === undefined) { @@ -52,7 +60,7 @@ export default defineComponent({ name: $gettext(' of %{name}', { name: user.displayName }), spaceQuota: drive.quota } as SpaceResource - selectedPersonalDrives.push(spaceResource) + selectedPersonalDrives.value.push(spaceResource) }) }, { deep: true, immediate: true } diff --git a/packages/web-app-admin-settings/src/views/Users.vue b/packages/web-app-admin-settings/src/views/Users.vue index 0a3e7b70c2e..4cc400f9ac2 100644 --- a/packages/web-app-admin-settings/src/views/Users.vue +++ b/packages/web-app-admin-settings/src/views/Users.vue @@ -129,6 +129,7 @@ import AppLoadingSpinner from 'web-pkg/src/components/AppLoadingSpinner.vue' import EditQuota from 'web-pkg/src/mixins/spaces/editQuota' import { toRaw } from 'vue' import { SpaceResource } from 'web-client/src' +import { useGettext } from 'vue3-gettext' export default defineComponent({ name: 'UsersView', @@ -144,7 +145,7 @@ export default defineComponent({ mixins: [Delete, EditQuota], setup() { const instance = getCurrentInstance().proxy as any - const $gettext = instance.$gettext + const { $gettext } = useGettext() const store = useStore() const accessToken = useAccessToken({ store }) const { graphClient } = useGraphClient() @@ -217,10 +218,13 @@ export default defineComponent({ Object.assign(user, additionalUserData) if (unref(selectedUsers).length === 1) { loadedUser.value = additionalUserData + sideBarLoading.value = false return } - loadedUser.value = null }) + if (unref(selectedUsers).length !== 1) { + loadedUser.value = null + } sideBarLoading.value = false selectedPersonalDrives.value.splice(0, unref(selectedPersonalDrives).length) unref(selectedUsers).forEach((user) => { diff --git a/packages/web-pkg/src/components/Spaces/QuotaModal.vue b/packages/web-pkg/src/components/Spaces/QuotaModal.vue index 1b3d287b650..92001ed5397 100644 --- a/packages/web-pkg/src/components/Spaces/QuotaModal.vue +++ b/packages/web-pkg/src/components/Spaces/QuotaModal.vue @@ -20,10 +20,11 @@