Skip to content

Commit

Permalink
Merge pull request #47553 from nextcloud/chore/cleanup-warnings
Browse files Browse the repository at this point in the history
chore: fix usage of deprecated functions and adjust code style
  • Loading branch information
susnux committed Sep 20, 2024
2 parents 292bd0b + b6facb8 commit 5a501f2
Show file tree
Hide file tree
Showing 35 changed files with 82 additions and 105 deletions.
19 changes: 10 additions & 9 deletions apps/files_sharing/src/components/SharingEntryLink.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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">
Expand Down Expand Up @@ -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'
Expand Down Expand Up @@ -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() })
},
/**
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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),
Expand Down
3 changes: 3 additions & 0 deletions apps/settings/src/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() }, () => {
Expand Down
6 changes: 0 additions & 6 deletions apps/settings/src/components/Users/UserRow.vue
Original file line number Diff line number Diff line change
Expand Up @@ -621,8 +621,6 @@ export default {
/**
* Set user displayName
*
* @param {string} displayName The display name
*/
async updateDisplayName() {
this.loading.displayName = true
Expand All @@ -643,8 +641,6 @@ export default {
/**
* Set user password
*
* @param {string} password The email address
*/
async updatePassword() {
this.loading.password = true
Expand All @@ -668,8 +664,6 @@ export default {
/**
* Set user mailAddress
*
* @param {string} mailAddress The email address
*/
async updateEmail() {
this.loading.mailAddress = true
Expand Down
51 changes: 1 addition & 50 deletions core/js/tests/specs/coreSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -765,6 +765,7 @@ describe('Core base tests', function() {
OC.currentUser = 'dummy';
clock = sinon.useFakeTimers();
reloadStub = sinon.stub(OC, 'reload');
document.head.dataset.user = 'dummy'
notificationStub = sinon.stub(OC.Notification, 'show');
// unstub the error processing method
ajaxErrorStub = OC._processAjaxError;
Expand All @@ -778,47 +779,6 @@ describe('Core base tests', function() {
clock.restore();
});

it('reloads current page in case of auth error', function() {
var dataProvider = [
[200, false],
[400, false],
[0, false],
[401, true],
[302, true],
[303, true],
[307, true]
];

for (var i = 0; i < dataProvider.length; i++) {
var xhr = { status: dataProvider[i][0] };
var expectedCall = dataProvider[i][1];

reloadStub.reset();
OC._reloadCalled = false;

$(document).trigger(new $.Event('ajaxError'), xhr);

// trigger timers
clock.tick(waitTimeMs);

if (expectedCall) {
expect(reloadStub.calledOnce).toEqual(true);
} else {
expect(reloadStub.notCalled).toEqual(true);
}
}
});
it('reload only called once in case of auth error', function() {
var xhr = { status: 401 };

$(document).trigger(new $.Event('ajaxError'), xhr);
$(document).trigger(new $.Event('ajaxError'), xhr);

// trigger timers
clock.tick(waitTimeMs);

expect(reloadStub.calledOnce).toEqual(true);
});
it('does not reload the page if the user was navigating away', function() {
var xhr = { status: 0 };
OC._userIsNavigatingAway = true;
Expand All @@ -829,16 +789,7 @@ describe('Core base tests', function() {
clock.tick(waitTimeMs);
expect(reloadStub.notCalled).toEqual(true);
});
it('displays notification', function() {
var xhr = { status: 401 };

notificationUpdateStub = sinon.stub(OC.Notification, 'showUpdate');

$(document).trigger(new $.Event('ajaxError'), xhr);

clock.tick(waitTimeMs);
expect(notificationUpdateStub.notCalled).toEqual(false);
});
it('shows a temporary notification if the connection is lost', function() {
var xhr = { status: 0 };
spyOn(OC, '_ajaxConnectionLostHandler');
Expand Down
2 changes: 1 addition & 1 deletion core/src/OC/l10n.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,

Expand Down
4 changes: 2 additions & 2 deletions core/src/OC/notification.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions core/src/OC/query-string.js
Original file line number Diff line number Diff line change
Expand Up @@ -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&param2=abcde&param3=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
Expand Down Expand Up @@ -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 => {
Expand Down
12 changes: 7 additions & 5 deletions core/src/OC/xhr-error.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 })

/**
Expand All @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion core/src/OCP/collaboration.js
Original file line number Diff line number Diff line change
Expand Up @@ -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] }
*/
Expand Down
2 changes: 2 additions & 0 deletions core/src/OCP/toast.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions core/src/jquery/contactsmenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ''
Expand Down Expand Up @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion core/src/jquery/showpassword.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 <[email protected]>
* author-website http://www.unwrongest.com
Expand Down
2 changes: 2 additions & 0 deletions dist/323-323.js

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions dist/6794-6794.js.license → dist/323-323.js.license
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ SPDX-FileCopyrightText: John Molakvoæ (skjnldsv) <[email protected]>
SPDX-FileCopyrightText: Jerry Bendy <[email protected]>
SPDX-FileCopyrightText: Jeff Sagal <[email protected]>
SPDX-FileCopyrightText: Jacob Clevenger<https://github.com/wheatjs>
SPDX-FileCopyrightText: Iskren Ivov Chernev <[email protected]> (https://github.com/ichernev)
SPDX-FileCopyrightText: Hypercontext
SPDX-FileCopyrightText: Guillaume Chau <[email protected]>
SPDX-FileCopyrightText: GitHub Inc.
Expand All @@ -44,6 +45,7 @@ SPDX-FileCopyrightText: Evan You
SPDX-FileCopyrightText: Eugene Sharygin <[email protected]>
SPDX-FileCopyrightText: Eric Norris (https://github.com/ericnorris)
SPDX-FileCopyrightText: Dr.-Ing. Mario Heiderich, Cure53 <[email protected]> (https://cure53.de/)
SPDX-FileCopyrightText: Denis Pushkarev
SPDX-FileCopyrightText: David Clark
SPDX-FileCopyrightText: Christoph Wurst <[email protected]>
SPDX-FileCopyrightText: Christoph Wurst
Expand Down Expand Up @@ -98,6 +100,12 @@ This file is generated from multiple sources. Included packages:
- @nextcloud/logger
- version: 3.0.2
- license: GPL-3.0-or-later
- @nextcloud/router
- version: 2.2.1
- license: GPL-3.0-or-later
- @nextcloud/moment
- version: 1.3.1
- license: GPL-3.0-or-later
- @nextcloud/paths
- version: 2.2.1
- license: GPL-3.0-or-later
Expand Down Expand Up @@ -146,6 +154,9 @@ This file is generated from multiple sources. Included packages:
- console-browserify
- version: 1.2.0
- license: MIT
- core-js
- version: 3.38.1
- license: MIT
- crypt
- version: 0.0.2
- license: BSD-3-Clause
Expand Down Expand Up @@ -245,6 +256,9 @@ This file is generated from multiple sources. Included packages:
- md5
- version: 2.3.0
- license: BSD-3-Clause
- moment
- version: 2.30.1
- license: MIT
- nextcloud-vue-collections
- version: 0.13.0
- license: AGPL-3.0-or-later
Expand Down
1 change: 1 addition & 0 deletions dist/323-323.js.map

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions dist/323-323.js.map.license
2 changes: 0 additions & 2 deletions dist/6794-6794.js

This file was deleted.

1 change: 0 additions & 1 deletion dist/6794-6794.js.map

This file was deleted.

1 change: 0 additions & 1 deletion dist/6794-6794.js.map.license

This file was deleted.

4 changes: 2 additions & 2 deletions dist/core-common.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/core-common.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/core-install.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/core-login.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/core-login.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/core-main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/core-main.js.map

Large diffs are not rendered by default.

Loading

0 comments on commit 5a501f2

Please sign in to comment.