From b73586563d756303ba3f4a75ebf0cfbe2902550e Mon Sep 17 00:00:00 2001 From: Ferdinand Thiessen Date: Thu, 10 Aug 2023 12:52:05 +0200 Subject: feat: Add new Vue FilePicker from `@nextcloud/dialogs` and use it by default. Still providing the legacy one until the Vue FilePicker is out of beta. Signed-off-by: Ferdinand Thiessen --- core/src/OC/dialogs.js | 28 +++++++++++++++++++++++++++- core/src/main.js | 4 ++++ 2 files changed, 31 insertions(+), 1 deletion(-) (limited to 'core/src') diff --git a/core/src/OC/dialogs.js b/core/src/OC/dialogs.js index bfb32fd671e..ad501ee0628 100644 --- a/core/src/OC/dialogs.js +++ b/core/src/OC/dialogs.js @@ -50,6 +50,7 @@ import $ from 'jquery' import OC from './index.js' import OCA from '../OCA/index.js' import { isA11yActivation } from '../Util/a11y.js' +import { filepicker } from '@nextcloud/dialogs/legacy.js' /** * this class to ease the usage of jquery dialogs @@ -226,6 +227,7 @@ const Dialogs = { Dialogs.dialogsCounter++ }) }, + /** * show a file picker to pick a file from * @@ -246,7 +248,31 @@ const Dialogs = { * @param {Object} [options] additonal options that need to be set * @param {Function} [options.filter] filter function for advanced filtering */ - filepicker: function(title, callback, multiselect, mimetypeFilter, modal, type, path, options) { + filepicker, + + /** + * Show the legacy file picker to pick a file from + * + * In order to pick several types of mime types they need to be passed as an + * array of strings. + * + * When no mime type filter is given only files can be selected. In order to + * be able to select both files and folders "['*', 'httpd/unix-directory']" + * should be used instead. + * + * @deprecated since 27.1.0 + * + * @param {string} title dialog title + * @param {function} callback which will be triggered when user presses Choose + * @param {boolean} [multiselect] whether it should be possible to select multiple files + * @param {string[]} [mimetypeFilter] mimetype to filter by - directories will always be included + * @param {boolean} [modal] make the dialog modal + * @param {string} [type] Type of file picker : Choose, copy, move, copy and move + * @param {string} [path] path to the folder that the the file can be picket from + * @param {Object} [options] additonal options that need to be set + * @param {Function} [options.filter] filter function for advanced filtering + */ + legacyFilepicker: function(title, callback, multiselect, mimetypeFilter, modal, type, path, options) { var self = this this.filepicker.sortField = 'name' diff --git a/core/src/main.js b/core/src/main.js index 9c7e150bee3..1e481bf877d 100644 --- a/core/src/main.js +++ b/core/src/main.js @@ -36,6 +36,10 @@ import OC from './OC/index.js' import './globals.js' import './jquery/index.js' import { initCore } from './init.js' +import { getRequestToken } from '@nextcloud/auth' + +// eslint-disable-next-line camelcase +__webpack_nonce__ = btoa(getRequestToken()) window.addEventListener('DOMContentLoaded', function() { initCore() -- cgit v1.2.3