]> source.dussan.org Git - nextcloud-server.git/commitdiff
fix(code-style): Adjust JS code to our code style
authorFerdinand Thiessen <opensource@fthiessen.de>
Wed, 16 Oct 2024 12:06:49 +0000 (14:06 +0200)
committerFerdinand Thiessen <opensource@fthiessen.de>
Wed, 16 Oct 2024 20:11:59 +0000 (22:11 +0200)
This resolves 68 ESLint warnings about invalid code style.

Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
36 files changed:
apps/comments/src/comments-activity-tab.ts
apps/files/src/store/viewConfig.ts
apps/files/src/views/FilesList.vue
apps/files_external/src/actions/enterCredentialsAction.ts
apps/files_external/src/actions/inlineStorageCheckAction.ts
apps/files_sharing/src/files_views/shares.spec.ts
apps/files_sharing/src/mixins/ShareRequests.js
apps/files_sharing/src/models/Share.ts
apps/files_sharing/src/utils/GeneratePassword.ts
apps/files_sharing/src/views/SharingDetailsTab.vue
apps/files_sharing/src/views/SharingTab.vue
apps/files_versions/src/files_versions_tab.js
apps/files_versions/src/views/VersionTab.vue
apps/settings/src/admin.js
apps/settings/src/components/AuthToken.vue
apps/settings/src/components/BasicSettings/BackgroundJob.vue
apps/settings/src/components/Encryption.vue
apps/settings/src/components/Markdown.vue
apps/settings/src/components/PersonalInfo/BirthdaySection.vue
apps/settings/src/components/PersonalInfo/DetailsSection.vue
apps/settings/src/components/Users/NewUserDialog.vue
apps/settings/src/main-apps-users-management.ts
apps/settings/src/main-declarative-settings-forms.ts
apps/settings/src/mixins/UserRowMixin.js
apps/settings/src/utils/userUtils.ts
apps/systemtags/src/services/api.ts
apps/systemtags/src/services/files.ts
apps/user_status/src/UserStatus.vue
apps/user_status/src/services/statusService.js
core/js/tests/html-domparser.js
core/src/OCP/loader.js
core/src/install.js
core/src/jquery/avatar.js
core/src/services/UnifiedSearchService.js
core/src/systemtags/systemtagmodel.js
tests/karma.config.js

index f38484d25e77aed29249dfdf08f81c4f3148623f..f092f2b8f5b13e05fbdc4351e35180d1a6789021 100644 (file)
@@ -24,7 +24,7 @@ export function registerCommentsPlugins() {
 
                        if (!ActivityTabPluginView) {
                                const { default: ActivityCommentAction } = await import('./views/ActivityCommentAction.vue')
-                               /** @ts-expect-error Types are broken for Vue2 */
+                               // @ts-expect-error Types are broken for Vue2
                                ActivityTabPluginView = Vue.extend(ActivityCommentAction)
                        }
                        ActivityTabPluginInstance = new ActivityTabPluginView({
@@ -50,7 +50,7 @@ export function registerCommentsPlugins() {
                const { data: comments } = await getComments({ resourceType: 'files', resourceId: fileInfo.id }, { limit, offset })
                logger.debug('Loaded comments', { fileInfo, comments })
                const { default: CommentView } = await import('./views/ActivityCommentEntry.vue')
-               /** @ts-expect-error Types are broken for Vue2 */
+               // @ts-expect-error Types are broken for Vue2
                const CommentsViewObject = Vue.extend(CommentView)
 
                return comments.map((comment) => ({
index 08d75b3d05047d28ac9395d0633a8035e300b851..76786306d60b0c55b8cb69c821c74db37963bfe1 100644 (file)
@@ -59,8 +59,8 @@ export const useViewConfigStore = function(...args) {
                         * Set the sorting key AND sort by ASC
                         * The key param must be a valid key of a File object
                         * If not found, will be searched within the File attributes
-                        * @param key
-                        * @param view
+                        * @param key Key to sort by
+                        * @param view View to set the sorting key for
                         */
                        setSortingBy(key = 'basename', view = 'files') {
                                // Save new config
@@ -70,7 +70,7 @@ export const useViewConfigStore = function(...args) {
 
                        /**
                         * Toggle the sorting direction
-                        * @param view
+                        * @param view view to set the sorting order for
                         */
                        toggleSortingDirection(view = 'files') {
                                const config = this.getConfig(view) || { sorting_direction: 'asc' }
index 5341502df249d7061cb421b5d4e19fb4b9c5620c..9383f98a00bfc6dda6c75a8d4b1fa0ff4e62bf3a 100644 (file)
@@ -410,7 +410,7 @@ export default defineComponent({
 
                showCustomEmptyView() {
                        return !this.loading && this.isEmptyDir && this.currentView?.emptyView !== undefined
-               }
+               },
        },
 
        watch: {
index 29d660315b469f61969227602501298b76b2d422..20821298db5dbe27f7c6268993121dd332f57c46 100644 (file)
@@ -23,8 +23,15 @@ type CredentialResponse = {
        password?: string,
 }
 
+/**
+ * Set credentials for external storage
+ *
+ * @param node The node for which to set the credentials
+ * @param login The username
+ * @param password The password
+ */
 async function setCredentials(node: Node, login: string, password: string): Promise<null|true> {
-       const configResponse = await axios.put(generateUrl('apps/files_external/userglobalstorages/{id}', node.attributes), {
+       const configResponse = await axios.put(generateUrl('apps/files_external/userglobalstorages/{id}', { id: node.attributes.id }), {
                backendOptions: { user: login, password },
        }) as AxiosResponse<StorageConfig>
 
index a213c196b50374039d1c591b27a6f0e9dd3a20e1..42b1d5b371862b80734eb790f4bfec65fa214301 100644 (file)
@@ -30,7 +30,8 @@ export const action = new FileAction({
        /**
         * Use this function to check the storage availability
         * We then update the node attributes directly.
-        * @param node
+        *
+        * @param node The node to render inline
         */
        async renderInline(node: Node) {
                let config = null as unknown as StorageConfig
index 153057bc0ad697f45b0a53cc9660386db097695f..79ef2a09843e329b1d7a93be076ed29e2aefd409 100644 (file)
@@ -3,6 +3,7 @@
  * SPDX-License-Identifier: AGPL-3.0-or-later
  */
 /* eslint-disable n/no-extraneous-import */
+/* eslint-disable @typescript-eslint/no-explicit-any */
 import type { OCSResponse } from '@nextcloud/typings/ocs'
 import { Folder, Navigation, View, getNavigation } from '@nextcloud/files'
 import { beforeEach, describe, expect, test, vi } from 'vitest'
index dcccd5e78ed926204713fcdb1ed34f64fa01cf30..24b4b12061e8760bc13b1acbb12c25bc207af128 100644 (file)
@@ -26,10 +26,10 @@ export default {
                 * @param {string} [data.password]  password to protect public link Share with
                 * @param {number} [data.permissions]  1 = read; 2 = update; 4 = create; 8 = delete; 16 = share; 31 = all (default: 31, for public shares: 1)
                 * @param {boolean} [data.sendPasswordByTalk] send the password via a talk conversation
-                * @param {string} [data.expireDate] expire the shareautomatically after
+                * @param {string} [data.expireDate] expire the share automatically after
                 * @param {string} [data.label] custom label
                 * @param {string} [data.attributes] Share attributes encoded as json
-                * @param data.note
+                * @param {string} data.note custom note to recipient
                 * @return {Share} the new share
                 * @throws {Error}
                 */
index dab409853d067bf6ef80e4f6a615a457cc161f4f..bfc6357240d2f134339a4c88f6c4149568cc4c28 100644 (file)
@@ -314,7 +314,7 @@ export default class Share {
 
        /**
         * Get the shared item id
-                */
+        */
        get fileSource(): number {
                return this._share.file_source
        }
index bbfa5e7b27d874b969252f430da55c416d65cce0..2f3f65c51d8e9e98e0832a6d8aa175cafd377ccd 100644 (file)
@@ -13,9 +13,9 @@ const config = new Config()
 const passwordSet = 'abcdefgijkmnopqrstwxyzABCDEFGHJKLMNPQRSTWXYZ23456789'
 
 /**
- * Generate a valid policy password or
- * request a valid password if password_policy
- * is enabled
+ * Generate a valid policy password or request a valid password if password_policy is enabled
+ *
+ * @param {boolean} verbose If enabled the the status is shown to the user via toast
  */
 export default async function(verbose = false): Promise<string> {
        // password policy is enabled, let's request a pass
index baa098352d1e713f76ee7be82b3ce0ccdba20026..3f9dca57d03cc7db17dcdb6a95de7bd021946962 100644 (file)
 import { emit } from '@nextcloud/event-bus'
 import { getLanguage } from '@nextcloud/l10n'
 import { ShareType } from '@nextcloud/sharing'
+import moment from '@nextcloud/moment'
 
 import NcAvatar from '@nextcloud/vue/dist/Components/NcAvatar.js'
 import NcButton from '@nextcloud/vue/dist/Components/NcButton.js'
index 318b8ca3b569907127018da41c899a2dedc0c61e..6870e43d81668bf7abe91e3cd8a6f942a26ff1dd 100644 (file)
 </template>
 
 <script>
-import axios from '@nextcloud/axios'
+import { getCurrentUser } from '@nextcloud/auth'
 import { orderBy } from '@nextcloud/files'
 import { loadState } from '@nextcloud/initial-state'
 import { generateOcsUrl } from '@nextcloud/router'
 import { CollectionList } from 'nextcloud-vue-collections'
+
+import axios from '@nextcloud/axios'
+import moment from '@nextcloud/moment'
 import NcAvatar from '@nextcloud/vue/dist/Components/NcAvatar.js'
 
-import Config from '../services/ConfigService.ts'
 import { shareWithTitle } from '../utils/SharedWithMe.js'
+
+import Config from '../services/ConfigService.ts'
 import Share from '../models/Share.ts'
 import ShareTypes from '../mixins/ShareTypes.js'
 import SharingEntryInternal from '../components/SharingEntryInternal.vue'
@@ -241,7 +245,7 @@ export default {
                updateExpirationSubtitle(share) {
                        const expiration = moment(share.expireDate).unix()
                        this.$set(this.sharedWithMe, 'subtitle', t('files_sharing', 'Expires {relativetime}', {
-                               relativetime: OC.Util.relativeModifiedDate(expiration * 1000),
+                               relativetime: moment(expiration * 1000).fromNow(),
                        }))
 
                        // share have expired
@@ -310,7 +314,7 @@ export default {
                                        // interval update
                                        this.expirationInterval = setInterval(this.updateExpirationSubtitle, 10000, share)
                                }
-                       } else if (this.fileInfo && this.fileInfo.shareOwnerId !== undefined ? this.fileInfo.shareOwnerId !== OC.currentUser : false) {
+                       } else if (this.fileInfo && this.fileInfo.shareOwnerId !== undefined ? this.fileInfo.shareOwnerId !== getCurrentUser().uid : false) {
                                // Fallback to compare owner and current user.
                                this.sharedWithMe = {
                                        displayName: this.fileInfo.shareOwner,
index 011cde11c0412b7211971434bd8f9a47b0f69d3c..12f36bad24ade7e0ac94d9b30c08ca8f2bed3fbe 100644 (file)
@@ -7,14 +7,14 @@ import Vue from 'vue'
 import { translate as t, translatePlural as n } from '@nextcloud/l10n'
 
 import VersionTab from './views/VersionTab.vue'
-import VTooltip from 'v-tooltip'
+import VTooltipPlugin from 'v-tooltip'
 // eslint-disable-next-line n/no-missing-import, import/no-unresolved
 import BackupRestore from '@mdi/svg/svg/backup-restore.svg?raw'
 
 Vue.prototype.t = t
 Vue.prototype.n = n
 
-Vue.use(VTooltip)
+Vue.use(VTooltipPlugin)
 
 // Init Sharing tab component
 const View = Vue.extend(VersionTab)
index 6fa5ac3fcaa75efd55a94904857bd7c81f5607b4..658b95c8e99a27b4c7ea1e0b6963c25006336cb6 100644 (file)
@@ -177,7 +177,7 @@ export default {
                /**
                 * Handle restored event from Version.vue
                 *
-                * @param {import('../utils/versions.ts').Version} version
+                * @param {import('../utils/versions.ts').Version} version The version to restore
                 */
                async handleRestore(version) {
                        // Update local copy of fileInfo as rendering depends on it.
@@ -217,7 +217,7 @@ export default {
 
                /**
                 * Handle label-updated event from Version.vue
-                * @param {import('../utils/versions.ts').Version} version
+                * @param {import('../utils/versions.ts').Version} version The version to update
                 */
                handleLabelUpdateRequest(version) {
                        this.showVersionLabelForm = true
@@ -226,7 +226,7 @@ export default {
 
                /**
                 * Handle label-updated event from Version.vue
-                * @param {string} newLabel
+                * @param {string} newLabel The new label
                 */
                async handleLabelUpdate(newLabel) {
                        const oldLabel = this.editedVersion.label
@@ -246,8 +246,7 @@ export default {
                /**
                 * Handle deleted event from Version.vue
                 *
-                * @param {import('../utils/versions.ts').Version} version
-                * @param {string} newName
+                * @param {import('../utils/versions.ts').Version} version The version to delete
                 */
                async handleDelete(version) {
                        const index = this.versions.indexOf(version)
index 88b32f941a5be294ba76a94867928b378064a4e9..52778aec7df7166c313d71ec7a753cc5fbbf880d 100644 (file)
@@ -3,11 +3,12 @@
  * SPDX-License-Identifier: AGPL-3.0-or-later
  */
 
+import { generateUrl } from '@nextcloud/router'
 import $ from 'jquery'
 
 window.addEventListener('DOMContentLoaded', () => {
        $('#loglevel').change(function() {
-               $.post(OC.generateUrl('/settings/admin/log/level'), { level: $(this).val() }, () => {
+               $.post(generateUrl('/settings/admin/log/level'), { level: $(this).val() }, () => {
                        OC.Log.reload()
                })
        })
@@ -48,7 +49,7 @@ window.addEventListener('DOMContentLoaded', () => {
 
                OC.msg.startSaving('#mail_settings_msg')
                $.ajax({
-                       url: OC.generateUrl('/settings/admin/mailsettings'),
+                       url: generateUrl('/settings/admin/mailsettings'),
                        type: 'POST',
                        data: $('#mail_general_settings_form').serialize(),
                        success: () => {
@@ -68,7 +69,7 @@ window.addEventListener('DOMContentLoaded', () => {
 
                OC.msg.startSaving('#mail_settings_msg')
                $.ajax({
-                       url: OC.generateUrl('/settings/admin/mailsettings/credentials'),
+                       url: generateUrl('/settings/admin/mailsettings/credentials'),
                        type: 'POST',
                        data: $('#mail_credentials_settings').serialize(),
                        success: () => {
@@ -94,7 +95,7 @@ window.addEventListener('DOMContentLoaded', () => {
                OC.msg.startAction('#sendtestmail_msg', t('settings', 'Sending…'))
 
                $.ajax({
-                       url: OC.generateUrl('/settings/admin/mailtest'),
+                       url: generateUrl('/settings/admin/mailtest'),
                        type: 'POST',
                        success: () => {
                                OC.msg.finishedSuccess('#sendtestmail_msg', t('settings', 'Email sent'))
index 2efe2db41459a031bb1d3b9dd9ef77629663fd7e..9e77d8b3749fddf31100e976eadde8fe46b7be22 100644 (file)
@@ -175,8 +175,8 @@ export default defineComponent({
                        return this.token.type === TokenType.PERMANENT_TOKEN
                },
                /**
-                * Object ob the current user agend used by the token
-                * @return Either an object containing user agent information or null if unknown
+                * Object ob the current user agent used by the token
+                * This either returns an object containing user agent information or `null` if unknown
                 */
                client() {
                        // pretty format sync client user agent
index 835f65a2477f77e930198c205e8587d2ee3ca74b..4924014b78a45013738066846ff166edbe78cb27 100644 (file)
@@ -56,6 +56,7 @@
                        @update:checked="onBackgroundJobModeChanged">
                        {{ t('settings', 'Cron (Recommended)') }}
                </NcCheckboxRadioSwitch>
+               <!-- eslint-disable-next-line vue/no-v-html The translation is sanitized-->
                <em v-html="cronLabel" />
        </NcSettingsSection>
 </template>
@@ -111,7 +112,7 @@ export default {
                                desc += '<br>' + t('settings', 'The PHP POSIX extension is required. See {linkstart}PHP documentation{linkend} for more details.', {
                                        linkstart: '<a target="_blank" rel="noreferrer nofollow" class="external" href="https://www.php.net/manual/en/book.posix.php">',
                                        linkend: '</a>',
-                               }, undefined, { escape: false, sanitize: false })
+                               }, undefined, { escape: false })
                        }
                        return desc
                },
index 72b597c61d366a957575f2ffea0df1746c5bac8d..4d80f9b98338e73ea4a4ed27d4f69e52540da387 100644 (file)
                                </template>
                        </div>
 
-                       <div v-else-if="externalBackendsEnabled" v-html="migrationMessage" />
+                       <div v-else-if="externalBackendsEnabled">
+                               {{
+                                       t(
+                                               'settings',
+                                               'You need to migrate your encryption keys from the old encryption (ownCloud <= 8.0) to the new one. Please enable the "Default encryption module" and run {command}',
+                                               { command: '"occ encryption:migrate"' },
+                                       )
+                               }}
+                       </div>
                </div>
        </NcSettingsSection>
 </template>
@@ -92,13 +100,6 @@ export default {
                        defaultCheckedModule: Object.entries(encryptionModules).find((module) => module[1].default)[0],
                }
        },
-       computed: {
-               migrationMessage() {
-                       return t('settings', 'You need to migrate your encryption keys from the old encryption (ownCloud <= 8.0) to the new one. Please enable the "Default encryption module" and run {command}', {
-                               command: '"occ encryption:migrate"',
-                       })
-               },
-       },
        methods: {
                displayWarning() {
                        if (!this.encryptionEnabled) {
index f3b8747119d38763d8fb40ebe914c6f1286a26ce..dc7a076a70023af303c39f2c57ffc227081016be 100644 (file)
@@ -4,6 +4,7 @@
 -->
 
 <template>
+       <!-- eslint-disable-next-line vue/no-v-html This is rendered markdown so should be "safe" -->
        <div class="settings-markdown" v-html="renderMarkdown" />
 </template>
 
index 86917257600be0e53a5aeba64e0fbfb4fc173f35..633794d9d5db189edfeaa07fbbebb84e09532fb5 100644 (file)
@@ -8,13 +8,11 @@
                        :input-id="inputId"
                        :readable="birthdate.readable" />
 
-               <template>
-                       <NcDateTimePickerNative :id="inputId"
-                               type="date"
-                               label=""
-                               :value="value"
-                               @input="onInput" />
-               </template>
+               <NcDateTimePickerNative :id="inputId"
+                       type="date"
+                       label=""
+                       :value="value"
+                       @input="onInput" />
 
                <p class="property__helper-text-message">
                        {{ t('settings', 'Enter your date of birth') }}
@@ -66,7 +64,7 @@ export default {
                        get() {
                                return new Date(this.birthdate.value)
                        },
-                       /** @param {Date} value */
+                       /** @param {Date} value The date to set */
                        set(value) {
                                const day = value.getDate().toString().padStart(2, '0')
                                const month = (value.getMonth() + 1).toString().padStart(2, '0')
index a69b6d58ed73f4124b29527bbfb9740a4bbf46b3..a5de95f7ee548c1289a103c4ff88dce6187c88a9 100644 (file)
@@ -20,6 +20,7 @@
                        <div class="details__quota">
                                <CircleSlice :size="20" />
                                <div class="details__quota-info">
+                                       <!-- eslint-disable-next-line vue/no-v-html -->
                                        <p class="details__quota-text" v-html="quotaText" />
                                        <NcProgressBar size="medium"
                                                :value="usageRelative"
@@ -32,8 +33,9 @@
 
 <script>
 import { loadState } from '@nextcloud/initial-state'
-import NcProgressBar from '@nextcloud/vue/dist/Components/NcProgressBar.js'
+import { t } from '@nextcloud/l10n'
 
+import NcProgressBar from '@nextcloud/vue/dist/Components/NcProgressBar.js'
 import Account from 'vue-material-design-icons/Account.vue'
 import CircleSlice from 'vue-material-design-icons/CircleSlice3.vue'
 
@@ -64,12 +66,14 @@ export default {
        computed: {
                quotaText() {
                        if (quota === SPACE_UNLIMITED) {
-                               return t('settings', 'You are using <strong>{usage}</strong>', { usage })
+                               return t('settings', 'You are using {s}{usage}{/s}', { usage, s: '<strong>', '/s': '</strong>' }, undefined, { escape: false })
                        }
                        return t(
                                'settings',
-                               'You are using <strong>{usage}</strong> of <strong>{totalSpace}</strong> (<strong>{usageRelative}%</strong>)',
-                               { usage, totalSpace, usageRelative },
+                               'You are using {s}{usage}{/s} of {s}{totalSpace}{/s} ({s}{usageRelative}%{/s})',
+                               { usage, totalSpace, usageRelative, s: '<strong>', '/s': '</strong>' },
+                               undefined,
+                               { escape: false },
                        )
                },
        },
index bc6ba0901d9bb4be562ebbc1739aa4dcc3db4315..26e4afbd9245314be3adcac7029f3cc20448db8e 100644 (file)
 </template>
 
 <script>
+import { formatFileSize, parseFileSize } from '@nextcloud/files'
 import NcButton from '@nextcloud/vue/dist/Components/NcButton.js'
 import NcDialog from '@nextcloud/vue/dist/Components/NcDialog.js'
 import NcPasswordField from '@nextcloud/vue/dist/Components/NcPasswordField.js'
@@ -317,7 +318,7 @@ export default {
                        const validQuota = OC.Util.computerFileSize(quota)
                        if (validQuota !== null && validQuota >= 0) {
                                // unify format output
-                               quota = OC.Util.humanFileSize(OC.Util.computerFileSize(quota))
+                               quota = formatFileSize(parseFileSize(quota))
                                this.newUser.quota = { id: quota, label: quota }
                                return this.newUser.quota
                        }
index c923406ce7f18806d3a6f929850a3dde5754eaf7..f24562d3e82b6648a48f5cca4cf008795f7dc4f0 100644 (file)
@@ -4,9 +4,9 @@
  */
 
 import Vue from 'vue'
-import VTooltip from 'v-tooltip'
+import VTooltipPlugin from 'v-tooltip'
 import { sync } from 'vuex-router-sync'
-import { translate as t, translatePlural as n } from '@nextcloud/l10n'
+import { t, n } from '@nextcloud/l10n'
 
 import SettingsApp from './views/SettingsApp.vue'
 import router from './router/index.ts'
@@ -14,19 +14,18 @@ import { useStore } from './store/index.js'
 import { getCSPNonce } from '@nextcloud/auth'
 import { PiniaVuePlugin, createPinia } from 'pinia'
 
-Vue.use(VTooltip, { defaultHtml: false })
-
-const store = useStore()
-sync(store, router)
-
 // CSP config for webpack dynamic chunk loading
 // eslint-disable-next-line camelcase
 __webpack_nonce__ = getCSPNonce()
 
+const store = useStore()
+sync(store, router)
+
 // bind to window
 Vue.prototype.t = t
 Vue.prototype.n = n
 Vue.use(PiniaVuePlugin)
+Vue.use(VTooltipPlugin, { defaultHtml: false })
 
 const pinia = createPinia()
 
index 7cd4cb6834533df24d084add4ee17b1b6bcc6068..6e2d71b69ca56b2398199e364588a939cf60ef35 100644 (file)
@@ -5,9 +5,10 @@
 import type { ComponentInstance } from 'vue'
 
 import { loadState } from '@nextcloud/initial-state'
-import { translate as t, translatePlural as n } from '@nextcloud/l10n'
+import { t, n } from '@nextcloud/l10n'
 import Vue from 'vue'
 import DeclarativeSection from './components/DeclarativeSettings/DeclarativeSection.vue'
+import logger from './logger'
 
 interface DeclarativeFormField {
        id: string,
@@ -34,12 +35,10 @@ interface DeclarativeForm {
        fields: Array<DeclarativeFormField>,
 }
 
-const forms = loadState('settings', 'declarative-settings-forms', []) as Array<DeclarativeForm>
-console.debug('Loaded declarative forms:', forms)
+const forms = loadState<DeclarativeForm[]>('settings', 'declarative-settings-forms', [])
 
 /**
- *
- * @param forms
+ * @param forms The forms to render
  */
 function renderDeclarativeSettingsSections(forms: Array<DeclarativeForm>): ComponentInstance[] {
        Vue.mixin({ methods: { t, n } })
@@ -57,5 +56,6 @@ function renderDeclarativeSettingsSections(forms: Array<DeclarativeForm>): Compo
 }
 
 document.addEventListener('DOMContentLoaded', () => {
+       logger.debug('Loaded declarative forms', { forms })
        renderDeclarativeSettingsSections(forms)
 })
index a06b310bccaefb6f045421ef6b0c52002c6b1fd9..6ed29cf00492f78ed35157d3bb82dc43c43d7537 100644 (file)
@@ -3,6 +3,8 @@
  * SPDX-License-Identifier: AGPL-3.0-or-later
  */
 
+import { formatFileSize } from '@nextcloud/files'
+
 export default {
        props: {
                user: {
@@ -68,11 +70,10 @@ export default {
 
                /* QUOTA MANAGEMENT */
                usedSpace() {
-                       if (this.user.quota.used) {
-                               return t('settings', '{size} used', { size: OC.Util.humanFileSize(this.user.quota.used) })
-                       }
-                       return t('settings', '{size} used', { size: OC.Util.humanFileSize(0) })
+                       const quotaUsed = this.user.quota.used > 0 ? this.user.quota.used : 0
+                       return t('settings', '{size} used', { size: formatFileSize(quotaUsed, true) })
                },
+
                usedQuota() {
                        let quota = this.user.quota.quota
                        if (quota > 0) {
@@ -84,11 +85,12 @@ export default {
                        }
                        return isNaN(quota) ? 0 : quota
                },
+
                // Mapping saved values to objects
                userQuota() {
                        if (this.user.quota.quota >= 0) {
                                // if value is valid, let's map the quotaOptions or return custom quota
-                               const humanQuota = OC.Util.humanFileSize(this.user.quota.quota)
+                               const humanQuota = formatFileSize(this.user.quota.quota)
                                const userQuota = this.quotaOptions.find(quota => quota.id === humanQuota)
                                return userQuota || { id: humanQuota, label: humanQuota }
                        } else if (this.user.quota.quota === 'default') {
index 9ac21fd4c0e5351080446d99a2566d57638c56b4..7d9a516a5426c876269b8b26ad3600e9ce08be2c 100644 (file)
@@ -18,8 +18,8 @@ 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]: unknown }) => {
        const keys = Object.keys(user)
index 64ca97fc02c81e26e16a31e6ba74547121896677..1e2c9aeb9d421438a7cd9d11ceb48b638a76045b 100644 (file)
@@ -52,8 +52,9 @@ export const fetchLastUsedTagIds = async (): Promise<number[]> => {
 }
 
 /**
- * @param tag
- * @return created tag id
+ * Create a tag and return the Id of the newly created tag.
+ *
+ * @param tag The tag to create
  */
 export const createTag = async (tag: Tag | ServerTag): Promise<number> => {
        const path = '/systemtags'
index 74917bf0415d52adc54842b85535363098820748..8759a99d560c3dc9387641aee599b95556f606f9 100644 (file)
@@ -6,6 +6,7 @@
 import type { FileStat, ResponseDataDetailed } from 'webdav'
 import type { ServerTagWithId, Tag, TagWithId } from '../types.js'
 
+import { t } from '@nextcloud/l10n'
 import { davClient } from './davClient.js'
 import { createTag, fetchTagsPayload } from './api.js'
 import { formatTag, parseTags } from '../utils.js'
@@ -27,9 +28,11 @@ export const fetchTagsForFile = async (fileId: number): Promise<TagWithId[]> =>
 }
 
 /**
- * @param tag
- * @param fileId
- * @return created tag id
+ * Create a tag and apply it to a given file (by id).
+ * This returns the id of the newly created tag.
+ *
+ * @param tag The tag to create
+ * @param fileId Id of the file to tag
  */
 export const createTagForFile = async (tag: Tag, fileId: number): Promise<number> => {
        const tagToCreate = formatTag(tag)
index d25629f3e5f067471a2b790f519f3bf7f3fe5953..3ed24e419b88982be56142c9847e82fecc4410e1 100644 (file)
@@ -36,6 +36,7 @@
 </template>
 
 <script>
+import { getCurrentUser } from '@nextcloud/auth'
 import { subscribe, unsubscribe } from '@nextcloud/event-bus'
 import { Fragment } from 'vue-frag'
 import NcButton from '@nextcloud/vue/dist/Components/NcButton.js'
@@ -159,7 +160,7 @@ export default {
                        }
                },
                handleUserStatusUpdated(state) {
-                       if (OC.getCurrentUser().uid === state.userId) {
+                       if (getCurrentUser()?.uid === state.userId) {
                                this.$store.dispatch('setStatusFromObject', {
                                        status: state.status,
                                        icon: state.icon,
index fcaf2ef9902d97e24ded458d7cd0c6cc66327346..6504411c996a06d09a7c614939fb4ebc05bdacb3 100644 (file)
@@ -21,7 +21,7 @@ const fetchCurrentStatus = async () => {
 /**
  * Fetches the current user-status
  *
- * @param {string} userId
+ * @param {string} userId Id of the user to fetch the status
  * @return {Promise<object>}
  */
 const fetchBackupStatus = async (userId) => {
@@ -89,7 +89,7 @@ const clearMessage = async () => {
 /**
  * Revert the automated status
  *
- * @param {string} messageId
+ * @param {string} messageId ID of the message to revert
  * @return {Promise<object>}
  */
 const revertToBackupStatus = async (messageId) => {
index b0bb4e62718d660500b140dbeeab7017e5a51c31..945d4b1f44121d4ce40380e847e386cb97e5842a 100644 (file)
 (function(DOMParser) {
        "use strict";
 
-       var
-         DOMParser_proto = DOMParser.prototype
-       , real_parseFromString = DOMParser_proto.parseFromString
-       ;
+       var DOMParser_proto = DOMParser.prototype;
+       var real_parseFromString = DOMParser_proto.parseFromString;
 
        // Firefox/Opera/IE throw errors on unsupported types
        try {
 
        DOMParser_proto.parseFromString = function(markup, type) {
                if (/^\s*text\/html\s*(?:;|$)/i.test(type)) {
-                       var
-                         doc = document.implementation.createHTMLDocument("")
-                       ;
-                       if (markup.toLowerCase().indexOf('<!doctype') > -1) {
-                               doc.documentElement.innerHTML = markup;
-                       }
-                       else {
-                               doc.body.innerHTML = markup;
-                       }
+                       var doc = document.implementation.createHTMLDocument("");
+                       if (markup.toLowerCase().indexOf('<!doctype') > -1) {
+                               doc.documentElement.innerHTML = markup;
+                       } else {
+                               doc.body.innerHTML = markup;
+                       }
                        return doc;
                } else {
                        return real_parseFromString.apply(this, arguments);
index 7b4e87dd9b499392fe1ccef6ac03e1bbe63738e8..d307eb279966bf459cf42f67ba1ae91566747892 100644 (file)
@@ -3,6 +3,8 @@
  * SPDX-License-Identifier: AGPL-3.0-or-later
  */
 
+import { generateFilePath } from '@nextcloud/router'
+
 const loadedScripts = {}
 const loadedStylesheets = {}
 /**
@@ -25,7 +27,7 @@ export default {
                }
                loadedScripts[key] = true
                return new Promise(function(resolve, reject) {
-                       const scriptPath = OC.filePath(app, 'js', file)
+                       const scriptPath = generateFilePath(app, 'js', file)
                        const script = document.createElement('script')
                        script.src = scriptPath
                        script.setAttribute('nonce', btoa(OC.requestToken))
@@ -49,7 +51,7 @@ export default {
                }
                loadedStylesheets[key] = true
                return new Promise(function(resolve, reject) {
-                       const stylePath = OC.filePath(app, 'css', file)
+                       const stylePath = generateFilePath(app, 'css', file)
                        const link = document.createElement('link')
                        link.href = stylePath
                        link.type = 'text/css'
index 261cb4bedd7fb4a306e68d9a64c0684aacc695c2..ea2e2996a2adb009f19ce89ba7aebfb5b00a3354 100644 (file)
@@ -5,6 +5,8 @@
 
 import $ from 'jquery'
 import { translate as t } from '@nextcloud/l10n'
+import { linkTo } from '@nextcloud/router'
+
 import { getToken } from './OC/requesttoken.js'
 import getURLParameter from './Util/get-url-parameter.js'
 
@@ -129,7 +131,7 @@ window.addEventListener('DOMContentLoaded', function() {
        }
 
        $('#adminpass').strengthify({
-               zxcvbn: OC.linkTo('core', 'vendor/zxcvbn/dist/zxcvbn.js'),
+               zxcvbn: linkTo('core', 'vendor/zxcvbn/dist/zxcvbn.js'),
                titles: [
                        t('core', 'Very weak password'),
                        t('core', 'Weak password'),
index 826d94f7a0822961f84aafb594b3eb03fb7140be..3851a26ce31dc04a85e25bc03947a958e132175d 100644 (file)
@@ -3,10 +3,10 @@
  * SPDX-License-Identifier: AGPL-3.0-or-later
  */
 
+import { getCurrentUser } from '@nextcloud/auth'
+import { generateUrl } from '@nextcloud/router'
 import $ from 'jquery'
 
-import OC from '../OC/index.js'
-
 /**
  * This plugin inserts the right avatar for the user, depending on, whether a
  * custom avatar is uploaded - which it uses then - or not, and display a
@@ -90,8 +90,8 @@ $.fn.avatar = function(user, size, ie8fix, hidedefault, callback, displayname) {
        let url
 
        // If this is our own avatar we have to use the version attribute
-       if (user === OC.getCurrentUser().uid) {
-               url = OC.generateUrl(
+       if (user === getCurrentUser()?.uid) {
+               url = generateUrl(
                        '/avatar/{user}/{size}?v={version}',
                        {
                                user,
@@ -99,7 +99,7 @@ $.fn.avatar = function(user, size, ie8fix, hidedefault, callback, displayname) {
                                version: oc_userconfig.avatar.version,
                        })
        } else {
-               url = OC.generateUrl(
+               url = generateUrl(
                        '/avatar/{user}/{size}',
                        {
                                user,
index 1fa5cae8ef85e012e1c9fb84df161d72d2a04dc0..7067c994c9083d2d59d73fec08b460b7282435c9 100644 (file)
@@ -82,7 +82,7 @@ export function search({ type, query, cursor, since, until, limit, person, extra
  * Get the list of active contacts
  *
  * @param {object} filter filter contacts by string
- * @param filter.searchTerm
+ * @param {string} filter.searchTerm the query
  * @return {object} {request: Promise}
  */
 export async function getContacts({ searchTerm }) {
index 349650e02be80908ef42d1b83e293def3aa78802..1d2cd3ae57d5b05e351386a2a19e6c0c694288a3 100644 (file)
@@ -2,7 +2,7 @@
  * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
  * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
  * SPDX-License-Identifier: AGPL-3.0-or-later
- * @param OC
+ * @param {object} OC The OC namespace
  */
 
 (function(OC) {
index 2847b046b2571f2b8d90826d55abc5a4de58e0bf..db8e6e9734dc2d8fcdd0b8866e3c2eae6035fcd7 100644 (file)
@@ -41,14 +41,8 @@ module.exports = function(config) {
                                        // up with the global namespace/classes/state
                                        'dist/files_sharing-additionalScripts.js',
                                        'dist/files_sharing-files_sharing_tab.js',
-                                       'dist/files_sharing-files_sharing.js',
                                        'dist/files_sharing-main.js',
-                                       'apps/files_sharing/js/files_drop.js',
-                                       'apps/files_sharing/js/public.js',
-                                       'apps/files_sharing/js/sharedfilelist.js',
-                                       'apps/files_sharing/js/templates.js',
                                ],
-                               testFiles: ['apps/files_sharing/tests/js/*.js']
                        },
                        'files_trashbin',
                ];