aboutsummaryrefslogtreecommitdiffstats
path: root/apps/settings/src/utils
diff options
context:
space:
mode:
Diffstat (limited to 'apps/settings/src/utils')
-rw-r--r--apps/settings/src/utils/appDiscoverParser.spec.ts2
-rw-r--r--apps/settings/src/utils/handlers.ts (renamed from apps/settings/src/utils/handlers.js)10
-rw-r--r--apps/settings/src/utils/sorting.ts14
-rw-r--r--apps/settings/src/utils/userUtils.ts8
-rw-r--r--apps/settings/src/utils/validate.js2
5 files changed, 27 insertions, 9 deletions
diff --git a/apps/settings/src/utils/appDiscoverParser.spec.ts b/apps/settings/src/utils/appDiscoverParser.spec.ts
index f025b1346fb..2a631014679 100644
--- a/apps/settings/src/utils/appDiscoverParser.spec.ts
+++ b/apps/settings/src/utils/appDiscoverParser.spec.ts
@@ -5,7 +5,7 @@
import type { IAppDiscoverElement } from '../constants/AppDiscoverTypes'
-import { describe, expect, it } from '@jest/globals'
+import { describe, expect, it } from 'vitest'
import { filterElements, parseApiResponse } from './appDiscoverParser'
describe('App Discover API parser', () => {
diff --git a/apps/settings/src/utils/handlers.js b/apps/settings/src/utils/handlers.ts
index 276ab675050..edd9a6c0cff 100644
--- a/apps/settings/src/utils/handlers.js
+++ b/apps/settings/src/utils/handlers.ts
@@ -3,16 +3,17 @@
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
+import type { AxiosError } from '@nextcloud/axios'
import { showError } from '@nextcloud/dialogs'
import { translate as t } from '@nextcloud/l10n'
import logger from '../logger.ts'
/**
- * @param {import('axios').AxiosError} error the error
- * @param {string?} message the message to display
+ * @param error the error
+ * @param message the message to display
*/
-export const handleError = (error, message) => {
+export function handleError(error: AxiosError, message: string) {
let fullMessage = ''
if (message) {
@@ -26,6 +27,7 @@ export const handleError = (error, message) => {
fullMessage += t('settings', 'There were too many requests from your network. Retry later or contact your administrator if this is an error.')
}
+ fullMessage = fullMessage || t('settings', 'Error')
showError(fullMessage)
- logger.error(fullMessage || t('Error'), error)
+ logger.error(fullMessage, { error })
}
diff --git a/apps/settings/src/utils/sorting.ts b/apps/settings/src/utils/sorting.ts
new file mode 100644
index 00000000000..88f877733cc
--- /dev/null
+++ b/apps/settings/src/utils/sorting.ts
@@ -0,0 +1,14 @@
+/**
+ * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+
+import { getCanonicalLocale, getLanguage } from '@nextcloud/l10n'
+
+export const naturalCollator = Intl.Collator(
+ [getLanguage(), getCanonicalLocale()],
+ {
+ numeric: true,
+ usage: 'sort',
+ },
+)
diff --git a/apps/settings/src/utils/userUtils.ts b/apps/settings/src/utils/userUtils.ts
index 0d62138d7fe..7d9a516a542 100644
--- a/apps/settings/src/utils/userUtils.ts
+++ b/apps/settings/src/utils/userUtils.ts
@@ -3,6 +3,8 @@
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
+import { translate as t } from '@nextcloud/l10n'
+
export const unlimitedQuota = {
id: 'none',
label: t('settings', 'Unlimited'),
@@ -16,10 +18,10 @@ export const defaultQuota = {
/**
* Return `true` if the logged in user does not have permissions to view the
* data of `user`
- * @param user
- * @param user.id
+ * @param user The user to check
+ * @param user.id Id of the user
*/
-export const isObfuscated = (user: { id: string, [key: string]: any }) => {
+export const isObfuscated = (user: { id: string, [key: string]: unknown }) => {
const keys = Object.keys(user)
return keys.length === 1 && keys.at(0) === 'id'
}
diff --git a/apps/settings/src/utils/validate.js b/apps/settings/src/utils/validate.js
index d13ad52b026..0f76f4e6dc5 100644
--- a/apps/settings/src/utils/validate.js
+++ b/apps/settings/src/utils/validate.js
@@ -9,7 +9,7 @@
* TODO add nice validation errors for Profile page settings modal
*/
-import { VALIDATE_EMAIL_REGEX } from '../constants/AccountPropertyConstants.js'
+import { VALIDATE_EMAIL_REGEX } from '../constants/AccountPropertyConstants.ts'
/**
* Validate the email input