fix: editing buttons showing up even if no action is allowed (#2043)
* feat: Edit / Page Create Buttons showing up even if no action is allowed #1780
This commit is contained in:
@@ -156,7 +156,7 @@ export default {
|
||||
},
|
||||
computed: {
|
||||
pageId: get('page/id'),
|
||||
permissions: get('page/commentsPermissions'),
|
||||
permissions: get('page/effectivePermissions@comments'),
|
||||
isAuthenticated: get('user/authenticated'),
|
||||
userDisplayName: get('user/name')
|
||||
},
|
||||
|
@@ -111,7 +111,7 @@
|
||||
|
||||
//- PAGE ACTIONS
|
||||
|
||||
template(v-if='isAuthenticated && path && mode !== `edit`')
|
||||
template(v-if='hasAnyPagePermissions && path && mode !== `edit`')
|
||||
v-menu(offset-y, bottom, transition='slide-y-transition', left)
|
||||
template(v-slot:activator='{ on: menu }')
|
||||
v-tooltip(bottom)
|
||||
@@ -122,33 +122,33 @@
|
||||
v-list(nav, :light='!$vuetify.theme.dark', :dark='$vuetify.theme.dark', :class='$vuetify.theme.dark ? `grey darken-4` : ``')
|
||||
.overline.pa-4.grey--text {{$t('common:header.currentPage')}}
|
||||
v-list-item.pl-4(@click='pageView', v-if='mode !== `view`')
|
||||
v-list-item-avatar(size='24', tile): v-icon(color='indigo') mdi-file-document-box-outline
|
||||
v-list-item-avatar(size='24', tile): v-icon(color='indigo') mdi-file-document-outline
|
||||
v-list-item-title.body-2 {{$t('common:header.view')}}
|
||||
v-list-item.pl-4(@click='pageEdit', v-if='mode !== `edit` && isAuthenticated')
|
||||
v-list-item.pl-4(@click='pageEdit', v-if='mode !== `edit` && hasWritePagesPermission')
|
||||
v-list-item-avatar(size='24', tile): v-icon(color='indigo') mdi-file-document-edit-outline
|
||||
v-list-item-title.body-2 {{$t('common:header.edit')}}
|
||||
v-list-item.pl-4(@click='pageHistory', v-if='mode !== `history`')
|
||||
v-list-item.pl-4(@click='pageHistory', v-if='mode !== `history` && hasReadHistoryPermission')
|
||||
v-list-item-avatar(size='24', tile): v-icon(color='indigo') mdi-history
|
||||
v-list-item-content
|
||||
v-list-item-title.body-2 {{$t('common:header.history')}}
|
||||
v-list-item.pl-4(@click='pageSource', v-if='mode !== `source`')
|
||||
v-list-item.pl-4(@click='pageSource', v-if='mode !== `source` && hasReadSourcePermission')
|
||||
v-list-item-avatar(size='24', tile): v-icon(color='indigo') mdi-code-tags
|
||||
v-list-item-title.body-2 {{$t('common:header.viewSource')}}
|
||||
v-list-item.pl-4(@click='pageDuplicate', v-if='isAuthenticated')
|
||||
v-list-item.pl-4(@click='pageDuplicate', v-if='hasWritePagesPermission')
|
||||
v-list-item-avatar(size='24', tile): v-icon(color='indigo') mdi-content-duplicate
|
||||
v-list-item-title.body-2 {{$t('common:header.duplicate')}}
|
||||
v-list-item.pl-4(@click='pageMove', v-if='isAuthenticated')
|
||||
v-list-item.pl-4(@click='pageMove', v-if='hasManagePagesPermission')
|
||||
v-list-item-avatar(size='24', tile): v-icon(color='indigo') mdi-content-save-move-outline
|
||||
v-list-item-content
|
||||
v-list-item-title.body-2 {{$t('common:header.move')}}
|
||||
v-list-item.pl-4(@click='pageDelete', v-if='isAuthenticated')
|
||||
v-list-item.pl-4(@click='pageDelete', v-if='hasDeletePagesPermission')
|
||||
v-list-item-avatar(size='24', tile): v-icon(color='red darken-2') mdi-trash-can-outline
|
||||
v-list-item-title.body-2 {{$t('common:header.delete')}}
|
||||
v-divider(vertical)
|
||||
|
||||
//- NEW PAGE
|
||||
|
||||
template(v-if='isAuthenticated && path && mode !== `edit`')
|
||||
template(v-if='hasNewPagePermission && path && mode !== `edit`')
|
||||
v-tooltip(bottom)
|
||||
template(v-slot:activator='{ on }')
|
||||
v-btn(icon, tile, height='64', v-on='on', @click='pageNew')
|
||||
@@ -288,6 +288,19 @@ export default {
|
||||
},
|
||||
isAdmin () {
|
||||
return _.intersection(this.permissions, ['manage:system', 'write:users', 'manage:users', 'write:groups', 'manage:groups', 'manage:navigation', 'manage:theme', 'manage:api']).length > 0
|
||||
},
|
||||
hasNewPagePermission () {
|
||||
return this.hasAdminPermission || _.intersection(this.permissions, ['write:pages']).length > 0
|
||||
},
|
||||
hasAdminPermission: get('page/effectivePermissions@system.manage'),
|
||||
hasWritePagesPermission: get('page/effectivePermissions@pages.write'),
|
||||
hasManagePagesPermission: get('page/effectivePermissions@pages.manage'),
|
||||
hasDeletePagesPermission: get('page/effectivePermissions@pages.delete'),
|
||||
hasReadSourcePermission: get('page/effectivePermissions@source.read'),
|
||||
hasReadHistoryPermission: get('page/effectivePermissions@history.read'),
|
||||
hasAnyPagePermissions () {
|
||||
return this.hasAdminPermission || this.hasWritePagesPermission || this.hasManagePagesPermission ||
|
||||
this.hasDeletePagesPermission || this.hasReadSourcePermission || this.hasReadHistoryPermission
|
||||
}
|
||||
},
|
||||
created () {
|
||||
|
@@ -133,6 +133,10 @@ export default {
|
||||
checkoutDate: {
|
||||
type: String,
|
||||
default: new Date().toISOString()
|
||||
},
|
||||
effectivePermissions: {
|
||||
type: String,
|
||||
default: ''
|
||||
}
|
||||
},
|
||||
data() {
|
||||
@@ -197,6 +201,10 @@ export default {
|
||||
this.setCurrentSavedState()
|
||||
|
||||
this.checkoutDateActive = this.checkoutDate
|
||||
|
||||
if (this.effectivePermissions) {
|
||||
this.$store.set('page/effectivePermissions',JSON.parse(Buffer.from(this.effectivePermissions, 'base64').toString()))
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.$store.set('editor/mode', this.initMode || 'create')
|
||||
|
@@ -185,6 +185,10 @@ export default {
|
||||
liveContent: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
effectivePermissions: {
|
||||
type: String,
|
||||
default: ''
|
||||
}
|
||||
},
|
||||
data () {
|
||||
@@ -316,6 +320,10 @@ export default {
|
||||
})
|
||||
|
||||
this.target = this.cache[0]
|
||||
|
||||
if (this.effectivePermissions) {
|
||||
this.$store.set('page/effectivePermissions',JSON.parse(Buffer.from(this.effectivePermissions, 'base64').toString()))
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
async loadVersion (versionId) {
|
||||
|
@@ -50,6 +50,10 @@ export default {
|
||||
versionDate: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
effectivePermissions: {
|
||||
type: String,
|
||||
default: ''
|
||||
}
|
||||
},
|
||||
data() {
|
||||
@@ -60,7 +64,11 @@ export default {
|
||||
this.$store.commit('page/SET_LOCALE', this.locale)
|
||||
this.$store.commit('page/SET_PATH', this.path)
|
||||
|
||||
this.$store.commit('page/SET_MODE', 'history')
|
||||
this.$store.commit('page/SET_MODE', 'source')
|
||||
|
||||
if (this.effectivePermissions) {
|
||||
this.$store.set('page/effectivePermissions',JSON.parse(Buffer.from(this.effectivePermissions, 'base64').toString()))
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
goLive() {
|
||||
|
Reference in New Issue
Block a user