Skip to content

Commit

Permalink
fix: update context navigation display elements
Browse files Browse the repository at this point in the history
Signed-off-by: Cleopatra Enjeck M <patrathewhiz@gmail.com>
  • Loading branch information
enjeck committed Sep 4, 2024
1 parent 67e2b31 commit 215ca74
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 21 deletions.
1 change: 1 addition & 0 deletions lib/Service/ShareService.php
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,7 @@ public function updateDisplayMode(int $shareId, int $displayMode, string $userId
}
} else {
// setting user display mode override only requires access
// this does not seem to work
if (!$this->permissionsService->canAccessContextById($item->getId())) {
throw new PermissionError(sprintf('PermissionError: can not update share with id %d', $shareId));
}
Expand Down
8 changes: 4 additions & 4 deletions src/modules/modals/CreateContext.vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,19 @@
</div>
<div class="row space-T">
<div>
{{ t('tables', 'Navigation bar entry') }}
{{ t('tables', 'Navigation bar display') }}
</div>
<NcCheckboxRadioSwitch :checked.sync="displayMode" value="NAV_ENTRY_MODE_HIDDEN"
name="NAV_ENTRY_MODE_HIDDEN" type="radio">
No navigation bar entry
Hide navigation entry for everybody
</NcCheckboxRadioSwitch>
<NcCheckboxRadioSwitch :checked.sync="displayMode" value="NAV_ENTRY_MODE_RECIPIENTS"
name="NAV_ENTRY_MODE_RECIPIENTS" type="radio">
Navigation bar entry for share recipients, but not the owner
Show navigation entry for everybody, except me
</NcCheckboxRadioSwitch>
<NcCheckboxRadioSwitch :checked.sync="displayMode" value="NAV_ENTRY_MODE_ALL" name="NAV_ENTRY_MODE_ALL"
type="radio">
Navigation bar entry for everybody
Show navigation entry for everybody
</NcCheckboxRadioSwitch>
<br>
</div>
Expand Down
24 changes: 22 additions & 2 deletions src/modules/modals/EditContext.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,24 @@
</div>
<NcContextResource :resources.sync="resources" :receivers.sync="receivers" />
</div>

<div class="row space-T">
<div>
{{ t('tables', 'Navigation bar display') }}
</div>
<NcCheckboxRadioSwitch :checked.sync="displayMode" value="NAV_ENTRY_MODE_HIDDEN"
name="NAV_ENTRY_MODE_HIDDEN" type="radio">
Hide navigation entry for everybody
</NcCheckboxRadioSwitch>
<NcCheckboxRadioSwitch :checked.sync="displayMode" value="NAV_ENTRY_MODE_RECIPIENTS"
name="NAV_ENTRY_MODE_RECIPIENTS" type="radio">
Show navigation entry for everybody, except me
</NcCheckboxRadioSwitch>
<NcCheckboxRadioSwitch :checked.sync="displayMode" value="NAV_ENTRY_MODE_ALL" name="NAV_ENTRY_MODE_ALL"
type="radio">
Show navigation entry for everybody
</NcCheckboxRadioSwitch>
<br>
</div>
<div class="row space-T">
<div class="fix-col-4 space-T justify-between">
<NcButton v-if="!prepareDeleteContext" type="error" @click="prepareDeleteContext = true">
Expand All @@ -62,7 +79,7 @@
</template>

<script>
import { NcDialog, NcButton, NcIconSvgWrapper } from '@nextcloud/vue'
import { NcModal, NcButton, NcIconSvgWrapper, NcCheckboxRadioSwitch } from '@nextcloud/vue'

Check failure on line 82 in src/modules/modals/EditContext.vue

View workflow job for this annotation

GitHub Actions / NPM lint

'NcModal' is defined but never used
import { showError, showSuccess } from '@nextcloud/dialogs'
import { getCurrentUser } from '@nextcloud/auth'
import '@nextcloud/dialogs/style.css'
Expand All @@ -74,6 +91,7 @@ import svgHelper from '../../shared/components/ncIconPicker/mixins/svgHelper.js'
import permissionBitmask from '../../shared/components/ncContextResource/mixins/permissionBitmask.js'
import { emit } from '@nextcloud/event-bus'
import permissionsMixin from '../../shared/components/ncTable/mixins/permissionsMixin.js'
import { NAV_ENTRY_MODE } from '../../shared/constants.js'

Check failure on line 94 in src/modules/modals/EditContext.vue

View workflow job for this annotation

GitHub Actions / NPM lint

'NAV_ENTRY_MODE' is defined but never used

Check failure on line 94 in src/modules/modals/EditContext.vue

View workflow job for this annotation

GitHub Actions / NPM lint

'/home/runner/actions-runner/_work/tables/tables/src/shared/constants.js' imported multiple times
export default {
name: 'EditContext',
Expand All @@ -83,6 +101,7 @@ export default {
NcIconPicker,
NcIconSvgWrapper,
NcContextResource,
NcCheckboxRadioSwitch,
},
mixins: [svgHelper, permissionBitmask, permissionsMixin],
props: {
Expand Down Expand Up @@ -111,6 +130,7 @@ export default {
PERMISSION_UPDATE,
PERMISSION_DELETE,
prepareDeleteContext: false,
displayMode: 'NAV_ENTRY_MODE_HIDDEN', // TODO: get the actual saved display mode
}
},
computed: {
Expand Down
28 changes: 18 additions & 10 deletions src/modules/navigation/partials/NavigationContextItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
</template>
</template>
<template #actions>
<NcActionButton v-if="ownsContext(context)" :close-after-click="true" data-cy="navigationContextEditBtn" @click="editContext">
<NcActionButton v-if="ownsContext(context)" :close-after-click="true" data-cy="navigationContextEditBtn"
@click="editContext">
<template #icon>
<PlaylistEdit :size="20" />
</template>
Expand All @@ -27,13 +28,14 @@
</template>
{{ t('tables', 'Transfer application') }}
</NcActionButton>
<NcActionButton v-if="ownsContext(context)" :close-after-click="true" data-cy="navigationContextDeleteBtn" @click="deleteContext">
<NcActionButton v-if="ownsContext(context)" :close-after-click="true" data-cy="navigationContextDeleteBtn"
@click="deleteContext">
<template #icon>
<Delete :size="20" />
</template>
{{ t('tables', 'Delete application') }}
</NcActionButton>
<NcActionCheckbox :value="showInNavigation" @change="updateDisplayMode">
<NcActionCheckbox v-if="!ownsContext(context)" :value="showInNavigation" @change="updateDisplayMode">
Show in Navigation
</NcActionCheckbox>
</template>
Expand All @@ -51,6 +53,7 @@ import Delete from 'vue-material-design-icons/Delete.vue'
import permissionsMixin from '../../../shared/components/ncTable/mixins/permissionsMixin.js'
import svgHelper from '../../../shared/components/ncIconPicker/mixins/svgHelper.js'
import { getCurrentUser } from '@nextcloud/auth'
import { NAV_ENTRY_MODE } from '../../../shared/constants.js'
export default {
name: 'NavigationContextItem',
Expand Down Expand Up @@ -78,7 +81,7 @@ export default {
data() {
return {
icon: null,
showInNavigation: false,
showInNavigation: this.getDisplayMode(),
}
},
computed: {
Expand All @@ -105,13 +108,18 @@ export default {
deleteContext() {
emit('tables:context:delete', this.context)
},
getDisplayMode() {
const share = Object.values(this.context.sharing || {}).find(share => share.receiver === getCurrentUser().uid)
if (share) {
return share.display_mode
}
return 0
},
updateDisplayMode() {
this.showInNavigation = !this.showInNavigation
if (this.context) {
const share = Object.values(this.context.sharing || {}).find(share => share.receiver === getCurrentUser().uid)
if (share) {
this.$store.dispatch('updateDisplayMode', { shareId: share.share_id, displayMode: this.showInNavigation ? 1 : 0, userId: getCurrentUser().uid })
}
this.showInNavigation = this.showInNavigation ? 0 : 1
const share = Object.values(this.context.sharing || {}).find(share => share.receiver === getCurrentUser().uid)
if (share) {
this.$store.dispatch('updateDisplayMode', { shareId: share.share_id, displayMode: this.showInNavigation ? NAV_ENTRY_MODE['NAV_ENTRY_MODE_RECIPIENTS'] : NAV_ENTRY_MODE['NAV_ENTRY_MODE_HIDDEN'], target: 'self' })

Check failure on line 122 in src/modules/navigation/partials/NavigationContextItem.vue

View workflow job for this annotation

GitHub Actions / NPM lint

["NAV_ENTRY_MODE_RECIPIENTS"] is better written in dot notation
}
},
},
Expand Down
6 changes: 3 additions & 3 deletions src/shared/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const TYPE_DATETIME = 'datetime'
export const TYPE_USERGROUP = 'usergroup'

export const NAV_ENTRY_MODE = {
NAV_ENTRY_MODE_HIDDEN: 0,
NAV_ENTRY_MODE_RECIPIENTS: 1,
NAV_ENTRY_MODE_ALL: 2,
NAV_ENTRY_MODE_HIDDEN: 0, // no nav bar entry
NAV_ENTRY_MODE_RECIPIENTS: 1, // nav bar entry for share recipients, but not the owner
NAV_ENTRY_MODE_ALL: 2, // nav bar entry for everybody
}
4 changes: 2 additions & 2 deletions src/store/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -381,9 +381,9 @@ export default new Vuex.Store({
}
},

async updateDisplayMode({ dispatch }, { shareId, displayMode, userId }) {
async updateDisplayMode({ dispatch }, { shareId, displayMode, target }) {
try {
await axios.put(generateUrl('/apps/tables/share/' + shareId + '/display-mode'), { displayMode, userId })
await axios.put(generateUrl('/apps/tables/share/' + shareId + '/display-mode'), { displayMode, target })
} catch (e) {
displayError(e, t('tables', 'Could not update display mode.'))
}
Expand Down

0 comments on commit 215ca74

Please sign in to comment.