From 184767224c0f403d0f99aa94bc5a0e1de1ffe973 Mon Sep 17 00:00:00 2001 From: Jannik Stehle Date: Tue, 21 Dec 2021 11:21:43 +0100 Subject: [PATCH 1/6] Remember the UI that was last selected via the application switcher --- Makefile.release | 1 + packages/web-integration-oc10/appinfo/app.php | 1 + .../web-integration-oc10/appinfo/routes.php | 1 + packages/web-integration-oc10/js/app.js | 7 ++ .../web-integration-oc10/lib/Application.php | 5 ++ .../lib/Controller/SettingsController.php | 84 +++++++++++++++++++ 6 files changed, 99 insertions(+) create mode 100644 packages/web-integration-oc10/js/app.js create mode 100644 packages/web-integration-oc10/lib/Controller/SettingsController.php diff --git a/Makefile.release b/Makefile.release index 465f1f75081..a43086232da 100644 --- a/Makefile.release +++ b/Makefile.release @@ -75,6 +75,7 @@ endif .PHONY: ocx-app-config ocx-app-config: cp -R packages/web-integration-oc10/appinfo $(dist_dir) + cp -R packages/web-integration-oc10/js $(dist_dir) cp -R packages/web-integration-oc10/lib $(dist_dir) .PHONY: ocx-app-bundle diff --git a/packages/web-integration-oc10/appinfo/app.php b/packages/web-integration-oc10/appinfo/app.php index 621ca0cb365..84805914f20 100644 --- a/packages/web-integration-oc10/appinfo/app.php +++ b/packages/web-integration-oc10/appinfo/app.php @@ -20,3 +20,4 @@ */ $app = new OCA\Web\Application(); +$app->boot(); diff --git a/packages/web-integration-oc10/appinfo/routes.php b/packages/web-integration-oc10/appinfo/routes.php index b64b62ae9f0..ab73a0eb59b 100644 --- a/packages/web-integration-oc10/appinfo/routes.php +++ b/packages/web-integration-oc10/appinfo/routes.php @@ -28,6 +28,7 @@ 'routes' => [ ['name' => 'Index#index', 'url' => '/', 'verb' => 'GET'], ['name' => 'Config#getConfig', 'url' => '/config.json', 'verb' => 'GET'], + ['name' => 'Settings#setWebDefaultConfig', 'url' => '/settings/default', 'verb' => 'POST'], [ 'name' => 'Files#getFile', 'url' => '/{path}', diff --git a/packages/web-integration-oc10/js/app.js b/packages/web-integration-oc10/js/app.js new file mode 100644 index 00000000000..88c1168f994 --- /dev/null +++ b/packages/web-integration-oc10/js/app.js @@ -0,0 +1,7 @@ +$(document).ready(function () { + $('#apps') + .find('li[data-id=web]') + .click(function () { + $.post(OC.generateUrl('/apps/web/settings/default'), { isDefault: true }) + }) +}) diff --git a/packages/web-integration-oc10/lib/Application.php b/packages/web-integration-oc10/lib/Application.php index cbbb7197a71..ee0e95080ee 100644 --- a/packages/web-integration-oc10/lib/Application.php +++ b/packages/web-integration-oc10/lib/Application.php @@ -22,6 +22,7 @@ namespace OCA\Web; use OCP\AppFramework\App; +use OCP\Util; class Application extends App { @@ -33,4 +34,8 @@ class Application extends App { public function __construct(array $urlParams = []) { parent::__construct(Application::APPID, $urlParams); } + + public function boot(): void { + Util::addscript(Application::APPID, 'app'); + } } diff --git a/packages/web-integration-oc10/lib/Controller/SettingsController.php b/packages/web-integration-oc10/lib/Controller/SettingsController.php new file mode 100644 index 00000000000..3fa53a18954 --- /dev/null +++ b/packages/web-integration-oc10/lib/Controller/SettingsController.php @@ -0,0 +1,84 @@ + + * @author Jan Ackermann + * + * @copyright Copyright (c) 2021, ownCloud GmbH + * @license AGPL-3.0 + * + * This code is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License, version 3, + * as published by the Free Software Foundation. + * + * 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, version 3, + * along with this program. If not, see + * + */ + +namespace OCA\Web\Controller; + +use OCP\AppFramework\Controller; +use OCP\AppFramework\Http\JSONResponse; +use OCP\IConfig; +use OCP\IRequest; +use OCP\IUserSession; + +/** + * Class SettingsController + * + * @package OCA\Web\Controller + */ +class SettingsController extends Controller { + + /** + * @var IConfig + */ + private $config; + + /** + * @var IUserSession + */ + private $userSession; + + /** + * @param string $appName + * @param IRequest $request an instance of the request + * @param IUserSession $userSession + * @param IConfig $config + */ + public function __construct( + $appName, + IRequest $request, + IUserSession $userSession, + IConfig $config + ) { + parent::__construct($appName, $request); + $this->config = $config; + $this->userSession = $userSession; + } + + /** + * Set the web default config. + * + * @NoAdminRequired + * + * @return JSONResponse + */ + public function setWebDefaultConfig() { + $value = \filter_var($this->request->getParam('isDefault'), FILTER_VALIDATE_BOOLEAN); + $user = $this->userSession->getUser(); + $configToSet = $value === true ? 'web' : null; + if (!$configToSet) { + $this->config->deleteUserValue($user->getUID(), 'core', 'defaultapp'); + } else { + $this->config->setUserValue($user->getUID(), 'core', 'defaultapp', $configToSet); + } + + return new JSONResponse([]); + } +} From bde2cda2254b262c97158792cadd28e0bc1148db Mon Sep 17 00:00:00 2001 From: Jannik Stehle Date: Tue, 21 Dec 2021 11:29:47 +0100 Subject: [PATCH 2/6] Exclude oC10 js files from eslint --- .eslintrc.js | 1 + 1 file changed, 1 insertion(+) diff --git a/.eslintrc.js b/.eslintrc.js index 2e072073763..035d949fb1c 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -35,6 +35,7 @@ module.exports = { requirejs: false }, plugins: ['jest', 'unused-imports'], + ignorePatterns: ['packages/web-integration-oc10/js'], overrides: [ { files: ['**/*.vue'], From 7feea13da4bc6ecdd9b8bfa799b9d40bd353a174 Mon Sep 17 00:00:00 2001 From: Jannik Stehle Date: Tue, 21 Dec 2021 11:52:35 +0100 Subject: [PATCH 3/6] Add changelog item, exclude oC10 app from SonarCloud --- changelog/unreleased/enhancement-remember-selected-ui | 6 ++++++ sonar-project.properties | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 changelog/unreleased/enhancement-remember-selected-ui diff --git a/changelog/unreleased/enhancement-remember-selected-ui b/changelog/unreleased/enhancement-remember-selected-ui new file mode 100644 index 00000000000..15b96a5a518 --- /dev/null +++ b/changelog/unreleased/enhancement-remember-selected-ui @@ -0,0 +1,6 @@ +Enhancement: Remember the UI that was last selected via the application switcher + +With this change, ownCloud will remember the UI that was last selected via the application switcher. This only works when using ownCloud 10 as backend. + +https://github.com/owncloud/web/pull/6173 +https://github.com/owncloud/enterprise/issues/4694 diff --git a/sonar-project.properties b/sonar-project.properties index 75a6c46ce02..1af4389ef5a 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -32,4 +32,4 @@ sonar.pullrequest.key=${env.SONAR_PULL_REQUEST_KEY} sonar.javascript.lcov.reportPaths=coverage/lcov.info # Exclude files -sonar.exclusions=docs/**,node_modules/**,deployments/**,**/tests/**,__mocks__/**,__fixtures__/**,dist/**,changelog/**,config/**,docker/**,release/**,**/package.json,package.json,rollup.config.js,nightwatch.conf.js,Makefile,Makefile.release,CHANGELOG.md,README.md,packages/web-client/src/generated/** +sonar.exclusions=docs/**,node_modules/**,deployments/**,**/tests/**,__mocks__/**,__fixtures__/**,dist/**,changelog/**,config/**,docker/**,release/**,**/package.json,package.json,rollup.config.js,nightwatch.conf.js,Makefile,Makefile.release,CHANGELOG.md,README.md,packages/web-client/src/generated/**,packages/web-integration-oc10/** From 74c80c77bf1df3d5351b493f0a371e4bd023dbfd Mon Sep 17 00:00:00 2001 From: Jannik Stehle Date: Tue, 8 Feb 2022 11:11:38 +0100 Subject: [PATCH 4/6] Move code changes after rebase --- .../components/Topbar/ApplicationsMenu.vue | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/packages/web-runtime/src/components/Topbar/ApplicationsMenu.vue b/packages/web-runtime/src/components/Topbar/ApplicationsMenu.vue index 4d34459c1ac..665a17551c6 100644 --- a/packages/web-runtime/src/components/Topbar/ApplicationsMenu.vue +++ b/packages/web-runtime/src/components/Topbar/ApplicationsMenu.vue @@ -34,6 +34,7 @@ appearance="raw" :class="{ 'oc-background-primary-gradient': n.active }" :variation="n.active ? 'inverse' : 'passive'" + @click="clickApp(n)" > @@ -48,6 +49,8 @@ From 2cb4f8b1ecd60ec420d4db42951bc2b290338625 Mon Sep 17 00:00:00 2001 From: Jannik Stehle Date: Thu, 8 Sep 2022 14:33:53 +0200 Subject: [PATCH 5/6] Minor improvements --- .../components/Topbar/ApplicationsMenu.vue | 22 ++++++++----------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/packages/web-runtime/src/components/Topbar/ApplicationsMenu.vue b/packages/web-runtime/src/components/Topbar/ApplicationsMenu.vue index 665a17551c6..e7e48532b23 100644 --- a/packages/web-runtime/src/components/Topbar/ApplicationsMenu.vue +++ b/packages/web-runtime/src/components/Topbar/ApplicationsMenu.vue @@ -24,7 +24,7 @@ close-on-click > -
  • +
  • @@ -49,6 +48,8 @@