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

Allow admins to hide event export buttons #3995

Merged
merged 1 commit into from
Mar 3, 2022
Merged
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/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