Skip to content

Commit 5a501f2

Browse files
authored
Merge pull request #47553 from nextcloud/chore/cleanup-warnings
chore: fix usage of deprecated functions and adjust code style
2 parents 292bd0b + b6facb8 commit 5a501f2

35 files changed

Lines changed: 82 additions & 105 deletions

apps/files_sharing/src/components/SharingEntryLink.vue

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,8 @@
150150
:share="share" />
151151

152152
<!-- external legacy sharing via url (social...) -->
153-
<NcActionLink v-for="({ icon, url, name }, index) in externalLegacyLinkActions"
154-
:key="index"
153+
<NcActionLink v-for="({ icon, url, name }, actionIndex) in externalLegacyLinkActions"
154+
:key="actionIndex"
155155
:href="url(shareLink)"
156156
:icon="icon"
157157
target="_blank">
@@ -207,11 +207,12 @@
207207

208208
<script>
209209
import { emit } from '@nextcloud/event-bus'
210-
import { generateUrl } from '@nextcloud/router'
210+
import { generateUrl, getBaseUrl } from '@nextcloud/router'
211211
import { showError, showSuccess } from '@nextcloud/dialogs'
212-
import { Type as ShareTypes } from '@nextcloud/sharing'
213-
import Vue from 'vue'
212+
import { ShareType } from '@nextcloud/sharing'
214213
import VueQrcode from '@chenfengyuan/vue-qrcode'
214+
import moment from '@nextcloud/moment'
215+
import Vue from 'vue'
215216
216217
import NcActionButton from '@nextcloud/vue/dist/Components/NcActionButton.js'
217218
import NcActionCheckbox from '@nextcloud/vue/dist/Components/NcActionCheckbox.js'
@@ -508,7 +509,7 @@ export default {
508509
* @return {string}
509510
*/
510511
shareLink() {
511-
return window.location.protocol + '//' + window.location.host + generateUrl('/s/') + this.share.token
512+
return generateUrl('/s/{toen}', { token: this.share.token }, { baseURL: getBaseUrl() })
512513
},
513514
514515
/**
@@ -551,7 +552,7 @@ export default {
551552
* @return {Array}
552553
*/
553554
externalLinkActions() {
554-
const filterValidAction = (action) => (action.shareType.includes(ShareTypes.SHARE_TYPE_LINK) || action.shareType.includes(ShareTypes.SHARE_TYPE_EMAIL)) && !action.advanced
555+
const filterValidAction = (action) => (action.shareType.includes(ShareType.Link) || action.shareType.includes(ShareType.Email)) && !action.advanced
555556
// filter only the registered actions for said link
556557
return this.ExternalShareActions.actions
557558
.filter(filterValidAction)
@@ -583,7 +584,7 @@ export default {
583584
}
584585
585586
const shareDefaults = {
586-
share_type: ShareTypes.SHARE_TYPE_LINK,
587+
share_type: ShareType.Link,
587588
}
588589
if (this.config.isDefaultExpireDateEnforced) {
589590
// default is empty string if not set
@@ -669,7 +670,7 @@ export default {
669670
const path = (this.fileInfo.path + '/' + this.fileInfo.name).replace('//', '/')
670671
const options = {
671672
path,
672-
shareType: ShareTypes.SHARE_TYPE_LINK,
673+
shareType: ShareType.Link,
673674
password: share.password,
674675
expireDate: share.expireDate,
675676
attributes: JSON.stringify(this.fileInfo.shareAttributes),

apps/settings/src/admin.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
* SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors
33
* SPDX-License-Identifier: AGPL-3.0-or-later
44
*/
5+
6+
import $ from 'jquery'
7+
58
window.addEventListener('DOMContentLoaded', () => {
69
$('#loglevel').change(function() {
710
$.post(OC.generateUrl('/settings/admin/log/level'), { level: $(this).val() }, () => {

apps/settings/src/components/Users/UserRow.vue

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -621,8 +621,6 @@ export default {
621621
622622
/**
623623
* Set user displayName
624-
*
625-
* @param {string} displayName The display name
626624
*/
627625
async updateDisplayName() {
628626
this.loading.displayName = true
@@ -643,8 +641,6 @@ export default {
643641
644642
/**
645643
* Set user password
646-
*
647-
* @param {string} password The email address
648644
*/
649645
async updatePassword() {
650646
this.loading.password = true
@@ -668,8 +664,6 @@ export default {
668664
669665
/**
670666
* Set user mailAddress
671-
*
672-
* @param {string} mailAddress The email address
673667
*/
674668
async updateEmail() {
675669
this.loading.mailAddress = true

core/js/tests/specs/coreSpec.js

Lines changed: 1 addition & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -765,6 +765,7 @@ describe('Core base tests', function() {
765765
OC.currentUser = 'dummy';
766766
clock = sinon.useFakeTimers();
767767
reloadStub = sinon.stub(OC, 'reload');
768+
document.head.dataset.user = 'dummy'
768769
notificationStub = sinon.stub(OC.Notification, 'show');
769770
// unstub the error processing method
770771
ajaxErrorStub = OC._processAjaxError;
@@ -778,47 +779,6 @@ describe('Core base tests', function() {
778779
clock.restore();
779780
});
780781

781-
it('reloads current page in case of auth error', function() {
782-
var dataProvider = [
783-
[200, false],
784-
[400, false],
785-
[0, false],
786-
[401, true],
787-
[302, true],
788-
[303, true],
789-
[307, true]
790-
];
791-
792-
for (var i = 0; i < dataProvider.length; i++) {
793-
var xhr = { status: dataProvider[i][0] };
794-
var expectedCall = dataProvider[i][1];
795-
796-
reloadStub.reset();
797-
OC._reloadCalled = false;
798-
799-
$(document).trigger(new $.Event('ajaxError'), xhr);
800-
801-
// trigger timers
802-
clock.tick(waitTimeMs);
803-
804-
if (expectedCall) {
805-
expect(reloadStub.calledOnce).toEqual(true);
806-
} else {
807-
expect(reloadStub.notCalled).toEqual(true);
808-
}
809-
}
810-
});
811-
it('reload only called once in case of auth error', function() {
812-
var xhr = { status: 401 };
813-
814-
$(document).trigger(new $.Event('ajaxError'), xhr);
815-
$(document).trigger(new $.Event('ajaxError'), xhr);
816-
817-
// trigger timers
818-
clock.tick(waitTimeMs);
819-
820-
expect(reloadStub.calledOnce).toEqual(true);
821-
});
822782
it('does not reload the page if the user was navigating away', function() {
823783
var xhr = { status: 0 };
824784
OC._userIsNavigatingAway = true;
@@ -829,16 +789,7 @@ describe('Core base tests', function() {
829789
clock.tick(waitTimeMs);
830790
expect(reloadStub.notCalled).toEqual(true);
831791
});
832-
it('displays notification', function() {
833-
var xhr = { status: 401 };
834792

835-
notificationUpdateStub = sinon.stub(OC.Notification, 'showUpdate');
836-
837-
$(document).trigger(new $.Event('ajaxError'), xhr);
838-
839-
clock.tick(waitTimeMs);
840-
expect(notificationUpdateStub.notCalled).toEqual(false);
841-
});
842793
it('shows a temporary notification if the connection is lost', function() {
843794
var xhr = { status: 0 };
844795
spyOn(OC, '_ajaxConnectionLostHandler');

core/src/OC/l10n.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ const L10n = {
4040
* @deprecated 26.0.0 use `register` from https://www.npmjs.com/package/@nextcloud/l10
4141
*
4242
* @param {string} appName name of the app
43-
* @param {Object<string, string>} bundle bundle
43+
* @param {Record<string, string>} bundle bundle
4444
*/
4545
register,
4646

core/src/OC/notification.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ export default {
120120
* Updates (replaces) a sanitized notification.
121121
*
122122
* @param {string} text Message to display
123-
* @return {jQuery} JQuery element for notificaiton row
123+
* @return {jQuery} JQuery element for notification row
124124
* @deprecated 17.0.0 use the `@nextcloud/dialogs` package
125125
*/
126126
showUpdate(text) {
@@ -141,7 +141,7 @@ export default {
141141
* @param {number} [options.timeout] timeout in seconds, if this is 0 it will show the message permanently
142142
* @param {boolean} [options.isHTML] an indicator for HTML notifications (true) or text (false)
143143
* @param {string} [options.type] notification type
144-
* @return {JQuery} the toast element
144+
* @return {jQuery} the toast element
145145
* @deprecated 17.0.0 use the `@nextcloud/dialogs` package
146146
*/
147147
showTemporary(text, options) {

core/src/OC/query-string.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import $ from 'jquery'
99
* Parses a URL query string into a JS map
1010
*
1111
* @param {string} queryString query string in the format param1=1234&param2=abcde&param3=xyz
12-
* @return {Object<string, string>} map containing key/values matching the URL parameters
12+
* @return {Record<string, string>} map containing key/values matching the URL parameters
1313
*/
1414
export const parse = queryString => {
1515
let pos
@@ -58,7 +58,7 @@ export const parse = queryString => {
5858
/**
5959
* Builds a URL query from a JS map.
6060
*
61-
* @param {Object<string, string>} params map containing key/values matching the URL parameters
61+
* @param {Record<string, string>} params map containing key/values matching the URL parameters
6262
* @return {string} String containing a URL query (without question) mark
6363
*/
6464
export const build = params => {

core/src/OC/xhr-error.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,18 @@ import $ from 'jquery'
88

99
import OC from './index.js'
1010
import Notification from './notification.js'
11+
import { getCurrentUser } from '@nextcloud/auth'
12+
import { showWarning } from '@nextcloud/dialogs'
1113

1214
/**
1315
* Warn users that the connection to the server was lost temporarily
1416
*
15-
* This function is throttled to prevent stacked notfications.
17+
* This function is throttled to prevent stacked notifications.
1618
* After 7sec the first notification is gone, then we can show another one
1719
* if necessary.
1820
*/
1921
export const ajaxConnectionLostHandler = _.throttle(() => {
20-
Notification.showTemporary(t('core', 'Connection to server lost'))
22+
showWarning(t('core', 'Connection to server lost'))
2123
}, 7 * 1000, { trailing: false })
2224

2325
/**
@@ -28,13 +30,13 @@ export const ajaxConnectionLostHandler = _.throttle(() => {
2830
*/
2931
export const processAjaxError = xhr => {
3032
// purposefully aborted request ?
31-
// OC._userIsNavigatingAway needed to distinguish ajax calls cancelled by navigating away
32-
// from calls cancelled by failed cross-domain ajax due to SSO redirect
33+
// OC._userIsNavigatingAway needed to distinguish Ajax calls cancelled by navigating away
34+
// from calls cancelled by failed cross-domain Ajax due to SSO redirect
3335
if (xhr.status === 0 && (xhr.statusText === 'abort' || xhr.statusText === 'timeout' || OC._reloadCalled)) {
3436
return
3537
}
3638

37-
if (_.contains([302, 303, 307, 401], xhr.status) && OC.currentUser) {
39+
if ([302, 303, 307, 401].includes(xhr.status) && getCurrentUser()) {
3840
// sometimes "beforeunload" happens later, so need to defer the reload a bit
3941
setTimeout(function() {
4042
if (!OC._userIsNavigatingAway && !OC._reloadCalled) {

core/src/OCP/collaboration.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import escapeHTML from 'escape-html'
77

88
/**
99
* @typedef TypeDefinition
10-
* @function {Function} action This action is executed to let the user select a resource
10+
* @function action This action is executed to let the user select a resource
1111
* @param {string} icon Contains the icon css class for the type
1212
* @function Object() { [native code] }
1313
*/

core/src/OCP/toast.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import {
1010
showWarning,
1111
} from '@nextcloud/dialogs'
1212

13+
/** @typedef {import('toastify-js')} Toast */
14+
1315
export default {
1416
/**
1517
* @deprecated 19.0.0 use `showSuccess` from the `@nextcloud/dialogs` package instead

0 commit comments

Comments
 (0)