Skip to content

Commit

Permalink
Merge pull request #3995 from nextcloud/enhancement/optionally-hide-e…
Browse files Browse the repository at this point in the history
…vent-download

Allow admins to hide event export buttons
  • Loading branch information
ChristophWurst authored Mar 3, 2022
2 parents 59cc000 + 6bf4d07 commit 3633e7a
Show file tree
Hide file tree
Showing 7 changed files with 21 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';
$hideEventExport = $this->config->getAppValue($this->appName, 'hideEventExport', '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_export', $hideEventExport);
$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',
hideEventExport: 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.hideEventExport
*/
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, hideEventExport }) {
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.hideEventExport = hideEventExport
},

/**
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'),
hideEventExport: loadState('calendar', 'hide_event_export'),
})
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="!hideEventExport && 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,
hideEventExport: (state) => state.settings.hideEventExport,
}),
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="!hideEventExport && 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({
hideEventExport: (state) => state.settings.hideEventExport,
}),
},
data() {
return {
placement: 'auto',
Expand Down
1 change: 1 addition & 0 deletions tests/javascript/unit/store/settings.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ describe('store/settings test suite', () => {
expect(settingsStore.state).toEqual({
appVersion: null,
firstRun: null,
hideEventExport: false,
talkEnabled: false,
eventLimit: null,
showTasks: null,
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', 'hideEventExport', '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_export', true],
['appointmentConfigs', [new AppointmentConfig()]],
);

Expand Down

0 comments on commit 3633e7a

Please sign in to comment.