From 5543d3dc8dbe01e7ae15a7ca3567c0fd480be02c Mon Sep 17 00:00:00 2001 From: Harold Gray Date: Wed, 31 Oct 2018 02:59:14 -0400 Subject: [PATCH 1/4] indicate default quota in selection Signed-off-by: Harold Gray --- apps/provisioning_api/lib/Controller/AUserData.php | 2 +- lib/private/User/User.php | 6 +----- settings/src/components/userList/userRow.vue | 6 +++--- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/apps/provisioning_api/lib/Controller/AUserData.php b/apps/provisioning_api/lib/Controller/AUserData.php index 25e5ab5c86d1a..a87ca79fc7b1c 100644 --- a/apps/provisioning_api/lib/Controller/AUserData.php +++ b/apps/provisioning_api/lib/Controller/AUserData.php @@ -176,7 +176,7 @@ protected function fillStorageInfo(string $userId): array { throw new OCSException('User does not exist', 101); } $quota = $user->getQuota(); - if ($quota !== 'none') { + if ($quota !== 'none' && $quota !== 'default') { $quota = OC_Helper::computerFileSize($quota); } $data = [ diff --git a/lib/private/User/User.php b/lib/private/User/User.php index e171a65f8ce7f..8f6c14ab6c401 100644 --- a/lib/private/User/User.php +++ b/lib/private/User/User.php @@ -375,11 +375,7 @@ public function getEMailAddress() { * @since 9.0.0 */ public function getQuota() { - $quota = $this->config->getUserValue($this->uid, 'files', 'quota', 'default'); - if($quota === 'default') { - $quota = $this->config->getAppValue('files', 'default_quota', 'none'); - } - return $quota; + return $this->config->getUserValue($this->uid, 'files', 'quota', 'default'); } /** diff --git a/settings/src/components/userList/userRow.vue b/settings/src/components/userList/userRow.vue index 138f855eaf06d..b6dffb24d5dad 100644 --- a/settings/src/components/userList/userRow.vue +++ b/settings/src/components/userList/userRow.vue @@ -234,13 +234,13 @@ export default { }, // Mapping saved values to objects userQuota() { - if (this.user.quota.quota >= 0) { + if (this.user.quota.quota > 0) { // if value is valid, let's map the quotaOptions or return custom quota let humanQuota = OC.Util.humanFileSize(this.user.quota.quota); let userQuota = this.quotaOptions.find(quota => quota.id === humanQuota); return userQuota ? userQuota : {id:humanQuota, label:humanQuota}; - } else if (this.user.quota.quota === 'default') { - // default quota is replaced by the proper value on load + } else if (this.user.quota.quota === 0 || this.user.quota.quota === 'default') { + this.quotaOptions[0]['label'] = this.settings.defaultQuota + ' (default)'; return this.quotaOptions[0]; } return this.quotaOptions[1]; // unlimited From 224df5afedb29e97c46ab50dd77d00e473b3094c Mon Sep 17 00:00:00 2001 From: Harold Gray Date: Wed, 31 Oct 2018 04:32:26 -0400 Subject: [PATCH 2/4] fix quota fail on new account default check Signed-off-by: Harold Gray --- settings/src/components/userList/userRow.vue | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/settings/src/components/userList/userRow.vue b/settings/src/components/userList/userRow.vue index b6dffb24d5dad..06ba4340702c3 100644 --- a/settings/src/components/userList/userRow.vue +++ b/settings/src/components/userList/userRow.vue @@ -239,11 +239,12 @@ export default { let humanQuota = OC.Util.humanFileSize(this.user.quota.quota); let userQuota = this.quotaOptions.find(quota => quota.id === humanQuota); return userQuota ? userQuota : {id:humanQuota, label:humanQuota}; - } else if (this.user.quota.quota === 0 || this.user.quota.quota === 'default') { - this.quotaOptions[0]['label'] = this.settings.defaultQuota + ' (default)'; - return this.quotaOptions[0]; + } else if (this.settings.defaultQuota === 'none' || this.user.quota.quota === 'none') { + return this.quotaOptions[1]; // unlimited } - return this.quotaOptions[1]; // unlimited + + this.quotaOptions[0]['label'] = this.settings.defaultQuota + ' (default)'; // otherwise + return this.quotaOptions[0]; }, /* PASSWORD POLICY? */ From 83e1b2d3f4d35a827b3784928630abb67c955dea Mon Sep 17 00:00:00 2001 From: Harold Gray Date: Wed, 31 Oct 2018 05:10:12 -0400 Subject: [PATCH 3/4] differentiate between unlimited and default Signed-off-by: Harold Gray --- settings/src/components/userList/userRow.vue | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/settings/src/components/userList/userRow.vue b/settings/src/components/userList/userRow.vue index 06ba4340702c3..ad644696a0189 100644 --- a/settings/src/components/userList/userRow.vue +++ b/settings/src/components/userList/userRow.vue @@ -239,8 +239,13 @@ export default { let humanQuota = OC.Util.humanFileSize(this.user.quota.quota); let userQuota = this.quotaOptions.find(quota => quota.id === humanQuota); return userQuota ? userQuota : {id:humanQuota, label:humanQuota}; - } else if (this.settings.defaultQuota === 'none' || this.user.quota.quota === 'none') { - return this.quotaOptions[1]; // unlimited + } else if (this.settings.defaultQuota === 'none') { // unlimited + if(this.user.quota.quota === 'default') { + this.quotaOptions[0]['label'] = '∞ (default)'; + return this.quotaOptions[0]; + } else if (this.user.quota.quota === 'none') { + return this.quotaOptions[1]; + } } this.quotaOptions[0]['label'] = this.settings.defaultQuota + ' (default)'; // otherwise From 6cf2d2993e24f7f14f35266b9d14da34d2f3b486 Mon Sep 17 00:00:00 2001 From: Harold Gray Date: Wed, 31 Oct 2018 23:31:32 -0400 Subject: [PATCH 4/4] reworked default quota label and added js update of users' default value when default is changed Signed-off-by: Harold Gray --- settings/src/components/userList.vue | 20 +++++++++++++++++++- settings/src/components/userList/userRow.vue | 14 ++++---------- settings/src/views/Users.vue | 2 +- 3 files changed, 24 insertions(+), 12 deletions(-) diff --git a/settings/src/components/userList.vue b/settings/src/components/userList.vue index 521ad7cc39270..743db7ff58985 100644 --- a/settings/src/components/userList.vue +++ b/settings/src/components/userList.vue @@ -143,7 +143,7 @@ import Vue from 'vue'; export default { name: 'userList', - props: ['users', 'showConfig', 'selectedGroup', 'externalActions'], + props: ['users', 'showConfig', 'selectedGroup', 'externalActions', 'defaultQuotaValue'], components: { userRow, Multiselect, @@ -195,6 +195,10 @@ export default { * Register search */ this.userSearch = new OCA.Search(this.search, this.resetSearch); + + this.$nextTick(function () { + this.updateDefaultLabel(); + }); }, computed: { settings() { @@ -274,6 +278,9 @@ export default { this.$store.commit('resetUsers'); this.$refs.infiniteLoading.$emit('$InfiniteLoading:reset'); this.setNewUserDefaultGroup(val); + }, + defaultQuotaValue: function () { + this.updateDefaultLabel(); } }, methods: { @@ -368,6 +375,17 @@ export default { this.loading.groups = false; }); return this.$store.getters.getGroups[this.groups.length]; + }, + updateDefaultLabel() { + let defaultLabel = undefined; + + if (this.defaultQuotaValue.label === 'Unlimited') { + defaultLabel = '∞'; + } else { + defaultLabel = this.defaultQuotaValue.label; + } + + this.defaultQuota = {id: 'default', label: defaultLabel + ' (default)'}; } } } diff --git a/settings/src/components/userList/userRow.vue b/settings/src/components/userList/userRow.vue index ad644696a0189..754afe881b7f8 100644 --- a/settings/src/components/userList/userRow.vue +++ b/settings/src/components/userList/userRow.vue @@ -239,17 +239,11 @@ export default { let humanQuota = OC.Util.humanFileSize(this.user.quota.quota); let userQuota = this.quotaOptions.find(quota => quota.id === humanQuota); return userQuota ? userQuota : {id:humanQuota, label:humanQuota}; - } else if (this.settings.defaultQuota === 'none') { // unlimited - if(this.user.quota.quota === 'default') { - this.quotaOptions[0]['label'] = '∞ (default)'; - return this.quotaOptions[0]; - } else if (this.user.quota.quota === 'none') { - return this.quotaOptions[1]; - } + } else if (this.user.quota.quota === 0 || this.user.quota.quota === 'default') { + // default quota is replaced by the proper value on load + return this.quotaOptions[0]; } - - this.quotaOptions[0]['label'] = this.settings.defaultQuota + ' (default)'; // otherwise - return this.quotaOptions[0]; + return this.quotaOptions[1]; // unlimited }, /* PASSWORD POLICY? */ diff --git a/settings/src/views/Users.vue b/settings/src/views/Users.vue index b213e234f326d..55d9bcd47c151 100644 --- a/settings/src/views/Users.vue +++ b/settings/src/views/Users.vue @@ -52,7 +52,7 @@ - +