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

Hide sharing calendar via link in UI when sharing via link is disabled #4572

Closed
wants to merge 1 commit 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
3 changes: 3 additions & 0 deletions lib/Controller/PublicViewController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,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 @@ -128,6 +129,7 @@ private function publicIndex(string $token,
$defaultSlotDuration = $this->config->getAppValue($this->appName, 'slotDuration', '00:30:00');
$defaultDefaultReminder = $this->config->getAppValue($this->appName, 'defaultReminder', 'none');
$defaultShowTasks = $this->config->getAppValue($this->appName, 'showTasks', 'yes');
$defaultCanSharePublicLink = $this->config->getAppValue('core', 'shareapi_allow_links', 'yes');

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

Expand All @@ -146,6 +148,7 @@ private function publicIndex(string $token,
$this->initialStateService->provideInitialState($this->appName, 'show_tasks', $defaultShowTasks === 'yes');
$this->initialStateService->provideInitialState($this->appName, 'tasks_enabled', false);
$this->initialStateService->provideInitialState($this->appName, 'hide_event_export', false);
$this->initialStateService->provideInitialState($this->appName, 'can_share_public_link', $defaultCanSharePublicLink);

return new TemplateResponse($this->appName, 'main', [
'share_url' => $this->getShareURL(),
Expand Down
3 changes: 3 additions & 0 deletions lib/Controller/ViewController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,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 @@ -100,6 +101,7 @@ public function index():TemplateResponse {
if (!in_array($forceEventAlarmType, ['DISPLAY', 'EMAIL'], true)) {
$forceEventAlarmType = false;
}
$canSharePublicLink = $this->config->getAppValue('core', 'shareapi_allow_links', 'yes') === 'yes';

$talkEnabled = $this->appManager->isEnabledForUser('spreed');
$talkApiVersion = version_compare($this->appManager->getAppVersion('spreed'), '12.0.0', '>=') ? 'v4' : 'v1';
Expand All @@ -123,6 +125,7 @@ public function index():TemplateResponse {
$this->initialStateService->provideInitialState('force_event_alarm_type', $forceEventAlarmType);
$this->initialStateService->provideInitialState('appointmentConfigs', $this->appointmentConfigService->getAllAppointmentConfigurations($this->userId));
$this->initialStateService->provideInitialState('disable_appointments', $disableAppointments);
$this->initialStateService->provideInitialState('can_share_public_link', $canSharePublicLink);

return new TemplateResponse($this->appName, 'main');
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<!--
- @copyright Copyright (c) 2019 Georg Ehrke <oc.list@georgehrke.com>
- @copyright Copyright (c) 2022 Informatyka Boguslawski sp. z o.o. sp.k., http://www.ib.pl/
- @author Georg Ehrke <oc.list@georgehrke.com>
-
- @license GNU AGPL version 3 or any later version
Expand Down Expand Up @@ -140,7 +141,7 @@
<template v-if="!deleteTimeout">
<div v-show="shareMenuOpen" class="sharing-section">
<CalendarListItemSharingSearch v-if="calendar.canBeShared" :calendar="calendar" />
<CalendarListItemSharingPublishItem v-if="calendar.canBePublished" :calendar="calendar" />
<CalendarListItemSharingPublishItem v-if="calendar.canBePublished && canSharePublicLink" :calendar="calendar" />
<CalendarListItemSharingShareItem v-for="sharee in calendar.shares"
v-show="shareMenuOpen"
:key="sharee.uri"
Expand Down Expand Up @@ -181,6 +182,7 @@ import LinkVariant from 'vue-material-design-icons/LinkVariant.vue'
import Pencil from 'vue-material-design-icons/Pencil.vue'
import ShareVariant from 'vue-material-design-icons/ShareVariant.vue'
import Undo from 'vue-material-design-icons/Undo.vue'
import { mapState } from 'vuex'

export default {
name: 'CalendarListItem',
Expand Down Expand Up @@ -233,6 +235,9 @@ export default {
}
},
computed: {
...mapState({
canSharePublicLink: state => state.settings.canSharePublicLink,
}),
/**
* Download url of the calendar
*
Expand Down
7 changes: 6 additions & 1 deletion src/store/settings.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/**
* @copyright Copyright (c) 2020 Georg Ehrke
* @copyright Copyright (c) 2022 Informatyka Boguslawski sp. z o.o. sp.k., http://www.ib.pl/
*
* @author Georg Ehrke <oc.list@georgehrke.com>
*
Expand Down Expand Up @@ -45,6 +46,7 @@ const state = {
timezone: 'automatic',
hideEventExport: false,
forceEventAlarmType: false,
canSharePublicLink: true,
// user-defined Nextcloud settings
momentLocale: 'en',
}
Expand Down Expand Up @@ -149,8 +151,9 @@ const mutations = {
* @param {boolean} data.hideEventExport
* @param {string} data.forceEventAlarmType
* @param {boolean} data.disableAppointments Allow to disable the appointments feature
* @param {boolean} data.canSharePublicLink
*/
loadSettingsFromServer(state, { appVersion, eventLimit, firstRun, showWeekNumbers, showTasks, showWeekends, skipPopover, slotDuration, defaultReminder, talkEnabled, tasksEnabled, timezone, hideEventExport, forceEventAlarmType, disableAppointments }) {
loadSettingsFromServer(state, { appVersion, eventLimit, firstRun, showWeekNumbers, showTasks, showWeekends, skipPopover, slotDuration, defaultReminder, talkEnabled, tasksEnabled, timezone, hideEventExport, forceEventAlarmType, disableAppointments, canSharePublicLink }) {
logInfo(`
Initial settings:
- AppVersion: ${appVersion}
Expand All @@ -168,6 +171,7 @@ Initial settings:
- HideEventExport: ${hideEventExport}
- ForceEventAlarmType: ${forceEventAlarmType}
- disableAppointments: ${disableAppointments}
- CanSharePublicLink: ${canSharePublicLink}
`)

state.appVersion = appVersion
Expand All @@ -185,6 +189,7 @@ Initial settings:
state.hideEventExport = hideEventExport
state.forceEventAlarmType = forceEventAlarmType
state.disableAppointments = disableAppointments
state.canSharePublicLink = canSharePublicLink
},

/**
Expand Down
2 changes: 2 additions & 0 deletions src/views/Calendar.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<!--
- @copyright Copyright (c) 2020 Georg Ehrke <oc.list@georgehrke.com>
- @copyright Copyright (c) 2022 Informatyka Boguslawski sp. z o.o. sp.k., http://www.ib.pl/
- @author Georg Ehrke <oc.list@georgehrke.com>
-
- @license GNU AGPL version 3 or any later version
Expand Down Expand Up @@ -218,6 +219,7 @@ export default {
hideEventExport: loadState('calendar', 'hide_event_export'),
forceEventAlarmType: loadState('calendar', 'force_event_alarm_type', false),
disableAppointments: loadState('calendar', 'disable_appointments', false),
canSharePublicLink: loadState('calendar', 'can_share_public_link'),
})
this.$store.dispatch('initializeCalendarJsConfig')

Expand Down
3 changes: 3 additions & 0 deletions tests/javascript/unit/store/settings.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/**
* @copyright Copyright (c) 2019 Georg Ehrke
* @copyright Copyright (c) 2022 Informatyka Boguslawski sp. z o.o. sp.k., http://www.ib.pl/
*
* @author Georg Ehrke <oc.list@georgehrke.com>
*
Expand Down Expand Up @@ -213,6 +214,7 @@ Initial settings:
- HideEventExport: false
- ForceEventAlarmType: false
- disableAppointments: false
- CanSharePublicLink: true
`)
expect(state).toEqual({
appVersion: '2.1.0',
Expand All @@ -232,6 +234,7 @@ Initial settings:
hideEventExport: false,
forceEventAlarmType: false,
disableAppointments: false,
canSharePublicLink: true,
})
})

Expand Down