mirror of
https://github.com/nextcloud/server.git
synced 2026-04-15 22:11:17 -04:00
chore: fix usage of deprecated functions and adjust code style
This solves 57 ESLint warnings by replacing deprecated code with `@nextcloud/` libraries, as well as adding missing type information, importing jQuery instead of relying on global one, and the same with Moment.js. Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
This commit is contained in:
parent
4ba3d4a31a
commit
085aab24ff
11 changed files with 32 additions and 29 deletions
|
|
@ -150,8 +150,8 @@
|
|||
:share="share" />
|
||||
|
||||
<!-- external legacy sharing via url (social...) -->
|
||||
<NcActionLink v-for="({ icon, url, name }, index) in externalLegacyLinkActions"
|
||||
:key="index"
|
||||
<NcActionLink v-for="({ icon, url, name }, actionIndex) in externalLegacyLinkActions"
|
||||
:key="actionIndex"
|
||||
:href="url(shareLink)"
|
||||
:icon="icon"
|
||||
target="_blank">
|
||||
|
|
@ -207,11 +207,12 @@
|
|||
|
||||
<script>
|
||||
import { emit } from '@nextcloud/event-bus'
|
||||
import { generateUrl } from '@nextcloud/router'
|
||||
import { generateUrl, getBaseUrl } from '@nextcloud/router'
|
||||
import { showError, showSuccess } from '@nextcloud/dialogs'
|
||||
import { Type as ShareTypes } from '@nextcloud/sharing'
|
||||
import Vue from 'vue'
|
||||
import { ShareType } from '@nextcloud/sharing'
|
||||
import VueQrcode from '@chenfengyuan/vue-qrcode'
|
||||
import moment from '@nextcloud/moment'
|
||||
import Vue from 'vue'
|
||||
|
||||
import NcActionButton from '@nextcloud/vue/dist/Components/NcActionButton.js'
|
||||
import NcActionCheckbox from '@nextcloud/vue/dist/Components/NcActionCheckbox.js'
|
||||
|
|
@ -508,7 +509,7 @@ export default {
|
|||
* @return {string}
|
||||
*/
|
||||
shareLink() {
|
||||
return window.location.protocol + '//' + window.location.host + generateUrl('/s/') + this.share.token
|
||||
return generateUrl('/s/{toen}', { token: this.share.token }, { baseURL: getBaseUrl() })
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
@ -551,7 +552,7 @@ export default {
|
|||
* @return {Array}
|
||||
*/
|
||||
externalLinkActions() {
|
||||
const filterValidAction = (action) => (action.shareType.includes(ShareTypes.SHARE_TYPE_LINK) || action.shareType.includes(ShareTypes.SHARE_TYPE_EMAIL)) && !action.advanced
|
||||
const filterValidAction = (action) => (action.shareType.includes(ShareType.Link) || action.shareType.includes(ShareType.Email)) && !action.advanced
|
||||
// filter only the registered actions for said link
|
||||
return this.ExternalShareActions.actions
|
||||
.filter(filterValidAction)
|
||||
|
|
@ -583,7 +584,7 @@ export default {
|
|||
}
|
||||
|
||||
const shareDefaults = {
|
||||
share_type: ShareTypes.SHARE_TYPE_LINK,
|
||||
share_type: ShareType.Link,
|
||||
}
|
||||
if (this.config.isDefaultExpireDateEnforced) {
|
||||
// default is empty string if not set
|
||||
|
|
@ -669,7 +670,7 @@ export default {
|
|||
const path = (this.fileInfo.path + '/' + this.fileInfo.name).replace('//', '/')
|
||||
const options = {
|
||||
path,
|
||||
shareType: ShareTypes.SHARE_TYPE_LINK,
|
||||
shareType: ShareType.Link,
|
||||
password: share.password,
|
||||
expireDate: share.expireDate,
|
||||
attributes: JSON.stringify(this.fileInfo.shareAttributes),
|
||||
|
|
|
|||
|
|
@ -2,6 +2,9 @@
|
|||
* SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
import $ from 'jquery'
|
||||
|
||||
window.addEventListener('DOMContentLoaded', () => {
|
||||
$('#loglevel').change(function() {
|
||||
$.post(OC.generateUrl('/settings/admin/log/level'), { level: $(this).val() }, () => {
|
||||
|
|
|
|||
|
|
@ -621,8 +621,6 @@ export default {
|
|||
|
||||
/**
|
||||
* Set user displayName
|
||||
*
|
||||
* @param {string} displayName The display name
|
||||
*/
|
||||
async updateDisplayName() {
|
||||
this.loading.displayName = true
|
||||
|
|
@ -643,8 +641,6 @@ export default {
|
|||
|
||||
/**
|
||||
* Set user password
|
||||
*
|
||||
* @param {string} password The email address
|
||||
*/
|
||||
async updatePassword() {
|
||||
this.loading.password = true
|
||||
|
|
@ -668,8 +664,6 @@ export default {
|
|||
|
||||
/**
|
||||
* Set user mailAddress
|
||||
*
|
||||
* @param {string} mailAddress The email address
|
||||
*/
|
||||
async updateEmail() {
|
||||
this.loading.mailAddress = true
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ const L10n = {
|
|||
* @deprecated 26.0.0 use `register` from https://www.npmjs.com/package/@nextcloud/l10
|
||||
*
|
||||
* @param {string} appName name of the app
|
||||
* @param {Object<string, string>} bundle bundle
|
||||
* @param {Record<string, string>} bundle bundle
|
||||
*/
|
||||
register,
|
||||
|
||||
|
|
|
|||
|
|
@ -120,7 +120,7 @@ export default {
|
|||
* Updates (replaces) a sanitized notification.
|
||||
*
|
||||
* @param {string} text Message to display
|
||||
* @return {jQuery} JQuery element for notificaiton row
|
||||
* @return {jQuery} JQuery element for notification row
|
||||
* @deprecated 17.0.0 use the `@nextcloud/dialogs` package
|
||||
*/
|
||||
showUpdate(text) {
|
||||
|
|
@ -141,7 +141,7 @@ export default {
|
|||
* @param {number} [options.timeout] timeout in seconds, if this is 0 it will show the message permanently
|
||||
* @param {boolean} [options.isHTML] an indicator for HTML notifications (true) or text (false)
|
||||
* @param {string} [options.type] notification type
|
||||
* @return {JQuery} the toast element
|
||||
* @return {jQuery} the toast element
|
||||
* @deprecated 17.0.0 use the `@nextcloud/dialogs` package
|
||||
*/
|
||||
showTemporary(text, options) {
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import $ from 'jquery'
|
|||
* Parses a URL query string into a JS map
|
||||
*
|
||||
* @param {string} queryString query string in the format param1=1234¶m2=abcde¶m3=xyz
|
||||
* @return {Object<string, string>} map containing key/values matching the URL parameters
|
||||
* @return {Record<string, string>} map containing key/values matching the URL parameters
|
||||
*/
|
||||
export const parse = queryString => {
|
||||
let pos
|
||||
|
|
@ -58,7 +58,7 @@ export const parse = queryString => {
|
|||
/**
|
||||
* Builds a URL query from a JS map.
|
||||
*
|
||||
* @param {Object<string, string>} params map containing key/values matching the URL parameters
|
||||
* @param {Record<string, string>} params map containing key/values matching the URL parameters
|
||||
* @return {string} String containing a URL query (without question) mark
|
||||
*/
|
||||
export const build = params => {
|
||||
|
|
|
|||
|
|
@ -8,16 +8,18 @@ import $ from 'jquery'
|
|||
|
||||
import OC from './index.js'
|
||||
import Notification from './notification.js'
|
||||
import { getCurrentUser } from '@nextcloud/auth'
|
||||
import { showWarning } from '@nextcloud/dialogs'
|
||||
|
||||
/**
|
||||
* Warn users that the connection to the server was lost temporarily
|
||||
*
|
||||
* This function is throttled to prevent stacked notfications.
|
||||
* This function is throttled to prevent stacked notifications.
|
||||
* After 7sec the first notification is gone, then we can show another one
|
||||
* if necessary.
|
||||
*/
|
||||
export const ajaxConnectionLostHandler = _.throttle(() => {
|
||||
Notification.showTemporary(t('core', 'Connection to server lost'))
|
||||
showWarning(t('core', 'Connection to server lost'))
|
||||
}, 7 * 1000, { trailing: false })
|
||||
|
||||
/**
|
||||
|
|
@ -28,13 +30,13 @@ export const ajaxConnectionLostHandler = _.throttle(() => {
|
|||
*/
|
||||
export const processAjaxError = xhr => {
|
||||
// purposefully aborted request ?
|
||||
// OC._userIsNavigatingAway needed to distinguish ajax calls cancelled by navigating away
|
||||
// from calls cancelled by failed cross-domain ajax due to SSO redirect
|
||||
// OC._userIsNavigatingAway needed to distinguish Ajax calls cancelled by navigating away
|
||||
// from calls cancelled by failed cross-domain Ajax due to SSO redirect
|
||||
if (xhr.status === 0 && (xhr.statusText === 'abort' || xhr.statusText === 'timeout' || OC._reloadCalled)) {
|
||||
return
|
||||
}
|
||||
|
||||
if (_.contains([302, 303, 307, 401], xhr.status) && OC.currentUser) {
|
||||
if ([302, 303, 307, 401].includes(xhr.status) && getCurrentUser()) {
|
||||
// sometimes "beforeunload" happens later, so need to defer the reload a bit
|
||||
setTimeout(function() {
|
||||
if (!OC._userIsNavigatingAway && !OC._reloadCalled) {
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import escapeHTML from 'escape-html'
|
|||
|
||||
/**
|
||||
* @typedef TypeDefinition
|
||||
* @function {Function} action This action is executed to let the user select a resource
|
||||
* @function action This action is executed to let the user select a resource
|
||||
* @param {string} icon Contains the icon css class for the type
|
||||
* @function Object() { [native code] }
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@ import {
|
|||
showWarning,
|
||||
} from '@nextcloud/dialogs'
|
||||
|
||||
/** @typedef {import('toastify-js')} Toast */
|
||||
|
||||
export default {
|
||||
/**
|
||||
* @deprecated 19.0.0 use `showSuccess` from the `@nextcloud/dialogs` package instead
|
||||
|
|
|
|||
4
core/src/jquery/contactsmenu.js
vendored
4
core/src/jquery/contactsmenu.js
vendored
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
import $ from 'jquery'
|
||||
|
||||
import OC from '../OC/index.js'
|
||||
import { generateUrl } from '@nextcloud/router'
|
||||
import { isA11yActivation } from '../Util/a11y.js'
|
||||
|
||||
const LIST = ''
|
||||
|
|
@ -51,7 +51,7 @@ $.fn.contactsMenu = function(shareWith, shareType, appendTo) {
|
|||
}
|
||||
|
||||
$list.addClass('loaded')
|
||||
$.ajax(OC.generateUrl('/contactsmenu/findOne'), {
|
||||
$.ajax(generateUrl('/contactsmenu/findOne'), {
|
||||
method: 'POST',
|
||||
data: {
|
||||
shareType,
|
||||
|
|
|
|||
3
core/src/jquery/showpassword.js
vendored
3
core/src/jquery/showpassword.js
vendored
|
|
@ -3,13 +3,14 @@
|
|||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
/** @typedef {import('jquery')} jQuery */
|
||||
import $ from 'jquery'
|
||||
|
||||
/**
|
||||
* @name Show Password
|
||||
* @description
|
||||
* @version 1.3.0
|
||||
* @requires Jquery 1.5
|
||||
* @requires jQuery 1.5
|
||||
*
|
||||
* @author Jan Jarfalk <jan.jarfalk@unwrongest.com>
|
||||
* author-website http://www.unwrongest.com
|
||||
|
|
|
|||
Loading…
Reference in a new issue