diff --git a/css/icons.scss b/css/icons.scss index 563898b08a7..a31c35911be 100644 --- a/css/icons.scss +++ b/css/icons.scss @@ -11,6 +11,7 @@ .app-talk, .talk-modal, +#talk-panel, #talk-sidebar, #call-container, .talkChatTab { diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php index d7d3be81a7a..e56ce60b5f5 100644 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -35,6 +35,7 @@ use OCA\Talk\Collaboration\Resources\ConversationProvider; use OCA\Talk\Collaboration\Resources\Listener as ResourceListener; use OCA\Talk\Config; +use OCA\Talk\Dashboard\TalkWidget; use OCA\Talk\Events\ChatEvent; use OCA\Talk\Events\RoomEvent; use OCA\Talk\Files\Listener as FilesListener; @@ -95,6 +96,8 @@ public function register(IRegistrationContext $context): void { $context->registerEventListener(\OCP\AppFramework\Http\Events\BeforeTemplateRenderedEvent::class, UnifiedSearchCSSLoader::class); $context->registerSearchProvider(ConversationSearch::class); + + $context->registerDashboardWidget(TalkWidget::class); } public function boot(IBootContext $context): void { diff --git a/lib/Dashboard/TalkWidget.php b/lib/Dashboard/TalkWidget.php new file mode 100644 index 00000000000..16d1b962881 --- /dev/null +++ b/lib/Dashboard/TalkWidget.php @@ -0,0 +1,90 @@ + + * + * @author Julius Härtl + * + * @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 . + * + */ + +namespace OCA\Talk\Dashboard; + +use OCP\Dashboard\IWidget; +use OCP\IL10N; +use OCP\IURLGenerator; +use OCP\Util; + +class TalkWidget implements IWidget { + + /** @var IURLGenerator */ + private $url; + /** @var IL10N */ + private $l10n; + + public function __construct( + IURLGenerator $url, + IL10N $l10n + ) { + $this->url = $url; + $this->l10n = $l10n; + } + + /** + * @inheritDoc + */ + public function getId(): string { + return 'spreed'; + } + + /** + * @inheritDoc + */ + public function getTitle(): string { + return $this->l10n->t('Talk mentions'); + } + + /** + * @inheritDoc + */ + public function getOrder(): int { + return 10; + } + + /** + * @inheritDoc + */ + public function getIconClass(): string { + return 'icon-talk'; + } + + /** + * @inheritDoc + */ + public function getUrl(): ?string { + return $this->url->linkToRouteAbsolute('spreed.Page.index'); + } + + /** + * @inheritDoc + */ + public function load(): void { + Util::addStyle('spreed', 'icons'); + Util::addScript('spreed', 'dashboard'); + } +} diff --git a/package-lock.json b/package-lock.json index 4c13ffd1e38..b6ba71da729 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3617,6 +3617,16 @@ "vue2-datepicker": "^3.4.1" } }, + "@nextcloud/vue-dashboard": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/@nextcloud/vue-dashboard/-/vue-dashboard-0.1.3.tgz", + "integrity": "sha512-7b02zkarX7b18IRQmZEW1NM+dvtcUih2M0+CZyuQfcvfyMQudOz+BdA/oD1p7PmdBds1IR8OvY1+CnpmgAzfQg==", + "requires": { + "@nextcloud/vue": "^2.3.0", + "core-js": "^3.6.4", + "vue": "^2.6.11" + } + }, "@nodelib/fs.scandir": { "version": "2.1.3", "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.3.tgz", diff --git a/package.json b/package.json index d86b4195541..762a6f5bb1a 100644 --- a/package.json +++ b/package.json @@ -27,6 +27,7 @@ "@nextcloud/moment": "^1.1.1", "@nextcloud/router": "^1.1.0", "@nextcloud/vue": "^2.3.0", + "@nextcloud/vue-dashboard": "^0.1.3", "attachmediastream": "^2.1.0", "crypto-js": "^4.0.0", "debounce": "^1.2.0", diff --git a/src/App.vue b/src/App.vue index 655be16cd52..28105deedce 100644 --- a/src/App.vue +++ b/src/App.vue @@ -79,7 +79,7 @@ export default { isInCall, ], - data: function() { + data() { return { savedLastMessageMap: {}, defaultPageTitle: false, diff --git a/src/dashboard.js b/src/dashboard.js new file mode 100644 index 00000000000..b516f8d26a2 --- /dev/null +++ b/src/dashboard.js @@ -0,0 +1,54 @@ +/* + * @copyright Copyright (c) 2020 Julius Härtl + * + * @author Julius Härtl + * + * @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 . + * + */ + +import Vue from 'vue' +import { generateFilePath } from '@nextcloud/router' +import { getRequestToken } from '@nextcloud/auth' +import { translate, translatePlural } from '@nextcloud/l10n' +import Dashboard from './views/Dashboard' + +// CSP config for webpack dynamic chunk loading +// eslint-disable-next-line +__webpack_nonce__ = btoa(getRequestToken()) + +// Correct the root of the app for chunk loading +// OC.linkTo matches the apps folders +// OC.generateUrl ensure the index.php (or not) +// We do not want the index.php since we're loading files +// eslint-disable-next-line +__webpack_public_path__ = generateFilePath('spreed', '', 'js/') + +Vue.prototype.t = translate +Vue.prototype.n = translatePlural +Vue.prototype.OC = OC +Vue.prototype.OCA = OCA + +document.addEventListener('DOMContentLoaded', function() { + + OCA.Dashboard.register('spreed', (el) => { + const View = Vue.extend(Dashboard) + new View({ + propsData: {}, + }).$mount(el) + }) + +}) diff --git a/src/views/Dashboard.vue b/src/views/Dashboard.vue new file mode 100644 index 00000000000..fd7421a7d71 --- /dev/null +++ b/src/views/Dashboard.vue @@ -0,0 +1,192 @@ + + + + + + + diff --git a/webpack.common.js b/webpack.common.js index 1c7e14db8e8..d86608e0e5e 100644 --- a/webpack.common.js +++ b/webpack.common.js @@ -13,6 +13,7 @@ module.exports = { 'talk-public-share-auth-sidebar': path.join(__dirname, 'src', 'mainPublicShareAuthSidebar.js'), 'talk-public-share-sidebar': path.join(__dirname, 'src', 'mainPublicShareSidebar.js'), 'flow': path.join(__dirname, 'src', 'flow.js'), + 'dashboard': path.join(__dirname, 'src', 'dashboard.js'), }, output: { path: path.resolve(__dirname, './js'),