Skip to content

Commit

Permalink
Allow admins to hide event downloads
Browse files Browse the repository at this point in the history
occ config:app:set calendar hide_event_download --value=yes

Signed-off-by: Christoph Wurst <[email protected]>
  • Loading branch information
ChristophWurst committed Feb 25, 2022
1 parent cbd0d8a commit 49fc0e3
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 4 deletions.
2 changes: 2 additions & 0 deletions lib/Controller/ViewController.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ public function index():TemplateResponse {
$slotDuration = $this->config->getUserValue($this->userId, $this->appName, 'slotDuration', $defaultSlotDuration);
$defaultReminder = $this->config->getUserValue($this->userId, $this->appName, 'defaultReminder', $defaultDefaultReminder);
$showTasks = $this->config->getUserValue($this->userId, $this->appName, 'showTasks', $defaultShowTasks) === 'yes';
$hideEventDownload = $this->config->getAppValue($this->appName, 'hide_event_download', 'no') === 'yes';

$talkEnabled = $this->appManager->isEnabledForUser('spreed');
$talkApiVersion = version_compare($this->appManager->getAppVersion('spreed'), '12.0.0', '>=') ? 'v4' : 'v1';
Expand All @@ -112,6 +113,7 @@ public function index():TemplateResponse {
$this->initialStateService->provideInitialState('default_reminder', $defaultReminder);
$this->initialStateService->provideInitialState('show_tasks', $showTasks);
$this->initialStateService->provideInitialState('tasks_enabled', $tasksEnabled);
$this->initialStateService->provideInitialState('hide_event_download', $hideEventDownload);
$this->initialStateService->provideInitialState('appointmentConfigs',$this->appointmentConfigService->getAllAppointmentConfigurations($this->userId));

return new TemplateResponse($this->appName, 'main');
Expand Down
5 changes: 4 additions & 1 deletion src/store/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const state = {
defaultReminder: null,
tasksEnabled: false,
timezone: 'automatic',
hideEventDownload: false,
// user-defined Nextcloud settings
momentLocale: 'en',
}
Expand Down Expand Up @@ -142,8 +143,9 @@ const mutations = {
* @param {boolean} data.talkEnabled Whether or not the talk app is enabled
* @param {boolean} data.tasksEnabled Whether ot not the tasks app is enabled
* @param {string} data.timezone The timezone to view the calendar in. Either an Olsen timezone or "automatic"
* @param data.hideEventDownload
*/
loadSettingsFromServer(state, { appVersion, eventLimit, firstRun, showWeekNumbers, showTasks, showWeekends, skipPopover, slotDuration, defaultReminder, talkEnabled, tasksEnabled, timezone }) {
loadSettingsFromServer(state, { appVersion, eventLimit, firstRun, showWeekNumbers, showTasks, showWeekends, skipPopover, slotDuration, defaultReminder, talkEnabled, tasksEnabled, timezone, hideEventDownload }) {
logInfo(`
Initial settings:
- AppVersion: ${appVersion}
Expand Down Expand Up @@ -172,6 +174,7 @@ Initial settings:
state.talkEnabled = talkEnabled
state.tasksEnabled = tasksEnabled
state.timezone = timezone
state.hideEventDownload = hideEventDownload
},

/**
Expand Down
1 change: 1 addition & 0 deletions src/views/Calendar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ export default {
tasksEnabled: loadState('calendar', 'tasks_enabled'),
timezone: loadState('calendar', 'timezone'),
showTasks: loadState('calendar', 'show_tasks'),
hideEventDownload: loadState('calendar', 'hide_event_download'),
})
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
Expand Up @@ -30,6 +30,7 @@
:title-placeholder="$t('calendar', 'Event title')"
:subtitle="subTitle"
:empty="isLoading || isError"
:force-menu="true"
@close="cancel"
@update:title="updateTitle">
<template v-if="isLoading">
Expand Down Expand Up @@ -57,7 +58,7 @@
<template
v-if="!isLoading && !isError"
#secondary-actions>
<ActionLink v-if="hasDownloadURL"
<ActionLink v-if="!hideEventDownload && hasDownloadURL"
:href="downloadURL">
<template #icon>
<Download :size="20" decorative />
Expand Down Expand Up @@ -311,6 +312,7 @@ export default {
computed: {
...mapState({
locale: (state) => state.settings.momentLocale,
hideEventDownload: (state) => state.settings.hideEventDownload,
}),
accessClass() {
return this.calendarObjectInstance?.accessClass || null
Expand Down
10 changes: 8 additions & 2 deletions src/views/EditSimple.vue
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@
{{ $t('calendar', 'Show more details') }}
</ActionButton>
</Actions>
<Actions v-if="!isLoading && !isError">
<ActionLink v-if="hasDownloadURL"
<Actions v-if="!isLoading && !isError" :force-menu="true">
<ActionLink v-if="!hideEventDownload && hasDownloadURL"
:href="downloadURL">
<template #icon>
<Download :size="20" decorative />
Expand Down Expand Up @@ -189,6 +189,7 @@ import CalendarBlank from 'vue-material-design-icons/CalendarBlank.vue'
import Close from 'vue-material-design-icons/Close.vue'
import Delete from 'vue-material-design-icons/Delete.vue'
import Download from 'vue-material-design-icons/Download.vue'
import { mapState } from 'vuex'
export default {
name: 'EditSimple',
Expand All @@ -215,6 +216,11 @@ export default {
mixins: [
EditorMixin,
],
computed: {
...mapState({
hideEventDownload: (state) => state.settings.hideEventDownload,
}),
},
data() {
return {
placement: 'auto',
Expand Down
2 changes: 2 additions & 0 deletions tests/php/unit/Controller/ViewControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ public function testIndex(): void {
['calendar', 'slotDuration', '00:30:00', 'defaultSlotDuration'],
['calendar', 'defaultReminder', 'none', 'defaultDefaultReminder'],
['calendar', 'showTasks', 'yes', 'defaultShowTasks'],
['calendar', 'hide_event_download', 'no', 'yes'],
['calendar', 'installed_version', null, '1.0.0'],
]);
$this->config
Expand Down Expand Up @@ -143,6 +144,7 @@ public function testIndex(): void {
['default_reminder', '00:10:00'],
['show_tasks', false],
['tasks_enabled', true],
['hide_event_download', true],
['appointmentConfigs', [new AppointmentConfig()]],
);

Expand Down

0 comments on commit 49fc0e3

Please sign in to comment.