diff options
author | Azul <azul@riseup.net> | 2020-06-16 11:00:16 +0300 |
---|---|---|
committer | Azul <azul@riseup.net> | 2020-08-11 16:24:35 +0300 |
commit | 03ccc8aa0369ada0ed0d50b50e60171696fdd2e6 (patch) | |
tree | f554a8047ca376f63694fa741951ba9cdfce9e31 /src/helpers/files.js | |
parent | 8d9535fd7cc9d1530cc1fb45a7aae8d189092567 (diff) |
button in menu bubble to link to files
Since the menu bubble deals with links
it makes more sense to add the button here.
Moved it to the initial part of the menu bubble
as an alternative to the link form.
Hand current path to menu bubble and use it
* to start from there when picking the file to link to
* to calculate the relative path.
Signed-off-by: Azul <azul@riseup.net>
Diffstat (limited to 'src/helpers/files.js')
-rw-r--r-- | src/helpers/files.js | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/helpers/files.js b/src/helpers/files.js index 29eeb768f..b85319dfb 100644 --- a/src/helpers/files.js +++ b/src/helpers/files.js @@ -30,6 +30,21 @@ import { imagePath } from '@nextcloud/router' const FILE_ACTION_IDENTIFIER = 'Edit with text app' +const optimalPath = function(from, to) { + const current = from.split('/') + const target = to.split('/') + current.pop() // ignore filename + while (current[0] === target[0]) { + current.shift() + target.shift() + } + const relativePath = current.fill('..').concat(target) + const absolutePath = to.split('/') + return relativePath.length < absolutePath.length + ? relativePath.join('/') + : to +} + const registerFileCreate = () => { const newFileMenuPlugin = { attach(menu) { @@ -157,6 +172,7 @@ const FilesWorkspacePlugin = { } export { + optimalPath, registerFileActionFallback, registerFileCreate, FilesWorkspacePlugin, |