From 8d58e6b584b6076a8a5a8721d8119c29ee6d1ca6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakob=20R=C3=B6hrl?= Date: Thu, 30 Jan 2020 14:19:56 +0100 Subject: [PATCH] add calendar link MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jakob Röhrl --- lib/Controller/PageController.php | 11 ++- package-lock.json | 25 +++++-- package.json | 1 + src/components/navigation/AppNavigation.vue | 3 + .../navigation/AppNavigationCalendar.vue | 72 +++++++++++++++++++ src/router.js | 15 ++++ src/services/IsCalendarInstalled.js | 26 +++++++ 7 files changed, 147 insertions(+), 6 deletions(-) create mode 100644 src/components/navigation/AppNavigationCalendar.vue create mode 100644 src/services/IsCalendarInstalled.js diff --git a/lib/Controller/PageController.php b/lib/Controller/PageController.php index bcd45b1c6..1165dd3e2 100644 --- a/lib/Controller/PageController.php +++ b/lib/Controller/PageController.php @@ -28,25 +28,32 @@ use OCP\IRequest; use OCP\AppFramework\Http\TemplateResponse; use OCP\AppFramework\Controller; use OCP\IL10N; +use OCP\IConfig; +use OCP\IInitialStateService; class PageController extends Controller { private $permissionService; private $userId; private $l10n; + private $config; public function __construct( $AppName, IRequest $request, PermissionService $permissionService, IL10N $l10n, - $userId + $userId, + IConfig $config, + IInitialStateService $initialStateService ) { parent::__construct($AppName, $request); $this->userId = $userId; $this->permissionService = $permissionService; $this->l10n = $l10n; + $this->config = $config; + $this->initialStateService = $initialStateService; } /** @@ -63,6 +70,8 @@ class PageController extends Controller { 'canCreate' => $this->permissionService->canCreate() ]; + $this->initialStateService->provideInitialState($this->appName, 'calendar', $this->config->getAppValue('calendar', 'enabled', 'no') === 'yes'); + return new TemplateResponse('deck', 'main', $params); } diff --git a/package-lock.json b/package-lock.json index 2a3b643d8..88cf218d9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3539,6 +3539,21 @@ } } }, + "@nextcloud/initial-state": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@nextcloud/initial-state/-/initial-state-1.1.0.tgz", + "integrity": "sha512-c8VNSv7CbcPdaMNQO3ERJUMhsGyCvAgSBlvBHhugYHxGqlySjE+J+SqkpXmqB+eQ/DujDTahBX1IwoF3zjPtOw==", + "requires": { + "core-js": "3.6.1" + }, + "dependencies": { + "core-js": { + "version": "3.6.1", + "resolved": "https://registry.npmjs.org/core-js/-/core-js-3.6.1.tgz", + "integrity": "sha512-186WjSik2iTGfDjfdCZAxv2ormxtKgemjC3SI6PL31qOA0j5LhTDVjHChccoc7brwLvpvLPiMyRlcO88C4l1QQ==" + } + } + }, "@nextcloud/l10n": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/@nextcloud/l10n/-/l10n-1.0.1.tgz", @@ -13369,7 +13384,7 @@ }, "mkdirp": { "version": "0.5.1", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", + "resolved": "http://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", "dev": true, "requires": { @@ -14049,7 +14064,7 @@ }, "os-homedir": { "version": "1.0.2", - "resolved": "https://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz", + "resolved": "http://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz", "integrity": "sha1-/7xJiDNuDoM94MFox+8VISGqf7M=", "dev": true }, @@ -14066,7 +14081,7 @@ }, "os-tmpdir": { "version": "1.0.2", - "resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", + "resolved": "http://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", "integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=", "dev": true }, @@ -14238,7 +14253,7 @@ }, "path-is-absolute": { "version": "1.0.1", - "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "resolved": "http://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=" }, "path-key": { @@ -17177,7 +17192,7 @@ }, "string_decoder": { "version": "1.1.1", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "resolved": "http://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", "requires": { "safe-buffer": "~5.1.0" diff --git a/package.json b/package.json index b953efc15..9c33ec020 100644 --- a/package.json +++ b/package.json @@ -30,6 +30,7 @@ "@babel/runtime": "^7.8.3", "@nextcloud/auth": "^1.2.1", "@nextcloud/axios": "^1.3.1", + "@nextcloud/initial-state": "^1.1.0", "@nextcloud/l10n": "^1.0.1", "@nextcloud/router": "^1.0.0", "@nextcloud/vue": "^1.3.0", diff --git a/src/components/navigation/AppNavigation.vue b/src/components/navigation/AppNavigation.vue index e85de43c2..3993fd672 100644 --- a/src/components/navigation/AppNavigation.vue +++ b/src/components/navigation/AppNavigation.vue @@ -40,6 +40,7 @@ :boards="sharedBoards" icon="icon-shared" /> +
+ - + - @author John Molakvoæ + - + - @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 . + - + --> + + + + diff --git a/src/router.js b/src/router.js index 285cf93d4..7548b9c6b 100644 --- a/src/router.js +++ b/src/router.js @@ -29,13 +29,28 @@ import Board from './components/board/Board' import Sidebar from './components/Sidebar' import BoardSidebar from './components/board/BoardSidebar' import CardSidebar from './components/card/CardSidebar' +import IsCalendarInstalled from '../src/services/IsCalendarInstalled' Vue.use(Router) +let calendarPath = generateUrl('/apps/calendar') +if (!IsCalendarInstalled) { + calendarPath = generateUrl('/settings/apps/integration/calendar') +} + + + export default new Router({ base: generateUrl('/apps/deck/'), linkActiveClass: 'active', routes: [ + { + path: '/calendar', + name: 'calendar', + beforeEnter() { + location.href = calendarPath + } + }, { path: '/', name: 'main', diff --git a/src/services/IsCalendarInstalled.js b/src/services/IsCalendarInstalled.js new file mode 100644 index 000000000..fede2d7ae --- /dev/null +++ b/src/services/IsCalendarInstalled.js @@ -0,0 +1,26 @@ +/** + * @copyright Copyright (c) 2018 John Molakvoæ + * + * @author John Molakvoæ + * + * @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 { loadState } from '@nextcloud/initial-state' + +const calendar = loadState('deck', 'calendar') +export default calendar \ No newline at end of file