From 6958277f11309fb132f1b4a2debf38e0cdffe5d8 Mon Sep 17 00:00:00 2001 From: Jana Peper Date: Thu, 21 Nov 2024 14:51:34 +0100 Subject: [PATCH] feat: admin setting to enable navigation link per default Signed-off-by: Jana Peper --- lib/AppInfo/Application.php | 4 ++-- lib/Settings/Admin.php | 2 ++ lib/Settings/Personal.php | 3 ++- src/components/AdminSettings.vue | 8 ++++++++ 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php index d11da7e..7e592b8 100644 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -89,8 +89,8 @@ public function registerNavigation(IUserSession $userSession): void { if ($user !== null) { $userId = $user->getUID(); $container = $this->getContainer(); - - if ($this->config->getUserValue($userId, self::APP_ID, 'navigation_enabled', '0') === '1') { + $navlink_default = $this->config->getAppValue(Application::APP_ID, 'navlink_default'); + if ($this->config->getUserValue($userId, self::APP_ID, 'navigation_enabled', $navlink_default) === '1') { $adminOauthUrl = $this->config->getAppValue(Application::APP_ID, 'oauth_instance_url'); $mattermostUrl = $this->config->getUserValue($userId, self::APP_ID, 'url', $adminOauthUrl) ?: $adminOauthUrl; if ($mattermostUrl === '') { diff --git a/lib/Settings/Admin.php b/lib/Settings/Admin.php index c7945ab..50c01dc 100644 --- a/lib/Settings/Admin.php +++ b/lib/Settings/Admin.php @@ -29,6 +29,7 @@ public function getForm(): TemplateResponse { $oauthUrl = $this->config->getAppValue(Application::APP_ID, 'oauth_instance_url'); $usePopup = $this->config->getAppValue(Application::APP_ID, 'use_popup', '0'); + $navlink_default = $this->config->getAppValue(Application::APP_ID, 'navlink_default', '0'); $adminConfig = [ 'client_id' => $clientID, @@ -36,6 +37,7 @@ public function getForm(): TemplateResponse { 'client_secret' => $clientSecret !== '' ? 'dummySecret' : '', 'oauth_instance_url' => $oauthUrl, 'use_popup' => ($usePopup === '1'), + 'navlink_default' => ($navlink_default === '1'), ]; $this->initialStateService->provideInitialState('admin-config', $adminConfig); return new TemplateResponse(Application::APP_ID, 'adminSettings'); diff --git a/lib/Settings/Personal.php b/lib/Settings/Personal.php index b75ae63..96f850e 100644 --- a/lib/Settings/Personal.php +++ b/lib/Settings/Personal.php @@ -26,7 +26,8 @@ public function getForm(): TemplateResponse { $token = $this->config->getUserValue($this->userId, Application::APP_ID, 'token'); $token = $token === '' ? '' : $this->crypto->decrypt($token); $searchMessagesEnabled = $this->config->getUserValue($this->userId, Application::APP_ID, 'search_messages_enabled', '0') === '1'; - $navigationEnabled = $this->config->getUserValue($this->userId, Application::APP_ID, 'navigation_enabled', '0') === '1'; + $navlinkDefault = $this->config->getAppValue(Application::APP_ID, 'navlink_default', '0'); + $navigationEnabled = $this->config->getUserValue($this->userId, Application::APP_ID, 'navigation_enabled', $navlinkDefault) === '1'; $fileActionEnabled = $this->config->getUserValue($this->userId, Application::APP_ID, 'file_action_enabled', '1') === '1'; $mmUserId = $this->config->getUserValue($this->userId, Application::APP_ID, 'user_id'); $mmUserName = $this->config->getUserValue($this->userId, Application::APP_ID, 'user_name'); diff --git a/src/components/AdminSettings.vue b/src/components/AdminSettings.vue index 770ed62..9f7e44e 100644 --- a/src/components/AdminSettings.vue +++ b/src/components/AdminSettings.vue @@ -60,6 +60,11 @@ @update:checked="onUsePopupChanged"> {{ t('integration_mattermost', 'Use a popup to authenticate') }} + + {{ t('integration_mattermost', 'Enable navigation link as default for all users') }} + @@ -113,6 +118,9 @@ export default { onUsePopupChanged(newValue) { this.saveOptions({ use_popup: newValue ? '1' : '0' }, false) }, + onNavlinkDefaultChanged(newValue) { + this.saveOptions({ navlink_default: newValue ? '1' : '0' }, false) + }, onInput() { delay(() => { const values = {