Merge pull request #9616 from nextcloud/zero-quota-fix
Allow 0 quota by provisioning api
This commit is contained in:
commit
44c6d22b22
|
@ -174,9 +174,12 @@ abstract class AUserData extends OCSController {
|
|||
if ($user === null) {
|
||||
throw new OCSException('User does not exist', 101);
|
||||
}
|
||||
$quota = OC_Helper::computerFileSize($user->getQuota());
|
||||
$quota = $user->getQuota();
|
||||
if ($quota !== 'none') {
|
||||
$quota = OC_Helper::computerFileSize($quota);
|
||||
}
|
||||
$data = [
|
||||
'quota' => $quota ? $quota : 'none',
|
||||
'quota' => $quota !== false ? $quota : 'none',
|
||||
'used' => 0
|
||||
];
|
||||
}
|
||||
|
|
|
@ -487,9 +487,7 @@ class UsersController extends AUserData {
|
|||
if ($quota === false) {
|
||||
throw new OCSException('Invalid quota value '.$value, 103);
|
||||
}
|
||||
if ($quota === 0) {
|
||||
$quota = 'default';
|
||||
}else if ($quota === -1) {
|
||||
if ($quota === -1) {
|
||||
$quota = 'none';
|
||||
} else {
|
||||
$quota = \OCP\Util::humanFileSize($quota);
|
||||
|
|
|
@ -202,7 +202,8 @@ class Quota extends Wrapper {
|
|||
}
|
||||
|
||||
public function mkdir($path) {
|
||||
if ($this->quota === 0.0) {
|
||||
$free = $this->free_space($path);
|
||||
if ($free === 0.0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -179,7 +179,7 @@ export default {
|
|||
}
|
||||
return disabledUsers;
|
||||
}
|
||||
if (!settings.isAdmin) {
|
||||
if (!this.settings.isAdmin) {
|
||||
// We don't want subadmins to edit themselves
|
||||
return this.users.filter(user => user.enabled !== false && user.id !== oc_current_user);
|
||||
}
|
||||
|
@ -249,7 +249,7 @@ export default {
|
|||
validateQuota(quota) {
|
||||
// only used for new presets sent through @Tag
|
||||
let validQuota = OC.Util.computerFileSize(quota);
|
||||
if (validQuota !== null && validQuota > 0) {
|
||||
if (validQuota !== null && validQuota >= 0) {
|
||||
// unify format output
|
||||
quota = OC.Util.humanFileSize(OC.Util.computerFileSize(quota));
|
||||
return this.newUser.quota = {id: quota, label: quota};
|
||||
|
|
|
@ -175,12 +175,12 @@ 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 === 0 || this.user.quota.quota === 'default') {
|
||||
} else if (this.user.quota.quota === 'default') {
|
||||
// default quota is replaced by the proper value on load
|
||||
return this.quotaOptions[0];
|
||||
}
|
||||
|
@ -437,9 +437,7 @@ export default {
|
|||
validateQuota(quota) {
|
||||
// only used for new presets sent through @Tag
|
||||
let validQuota = OC.Util.computerFileSize(quota);
|
||||
if (validQuota === 0) {
|
||||
return this.setUserQuota('none');
|
||||
} else if (validQuota !== null) {
|
||||
if (validQuota !== null && validQuota >= 0) {
|
||||
// unify format output
|
||||
return this.setUserQuota(OC.Util.humanFileSize(OC.Util.computerFileSize(quota)));
|
||||
}
|
||||
|
|
|
@ -118,7 +118,7 @@ const mutations = {
|
|||
setUserData(state, { userid, key, value }) {
|
||||
if (key === 'quota') {
|
||||
let humanValue = OC.Util.computerFileSize(value);
|
||||
state.users.find(user => user.id == userid)[key][key] = humanValue?humanValue:value;
|
||||
state.users.find(user => user.id == userid)[key][key] = humanValue!==null ? humanValue : value;
|
||||
} else {
|
||||
state.users.find(user => user.id == userid)[key] = value;
|
||||
}
|
||||
|
|
|
@ -63,8 +63,8 @@ export default {
|
|||
},
|
||||
data() {
|
||||
return {
|
||||
// default quota is unlimited
|
||||
unlimitedQuota: {id:'default', label:t('settings', 'Unlimited')},
|
||||
// default quota is set to unlimited
|
||||
unlimitedQuota: {id: 'none', label: t('settings', 'Unlimited')},
|
||||
// temporary value used for multiselect change
|
||||
selectedQuota: false,
|
||||
showConfig: {
|
||||
|
|
|
@ -112,4 +112,13 @@ Feature: users
|
|||
# https://github.com/minkphp/MinkSelenium2Driver/pull/244
|
||||
# When I set the user user0 quota to 1GB
|
||||
# And I see that the quota cell for user user0 is done loading
|
||||
# Then I see that the user quota of user0 is "1 GB"
|
||||
# Then I see that the user quota of user0 is "1 GB"
|
||||
# When I set the user user0 quota to Unlimited
|
||||
# And I see that the quota cell for user user0 is done loading
|
||||
# Then I see that the user quota of user0 is Unlimited
|
||||
# When I set the user user0 quota to 0
|
||||
# And I see that the quota cell for user user0 is done loading
|
||||
# Then I see that the user quota of user0 is "0 B"
|
||||
# When I set the user user0 quota to Default
|
||||
# And I see that the quota cell for user user0 is done loading
|
||||
# Then I see that the user quota of user0 is "Default quota"
|
Loading…
Reference in New Issue