diff options
Diffstat (limited to 'apps/comments/src/services/CommentsInstance.js')
-rw-r--r-- | apps/comments/src/services/CommentsInstance.js | 58 |
1 files changed, 22 insertions, 36 deletions
diff --git a/apps/comments/src/services/CommentsInstance.js b/apps/comments/src/services/CommentsInstance.js index f5263f35c3d..cc45d0cbea7 100644 --- a/apps/comments/src/services/CommentsInstance.js +++ b/apps/comments/src/services/CommentsInstance.js @@ -1,34 +1,18 @@ /** - * @copyright Copyright (c) 2020 John Molakvoæ <skjnldsv@protonmail.com> - * - * @author John Molakvoæ <skjnldsv@protonmail.com> - * - * @license AGPL-3.0-or-later - * - * 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/>. - * + * SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later */ -import { getLoggerBuilder } from '@nextcloud/logger' -import { translate as t, translatePlural as n } from '@nextcloud/l10n' -import CommentsApp from '../views/Comments' +import { getCSPNonce } from '@nextcloud/auth' +import { t, n } from '@nextcloud/l10n' +import { PiniaVuePlugin, createPinia } from 'pinia' import Vue from 'vue' +import CommentsApp from '../views/Comments.vue' +import logger from '../logger.js' -const logger = getLoggerBuilder() - .setApp('comments') - .detectUser() - .build() +Vue.use(PiniaVuePlugin) +// eslint-disable-next-line camelcase +__webpack_nonce__ = getCSPNonce() // Add translates functions Vue.mixin({ @@ -48,19 +32,21 @@ export default class CommentInstance { /** * Initialize a new Comments instance for the desired type * - * @param {string} commentsType the comments endpoint type + * @param {string} resourceType the comments endpoint type * @param {object} options the vue options (propsData, parent, el...) */ - constructor(commentsType = 'files', options) { - // Add comments type as a global mixin - Vue.mixin({ - data() { - return { - commentsType, - } - }, - }) + constructor(resourceType = 'files', options = {}) { + const pinia = createPinia() + // Merge options and set `resourceType` property + options = { + ...options, + propsData: { + ...(options.propsData ?? {}), + resourceType, + }, + pinia, + } // Init Comments component const View = Vue.extend(CommentsApp) return new View(options) |