From 148c0bfde77838e7fc158039adc7d977e89c0aa5 Mon Sep 17 00:00:00 2001 From: Tatiana Lopaeva Date: Mon, 14 Aug 2023 13:01:49 +0300 Subject: [PATCH] Web: Added ability to set default quota in section header of accounts. --- packages/client/src/store/AccessRightsStore.js | 12 ++++++++++++ packages/client/src/store/PeopleStore.js | 10 ++++++++++ packages/client/src/store/SelectionPeopleStore.js | 6 ++++++ public/images/default.quota.react.svg | 12 ++++++++++++ 4 files changed, 40 insertions(+) create mode 100644 public/images/default.quota.react.svg diff --git a/packages/client/src/store/AccessRightsStore.js b/packages/client/src/store/AccessRightsStore.js index c13e96873e..42407531a3 100644 --- a/packages/client/src/store/AccessRightsStore.js +++ b/packages/client/src/store/AccessRightsStore.js @@ -178,6 +178,18 @@ class AccessRightsStore { return true; }; + + canSetDefaultQuota = () => { + const { + isOwner, + isAdmin, + isCustomQuota = true, + } = this.authStore.userStore.user; + + if (!isOwner && !isAdmin) return false; + + return isCustomQuota; + }; } export default AccessRightsStore; diff --git a/packages/client/src/store/PeopleStore.js b/packages/client/src/store/PeopleStore.js index b9c9c72d04..f415fbed02 100644 --- a/packages/client/src/store/PeopleStore.js +++ b/packages/client/src/store/PeopleStore.js @@ -6,6 +6,7 @@ import InviteAgainReactSvgUrl from "PUBLIC_DIR/images/invite.again.react.svg?url import DeleteReactSvgUrl from "PUBLIC_DIR/images/delete.react.svg?url"; import ChangQuotaReactSvgUrl from "PUBLIC_DIR/images/change.quota.react.svg?url"; import DisableQuotaReactSvgUrl from "PUBLIC_DIR/images/disable.quota.react.svg?url"; +import DefaultQuotaReactSvgUrl from "PUBLIC_DIR/images/default.quota.react.svg?url"; import { makeAutoObservable } from "mobx"; import GroupsStore from "./GroupsStore"; import UsersStore from "./UsersStore"; @@ -212,6 +213,7 @@ class PeopleStore { hasFreeUsers, hasUsersToChangeQuota, hasUsersToDisableQuota, + hasUsersToSetDefaultQuota, selection, } = this.selectionStore; const { @@ -312,6 +314,14 @@ class PeopleStore { iconUrl: ChangQuotaReactSvgUrl, onClick: () => this.changeUserQuota(selection), }, + { + id: "menu-default-quota", + key: "default-quota", + label: "Set to default", + disabled: !hasUsersToSetDefaultQuota, + iconUrl: DefaultQuotaReactSvgUrl, + onClick: () => console.log("set to default", selection), + }, { id: "menu-disable-quota", key: "disable-quota", diff --git a/packages/client/src/store/SelectionPeopleStore.js b/packages/client/src/store/SelectionPeopleStore.js index aa8d917b2b..dbad9f6422 100644 --- a/packages/client/src/store/SelectionPeopleStore.js +++ b/packages/client/src/store/SelectionPeopleStore.js @@ -258,6 +258,12 @@ class SelectionStore { return this.selection.every((x) => canDisableQuota(x)); } + + get hasUsersToSetDefaultQuota() { + const { canSetDefaultQuota } = this.peopleStore.accessRightsStore; + + return this.selection.every((x) => canSetDefaultQuota(x)); + } } export default SelectionStore; diff --git a/public/images/default.quota.react.svg b/public/images/default.quota.react.svg new file mode 100644 index 0000000000..b1f9b734d7 --- /dev/null +++ b/public/images/default.quota.react.svg @@ -0,0 +1,12 @@ + + + + + + + + + + + +