Skip to content

Commit

Permalink
feat: admin setting to enable navigation link per default
Browse files Browse the repository at this point in the history
Signed-off-by: Jana Peper <[email protected]>
  • Loading branch information
janepie committed Nov 21, 2024
1 parent 5bdd57f commit 6958277
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 === '') {
Expand Down
2 changes: 2 additions & 0 deletions lib/Settings/Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,15 @@ 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,
// Do not expose the saved client secret to the user
'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');
Expand Down
3 changes: 2 additions & 1 deletion lib/Settings/Personal.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
8 changes: 8 additions & 0 deletions src/components/AdminSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@
@update:checked="onUsePopupChanged">
{{ t('integration_mattermost', 'Use a popup to authenticate') }}
</NcCheckboxRadioSwitch>
<NcCheckboxRadioSwitch
:checked.sync="state.navlink_default"
@update:checked="onNavlinkDefaultChanged">
{{ t('integration_mattermost', 'Enable navigation link as default for all users') }}
</NcCheckboxRadioSwitch>
</div>
</div>
</template>
Expand Down Expand Up @@ -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 = {
Expand Down

0 comments on commit 6958277

Please sign in to comment.