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.ts23
-rw-r--r--apps/settings/src/utils/appDiscoverParser.ts21
-rw-r--r--apps/settings/src/utils/handlers.js48
-rw-r--r--apps/settings/src/utils/handlers.ts33
-rw-r--r--apps/settings/src/utils/sorting.ts14
-rw-r--r--apps/settings/src/utils/userUtils.ts29
-rw-r--r--apps/settings/src/utils/validate.js23
7 files changed, 62 insertions, 129 deletions
diff --git a/apps/settings/src/utils/appDiscoverParser.spec.ts b/apps/settings/src/utils/appDiscoverParser.spec.ts
index e00b24dff49..2a631014679 100644
--- a/apps/settings/src/utils/appDiscoverParser.spec.ts
+++ b/apps/settings/src/utils/appDiscoverParser.spec.ts
@@ -1,28 +1,11 @@
/**
- * @copyright Copyright (c) 2024 Ferdinand Thiessen <opensource@fthiessen.de>
- *
- * @author Ferdinand Thiessen <opensource@fthiessen.de>
- *
- * @license AGPL-3.0-or-later
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
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/appDiscoverParser.ts b/apps/settings/src/utils/appDiscoverParser.ts
index 96f7d3e4b7d..1be44f01068 100644
--- a/apps/settings/src/utils/appDiscoverParser.ts
+++ b/apps/settings/src/utils/appDiscoverParser.ts
@@ -1,23 +1,6 @@
/**
- * @copyright Copyright (c) 2024 Ferdinand Thiessen <opensource@fthiessen.de>
- *
- * @author Ferdinand Thiessen <opensource@fthiessen.de>
- *
- * @license AGPL-3.0-or-later
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
import type { IAppDiscoverCarousel, IAppDiscoverElement, IAppDiscoverElements, IAppDiscoverPost, IAppDiscoverShowcase } from '../constants/AppDiscoverTypes.ts'
diff --git a/apps/settings/src/utils/handlers.js b/apps/settings/src/utils/handlers.js
deleted file mode 100644
index 076aaf03e67..00000000000
--- a/apps/settings/src/utils/handlers.js
+++ /dev/null
@@ -1,48 +0,0 @@
-/**
- * @copyright 2023 Christopher Ng <chrng8@gmail.com>
- *
- * @author Christopher Ng <chrng8@gmail.com>
- *
- * @license AGPL-3.0-or-later
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-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
- */
-export const handleError = (error, message) => {
- let fullMessage = ''
-
- if (message) {
- fullMessage += message
- }
-
- if (error.response?.status === 429) {
- if (fullMessage) {
- fullMessage += '\n'
- }
- fullMessage += t('settings', 'There were too many requests from your network. Retry later or contact your administrator if this is an error.')
- }
-
- showError(fullMessage)
- logger.error(fullMessage || t('Error'), error)
-}
diff --git a/apps/settings/src/utils/handlers.ts b/apps/settings/src/utils/handlers.ts
new file mode 100644
index 00000000000..edd9a6c0cff
--- /dev/null
+++ b/apps/settings/src/utils/handlers.ts
@@ -0,0 +1,33 @@
+/**
+ * SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
+ * 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 error the error
+ * @param message the message to display
+ */
+export function handleError(error: AxiosError, message: string) {
+ let fullMessage = ''
+
+ if (message) {
+ fullMessage += message
+ }
+
+ if (error.response?.status === 429) {
+ if (fullMessage) {
+ fullMessage += '\n'
+ }
+ 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, { 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 b6c96624139..7d9a516a542 100644
--- a/apps/settings/src/utils/userUtils.ts
+++ b/apps/settings/src/utils/userUtils.ts
@@ -1,25 +1,10 @@
/**
- * @copyright 2023 Christopher Ng <chrng8@gmail.com>
- *
- * @author Christopher Ng <chrng8@gmail.com>
- *
- * @license AGPL-3.0-or-later
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
+import { translate as t } from '@nextcloud/l10n'
+
export const unlimitedQuota = {
id: 'none',
label: t('settings', 'Unlimited'),
@@ -33,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 4ea95593fbc..0f76f4e6dc5 100644
--- a/apps/settings/src/utils/validate.js
+++ b/apps/settings/src/utils/validate.js
@@ -1,23 +1,6 @@
/**
- * @copyright 2021, Christopher Ng <chrng8@gmail.com>
- *
- * @author Christopher Ng <chrng8@gmail.com>
- *
- * @license AGPL-3.0-or-later
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2021 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
/*
@@ -26,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