Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
fix(Users/Quota setting): Prevent floating point value from getting t…
…runcated in locales other than english

fixes #18468

Signed-off-by: Marcel Klehr <[email protected]>
  • Loading branch information
marcelklehr committed Jan 18, 2024
commit fa2cf8d80538348b9a9c969f350ae49e2260b80c
5 changes: 3 additions & 2 deletions apps/settings/src/components/UserList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ import Vue from 'vue'
import NcModal from '@nextcloud/vue/dist/Components/NcModal.js'
import NcButton from '@nextcloud/vue/dist/Components/NcButton.js'
import NcMultiselect from '@nextcloud/vue/dist/Components/NcMultiselect.js'
import { formatFileSize, parseFileSize } from '@nextcloud/files'

import userRow from './UserList/UserRow.vue'

Expand Down Expand Up @@ -486,10 +487,10 @@ export default {
*/
validateQuota(quota) {
// only used for new presets sent through @Tag
const validQuota = OC.Util.computerFileSize(quota)
const validQuota = parseFileSize(quota, true)
if (validQuota !== null && validQuota >= 0) {
// unify format output
quota = OC.Util.humanFileSize(OC.Util.computerFileSize(quota))
quota = formatFileSize(parseFileSize(quota, true))
this.newUser.quota = { id: quota, label: quota }
return this.newUser.quota
}
Expand Down
7 changes: 4 additions & 3 deletions apps/settings/src/components/UserList/UserRow.vue
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@

<script>
import ClickOutside from 'vue-click-outside'
import { formatFileSize, parseFileSize } from '@nextcloud/files'

import {
NcPopoverMenu,
Expand Down Expand Up @@ -688,7 +689,7 @@ export default {
await this.$store.dispatch('setUserData', {
userid: this.user.id,
key: 'quota',
value: quota,
value: '' + parseFileSize(quota, true),
})
} catch (error) {
console.error(error)
Expand All @@ -706,10 +707,10 @@ export default {
*/
validateQuota(quota) {
// only used for new presets sent through @Tag
const validQuota = OC.Util.computerFileSize(quota)
const validQuota = parseFileSize(quota, true)
if (validQuota !== null && validQuota >= 0) {
// unify format output
return this.setUserQuota(OC.Util.humanFileSize(OC.Util.computerFileSize(quota)))
return this.setUserQuota(formatFileSize(parseFileSize(quota, true)))
}
// if no valid do not change
return false
Expand Down
3 changes: 2 additions & 1 deletion apps/settings/src/store/users.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import api from './api.js'
import axios from '@nextcloud/axios'
import { generateOcsUrl } from '@nextcloud/router'
import logger from '../logger.js'
import { parseFileSize } from '@nextcloud/files'

const orderGroups = function(groups, orderBy) {
/* const SORT_USERCOUNT = 1;
Expand Down Expand Up @@ -211,7 +212,7 @@ const mutations = {
},
setUserData(state, { userid, key, value }) {
if (key === 'quota') {
const humanValue = OC.Util.computerFileSize(value)
const humanValue = parseFileSize(value, true)
state.users.find(user => user.id === userid)[key][key] = humanValue !== null ? humanValue : value
} else {
state.users.find(user => user.id === userid)[key] = value
Expand Down
4 changes: 2 additions & 2 deletions core/src/components/UserMenu/UserMenuEntry.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@
<NcLoadingIcon v-if="loading"
class="menu-entry__loading-icon"
:size="18" />
<img v-else :src="cachedIcon" alt="" />
<img v-else :src="cachedIcon" alt="">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In future let's not add unrelated changes in backports @marcelklehr ;)

{{ name }}
</a>
<button v-else>
<img :src="cachedIcon" alt="" />
<img :src="cachedIcon" alt="">
{{ name }}
</button>
</li>
Expand Down
Loading