Skip to content

Commit

Permalink
Merge pull request #5385 from nextcloud/feat/editor/hide-resources
Browse files Browse the repository at this point in the history
feat(editor): implement app config to hide resources tab
  • Loading branch information
st3iny authored Aug 1, 2023
2 parents 93a7dd7 + 28d672c commit 98cadcd
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 2 deletions.
1 change: 1 addition & 0 deletions lib/Controller/PublicViewController.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ private function publicIndex(string $token):PublicTemplateResponse {
$this->initialStateService->provideInitialState($this->appName, 'tasks_enabled', false);
$this->initialStateService->provideInitialState($this->appName, 'hide_event_export', false);
$this->initialStateService->provideInitialState($this->appName, 'can_subscribe_link', $defaultCanSubscribeLink);
$this->initialStateService->provideInitialState($this->appName, 'show_resources', false);

return new PublicTemplateResponse($this->appName, 'main', [
'share_url' => $this->getShareURL(),
Expand Down
2 changes: 2 additions & 0 deletions lib/Controller/ViewController.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ public function index():TemplateResponse {
$forceEventAlarmType = false;
}
$canSubscribeLink = $this->config->getAppValue('dav', 'allow_calendar_link_subscriptions', 'yes') === 'yes';
$showResources = $this->config->getAppValue($this->appName, 'showResources', 'yes') === 'yes';

$talkEnabled = $this->appManager->isEnabledForUser('spreed');
$talkApiVersion = version_compare($this->appManager->getAppVersion('spreed'), '12.0.0', '>=') ? 'v4' : 'v1';
Expand All @@ -142,6 +143,7 @@ public function index():TemplateResponse {
$this->initialStateService->provideInitialState('disable_appointments', $disableAppointments);
$this->initialStateService->provideInitialState('can_subscribe_link', $canSubscribeLink);
$this->initialStateService->provideInitialState('categories', $this->categoriesService->getCategories($this->userId));
$this->initialStateService->provideInitialState('show_resources', $showResources);

return new TemplateResponse($this->appName, 'main');
}
Expand Down
6 changes: 5 additions & 1 deletion src/store/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ const state = {
hideEventExport: false,
forceEventAlarmType: false,
canSubscribeLink: true,
showResources: true,
// user-defined Nextcloud settings
momentLocale: 'en',
attachmentsFolder: '/Calendar',
Expand Down Expand Up @@ -165,8 +166,9 @@ const mutations = {
* @param {boolean} data.disableAppointments Allow to disable the appointments feature
* @param {boolean} data.canSubscribeLink
* @param {string} data.attachmentsFolder Default user's attachments folder
* @param {boolean} data.showResources Show or hide the resources tab
*/
loadSettingsFromServer(state, { appVersion, eventLimit, firstRun, showWeekNumbers, showTasks, showWeekends, skipPopover, slotDuration, defaultReminder, talkEnabled, tasksEnabled, timezone, hideEventExport, forceEventAlarmType, disableAppointments, canSubscribeLink, attachmentsFolder }) {
loadSettingsFromServer(state, { appVersion, eventLimit, firstRun, showWeekNumbers, showTasks, showWeekends, skipPopover, slotDuration, defaultReminder, talkEnabled, tasksEnabled, timezone, hideEventExport, forceEventAlarmType, disableAppointments, canSubscribeLink, attachmentsFolder, showResources }) {
logInfo(`
Initial settings:
- AppVersion: ${appVersion}
Expand All @@ -186,6 +188,7 @@ Initial settings:
- disableAppointments: ${disableAppointments}
- CanSubscribeLink: ${canSubscribeLink}
- attachmentsFolder: ${attachmentsFolder}
- ShowResources: ${showResources}
`)

state.appVersion = appVersion
Expand All @@ -205,6 +208,7 @@ Initial settings:
state.disableAppointments = disableAppointments
state.canSubscribeLink = canSubscribeLink
state.attachmentsFolder = attachmentsFolder
state.showResources = showResources
},

/**
Expand Down
1 change: 1 addition & 0 deletions src/views/Calendar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ export default {
disableAppointments: loadState('calendar', 'disable_appointments', false),
canSubscribeLink: loadState('calendar', 'can_subscribe_link', false),
attachmentsFolder: loadState('calendar', 'attachments_folder', false),
showResources: loadState('calendar', 'show_resources', true),
})
this.$store.dispatch('initializeCalendarJsConfig')
Expand Down
4 changes: 3 additions & 1 deletion src/views/EditSidebar.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<!--
- @copyright Copyright (c) 2019 Georg Ehrke <oc.list@georgehrke.com>
- @copyright Copyright (c) 2019 Jakob Röhrl <jakob.roehrl@web.de>
- @copyright Copyright (c) 2022 Informatyka Boguslawski sp. z o.o. sp.k., http://www.ib.pl/
-
- @author Georg Ehrke <oc.list@georgehrke.com>
- @author Jakob Röhrl <jakob.roehrl@web.de>
Expand Down Expand Up @@ -253,7 +254,7 @@
@save-this-only="prepareAccessForAttachments(false)"
@save-this-and-all-future="prepareAccessForAttachments(true)" />
</NcAppSidebarTab>
<NcAppSidebarTab v-if="!isLoading && !isError"
<NcAppSidebarTab v-if="!isLoading && !isError && showResources"
id="app-sidebar-tab-resources"
class="app-sidebar-tab"
:name="$t('calendar', 'Resources')"
Expand Down Expand Up @@ -377,6 +378,7 @@ export default {
locale: (state) => state.settings.momentLocale,
hideEventExport: (state) => state.settings.hideEventExport,
attachmentsFolder: state => state.settings.attachmentsFolder,
showResources: state => state.settings.showResources,
}),
accessClass() {
return this.calendarObjectInstance?.accessClass || null
Expand Down
5 changes: 5 additions & 0 deletions tests/javascript/unit/store/settings.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ describe('store/settings test suite', () => {
disableAppointments: false,
canSubscribeLink: true,
attachmentsFolder: '/Calendar',
showResources: true,
})
})

Expand Down Expand Up @@ -177,6 +178,7 @@ describe('store/settings test suite', () => {
disableAppointments: false,
canSubscribeLink: true,
attachmentsFolder: '/Calendar',
showResources: true,
}

const settings = {
Expand All @@ -198,6 +200,7 @@ describe('store/settings test suite', () => {
disableAppointments: false,
canSubscribeLink: true,
attachmentsFolder: '/Attachments',
showResources: true,
}

settingsStore.mutations.loadSettingsFromServer(state, settings)
Expand All @@ -222,6 +225,7 @@ Initial settings:
- disableAppointments: false
- CanSubscribeLink: true
- attachmentsFolder: /Attachments
- ShowResources: true
`)
expect(state).toEqual({
appVersion: '2.1.0',
Expand All @@ -243,6 +247,7 @@ Initial settings:
disableAppointments: false,
canSubscribeLink: true,
attachmentsFolder: '/Attachments',
showResources: true,
})
})

Expand Down

0 comments on commit 98cadcd

Please sign in to comment.