Skip to content

Commit e0b033f

Browse files
committed
fix: update context navigation display elements
Signed-off-by: Cleopatra Enjeck M <[email protected]>
1 parent 774736f commit e0b033f

File tree

6 files changed

+50
-21
lines changed

6 files changed

+50
-21
lines changed

lib/Service/ShareService.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,7 @@ public function updateDisplayMode(int $shareId, int $displayMode, string $userId
334334
}
335335
} else {
336336
// setting user display mode override only requires access
337+
// this does not seem to work
337338
if (!$this->permissionsService->canAccessContextById($item->getId())) {
338339
throw new PermissionError(sprintf('PermissionError: can not update share with id %d', $shareId));
339340
}

src/modules/modals/CreateContext.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,19 +41,19 @@
4141
</div>
4242
<div class="row space-T">
4343
<div>
44-
{{ t('tables', 'Navigation bar entry') }}
44+
{{ t('tables', 'Navigation bar display') }}
4545
</div>
4646
<NcCheckboxRadioSwitch :checked.sync="displayMode" value="NAV_ENTRY_MODE_HIDDEN"
4747
name="NAV_ENTRY_MODE_HIDDEN" type="radio">
48-
No navigation bar entry
48+
Hide navigation entry for everybody
4949
</NcCheckboxRadioSwitch>
5050
<NcCheckboxRadioSwitch :checked.sync="displayMode" value="NAV_ENTRY_MODE_RECIPIENTS"
5151
name="NAV_ENTRY_MODE_RECIPIENTS" type="radio">
52-
Navigation bar entry for share recipients, but not the owner
52+
Show navigation entry for everybody, except me
5353
</NcCheckboxRadioSwitch>
5454
<NcCheckboxRadioSwitch :checked.sync="displayMode" value="NAV_ENTRY_MODE_ALL" name="NAV_ENTRY_MODE_ALL"
5555
type="radio">
56-
Navigation bar entry for everybody
56+
Show navigation entry for everybody
5757
</NcCheckboxRadioSwitch>
5858
<br>
5959
</div>

src/modules/modals/EditContext.vue

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,24 @@
3535
</div>
3636
<NcContextResource :resources.sync="resources" :receivers.sync="receivers" />
3737
</div>
38-
38+
<div class="row space-T">
39+
<div>
40+
{{ t('tables', 'Navigation bar display') }}
41+
</div>
42+
<NcCheckboxRadioSwitch :checked.sync="displayMode" value="NAV_ENTRY_MODE_HIDDEN"
43+
name="NAV_ENTRY_MODE_HIDDEN" type="radio">
44+
Hide navigation entry for everybody
45+
</NcCheckboxRadioSwitch>
46+
<NcCheckboxRadioSwitch :checked.sync="displayMode" value="NAV_ENTRY_MODE_RECIPIENTS"
47+
name="NAV_ENTRY_MODE_RECIPIENTS" type="radio">
48+
Show navigation entry for everybody, except me
49+
</NcCheckboxRadioSwitch>
50+
<NcCheckboxRadioSwitch :checked.sync="displayMode" value="NAV_ENTRY_MODE_ALL" name="NAV_ENTRY_MODE_ALL"
51+
type="radio">
52+
Show navigation entry for everybody
53+
</NcCheckboxRadioSwitch>
54+
<br>
55+
</div>
3956
<div class="row space-T">
4057
<div class="fix-col-4 space-T justify-between">
4158
<NcButton v-if="!prepareDeleteContext" type="error" @click="prepareDeleteContext = true">
@@ -59,7 +76,7 @@
5976
</template>
6077

6178
<script>
62-
import { NcModal, NcButton, NcIconSvgWrapper } from '@nextcloud/vue'
79+
import { NcModal, NcButton, NcIconSvgWrapper, NcCheckboxRadioSwitch } from '@nextcloud/vue'
6380
import { showError, showSuccess } from '@nextcloud/dialogs'
6481
import { getCurrentUser } from '@nextcloud/auth'
6582
import '@nextcloud/dialogs/dist/index.css'
@@ -71,6 +88,7 @@ import svgHelper from '../../shared/components/ncIconPicker/mixins/svgHelper.js'
7188
import permissionBitmask from '../../shared/components/ncContextResource/mixins/permissionBitmask.js'
7289
import { emit } from '@nextcloud/event-bus'
7390
import permissionsMixin from '../../shared/components/ncTable/mixins/permissionsMixin.js'
91+
import { NAV_ENTRY_MODE } from '../../shared/constants.js'
7492
7593
export default {
7694
name: 'EditContext',
@@ -80,6 +98,7 @@ export default {
8098
NcIconPicker,
8199
NcIconSvgWrapper,
82100
NcContextResource,
101+
NcCheckboxRadioSwitch,
83102
},
84103
mixins: [svgHelper, permissionBitmask, permissionsMixin],
85104
props: {
@@ -108,6 +127,7 @@ export default {
108127
PERMISSION_UPDATE,
109128
PERMISSION_DELETE,
110129
prepareDeleteContext: false,
130+
displayMode: 'NAV_ENTRY_MODE_HIDDEN', // TODO: get the actual saved display mode
111131
}
112132
},
113133
computed: {

src/modules/navigation/partials/NavigationContextItem.vue

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
</template>
1212
</template>
1313
<template #actions>
14-
<NcActionButton v-if="ownsContext(context)" :close-after-click="true" data-cy="navigationContextEditBtn" @click="editContext">
14+
<NcActionButton v-if="ownsContext(context)" :close-after-click="true" data-cy="navigationContextEditBtn"
15+
@click="editContext">
1516
<template #icon>
1617
<PlaylistEdit :size="20" />
1718
</template>
@@ -23,13 +24,14 @@
2324
</template>
2425
{{ t('tables', 'Transfer application') }}
2526
</NcActionButton>
26-
<NcActionButton v-if="ownsContext(context)" :close-after-click="true" data-cy="navigationContextDeleteBtn" @click="deleteContext">
27+
<NcActionButton v-if="ownsContext(context)" :close-after-click="true" data-cy="navigationContextDeleteBtn"
28+
@click="deleteContext">
2729
<template #icon>
2830
<Delete :size="20" />
2931
</template>
3032
{{ t('tables', 'Delete application') }}
3133
</NcActionButton>
32-
<NcActionCheckbox :value="showInNavigation" @change="updateDisplayMode">
34+
<NcActionCheckbox v-if="!ownsContext(context)" :value="showInNavigation" @change="updateDisplayMode">
3335
Show in Navigation
3436
</NcActionCheckbox>
3537
</template>
@@ -47,6 +49,7 @@ import Delete from 'vue-material-design-icons/Delete.vue'
4749
import permissionsMixin from '../../../shared/components/ncTable/mixins/permissionsMixin.js'
4850
import svgHelper from '../../../shared/components/ncIconPicker/mixins/svgHelper.js'
4951
import { getCurrentUser } from '@nextcloud/auth'
52+
import { NAV_ENTRY_MODE } from '../../../shared/constants.js'
5053
5154
export default {
5255
name: 'NavigationContextItem',
@@ -74,7 +77,7 @@ export default {
7477
data() {
7578
return {
7679
icon: null,
77-
showInNavigation: false,
80+
showInNavigation: this.getDisplayMode(),
7881
}
7982
},
8083
computed: {
@@ -101,13 +104,18 @@ export default {
101104
deleteContext() {
102105
emit('tables:context:delete', this.context)
103106
},
107+
getDisplayMode() {
108+
const share = Object.values(this.context.sharing || {}).find(share => share.receiver === getCurrentUser().uid)
109+
if (share) {
110+
return share.display_mode
111+
}
112+
return 0
113+
},
104114
updateDisplayMode() {
105-
this.showInNavigation = !this.showInNavigation
106-
if (this.context) {
107-
const share = Object.values(this.context.sharing || {}).find(share => share.receiver === getCurrentUser().uid)
108-
if (share) {
109-
this.$store.dispatch('updateDisplayMode', { shareId: share.share_id, displayMode: this.showInNavigation ? 1 : 0, userId: getCurrentUser().uid })
110-
}
115+
this.showInNavigation = this.showInNavigation ? 0 : 1
116+
const share = Object.values(this.context.sharing || {}).find(share => share.receiver === getCurrentUser().uid)
117+
if (share) {
118+
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' })
111119
}
112120
},
113121
},

src/shared/constants.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export const TYPE_DATETIME = 'datetime'
4343
export const TYPE_USERGROUP = 'usergroup'
4444

4545
export const NAV_ENTRY_MODE = {
46-
NAV_ENTRY_MODE_HIDDEN: 0,
47-
NAV_ENTRY_MODE_RECIPIENTS: 1,
48-
NAV_ENTRY_MODE_ALL: 2,
46+
NAV_ENTRY_MODE_HIDDEN: 0, // no nav bar entry
47+
NAV_ENTRY_MODE_RECIPIENTS: 1, // nav bar entry for share recipients, but not the owner
48+
NAV_ENTRY_MODE_ALL: 2, // nav bar entry for everybody
4949
}

src/store/store.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -377,9 +377,9 @@ export default new Vuex.Store({
377377
}
378378
},
379379

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

0 commit comments

Comments
 (0)