Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added option to remove Resources tab #4401

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/Controller/PublicViewController.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ private function publicIndex(string $token,
$defaultDefaultReminder = $this->config->getAppValue($this->appName, 'defaultReminder', 'none');
$defaultShowTasks = $this->config->getAppValue($this->appName, 'showTasks', 'yes');
$defaultCanSubscribeLink = $this->config->getAppValue('dav', 'allow_calendar_link_subscriptions', 'yes');
$defaultShowResources = $this->config->getAppValue($this->appName, 'showResources', 'yes');

$appVersion = $this->config->getAppValue($this->appName, 'installed_version', null);

Expand All @@ -149,6 +150,7 @@ private function publicIndex(string $token,
$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 TemplateResponse($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 @@ -110,6 +110,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 @@ -131,6 +132,7 @@ public function index():TemplateResponse {
$this->initialStateService->provideInitialState('tasks_enabled', $tasksEnabled);
$this->initialStateService->provideInitialState('hide_event_export', $hideEventExport);
$this->initialStateService->provideInitialState('force_event_alarm_type', $forceEventAlarmType);
$this->initialStateService->provideInitialState('show_resources', $showResources);
$this->initialStateService->provideInitialState('appointmentConfigs', $this->appointmentConfigService->getAllAppointmentConfigurations($this->userId));
$this->initialStateService->provideInitialState('disable_appointments', $disableAppointments);
$this->initialStateService->provideInitialState('can_subscribe_link', $canSubscribeLink);
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',
}
Expand Down Expand Up @@ -152,8 +153,9 @@ const mutations = {
* @param {string} data.forceEventAlarmType
* @param {boolean} data.disableAppointments Allow to disable the appointments feature
* @param {boolean} data.canSubscribeLink
* @param {boolean} data.showResources
*/
loadSettingsFromServer(state, { appVersion, eventLimit, firstRun, showWeekNumbers, showTasks, showWeekends, skipPopover, slotDuration, defaultReminder, talkEnabled, tasksEnabled, timezone, hideEventExport, forceEventAlarmType, disableAppointments, canSubscribeLink }) {
loadSettingsFromServer(state, { appVersion, eventLimit, firstRun, showWeekNumbers, showTasks, showWeekends, skipPopover, slotDuration, defaultReminder, talkEnabled, tasksEnabled, timezone, hideEventExport, forceEventAlarmType, disableAppointments, canSubscribeLink, showResources }) {
logInfo(`
Initial settings:
- AppVersion: ${appVersion}
Expand All @@ -172,6 +174,7 @@ Initial settings:
- ForceEventAlarmType: ${forceEventAlarmType}
- disableAppointments: ${disableAppointments}
- CanSubscribeLink: ${canSubscribeLink}
- ShowResources: ${showResources}
`)

state.appVersion = appVersion
Expand All @@ -190,6 +193,7 @@ Initial settings:
state.forceEventAlarmType = forceEventAlarmType
state.disableAppointments = disableAppointments
state.canSubscribeLink = canSubscribeLink
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 @@ -216,6 +216,7 @@ export default {
forceEventAlarmType: loadState('calendar', 'force_event_alarm_type', false),
disableAppointments: loadState('calendar', 'disable_appointments', false),
canSubscribeLink: loadState('calendar', 'can_subscribe_link'),
showResources: loadState('calendar', 'show_resources'),
})
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 @@ -200,7 +201,7 @@
@save-this-only="saveAndLeave(false)"
@save-this-and-all-future="saveAndLeave(true)" />
</AppSidebarTab>
<AppSidebarTab v-if="!isLoading && !isError"
<AppSidebarTab v-if="!isLoading && !isError && showResources"
id="app-sidebar-tab-resources"
class="app-sidebar-tab"
:name="$t('calendar', 'Resources')"
Expand Down Expand Up @@ -294,6 +295,7 @@ export default {
...mapState({
locale: (state) => state.settings.momentLocale,
hideEventExport: (state) => state.settings.hideEventExport,
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 @@ -65,6 +65,7 @@ describe('store/settings test suite', () => {
momentLocale: 'en',
disableAppointments: false,
canSubscribeLink: true,
enableResources: true,
})
})

Expand Down Expand Up @@ -175,6 +176,7 @@ describe('store/settings test suite', () => {
forceEventAlarmType: false,
disableAppointments: false,
canSubscribeLink: true,
enableResources: true,
}

const settings = {
Expand All @@ -195,6 +197,7 @@ describe('store/settings test suite', () => {
forceEventAlarmType: false,
disableAppointments: false,
canSubscribeLink: true,
enableResources: true,
}

settingsStore.mutations.loadSettingsFromServer(state, settings)
Expand All @@ -218,6 +221,7 @@ Initial settings:
- ForceEventAlarmType: false
- disableAppointments: false
- CanSubscribeLink: true
- ShowResources: true
`)
expect(state).toEqual({
appVersion: '2.1.0',
Expand All @@ -238,6 +242,7 @@ Initial settings:
forceEventAlarmType: false,
disableAppointments: false,
canSubscribeLink: true,
showResources: true,
})
})

Expand Down
3 changes: 3 additions & 0 deletions tests/php/unit/Controller/ViewControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*
* @author Georg Ehrke
* @copyright 2019 Georg Ehrke <oc.list@georgehrke.com>
* @copyright Copyright (c) 2022 Informatyka Boguslawski sp. z o.o. sp.k., http://www.ib.pl/
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
Expand Down Expand Up @@ -102,6 +103,7 @@ public function testIndex(): void {
['calendar', 'showTasks', 'yes', 'defaultShowTasks'],
['calendar', 'hideEventExport', 'no', 'yes'],
['calendar', 'forceEventAlarmType', '', ''],
['calendar', 'showResources', 'yes', 'defaultShowResources'],
['calendar', 'installed_version', null, '1.0.0'],
]);
$this->config
Expand Down Expand Up @@ -153,6 +155,7 @@ public function testIndex(): void {
['tasks_enabled', true],
['hide_event_export', true],
['force_event_alarm_type', null],
['show_resources', true],
['appointmentConfigs', [new AppointmentConfig()]],
);

Expand Down