diff --git a/src/modules/modals/CreateContext.vue b/src/modules/modals/CreateContext.vue index db1959036..6bbdc1b6a 100644 --- a/src/modules/modals/CreateContext.vue +++ b/src/modules/modals/CreateContext.vue @@ -171,7 +171,7 @@ export default { isUser: true, key: 'user-' + getCurrentUser().uid, }) - const displayMode = this.showInNavigation ? 'NAV_ENTRY_MODE_ALL' : 'NAV_ENTRY_MODE_HIDDEN' + const displayMode = this.showInNavigation ? 'NAV_ENTRY_MODE_RECIPIENTS' : 'NAV_ENTRY_MODE_HIDDEN' const res = await this.$store.dispatch('insertNewContext', { data, previousReceivers: [], receivers: this.receivers, displayMode: NAV_ENTRY_MODE[displayMode] }) if (res) { return res.id diff --git a/src/modules/modals/EditContext.vue b/src/modules/modals/EditContext.vue index b7eb13abf..baf08618f 100644 --- a/src/modules/modals/EditContext.vue +++ b/src/modules/modals/EditContext.vue @@ -185,7 +185,7 @@ export default { isUser: true, key: 'user-' + getCurrentUser().uid, }) - const displayMode = this.showInNavigation ? 'NAV_ENTRY_MODE_ALL' : 'NAV_ENTRY_MODE_HIDDEN' + const displayMode = this.showInNavigationDefault ? 'NAV_ENTRY_MODE_RECIPIENTS' : 'NAV_ENTRY_MODE_HIDDEN' const res = await this.$store.dispatch('updateContext', { id: this.contextId, data, previousReceivers: Object.values(context.sharing), receivers: this.receivers, displayMode: NAV_ENTRY_MODE[displayMode] }) if (res) { showSuccess(t('tables', 'Updated application "{contextTitle}".', { contextTitle: this.title })) @@ -269,7 +269,7 @@ export default { }, updateDisplayMode() { - this.showInNavigation = !this.showInNavigation + this.showInNavigationDefault = !this.showInNavigationDefault }, actionTransfer() { emit('tables:context:edit', null) diff --git a/src/modules/navigation/partials/NavigationContextItem.vue b/src/modules/navigation/partials/NavigationContextItem.vue index ce4b4ba52..2894134ff 100644 --- a/src/modules/navigation/partials/NavigationContextItem.vue +++ b/src/modules/navigation/partials/NavigationContextItem.vue @@ -117,9 +117,9 @@ export default { }, updateDisplayMode() { const value = !this.showInNavigation - let displayMode = value ? NAV_ENTRY_MODE.NAV_ENTRY_MODE_RECIPIENTS : NAV_ENTRY_MODE.NAV_ENTRY_MODE_HIDDEN + let displayMode = value ? NAV_ENTRY_MODE.NAV_ENTRY_MODE_ALL : NAV_ENTRY_MODE.NAV_ENTRY_MODE_HIDDEN if (this.ownsContext(this.context)) { - displayMode = value ? NAV_ENTRY_MODE.NAV_ENTRY_MODE_ALL : NAV_ENTRY_MODE.NAV_ENTRY_MODE_HIDDEN + displayMode = value ? NAV_ENTRY_MODE.NAV_ENTRY_MODE_RECIPIENTS : NAV_ENTRY_MODE.NAV_ENTRY_MODE_HIDDEN } const share = Object.values(this.context.sharing || {}).find(share => share.receiver === getCurrentUser().uid) if (share) { diff --git a/src/store/store.js b/src/store/store.js index b80bff150..3dc9a5575 100644 --- a/src/store/store.js +++ b/src/store/store.js @@ -10,7 +10,8 @@ import { showError } from '@nextcloud/dialogs' import '@nextcloud/dialogs/style.css' import data from './data.js' import displayError from '../shared/utils/displayError.js' -import { NODE_TYPE_TABLE, NODE_TYPE_VIEW } from '../shared/constants.js' +import { NODE_TYPE_TABLE, NODE_TYPE_VIEW, NAV_ENTRY_MODE } from '../shared/constants.js' +import { getCurrentUser } from '@nextcloud/auth' Vue.use(Vuex) @@ -359,7 +360,15 @@ export default new Vuex.Store({ // Avoid duplicate shares by checking if share exists first const existingShare = previousReceivers.find((p) => p.receiver === share.receiver && p.receiver_type === share.receiverType) if (!existingShare) { - await axios.post(generateUrl('/apps/tables/share'), share) + const createdShare = await axios.post(generateUrl('/apps/tables/share'), share) + if (createdShare?.data && createdShare?.data?.id) { + const shareId = createdShare.data.id + await dispatch('updateDisplayMode', { shareId, displayMode, target: 'default' }) + // since we switch between NAV_ENTRY_MODE_HIDDEN and NAV_ENTRY_MODE_RECIPIENTS, we need to handle owner separately + if (receiver.id === getCurrentUser().uid) { + await dispatch('updateDisplayMode', { shareId, displayMode: displayMode === NAV_ENTRY_MODE.NAV_ENTRY_MODE_HIDDEN ? NAV_ENTRY_MODE.NAV_ENTRY_MODE_HIDDEN : NAV_ENTRY_MODE.NAV_ENTRY_MODE_ALL, target: 'self' }) + } + } } } } catch (e) { @@ -374,6 +383,9 @@ export default new Vuex.Store({ }) if (!currentShare) { await axios.delete(generateUrl('/apps/tables/share/' + previousReceiver.share_id)) + } else { + const shareId = previousReceiver.share_id + await dispatch('updateDisplayMode', { shareId, displayMode, target: 'default' }) } } } catch (e) {