Skip to content

Commit

Permalink
Merge pull request #3467 from nextcloud/enh/relieve-nav-stable-6
Browse files Browse the repository at this point in the history
[stable-6]  Allow to remove the poll list from the navigation by admin setting
  • Loading branch information
dartcafe authored May 2, 2024
2 parents bce814e + e151f7a commit 6d44662
Show file tree
Hide file tree
Showing 7 changed files with 74 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .github/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ changelog:
- title: 🐛 Fixed bugs
labels:
- bug
- title: ⚡ Performance related changes
labels:
- performance
- title: Other Changes
labels:
- "*"
2 changes: 2 additions & 0 deletions lib/Model/Settings/AppSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class AppSettings implements JsonSerializable {
public const SETTING_PUBLIC_SHARES_GROUPS = 'publicSharesGroups';
public const SETTING_SHOW_MAIL_ADDRESSES_GROUPS = 'showMailAddressesGroups';
public const SETTING_COMBO_GROUPS = 'comboGroups';
public const SETTING_LOAD_POLLS_IN_NAVIGATION = 'navigationPollsInList';

public const SETTING_SHOW_MAIL_ADDRESSES = 'showMailAddresses';
public const SETTING_AUTO_ARCHIVE_OFFSET = 'autoArchiveOffset';
Expand Down Expand Up @@ -217,6 +218,7 @@ public function jsonSerialize(): array {
self::SETTING_ALLOW_POLL_CREATION => $this->getBooleanSetting(self::SETTING_ALLOW_POLL_CREATION),
self::SETTING_ALLOW_POLL_DOWNLOAD => $this->getBooleanSetting(self::SETTING_ALLOW_POLL_DOWNLOAD),
self::SETTING_LEGAL_TERMS_IN_EMAIL => $this->getBooleanSetting(self::SETTING_LEGAL_TERMS_IN_EMAIL),
self::SETTING_LOAD_POLLS_IN_NAVIGATION => $this->getBooleanSetting(self::SETTING_LOAD_POLLS_IN_NAVIGATION),
self::SETTING_SHOW_LOGIN => $this->getBooleanSetting(self::SETTING_SHOW_LOGIN),
self::SETTING_SHOW_MAIL_ADDRESSES => $this->getBooleanSetting(self::SETTING_SHOW_MAIL_ADDRESSES),
self::SETTING_USE_ACTIVITY => $this->getBooleanSetting(self::SETTING_USE_ACTIVITY),
Expand Down
3 changes: 2 additions & 1 deletion lib/Service/SettingsService.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ public function writeAppSettings(array $settingsArray): void {
$this->appSettings->setBooleanSetting(AppSettings::SETTING_SHOW_LOGIN, $settingsArray[AppSettings::SETTING_SHOW_LOGIN]);
$this->appSettings->setBooleanSetting(AppSettings::SETTING_USE_ACTIVITY, $settingsArray[AppSettings::SETTING_USE_ACTIVITY]);
$this->appSettings->setBooleanSetting(AppSettings::SETTING_LEGAL_TERMS_IN_EMAIL, $settingsArray[AppSettings::SETTING_LEGAL_TERMS_IN_EMAIL]);


$this->appSettings->setBooleanSetting(AppSettings::SETTING_LOAD_POLLS_IN_NAVIGATION, $settingsArray[AppSettings::SETTING_LOAD_POLLS_IN_NAVIGATION]);
$this->appSettings->setGroupSetting(AppSettings::SETTING_SHOW_MAIL_ADDRESSES_GROUPS, array_column($settingsArray[AppSettings::SETTING_SHOW_MAIL_ADDRESSES_GROUPS], 'id'));
$this->appSettings->setGroupSetting(AppSettings::SETTING_ALL_ACCESS_GROUPS, array_column($settingsArray[AppSettings::SETTING_ALL_ACCESS_GROUPS], 'id'));
$this->appSettings->setGroupSetting(AppSettings::SETTING_PUBLIC_SHARES_GROUPS, array_column($settingsArray[AppSettings::SETTING_PUBLIC_SHARES_GROUPS], 'id'));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<!--
- @copyright Copyright (c) 2018 René Gieling <github@dartcafe.de>
-
- @author René Gieling <github@dartcafe.de>
-
- @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 <http://www.gnu.org/licenses/>.
-
-->

<template>
<div class="user_settings">
<NcCheckboxRadioSwitch :checked.sync="navigationPollsInList" type="switch">
{{ t('polls', 'Load polls into the navigation.') }}
</NcCheckboxRadioSwitch>
</div>
</template>

<script>

import { NcCheckboxRadioSwitch } from '@nextcloud/vue'
import { writeValue } from '../../../mixins/adminSettingsMixin.js'

export default {
name: 'AdminPollsInNavigation',

components: {
NcCheckboxRadioSwitch,
},

mixins: [writeValue],

computed: {
// Add bindings
navigationPollsInList: {
get() {
return this.appSettings.navigationPollsInList
},
set(value) {
if (value < 0) {
value = 0
}
this.writeValue({ navigationPollsInList: value })
},
},
},
}
</script>
1 change: 1 addition & 0 deletions src/js/store/modules/appSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ const defaultAppSettings = () => ({
disclaimer: '',
imprintUrl: '',
legalTermsInEmail: false,
navigationPollsInList: true,
privacyUrl: '',
showMailAddresses: false,
showLogin: true,
Expand Down
3 changes: 3 additions & 0 deletions src/js/views/AdminSettingsPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
<NcSettingsSection :name="t('polls', 'Performance settings')"
:description="t('polls', 'If you are experiencing connection problems, change how auto updates are retrieved.')">
<AdminPerformance />
<AdminPollsInNavigation />
</NcSettingsSection>
</FlexSettings>
</template>
Expand All @@ -65,6 +66,7 @@ import AdminMisc from '../components/Settings/AdminSettings/AdminMisc.vue'
import AdminPerformance from '../components/Settings/AdminSettings/AdminPerformance.vue'
import AdminPollCreation from '../components/Settings/AdminSettings/AdminPollCreation.vue'
import AdminPollDownload from '../components/Settings/AdminSettings/AdminPollDownload.vue'
import AdminPollsInNavigation from '../components/Settings/AdminSettings/AdminPollsInNavigation.vue'
import AdminShareSettings from '../components/Settings/AdminSettings/AdminShareSettings.vue'
import AdminHideMailAddresses from '../components/Settings/AdminSettings/AdminHideMailAddresses.vue'
import { FlexSettings } from '../components/Base/index.js'
Expand All @@ -82,6 +84,7 @@ export default {
AdminPerformance,
AdminPollCreation,
AdminPollDownload,
AdminPollsInNavigation,
AdminShareSettings,
AdminHideMailAddresses,
NcSettingsSection,
Expand Down
5 changes: 3 additions & 2 deletions src/js/views/Navigation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@
<NcAppNavigationItem v-for="(pollCategory) in pollCategories"
:key="pollCategory.id"
:name="pollCategory.title"
:allow-collapse="true"
:allow-collapse="navigationPollsInList"
:pinned="pollCategory.pinned"
:to="{ name: 'list', params: {type: pollCategory.id}}"
:open="false">
<template #icon>
<Component :is="getIconComponent(pollCategory.id)" :size="iconSize" />
</template>
<ul>
<ul v-if="navigationPollsInList">
<PollNavigationItems v-for="(poll) in filteredPolls(pollCategory.id)"
:key="poll.id"
:poll="poll"
Expand Down Expand Up @@ -130,6 +130,7 @@ export default {
...mapState({
isPollCreationAllowed: (state) => state.polls.isPollCreationAllowed,
isComboActivated: (state) => state.polls.isComboAllowed,
navigationPollsInList: (state) => state.appSettings.navigationPollsInList,
}),

...mapGetters({
Expand Down

0 comments on commit 6d44662

Please sign in to comment.