Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable30] fix(settings): Correctly parse and display default quota #50218

Merged
merged 2 commits into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 28 additions & 11 deletions apps/settings/src/components/Users/UserSettingsDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,14 @@
<NcAppSettingsSection id="default-settings"
:name="t('settings', 'Defaults')">
<NcSelect v-model="defaultQuota"
:clearable="false"
:create-option="validateQuota"
:filter-by="filterQuotas"
:input-label="t('settings', 'Default quota')"
placement="top"
:taggable="true"
:options="quotaOptions"
:create-option="validateQuota"
placement="top"
:placeholder="t('settings', 'Select default quota')"
:clearable="false"
taggable
@option:selected="setDefaultQuota" />
</NcAppSettingsSection>
</NcAppSettingsDialog>
Expand All @@ -95,6 +96,7 @@ import NcSelect from '@nextcloud/vue/dist/Components/NcSelect.js'

import { GroupSorting } from '../../constants/GroupManagement.ts'
import { unlimitedQuota } from '../../utils/userUtils.ts'
import logger from '../../logger.ts'

export default {
name: 'UserSettingsDialog',
Expand Down Expand Up @@ -229,8 +231,8 @@ export default {
newUserSendEmail: value,
})
await axios.post(generateUrl('/settings/users/preferences/newUser.sendEmail'), { value: value ? 'yes' : 'no' })
} catch (e) {
console.error('could not update newUser.sendEmail preference: ' + e.message, e)
} catch (error) {
logger.error('Could not update newUser.sendEmail preference', { error })
} finally {
this.loadingSendMail = false
}
Expand All @@ -239,6 +241,22 @@ export default {
},

methods: {
/**
* Check if a quota matches the current search.
* This is a custom filter function to allow to map "1GB" to the label "1 GB" (ignoring whitespaces).
*
* @param option The quota to check
* @param label The label of the quota
* @param search The search string
*/
filterQuotas(option, label, search) {
const searchValue = search.toLocaleLowerCase().replaceAll(/\s/g, '')
return (label || '')
.toLocaleLowerCase()
.replaceAll(/\s/g, '')
.indexOf(searchValue) > -1
},

setShowConfig(key, status) {
this.$store.commit('setShowConfig', { key, value: status })
},
Expand All @@ -254,14 +272,13 @@ export default {
quota = quota?.id || quota.label
}
// only used for new presets sent through @Tag
const validQuota = parseFileSize(quota)
const validQuota = parseFileSize(quota, true)
if (validQuota === null) {
return unlimitedQuota
} else {
// unify format output
quota = formatFileSize(parseFileSize(quota))
return { id: quota, label: quota }
}
// unify format output
quota = formatFileSize(validQuota)
return { id: quota, label: quota }
},

/**
Expand Down
4 changes: 2 additions & 2 deletions dist/settings-users-3239.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/settings-users-3239.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/settings-vue-settings-apps-users-management.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/settings-vue-settings-apps-users-management.js.map

Large diffs are not rendered by default.

Loading