From 2ffd2fa808e27d1163f1cfbae7f3352b898858b2 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 21 Oct 2024 12:27:45 +0200 Subject: [PATCH 1/2] feat(api): Move from index.php to ocs API Signed-off-by: Joas Schilling --- appinfo/routes.php | 4 ++-- lib/Controller/SigningController.php | 24 ++++++++++----------- lib/Controller/TermsController.php | 32 ++++++++++++++-------------- src/App.vue | 24 +++++++++++---------- src/Registration.vue | 10 ++++----- src/UserApp.vue | 12 +++++------ src/components/Term.vue | 4 ++-- 7 files changed, 56 insertions(+), 54 deletions(-) diff --git a/appinfo/routes.php b/appinfo/routes.php index 9c6d14c6..f0f956c2 100644 --- a/appinfo/routes.php +++ b/appinfo/routes.php @@ -5,12 +5,12 @@ */ return [ - 'resources' => [ + 'ocs-resources' => [ 'terms' => [ 'url' => '/terms' ], ], - 'routes' => [ + 'ocs' => [ [ 'name' => 'Terms#getAdminFormData', 'url' => '/terms/admin', diff --git a/lib/Controller/SigningController.php b/lib/Controller/SigningController.php index e81714df..425db0f6 100644 --- a/lib/Controller/SigningController.php +++ b/lib/Controller/SigningController.php @@ -9,8 +9,8 @@ use OCA\TermsOfService\AppInfo\Application; use OCA\TermsOfService\Db\Entities\Signatory; use OCA\TermsOfService\Db\Mapper\SignatoryMapper; -use OCP\AppFramework\Controller; -use OCP\AppFramework\Http\JSONResponse; +use OCP\AppFramework\Http\DataResponse; +use OCP\AppFramework\OCSController; use OCP\IConfig; use OCP\IRequest; use OCP\ISession; @@ -20,7 +20,7 @@ use OCA\TermsOfService\Events\SignaturesResetEvent; use OCP\EventDispatcher\IEventDispatcher; -class SigningController extends Controller { +class SigningController extends OCSController { /** @var string */ private $userId; /** @var SignatoryMapper */ @@ -68,9 +68,9 @@ protected function resetAllSignaturesEvent(): SignaturesResetEvent { * * @param int $termId * - * @return JSONResponse + * @return DataResponse */ - public function signTerms(int $termId): JSONResponse { + public function signTerms(int $termId): DataResponse { $signatory = new Signatory(); $signatory->setUserId($this->userId); $signatory->setTermsId($termId); @@ -87,7 +87,7 @@ public function signTerms(int $termId): JSONResponse { // Mark all notifications as processed … $this->notificationsManager->markProcessed($notification); - return new JSONResponse(); + return new DataResponse(); } @@ -96,20 +96,20 @@ public function signTerms(int $termId): JSONResponse { * * @param int $termId * @UseSession - * @return JSONResponse + * @return DataResponse */ - public function signTermsPublic(int $termId): JSONResponse { + public function signTermsPublic(int $termId): DataResponse { $uuid = $this->config->getAppValue(Application::APPNAME, 'term_uuid', ''); $this->session->set('term_uuid', $uuid); - return new JSONResponse(); + return new DataResponse(); } /** - * @return JSONResponse + * @return DataResponse */ - public function resetAllSignatories(): JSONResponse { + public function resetAllSignatories(): DataResponse { $this->signatoryMapper->deleteAllSignatories(); $this->config->setAppValue(Application::APPNAME, 'term_uuid', uniqid()); @@ -132,6 +132,6 @@ public function resetAllSignatories(): JSONResponse { $event = $this->resetAllSignaturesEvent(); $this->eventDispatcher->dispatchTyped($event); - return new JSONResponse(); + return new DataResponse(); } } diff --git a/lib/Controller/TermsController.php b/lib/Controller/TermsController.php index f72ad7fd..1adbe956 100644 --- a/lib/Controller/TermsController.php +++ b/lib/Controller/TermsController.php @@ -15,16 +15,16 @@ use OCA\TermsOfService\Db\Mapper\SignatoryMapper; use OCA\TermsOfService\Db\Mapper\TermsMapper; use OCA\TermsOfService\Exceptions\TermsNotFoundException; -use OCP\AppFramework\Controller; +use OCP\AppFramework\OCSController; use OCP\AppFramework\Http; -use OCP\AppFramework\Http\JSONResponse; +use OCP\AppFramework\Http\DataResponse; use OCP\IConfig; use OCP\IRequest; use OCP\L10N\IFactory; use OCA\TermsOfService\Events\TermsCreatedEvent; use OCP\EventDispatcher\IEventDispatcher; -class TermsController extends Controller { +class TermsController extends OCSController { /** @var IFactory */ private $factory; /** @var TermsMapper */ @@ -71,9 +71,9 @@ public function __construct(string $appName, /** * @PublicPage - * @return JSONResponse + * @return DataResponse */ - public function index(): JSONResponse { + public function index(): DataResponse { $currentCountry = $this->countryDetector->getCountry(); $countryTerms = $this->termsMapper->getTermsForCountryCode($currentCountry); @@ -87,13 +87,13 @@ public function index(): JSONResponse { 'languages' => $this->languageMapper->getLanguages(), 'hasSigned' => $this->checker->currentUserHasSigned(), ]; - return new JSONResponse($response); + return new DataResponse($response); } /** - * @return JSONResponse + * @return DataResponse */ - public function getAdminFormData(): JSONResponse { + public function getAdminFormData(): DataResponse { $response = [ 'terms' => $this->termsMapper->getTerms(), 'countries' => $this->countryMapper->getCountries(), @@ -101,21 +101,21 @@ public function getAdminFormData(): JSONResponse { 'tos_on_public_shares' => $this->config->getAppValue(Application::APPNAME, 'tos_on_public_shares', '0'), 'tos_for_users' => $this->config->getAppValue(Application::APPNAME, 'tos_for_users', '1'), ]; - return new JSONResponse($response); + return new DataResponse($response); } /** * @param int $id - * @return JSONResponse + * @return DataResponse */ - public function destroy(int $id): JSONResponse { + public function destroy(int $id): DataResponse { $terms = new Terms(); $terms->setId($id); $this->termsMapper->delete($terms); $this->signatoryMapper->deleteTerm($terms); - return new JSONResponse(); + return new DataResponse(); } protected function createTermsCreatedEvent(): TermsCreatedEvent { return new TermsCreatedEvent(); @@ -125,11 +125,11 @@ protected function createTermsCreatedEvent(): TermsCreatedEvent { * @param string $countryCode * @param string $languageCode * @param string $body - * @return JSONResponse + * @return DataResponse */ public function create(string $countryCode, string $languageCode, - string $body): JSONResponse { + string $body): DataResponse { $update = false; try { // Update terms @@ -141,7 +141,7 @@ public function create(string $countryCode, } if (!$this->countryMapper->isValidCountry($countryCode) || !$this->languageMapper->isValidLanguage($languageCode)) { - return new JSONResponse([], Http::STATUS_EXPECTATION_FAILED); + return new DataResponse([], Http::STATUS_EXPECTATION_FAILED); } $terms->setCountryCode($countryCode); @@ -157,6 +157,6 @@ public function create(string $countryCode, $event = $this->createTermsCreatedEvent(); $this->eventDispatcher->dispatchTyped($event); - return new JSONResponse($terms); + return new DataResponse($terms); } } diff --git a/src/App.vue b/src/App.vue index 15768610..9beee15f 100644 --- a/src/App.vue +++ b/src/App.vue @@ -72,7 +72,7 @@ import NcCheckboxRadioSwitch from '@nextcloud/vue/dist/Components/NcCheckboxRadi import NcSelect from '@nextcloud/vue/dist/Components/NcSelect.js' import NcSettingsSection from '@nextcloud/vue/dist/Components/NcSettingsSection.js' import { showError, showSuccess } from '@nextcloud/dialogs' -import { generateUrl } from '@nextcloud/router' +import { generateOcsUrl } from '@nextcloud/router' // Styles import '@nextcloud/dialogs/style.css' @@ -139,15 +139,16 @@ export default { this.saveButtonText = t('terms_of_service', 'Loading …') this.resetButtonText = t('terms_of_service', 'Reset all signatories') axios - .get(generateUrl('/apps/terms_of_service/terms/admin')) + .get(generateOcsUrl('/apps/terms_of_service/terms/admin')) .then(response => { - if (response.data.terms.length !== 0) { - this.terms = response.data.terms + const data = response.data.ocs.data + if (data.terms.length !== 0) { + this.terms = data.terms } - this.countries = response.data.countries - this.languages = response.data.languages - this.showOnPublicShares = response.data.tos_on_public_shares === '1' - this.showForLoggedInUser = response.data.tos_for_users === '1' + this.countries = data.countries + this.languages = data.languages + this.showOnPublicShares = data.tos_on_public_shares === '1' + this.showForLoggedInUser = data.tos_for_users === '1' Object.keys(this.countries).forEach((countryCode) => { this.countryOptions.push({ value: countryCode, @@ -178,14 +179,15 @@ export default { this.saveButtonDisabled = true axios - .post(generateUrl('/apps/terms_of_service/terms'), + .post(generateOcsUrl('/apps/terms_of_service/terms'), { countryCode: this.country.value, languageCode: this.language.value, body: this.body, }) .then(response => { - this.$set(this.terms, response.data.id, response.data) + const data = response.data.ocs.data + this.$set(this.terms, data.id, data) showSuccess(t('terms_of_service', 'Terms saved successfully!')) this.saveButtonDisabled = false @@ -195,7 +197,7 @@ export default { this.resetButtonDisabled = true axios - .delete(generateUrl('/apps/terms_of_service/sign')) + .delete(generateOcsUrl('/apps/terms_of_service/sign')) .then(() => { showSuccess(t('terms_of_service', 'All signatories reset!')) this.resetButtonDisabled = false diff --git a/src/Registration.vue b/src/Registration.vue index 735717c1..5b1cf1f9 100644 --- a/src/Registration.vue +++ b/src/Registration.vue @@ -47,7 +47,7 @@ ","var render = function render(){var _vm=this,_c=_vm._self._c;return _c('span',_vm._b({staticClass:\"material-design-icon delete-icon\",attrs:{\"aria-hidden\":_vm.title ? null : 'true',\"aria-label\":_vm.title,\"role\":\"img\"},on:{\"click\":function($event){return _vm.$emit('click', $event)}}},'span',_vm.$attrs,false),[_c('svg',{staticClass:\"material-design-icon__svg\",attrs:{\"fill\":_vm.fillColor,\"width\":_vm.size,\"height\":_vm.size,\"viewBox\":\"0 0 24 24\"}},[_c('path',{attrs:{\"d\":\"M19,4H15.5L14.5,3H9.5L8.5,4H5V6H19M6,19A2,2 0 0,0 8,21H16A2,2 0 0,0 18,19V7H6V19Z\"}},[(_vm.title)?_c('title',[_vm._v(_vm._s(_vm.title))]):_vm._e()])])])\n}\nvar staticRenderFns = []\n\nexport { render, staticRenderFns }","import { render, staticRenderFns } from \"./Pencil.vue?vue&type=template&id=7adfde2b\"\nimport script from \"./Pencil.vue?vue&type=script&lang=js\"\nexport * from \"./Pencil.vue?vue&type=script&lang=js\"\n\n\n/* normalize component */\nimport normalizer from \"!../vue-loader/lib/runtime/componentNormalizer.js\"\nvar component = normalizer(\n script,\n render,\n staticRenderFns,\n false,\n null,\n null,\n null\n \n)\n\nexport default component.exports","\n\n","var render = function render(){var _vm=this,_c=_vm._self._c;return _c('span',_vm._b({staticClass:\"material-design-icon pencil-icon\",attrs:{\"aria-hidden\":_vm.title ? null : 'true',\"aria-label\":_vm.title,\"role\":\"img\"},on:{\"click\":function($event){return _vm.$emit('click', $event)}}},'span',_vm.$attrs,false),[_c('svg',{staticClass:\"material-design-icon__svg\",attrs:{\"fill\":_vm.fillColor,\"width\":_vm.size,\"height\":_vm.size,\"viewBox\":\"0 0 24 24\"}},[_c('path',{attrs:{\"d\":\"M20.71,7.04C21.1,6.65 21.1,6 20.71,5.63L18.37,3.29C18,2.9 17.35,2.9 16.96,3.29L15.12,5.12L18.87,8.87M3,17.25V21H6.75L17.81,9.93L14.06,6.18L3,17.25Z\"}},[(_vm.title)?_c('title',[_vm._v(_vm._s(_vm.title))]):_vm._e()])])])\n}\nvar staticRenderFns = []\n\nexport { render, staticRenderFns }","\n\n\n\n\n\n","import mod from \"-!../../node_modules/babel-loader/lib/index.js!../../node_modules/vue-loader/lib/index.js??vue-loader-options!./Term.vue?vue&type=script&lang=js\"; export default mod; export * from \"-!../../node_modules/babel-loader/lib/index.js!../../node_modules/vue-loader/lib/index.js??vue-loader-options!./Term.vue?vue&type=script&lang=js\"","\n import API from \"!../../node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js\";\n import domAPI from \"!../../node_modules/style-loader/dist/runtime/styleDomAPI.js\";\n import insertFn from \"!../../node_modules/style-loader/dist/runtime/insertBySelector.js\";\n import setAttributes from \"!../../node_modules/style-loader/dist/runtime/setAttributesWithoutAttributes.js\";\n import insertStyleElement from \"!../../node_modules/style-loader/dist/runtime/insertStyleElement.js\";\n import styleTagTransformFn from \"!../../node_modules/style-loader/dist/runtime/styleTagTransform.js\";\n import content, * as namedExport from \"!!../../node_modules/css-loader/dist/cjs.js!../../node_modules/vue-loader/lib/loaders/stylePostLoader.js!../../node_modules/sass-loader/dist/cjs.js!../../node_modules/vue-loader/lib/index.js??vue-loader-options!./Term.vue?vue&type=style&index=0&id=01348255&prod&lang=scss&scoped=true\";\n \n \n\nvar options = {};\n\noptions.styleTagTransform = styleTagTransformFn;\noptions.setAttributes = setAttributes;\noptions.insert = insertFn.bind(null, \"head\");\noptions.domAPI = domAPI;\noptions.insertStyleElement = insertStyleElement;\n\nvar update = API(content, options);\n\n\n\nexport * from \"!!../../node_modules/css-loader/dist/cjs.js!../../node_modules/vue-loader/lib/loaders/stylePostLoader.js!../../node_modules/sass-loader/dist/cjs.js!../../node_modules/vue-loader/lib/index.js??vue-loader-options!./Term.vue?vue&type=style&index=0&id=01348255&prod&lang=scss&scoped=true\";\n export default content && content.locals ? content.locals : undefined;\n","import { render, staticRenderFns } from \"./Term.vue?vue&type=template&id=01348255&scoped=true\"\nimport script from \"./Term.vue?vue&type=script&lang=js\"\nexport * from \"./Term.vue?vue&type=script&lang=js\"\nimport style0 from \"./Term.vue?vue&type=style&index=0&id=01348255&prod&lang=scss&scoped=true\"\n\n\n/* normalize component */\nimport normalizer from \"!../../node_modules/vue-loader/lib/runtime/componentNormalizer.js\"\nvar component = normalizer(\n script,\n render,\n staticRenderFns,\n false,\n null,\n \"01348255\",\n null\n \n)\n\nexport default component.exports","var render = function render(){var _vm=this,_c=_vm._self._c;return _c('li',{staticClass:\"terms-row\"},[_c('span',{staticClass:\"terms-row__label\"},[_vm._v(\"\\n\\t\\t\"+_vm._s(_vm.country)+\" (\"+_vm._s(_vm.language)+\")\\n\\t\")]),_vm._v(\" \"),_c('NcButton',{attrs:{\"aria-label\":_vm.editButtonLabel,\"type\":\"tertiary\"},on:{\"click\":_vm.onEdit},scopedSlots:_vm._u([{key:\"icon\",fn:function(){return [_c('IconPencil',{attrs:{\"size\":20}})]},proxy:true}])}),_vm._v(\" \"),_c('NcButton',{attrs:{\"disabled\":_vm.deleteButtonDisabled,\"type\":\"tertiary\",\"aria-label\":_vm.deleteButtonLabel},on:{\"click\":_vm.onDelete},scopedSlots:_vm._u([{key:\"icon\",fn:function(){return [_c('IconDelete',{attrs:{\"size\":20}})]},proxy:true}])})],1)\n}\nvar staticRenderFns = []\n\nexport { render, staticRenderFns }","import { basename } from \"path\";\nimport Vue, { toRaw, defineComponent, onMounted, onUnmounted } from \"vue\";\nimport { t, n, a as normalizeComponent } from \"./chunks/_plugin-vue2_normalizer-CQ6iBklL.mjs\";\nimport { h, f, g, d, e, c, T, b, l, k, s, i, m, j } from \"./chunks/_plugin-vue2_normalizer-CQ6iBklL.mjs\";\nimport NcDialog from \"@nextcloud/vue/dist/Components/NcDialog.js\";\nimport NcNoteCard from \"@nextcloud/vue/dist/Components/NcNoteCard.js\";\nconst spawnDialog = (dialog, props, onClose = () => {\n}) => {\n const el = document.createElement(\"div\");\n const container = document.querySelector(props == null ? void 0 : props.container) || document.body;\n container.appendChild(el);\n const vue = new Vue({\n el,\n name: \"VueDialogHelper\",\n render: (h2) => h2(dialog, {\n props,\n on: {\n close: (...rest) => {\n onClose(...rest.map((v) => toRaw(v)));\n vue.$destroy();\n }\n }\n })\n });\n return vue;\n};\nconst IconMove = '';\nconst IconCopy = '';\nvar __defProp = Object.defineProperty;\nvar __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;\nvar __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== \"symbol\" ? key + \"\" : key, value);\nvar FilePickerType = /* @__PURE__ */ ((FilePickerType2) => {\n FilePickerType2[FilePickerType2[\"Choose\"] = 1] = \"Choose\";\n FilePickerType2[FilePickerType2[\"Move\"] = 2] = \"Move\";\n FilePickerType2[FilePickerType2[\"Copy\"] = 3] = \"Copy\";\n FilePickerType2[FilePickerType2[\"CopyMove\"] = 4] = \"CopyMove\";\n FilePickerType2[FilePickerType2[\"Custom\"] = 5] = \"Custom\";\n return FilePickerType2;\n})(FilePickerType || {});\nclass FilePickerClosed extends Error {\n}\nclass FilePicker {\n constructor(title, multiSelect, mimeTypeFilter, directoriesAllowed, buttons, path, filter, container, disabledNavigation = false) {\n __publicField(this, \"title\");\n __publicField(this, \"multiSelect\");\n __publicField(this, \"mimeTypeFilter\");\n __publicField(this, \"directoriesAllowed\");\n __publicField(this, \"buttons\");\n __publicField(this, \"path\");\n __publicField(this, \"filter\");\n __publicField(this, \"container\");\n __publicField(this, \"disabledNavigation\");\n this.title = title;\n this.multiSelect = multiSelect;\n this.mimeTypeFilter = mimeTypeFilter;\n this.directoriesAllowed = directoriesAllowed;\n this.path = path;\n this.filter = filter;\n this.buttons = buttons;\n this.container = container;\n this.disabledNavigation = disabledNavigation;\n }\n /**\n * Pick files using the FilePicker\n *\n * @return Promise with array of picked files or rejected promise on close without picking\n */\n async pick() {\n const { FilePickerVue } = await import(\"./chunks/index-C1azEbgd.mjs\");\n return new Promise((resolve, reject) => {\n spawnDialog(FilePickerVue, {\n allowPickDirectory: this.directoriesAllowed,\n buttons: this.buttons,\n container: this.container,\n name: this.title,\n path: this.path,\n mimetypeFilter: this.mimeTypeFilter,\n multiselect: this.multiSelect,\n filterFn: this.filter,\n disabledNavigation: this.disabledNavigation\n }, (...rest) => {\n var _a;\n const [nodes] = rest;\n if (!Array.isArray(nodes) || nodes.length === 0) {\n reject(new FilePickerClosed(\"FilePicker: No nodes selected\"));\n } else {\n if (this.multiSelect) {\n resolve(nodes.map((node) => node.path));\n } else {\n resolve(((_a = nodes[0]) == null ? void 0 : _a.path) || \"/\");\n }\n }\n });\n });\n }\n}\nclass FilePickerBuilder {\n /**\n * Construct a new FilePicker\n *\n * @param title Title of the FilePicker\n */\n constructor(title) {\n __publicField(this, \"title\");\n __publicField(this, \"multiSelect\", false);\n __publicField(this, \"mimeTypeFilter\", []);\n __publicField(this, \"directoriesAllowed\", false);\n __publicField(this, \"path\");\n __publicField(this, \"filter\");\n __publicField(this, \"buttons\", []);\n __publicField(this, \"container\");\n __publicField(this, \"disabledNavigation\", false);\n this.title = title;\n }\n /**\n * Set the container where the FilePicker will be mounted\n * By default 'body' is used\n *\n * @param container The dialog container\n */\n setContainer(container) {\n this.container = container;\n return this;\n }\n /**\n * Enable or disable picking multiple files\n *\n * @param ms True to enable picking multiple files, false otherwise\n */\n setMultiSelect(ms) {\n this.multiSelect = ms;\n return this;\n }\n /**\n * Add allowed MIME type\n *\n * @param filter MIME type to allow\n */\n addMimeTypeFilter(filter) {\n this.mimeTypeFilter.push(filter);\n return this;\n }\n /**\n * Set allowed MIME types\n *\n * @param filter Array of allowed MIME types\n */\n setMimeTypeFilter(filter) {\n this.mimeTypeFilter = filter;\n return this;\n }\n /**\n * Add a button to the FilePicker\n * Note: This overrides any previous `setButtonFactory` call\n *\n * @param button The button\n */\n addButton(button) {\n if (typeof this.buttons === \"function\") {\n console.warn(\"FilePicker buttons were set to factory, now overwritten with button object.\");\n this.buttons = [];\n }\n this.buttons.push(button);\n return this;\n }\n /**\n * Set the button factory which is used to generate buttons from current view, path and selected nodes\n * Note: This overrides any previous `addButton` call\n *\n * @param factory The button factory\n */\n setButtonFactory(factory) {\n this.buttons = factory;\n return this;\n }\n /**\n * Set FilePicker type based on legacy file picker types\n * @param type The legacy filepicker type to emulate\n * @deprecated Use `addButton` or `setButtonFactory` instead as with setType you do not know which button was pressed\n */\n setType(type) {\n this.buttons = (nodes, path) => {\n var _a, _b, _c;\n const buttons = [];\n const node = ((_b = (_a = nodes == null ? void 0 : nodes[0]) == null ? void 0 : _a.attributes) == null ? void 0 : _b.displayName) || ((_c = nodes == null ? void 0 : nodes[0]) == null ? void 0 : _c.basename);\n const target = node || basename(path);\n if (type === 1) {\n let label = t(\"Choose\");\n if (nodes.length === 1) {\n label = t(\"Choose {file}\", { file: node });\n } else if (this.multiSelect) {\n label = n(\"Choose %n file\", \"Choose %n files\", nodes.length);\n }\n buttons.push({\n callback: () => {\n },\n type: \"primary\",\n label\n });\n }\n if (type === 4 || type === 3) {\n buttons.push({\n callback: () => {\n },\n label: target ? t(\"Copy to {target}\", { target }) : t(\"Copy\"),\n type: \"primary\",\n icon: IconCopy\n });\n }\n if (type === 2 || type === 4) {\n buttons.push({\n callback: () => {\n },\n label: target ? t(\"Move to {target}\", { target }) : t(\"Move\"),\n type: type === 2 ? \"primary\" : \"secondary\",\n icon: IconMove\n });\n }\n return buttons;\n };\n return this;\n }\n /**\n * Allow to pick directories besides files\n *\n * @param allow True to allow picking directories\n */\n allowDirectories(allow = true) {\n this.directoriesAllowed = allow;\n return this;\n }\n /**\n * Set starting path of the FilePicker\n *\n * @param path Path to start from picking\n */\n startAt(path) {\n this.path = path;\n return this;\n }\n /**\n * Add filter function to filter file list of FilePicker\n *\n * @param filter Filter function to apply\n */\n setFilter(filter) {\n this.filter = filter;\n return this;\n }\n /**\n * Allow to pick directories besides files\n *\n * @param allow True to allow picking directories\n */\n disableNavigation() {\n this.disabledNavigation = true;\n return this;\n }\n /**\n * Construct the configured FilePicker\n */\n build() {\n return new FilePicker(\n this.title,\n this.multiSelect,\n this.mimeTypeFilter,\n this.directoriesAllowed,\n this.buttons,\n this.path,\n this.filter,\n this.container,\n this.disabledNavigation\n );\n }\n}\nfunction getFilePickerBuilder(title) {\n return new FilePickerBuilder(title);\n}\nvar DialogSeverity = /* @__PURE__ */ ((DialogSeverity2) => {\n DialogSeverity2[\"Info\"] = \"info\";\n DialogSeverity2[\"Warning\"] = \"warning\";\n DialogSeverity2[\"Error\"] = \"error\";\n return DialogSeverity2;\n})(DialogSeverity || {});\nconst _sfc_main = /* @__PURE__ */ defineComponent({\n __name: \"GenericDialog\",\n props: {\n name: null,\n text: null,\n html: null,\n buttons: null,\n severity: null\n },\n setup(__props) {\n const props = __props;\n const handleUnload = () => \"\".concat(props.name, \": \").concat(props.text);\n onMounted(() => window.addEventListener(\"unload\", handleUnload));\n onUnmounted(() => window.removeEventListener(\"unload\", handleUnload));\n return { __sfc: true, props, handleUnload, NcDialog, NcNoteCard };\n }\n});\nvar _sfc_render = function render() {\n var _vm = this, _c = _vm._self._c, _setup = _vm._self._setupProxy;\n return _c(_setup.NcDialog, { attrs: { \"dialog-classes\": \"nc-generic-dialog\", \"buttons\": _vm.buttons, \"name\": _vm.name, \"message\": _vm.text }, on: { \"update:open\": function($event) {\n return _vm.$emit(\"close\");\n } } }, [_vm.severity ? _c(_setup.NcNoteCard, { attrs: { \"type\": _vm.severity } }, [_c(\"p\", { domProps: { \"textContent\": _vm._s(_vm.text) } })]) : _vm._e(), _vm.html ? _c(\"div\", { domProps: { \"innerHTML\": _vm._s(_vm.html) } }) : _vm._e()], 1);\n};\nvar _sfc_staticRenderFns = [];\nvar __component__ = /* @__PURE__ */ normalizeComponent(\n _sfc_main,\n _sfc_render,\n _sfc_staticRenderFns,\n false,\n null,\n null,\n null,\n null\n);\nconst GenericDialog = __component__.exports;\nvar __typeError = (msg) => {\n throw TypeError(msg);\n};\nvar __accessCheck = (obj, member, msg) => member.has(obj) || __typeError(\"Cannot \" + msg);\nvar __privateGet = (obj, member, getter) => (__accessCheck(obj, member, \"read from private field\"), getter ? getter.call(obj) : member.get(obj));\nvar __privateAdd = (obj, member, value) => member.has(obj) ? __typeError(\"Cannot add the same private member more than once\") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);\nvar __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, \"write to private field\"), setter ? setter.call(obj, value) : member.set(obj, value), value);\nvar _name, _text, _buttons, _severity, _dialog, _html, _severity2, _text2, _name2, _buttons2;\nclass Dialog {\n constructor(name, text, buttons = [], severity) {\n __privateAdd(this, _name);\n __privateAdd(this, _text);\n __privateAdd(this, _buttons);\n __privateAdd(this, _severity);\n __privateAdd(this, _dialog);\n __privateAdd(this, _html);\n __privateSet(this, _name, name);\n __privateSet(this, _text, text);\n __privateSet(this, _buttons, buttons);\n __privateSet(this, _severity, severity);\n __privateSet(this, _dialog, void 0);\n __privateSet(this, _html, void 0);\n }\n /**\n * @deprecated DO NOT USE! It will be removed in the near future!\n * @param html HTML content\n */\n setHTML(html) {\n __privateSet(this, _html, html);\n return this;\n }\n /**\n * Spawn and show the dialog - if already open the previous instance will be destroyed\n * @return Promise that resolves when the dialog is answered successfully and rejects on close\n */\n show() {\n if (__privateGet(this, _dialog)) {\n __privateGet(this, _dialog).$destroy();\n }\n return new Promise((resolve) => {\n __privateSet(this, _dialog, spawnDialog(\n GenericDialog,\n {\n buttons: __privateGet(this, _buttons),\n name: __privateGet(this, _name),\n text: __privateGet(this, _text),\n severity: __privateGet(this, _severity),\n html: __privateGet(this, _html)\n },\n resolve\n ));\n });\n }\n /**\n * Hide and destroy the current dialog instance\n */\n hide() {\n var _a;\n (_a = __privateGet(this, _dialog)) == null ? void 0 : _a.$destroy();\n }\n}\n_name = /* @__PURE__ */ new WeakMap();\n_text = /* @__PURE__ */ new WeakMap();\n_buttons = /* @__PURE__ */ new WeakMap();\n_severity = /* @__PURE__ */ new WeakMap();\n_dialog = /* @__PURE__ */ new WeakMap();\n_html = /* @__PURE__ */ new WeakMap();\nclass DialogBuilder {\n constructor(name) {\n __privateAdd(this, _severity2);\n __privateAdd(this, _text2);\n __privateAdd(this, _name2);\n __privateAdd(this, _buttons2);\n __privateSet(this, _severity2, void 0);\n __privateSet(this, _text2, \"\");\n __privateSet(this, _name2, name != null ? name : \"\");\n __privateSet(this, _buttons2, []);\n }\n /**\n * Set dialog name\n * @param name The name or headline of the dialog\n */\n setName(name) {\n __privateSet(this, _name2, name);\n return this;\n }\n /**\n * Set the dialog text\n * @param text Main text of the dialog\n */\n setText(text) {\n __privateSet(this, _text2, text);\n return this;\n }\n /**\n * Set the severity of the dialog\n * @param severity Severity of the dialog\n */\n setSeverity(severity) {\n __privateSet(this, _severity2, severity);\n return this;\n }\n /**\n * Set buttons from array\n * @param buttons Either an array of dialog buttons\n */\n setButtons(buttons) {\n if (__privateGet(this, _buttons2).length > 0) {\n console.warn(\"[@nextcloud/dialogs] Dialog buttons are already set - this overrides previous buttons.\");\n }\n __privateSet(this, _buttons2, buttons);\n return this;\n }\n /**\n * Add a single button\n * @param button Button to add\n */\n addButton(button) {\n __privateGet(this, _buttons2).push(button);\n return this;\n }\n build() {\n return new Dialog(__privateGet(this, _name2), __privateGet(this, _text2), __privateGet(this, _buttons2), __privateGet(this, _severity2));\n }\n}\n_severity2 = /* @__PURE__ */ new WeakMap();\n_text2 = /* @__PURE__ */ new WeakMap();\n_name2 = /* @__PURE__ */ new WeakMap();\n_buttons2 = /* @__PURE__ */ new WeakMap();\nfunction getDialogBuilder(name) {\n return new DialogBuilder(name);\n}\nexport {\n Dialog,\n DialogBuilder,\n DialogSeverity,\n FilePicker,\n FilePickerBuilder,\n FilePickerClosed,\n FilePickerType,\n h as TOAST_ARIA_LIVE_ASSERTIVE,\n f as TOAST_ARIA_LIVE_OFF,\n g as TOAST_ARIA_LIVE_POLITE,\n d as TOAST_DEFAULT_TIMEOUT,\n e as TOAST_PERMANENT_TIMEOUT,\n c as TOAST_UNDO_TIMEOUT,\n T as ToastAriaLive,\n b as ToastType,\n getDialogBuilder,\n getFilePickerBuilder,\n l as showError,\n k as showInfo,\n s as showMessage,\n i as showSuccess,\n m as showUndo,\n j as showWarning,\n spawnDialog\n};\n","\n import API from \"!../../../style-loader/dist/runtime/injectStylesIntoStyleTag.js\";\n import domAPI from \"!../../../style-loader/dist/runtime/styleDomAPI.js\";\n import insertFn from \"!../../../style-loader/dist/runtime/insertBySelector.js\";\n import setAttributes from \"!../../../style-loader/dist/runtime/setAttributesWithoutAttributes.js\";\n import insertStyleElement from \"!../../../style-loader/dist/runtime/insertStyleElement.js\";\n import styleTagTransformFn from \"!../../../style-loader/dist/runtime/styleTagTransform.js\";\n import content, * as namedExport from \"!!../../../css-loader/dist/cjs.js!./style.css\";\n \n \n\nvar options = {};\n\noptions.styleTagTransform = styleTagTransformFn;\noptions.setAttributes = setAttributes;\noptions.insert = insertFn.bind(null, \"head\");\noptions.domAPI = domAPI;\noptions.insertStyleElement = insertStyleElement;\n\nvar update = API(content, options);\n\n\n\nexport * from \"!!../../../css-loader/dist/cjs.js!./style.css\";\n export default content && content.locals ? content.locals : undefined;\n","import mod from \"-!../node_modules/babel-loader/lib/index.js!../node_modules/vue-loader/lib/index.js??vue-loader-options!./App.vue?vue&type=script&lang=js\"; export default mod; export * from \"-!../node_modules/babel-loader/lib/index.js!../node_modules/vue-loader/lib/index.js??vue-loader-options!./App.vue?vue&type=script&lang=js\"","\n\n