-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Expand file tree
/
Copy pathindex.js
More file actions
262 lines (250 loc) · 5.89 KB
/
index.js
File metadata and controls
262 lines (250 loc) · 5.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
/**
* SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
import { subscribe } from '@nextcloud/event-bus'
import {
getCanonicalLocale,
getLanguage,
getLocale,
} from '@nextcloud/l10n'
import {
basename,
dirname,
encodePath,
isSamePath,
join,
} from '@nextcloud/paths'
import {
generateFilePath,
generateOcsUrl,
generateRemoteUrl,
generateUrl,
getRootUrl,
imagePath,
linkTo,
} from '@nextcloud/router'
import logger from '../logger.js'
import { isUserAdmin } from './admin.js'
import { appConfig } from './appconfig.js'
import Apps from './apps.js'
import appswebroots from './appswebroots.js'
import Backbone from './backbone.js'
import { getCapabilities } from './capabilities.js'
import Config from './config.js'
import {
coreApps,
menuSpeed,
PERMISSION_ALL,
PERMISSION_CREATE,
PERMISSION_DELETE,
PERMISSION_NONE,
PERMISSION_READ,
PERMISSION_SHARE,
PERMISSION_UPDATE,
TAG_FAVORITE,
} from './constants.js'
import { currentUser, getCurrentUser } from './currentuser.js'
import { debug } from './debug.js'
import Dialogs from './dialogs.js'
import EventSource from './eventsource.js'
import L10N from './l10n.js'
import {
hideMenus,
registerMenu,
showMenu,
unregisterMenu,
} from './menu.js'
import * as MimeType from './mimeType.js'
import msg from './msg.js'
import Notification from './notification.js'
import PasswordConfirmation from './password-confirmation.js'
import Plugins from './plugins.js'
import {
build as buildQueryString,
parse as parseQueryString,
} from './query-string.ts'
import { getRequestToken } from './requesttoken.ts'
import {
linkToRemoteBase,
} from './routing.js'
import Settings from './settings.js'
import { theme } from './theme.js'
import Util from './util.js'
import webroot from './webroot.js'
import {
ajaxConnectionLostHandler,
processAjaxError,
registerXHRForErrorProcessing,
} from './xhr-error.js'
/** @namespace OC */
export default {
/*
* Constants
*/
coreApps,
menuSpeed,
PERMISSION_ALL,
PERMISSION_CREATE,
PERMISSION_DELETE,
PERMISSION_NONE,
PERMISSION_READ,
PERMISSION_SHARE,
PERMISSION_UPDATE,
TAG_FAVORITE,
/*
* Deprecated helpers to be removed
*/
Apps,
appConfig,
appswebroots,
Backbone,
config: Config,
/**
* Currently logged in user or null if none
*
* @type {string}
* @deprecated use `getCurrentUser` from https://www.npmjs.com/package/@nextcloud/auth
*/
currentUser,
dialogs: Dialogs,
EventSource,
MimeType,
/**
* Returns the currently logged in user or null if there is no logged in
* user (public page mode)
*
* @since 9.0.0
* @deprecated 19.0.0 use `getCurrentUser` from https://www.npmjs.com/package/@nextcloud/auth
*/
getCurrentUser,
isUserAdmin,
L10N,
/**
* Ajax error handlers
*
* @todo remove from here and keep internally -> requires new tests
*/
_ajaxConnectionLostHandler: ajaxConnectionLostHandler,
_processAjaxError: processAjaxError,
registerXHRForErrorProcessing,
/**
* Capabilities
*
* @type {Array}
* @deprecated 20.0.0 use @nextcloud/capabilities instead
*/
getCapabilities,
/*
* Legacy menu helpers
*/
hideMenus,
registerMenu,
showMenu,
unregisterMenu,
/*
* Path helpers
*/
/**
* @deprecated 18.0.0 use https://www.npmjs.com/package/@nextcloud/paths
*/
basename,
/**
* @deprecated 18.0.0 use https://www.npmjs.com/package/@nextcloud/paths
*/
encodePath,
/**
* @deprecated 18.0.0 use https://www.npmjs.com/package/@nextcloud/paths
*/
dirname,
/**
* @deprecated 18.0.0 use https://www.npmjs.com/package/@nextcloud/paths
*/
isSamePath,
/**
* @deprecated 18.0.0 use https://www.npmjs.com/package/@nextcloud/paths
*/
joinPaths: join,
/**
* @deprecated 20.0.0 use `getCanonicalLocale` from https://www.npmjs.com/package/@nextcloud/l10n
*/
getCanonicalLocale,
/**
* @deprecated 26.0.0 use `getLocale` from https://www.npmjs.com/package/@nextcloud/l10n
*/
getLocale,
/**
* @deprecated 26.0.0 use `getLanguage` from https://www.npmjs.com/package/@nextcloud/l10n
*/
getLanguage,
// Query string helpers
buildQueryString,
parseQueryString,
msg,
Notification,
/**
* @deprecated 28.0.0 use methods from '@nextcloud/password-confirmation'
*/
PasswordConfirmation,
Plugins,
/**
* @deprecated 25.0.0 Use Vue based (`@nextcloud/vue`) settings components instead
*/
Settings,
theme,
Util,
debug,
/**
* @deprecated 19.0.0 use `generateFilePath` from https://www.npmjs.com/package/@nextcloud/router
*/
filePath: generateFilePath,
/**
* @deprecated 19.0.0 use `generateUrl` from https://www.npmjs.com/package/@nextcloud/router
*/
generateUrl,
/**
* @deprecated 19.0.0 use `getRootUrl` from https://www.npmjs.com/package/@nextcloud/router
*/
getRootPath: getRootUrl,
/**
* @deprecated 19.0.0 use `imagePath` from https://www.npmjs.com/package/@nextcloud/router
*/
imagePath,
requestToken: getRequestToken(),
/**
* @deprecated 19.0.0 use `linkTo` from https://www.npmjs.com/package/@nextcloud/router
*/
linkTo,
/**
* @param {string} service service name
* @param {number} version OCS API version
* @return {string} OCS API base path
* @deprecated 19.0.0 use `generateOcsUrl` from https://www.npmjs.com/package/@nextcloud/router
*/
linkToOCS: (service, version) => {
return generateOcsUrl(service, {}, {
ocsVersion: version || 1,
}) + '/'
},
/**
* @deprecated 19.0.0 use `generateRemoteUrl` from https://www.npmjs.com/package/@nextcloud/router
*/
linkToRemote: generateRemoteUrl,
linkToRemoteBase,
/**
* Relative path to Nextcloud root.
* For example: "/nextcloud"
*
* @type {string}
*
* @deprecated 19.0.0 use `getRootUrl` from https://www.npmjs.com/package/@nextcloud/router
* @see OC#getRootPath
*/
webroot,
}
// Keep the request token prop in sync
subscribe('csrf-token-update', (e) => {
OC.requestToken = e.token
// Logging might help debug (Sentry) issues
logger.info('OC.requestToken changed', { token: e.token })
})