diff options
author | Roeland Jago Douma <rullzer@users.noreply.github.com> | 2021-01-28 18:17:29 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-28 18:17:29 +0300 |
commit | 62fa85c7bf1aba1cae637a10af8b2f3dfe5338f3 (patch) | |
tree | e7e331a06d899754f339dc2f0e350869a178c30c /apps/files/src/utils/davUtils.js | |
parent | 7e7284d790f55a14ec100771c08809e32514c533 (diff) | |
parent | 63a2ea8eaeae74107aca08d4cb04d770b1d8c1b7 (diff) |
Merge pull request #25090 from nextcloud/enh/file-templates
File templates
Diffstat (limited to 'apps/files/src/utils/davUtils.js')
-rw-r--r-- | apps/files/src/utils/davUtils.js | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/apps/files/src/utils/davUtils.js b/apps/files/src/utils/davUtils.js new file mode 100644 index 00000000000..cd5732a4772 --- /dev/null +++ b/apps/files/src/utils/davUtils.js @@ -0,0 +1,52 @@ +/** + * @copyright Copyright (c) 2019 John Molakvoæ <skjnldsv@protonmail.com> + * + * @author John Molakvoæ <skjnldsv@protonmail.com> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +import { generateRemoteUrl } from '@nextcloud/router' +import { getCurrentUser } from '@nextcloud/auth' + +export const getRootPath = function() { + if (getCurrentUser()) { + return generateRemoteUrl(`dav/files/${getCurrentUser().uid}`) + } else { + return generateRemoteUrl('webdav').replace('/remote.php', '/public.php') + } +} + +export const isPublic = function() { + return !getCurrentUser() +} + +export const getToken = function() { + return document.getElementById('sharingToken') && document.getElementById('sharingToken').value +} + +/** + * Return the current directory, fallback to root + * @returns {string} + */ +export const getCurrentDirectory = function() { + const currentDirInfo = OCA?.Files?.App?.currentFileList?.dirInfo + || { path: '/', name: '' } + + // Make sure we don't have double slashes + return `${currentDirInfo.path}/${currentDirInfo.name}`.replace(/\/\//gi, '/') +} |