Skip to content

Commit c73d7f1

Browse files
committed
enh: add share to oneself to control context nav display
Signed-off-by: Cleopatra Enjeck M <[email protected]>
1 parent 131c39a commit c73d7f1

File tree

2 files changed

+29
-3
lines changed

2 files changed

+29
-3
lines changed

src/modules/modals/CreateContext.vue

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ import NcContextResource from '../../shared/components/ncContextResource/NcConte
7979
import NcIconPicker from '../../shared/components/ncIconPicker/NcIconPicker.vue'
8080
import svgHelper from '../../shared/components/ncIconPicker/mixins/svgHelper.js'
8181
import permissionBitmask from '../../shared/components/ncContextResource/mixins/permissionBitmask.js'
82+
import { getCurrentUser } from '@nextcloud/auth'
8283
import { NAV_ENTRY_MODE } from '../../shared/constants.js'
8384
8485
export default {
@@ -171,6 +172,15 @@ export default {
171172
description: this.description,
172173
nodes: dataResources,
173174
}
175+
// adding share to oneself to have navigation display control
176+
this.receivers.push(
177+
{
178+
id: getCurrentUser().uid,
179+
displayName: getCurrentUser().uid,
180+
icon: 'icon-user',
181+
isUser: true,
182+
key: 'user-' + getCurrentUser().uid,
183+
})
174184
const res = await this.$store.dispatch('insertNewContext', { data, previousReceivers: [], receivers: this.receivers, displayMode: NAV_ENTRY_MODE[this.displayMode] })
175185
if (res) {
176186
return res.id

src/modules/modals/EditContext.vue

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,11 @@ import '@nextcloud/dialogs/style.css'
8686
import { mapGetters, mapState } from 'vuex'
8787
import NcContextResource from '../../shared/components/ncContextResource/NcContextResource.vue'
8888
import NcIconPicker from '../../shared/components/ncIconPicker/NcIconPicker.vue'
89-
import { NODE_TYPE_TABLE, NODE_TYPE_VIEW, PERMISSION_READ, PERMISSION_CREATE, PERMISSION_UPDATE, PERMISSION_DELETE } from '../../shared/constants.js'
89+
import { NODE_TYPE_TABLE, NODE_TYPE_VIEW, PERMISSION_READ, PERMISSION_CREATE, PERMISSION_UPDATE, PERMISSION_DELETE, NAV_ENTRY_MODE } from '../../shared/constants.js'
9090
import svgHelper from '../../shared/components/ncIconPicker/mixins/svgHelper.js'
9191
import permissionBitmask from '../../shared/components/ncContextResource/mixins/permissionBitmask.js'
9292
import { emit } from '@nextcloud/event-bus'
9393
import permissionsMixin from '../../shared/components/ncTable/mixins/permissionsMixin.js'
94-
import { NAV_ENTRY_MODE } from '../../shared/constants.js'
9594
9695
export default {
9796
name: 'EditContext',
@@ -186,7 +185,15 @@ export default {
186185
nodes: dataResources,
187186
}
188187
const context = this.getContext(this.contextId)
189-
188+
// adding share to oneself to have navigation display control
189+
this.receivers.push(
190+
{
191+
id: getCurrentUser().uid,
192+
displayName: getCurrentUser().uid,
193+
icon: 'icon-user',
194+
isUser: true,
195+
key: 'user-' + getCurrentUser().uid,
196+
})
190197
const res = await this.$store.dispatch('updateContext', { id: this.contextId, data, previousReceivers: Object.values(context.sharing), receivers: this.receivers })
191198
if (res) {
192199
showSuccess(t('tables', 'Updated application "{contextTitle}".', { contextTitle: this.title }))
@@ -204,6 +211,15 @@ export default {
204211
this.receivers = context ? this.getContextReceivers(context) : []
205212
this.prepareDeleteContext = false
206213
},
214+
getDisplayMode(context) {
215+
const shares = Object.keys(context.sharing || {})
216+
if (shares.length) {
217+
print('vals', context.sharing[shares[0]])
218+
const displayMode = context.sharing[shares[0]].display_mode_default
219+
return Object.keys(NAV_ENTRY_MODE).find(key => NAV_ENTRY_MODE[key] === displayMode)
220+
}
221+
return 'NAV_ENTRY_MODE_HIDDEN'
222+
},
207223
getContextReceivers(context) {
208224
let sharing = Object.values(context.sharing)
209225
sharing = sharing.filter((share) => !(getCurrentUser().uid === share.receiver && share.receiver_type === 'user'))

0 commit comments

Comments
 (0)