2018-12-30 02:30:51 +00:00
|
|
|
<template lang="pug">
|
2020-05-30 20:34:09 +00:00
|
|
|
v-card(flat)
|
2018-12-30 02:30:51 +00:00
|
|
|
v-card-text(v-if='group.id === 1')
|
2020-07-03 23:36:33 +00:00
|
|
|
v-alert.radius-7.mb-0(
|
2019-08-10 16:18:14 +00:00
|
|
|
:class='$vuetify.theme.dark ? "grey darken-4" : "orange lighten-5"'
|
2018-12-30 02:30:51 +00:00
|
|
|
color='orange darken-2'
|
2019-08-11 02:14:53 +00:00
|
|
|
outlined
|
|
|
|
icon='mdi-lock-outline'
|
2018-12-30 02:30:51 +00:00
|
|
|
) This group has access to everything.
|
|
|
|
template(v-else)
|
2019-08-11 02:14:53 +00:00
|
|
|
v-card-title(:class='$vuetify.theme.dark ? `grey darken-3-d5` : ``')
|
|
|
|
v-alert.radius-7.caption(
|
|
|
|
:class='$vuetify.theme.dark ? `grey darken-3-d3` : `grey lighten-4`'
|
2018-12-30 02:30:51 +00:00
|
|
|
color='grey'
|
2019-08-11 02:14:53 +00:00
|
|
|
outlined
|
|
|
|
icon='mdi-information'
|
2018-12-30 02:30:51 +00:00
|
|
|
) You must enable global content permissions (under Permissions tab) for page rules to have any effect.
|
|
|
|
v-spacer
|
2019-08-11 02:14:53 +00:00
|
|
|
v-btn.mx-2(depressed, color='primary', @click='addRule')
|
|
|
|
v-icon(left) mdi-plus
|
2018-12-30 02:30:51 +00:00
|
|
|
| Add Rule
|
|
|
|
v-menu(
|
|
|
|
right
|
|
|
|
offset-y
|
|
|
|
nudge-left='115'
|
|
|
|
)
|
2019-08-11 02:14:53 +00:00
|
|
|
template(v-slot:activator='{ on }')
|
|
|
|
v-btn.is-icon(v-on='on', outlined, color='primary')
|
|
|
|
v-icon mdi-dots-horizontal
|
2018-12-30 02:30:51 +00:00
|
|
|
v-list(dense)
|
2019-07-29 04:50:03 +00:00
|
|
|
v-list-item(@click='comingSoon')
|
|
|
|
v-list-item-avatar
|
2019-08-11 02:14:53 +00:00
|
|
|
v-icon mdi-application-import
|
2019-07-29 04:50:03 +00:00
|
|
|
v-list-item-title Load Preset
|
2018-12-30 02:30:51 +00:00
|
|
|
v-divider
|
2019-07-29 04:50:03 +00:00
|
|
|
v-list-item(@click='comingSoon')
|
|
|
|
v-list-item-avatar
|
2019-08-11 02:14:53 +00:00
|
|
|
v-icon mdi-application-export
|
2019-07-29 04:50:03 +00:00
|
|
|
v-list-item-title Save As Preset
|
2018-12-30 02:30:51 +00:00
|
|
|
v-divider
|
2019-07-29 04:50:03 +00:00
|
|
|
v-list-item(@click='comingSoon')
|
|
|
|
v-list-item-avatar
|
2019-08-11 02:14:53 +00:00
|
|
|
v-icon mdi-cloud-upload
|
2019-07-29 04:50:03 +00:00
|
|
|
v-list-item-title Import Rules
|
2018-12-30 02:30:51 +00:00
|
|
|
v-divider
|
2019-07-29 04:50:03 +00:00
|
|
|
v-list-item(@click='comingSoon')
|
|
|
|
v-list-item-avatar
|
2019-08-11 02:14:53 +00:00
|
|
|
v-icon mdi-cloud-download
|
2019-07-29 04:50:03 +00:00
|
|
|
v-list-item-title Export Rules
|
2019-08-10 16:18:14 +00:00
|
|
|
v-card-text(:class='$vuetify.theme.dark ? `grey darken-4-l5` : `white`')
|
2018-12-30 02:30:51 +00:00
|
|
|
.rules
|
|
|
|
.caption(v-if='group.pageRules.length === 0')
|
2019-08-10 16:18:14 +00:00
|
|
|
em(:class='$vuetify.theme.dark ? `grey--text` : `blue-grey--text`') This group has no page rules yet.
|
2018-12-30 02:30:51 +00:00
|
|
|
.rule(v-for='rule of group.pageRules', :key='rule.id')
|
2019-08-11 02:14:53 +00:00
|
|
|
v-btn.ma-0.radius-4.rule-deny-btn(
|
2018-12-30 02:30:51 +00:00
|
|
|
solo
|
|
|
|
:color='rule.deny ? "red" : "green"'
|
|
|
|
dark
|
|
|
|
@click='rule.deny = !rule.deny'
|
2019-08-11 02:14:53 +00:00
|
|
|
height='48'
|
2018-12-30 02:30:51 +00:00
|
|
|
)
|
2019-08-11 02:14:53 +00:00
|
|
|
v-icon(v-if='rule.deny') mdi-cancel
|
|
|
|
v-icon(v-else) mdi-check-circle
|
2018-12-30 02:30:51 +00:00
|
|
|
//- Roles
|
|
|
|
v-select.ml-1(
|
|
|
|
solo
|
|
|
|
:items='roles'
|
|
|
|
v-model='rule.roles'
|
|
|
|
placeholder='Select Role(s)...'
|
|
|
|
hide-details
|
|
|
|
multiple
|
|
|
|
chips
|
|
|
|
deletable-chips
|
|
|
|
small-chips
|
2019-11-02 20:04:43 +00:00
|
|
|
height='48px'
|
2018-12-30 02:30:51 +00:00
|
|
|
style='flex: 0 1 440px;'
|
|
|
|
:menu-props='{ "maxHeight": 500 }'
|
|
|
|
clearable
|
|
|
|
dense
|
|
|
|
)
|
|
|
|
template(slot='selection', slot-scope='{ item, index }')
|
2019-01-12 23:33:30 +00:00
|
|
|
v-chip.white--text.ml-0(v-if='index <= 1', small, label, :color='rule.deny ? `red` : `green`').caption {{ item.value }}
|
|
|
|
v-chip.white--text.ml-0(v-if='index === 2', small, label, :color='rule.deny ? `red lighten-2` : `green lighten-2`').caption + {{ rule.roles.length - 2 }} more
|
2018-12-30 02:30:51 +00:00
|
|
|
template(slot='item', slot-scope='props')
|
2019-07-29 04:50:03 +00:00
|
|
|
v-list-item-action(style='min-width: 30px;')
|
2018-12-30 02:30:51 +00:00
|
|
|
v-checkbox(
|
2019-08-11 02:14:53 +00:00
|
|
|
v-model='props.attrs.inputValue'
|
2018-12-30 02:30:51 +00:00
|
|
|
hide-details
|
|
|
|
color='primary'
|
|
|
|
)
|
|
|
|
v-icon.mr-2(:color='rule.deny ? `red` : `green`') {{props.item.icon}}
|
2019-07-29 04:50:03 +00:00
|
|
|
v-list-item-content
|
|
|
|
v-list-item-title.body-2 {{props.item.text}}
|
2019-08-10 16:18:14 +00:00
|
|
|
v-chip.mr-2.grey--text(label, small, :color='$vuetify.theme.dark ? `grey darken-4` : `grey lighten-4`').caption {{props.item.value}}
|
2018-12-30 02:30:51 +00:00
|
|
|
|
|
|
|
//- Match
|
|
|
|
v-select.ml-1.mr-1(
|
|
|
|
solo
|
|
|
|
:items='matches'
|
|
|
|
v-model='rule.match'
|
|
|
|
placeholder='Match...'
|
|
|
|
hide-details
|
2019-11-02 20:04:43 +00:00
|
|
|
height='48px'
|
2018-12-30 02:30:51 +00:00
|
|
|
style='flex: 0 1 250px;'
|
|
|
|
dense
|
|
|
|
)
|
|
|
|
template(slot='selection', slot-scope='{ item, index }')
|
2019-08-11 02:14:53 +00:00
|
|
|
.body-2 {{item.text}}
|
2018-12-30 02:30:51 +00:00
|
|
|
template(slot='item', slot-scope='data')
|
2019-07-29 04:50:03 +00:00
|
|
|
v-list-item-avatar
|
2018-12-30 02:30:51 +00:00
|
|
|
v-avatar.white--text.radius-4(color='blue', size='30', tile) {{ data.item.icon }}
|
2019-07-29 04:50:03 +00:00
|
|
|
v-list-item-content
|
|
|
|
v-list-item-title(v-html='data.item.text')
|
2018-12-30 02:30:51 +00:00
|
|
|
//- Locales
|
|
|
|
v-select.mr-1(
|
2019-08-10 16:18:14 +00:00
|
|
|
:background-color='$vuetify.theme.dark ? `grey darken-3-d5` : `blue-grey lighten-5`'
|
2018-12-30 02:30:51 +00:00
|
|
|
solo
|
|
|
|
:items='locales'
|
|
|
|
v-model='rule.locales'
|
|
|
|
placeholder='Any Locale'
|
2020-04-18 22:25:16 +00:00
|
|
|
item-value='code'
|
|
|
|
item-text='name'
|
2018-12-30 02:30:51 +00:00
|
|
|
multiple
|
|
|
|
hide-details
|
2019-11-02 20:04:43 +00:00
|
|
|
height='48px'
|
2018-12-30 02:30:51 +00:00
|
|
|
dense
|
|
|
|
:menu-props='{ "minWidth": 250 }'
|
|
|
|
style='flex: 0 1 150px;'
|
|
|
|
)
|
|
|
|
template(slot='selection', slot-scope='{ item, index }')
|
2020-04-18 22:25:16 +00:00
|
|
|
v-chip.white--text.ml-0(v-if='rule.locales.length === 1', small, label, :color='rule.deny ? `red` : `green`').caption {{ item.code.toUpperCase() }}
|
2018-12-30 02:30:51 +00:00
|
|
|
v-chip.white--text.ml-0(v-else-if='index === 0', small, label, :color='rule.deny ? `red` : `green`').caption {{ rule.locales.length }} locales
|
2019-07-29 04:50:03 +00:00
|
|
|
v-list-item(slot='prepend-item', @click='rule.locales = []')
|
|
|
|
v-list-item-action(style='min-width: 30px;')
|
2018-12-30 02:30:51 +00:00
|
|
|
v-checkbox(
|
|
|
|
:input-value='rule.locales.length === 0'
|
|
|
|
hide-details
|
|
|
|
color='primary'
|
|
|
|
readonly
|
|
|
|
)
|
2019-08-11 02:14:53 +00:00
|
|
|
v-icon.mr-2(:color='rule.deny ? `red` : `green`') mdi-earth
|
2019-07-29 04:50:03 +00:00
|
|
|
v-list-item-content
|
|
|
|
v-list-item-title.body-2 Any Locale
|
2018-12-30 02:30:51 +00:00
|
|
|
v-divider(slot='prepend-item')
|
|
|
|
template(slot='item', slot-scope='props')
|
2019-07-29 04:50:03 +00:00
|
|
|
v-list-item-action(style='min-width: 30px;')
|
2018-12-30 02:30:51 +00:00
|
|
|
v-checkbox(
|
2019-08-11 02:14:53 +00:00
|
|
|
v-model='props.attrs.inputValue'
|
2018-12-30 02:30:51 +00:00
|
|
|
hide-details
|
|
|
|
color='primary'
|
|
|
|
)
|
2019-08-11 02:14:53 +00:00
|
|
|
v-icon.mr-2(:color='rule.deny ? `red` : `green`') mdi-web
|
2019-07-29 04:50:03 +00:00
|
|
|
v-list-item-content
|
2020-04-18 22:25:16 +00:00
|
|
|
v-list-item-title.body-2 {{props.item.name}}
|
|
|
|
v-chip.mr-2.grey--text(label, small, :color='$vuetify.theme.dark ? `grey darken-4` : `grey lighten-4`').caption {{props.item.code.toUpperCase()}}
|
2018-12-30 02:30:51 +00:00
|
|
|
|
|
|
|
//- Path
|
|
|
|
v-text-field(
|
|
|
|
solo
|
|
|
|
v-model='rule.path'
|
|
|
|
label='Path'
|
2020-01-31 21:57:35 +00:00
|
|
|
:prefix='(rule.match !== `END` && rule.match !== `TAG`) ? `/` : null'
|
|
|
|
:placeholder='rule.match === `REGEX` ? `Regular Expression` : rule.match === `TAG` ? `Tag` : `Path`'
|
2018-12-30 02:30:51 +00:00
|
|
|
:suffix='rule.match === `REGEX` ? `/` : null'
|
|
|
|
hide-details
|
2019-08-10 16:18:14 +00:00
|
|
|
:color='$vuetify.theme.dark ? `grey` : `blue-grey`'
|
2018-12-30 02:30:51 +00:00
|
|
|
)
|
|
|
|
|
2019-11-02 20:04:43 +00:00
|
|
|
v-btn.ml-2(icon, @click='removeRule(rule.id)', small)
|
2019-08-11 02:14:53 +00:00
|
|
|
v-icon(:color='$vuetify.theme.dark ? `grey` : `blue-grey`') mdi-close
|
2019-01-12 23:33:30 +00:00
|
|
|
|
|
|
|
v-divider.mt-3
|
2019-08-11 02:14:53 +00:00
|
|
|
.overline.py-3 Rules Order
|
|
|
|
.body-2.pl-3 Rules are applied in order of path specificity. A more precise path will always override a less defined path.
|
|
|
|
.body-2.pl-5 For example, #[span.teal--text /geography/countries] will override #[span.teal--text /geography].
|
|
|
|
.body-2.pl-3.pt-2 When 2 rules have the same specificity, the priority is given from lowest to highest as follows:
|
|
|
|
.body-2.pl-3.pt-1
|
2019-01-12 23:33:30 +00:00
|
|
|
ul
|
|
|
|
li
|
|
|
|
strong Path Starts With...
|
|
|
|
em.caption.pl-1 (lowest)
|
|
|
|
li
|
|
|
|
strong Path Ends With...
|
|
|
|
li
|
|
|
|
strong Path Matches Regex...
|
2020-01-31 21:57:35 +00:00
|
|
|
li
|
|
|
|
strong Tag Matches...
|
2019-01-12 23:33:30 +00:00
|
|
|
li
|
|
|
|
strong Path Is Exactly...
|
|
|
|
em.caption.pl-1 (highest)
|
2019-08-11 02:14:53 +00:00
|
|
|
.body-2.pl-3.pt-2 When 2 rules have the same path specificity AND the same match type, #[strong.red--text DENY] will always override an #[strong.green--text ALLOW] rule.
|
2019-01-13 20:37:45 +00:00
|
|
|
v-divider.mt-3
|
2019-08-11 02:14:53 +00:00
|
|
|
.overline.py-3 Regular Expressions
|
2019-01-13 20:37:45 +00:00
|
|
|
span Expressions that are deemed unsafe or could result in exponential time processing will be rejected upon saving.
|
|
|
|
|
2018-12-30 02:30:51 +00:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import _ from 'lodash'
|
2020-04-05 22:51:48 +00:00
|
|
|
import { customAlphabet } from 'nanoid/non-secure'
|
|
|
|
|
2020-04-18 22:25:16 +00:00
|
|
|
/* global siteLangs */
|
|
|
|
|
2020-04-05 22:51:48 +00:00
|
|
|
const nanoid = customAlphabet('1234567890abcdef', 10)
|
2018-12-30 02:30:51 +00:00
|
|
|
|
|
|
|
export default {
|
|
|
|
props: {
|
|
|
|
value: {
|
2019-08-04 20:31:13 +00:00
|
|
|
type: Object,
|
|
|
|
default: () => ({})
|
2018-12-30 02:30:51 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
roles: [
|
2020-04-18 22:25:16 +00:00
|
|
|
{ text: 'Read Pages', value: 'read:pages', icon: 'mdi-file-eye-outline' },
|
|
|
|
{ text: 'Create Pages', value: 'write:pages', icon: 'mdi-file-plus-outline' },
|
2019-08-11 02:14:53 +00:00
|
|
|
{ text: 'Edit + Move Pages', value: 'manage:pages', icon: 'mdi-file-document-edit-outline' },
|
2020-04-18 22:25:16 +00:00
|
|
|
{ text: 'Delete Pages', value: 'delete:pages', icon: 'mdi-file-remove-outline' },
|
2019-08-11 02:14:53 +00:00
|
|
|
{ text: 'View Pages Source', value: 'read:source', icon: 'mdi-code-tags' },
|
|
|
|
{ text: 'View Pages History', value: 'read:history', icon: 'mdi-history' },
|
|
|
|
{ text: 'Read / Use Assets', value: 'read:assets', icon: 'mdi-image-search-outline' },
|
|
|
|
{ text: 'Upload Assets', value: 'write:assets', icon: 'mdi-image-plus' },
|
|
|
|
{ text: 'Edit + Delete Assets', value: 'manage:assets', icon: 'mdi-image-size-select-large' },
|
2021-01-29 19:17:30 +00:00
|
|
|
{ text: 'Edit Scripts', value: 'write:scripts', icon: 'mdi-language-javascript' },
|
|
|
|
{ text: 'Edit Styles', value: 'write:styles', icon: 'mdi-language-css3' },
|
2019-08-11 02:14:53 +00:00
|
|
|
{ text: 'Read Comments', value: 'read:comments', icon: 'mdi-comment-search-outline' },
|
|
|
|
{ text: 'Create Comments', value: 'write:comments', icon: 'mdi-comment-plus-outline' },
|
|
|
|
{ text: 'Edit + Delete Comments', value: 'manage:comments', icon: 'mdi-comment-remove-outline' }
|
2018-12-30 02:30:51 +00:00
|
|
|
],
|
|
|
|
matches: [
|
|
|
|
{ text: 'Path Starts With...', value: 'START', icon: '/...' },
|
|
|
|
{ text: 'Path is Exactly...', value: 'EXACT', icon: '=' },
|
|
|
|
{ text: 'Path Ends With...', value: 'END', icon: '.../' },
|
2020-01-31 21:57:35 +00:00
|
|
|
{ text: 'Path Matches Regex...', value: 'REGEX', icon: '$.*' },
|
|
|
|
{ text: 'Tag Matches...', value: 'TAG', icon: 'T' }
|
2018-12-30 02:30:51 +00:00
|
|
|
]
|
|
|
|
}
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
group: {
|
|
|
|
get() { return this.value },
|
|
|
|
set(val) { this.$set('input', val) }
|
2020-04-18 22:25:16 +00:00
|
|
|
},
|
|
|
|
locales() { return siteLangs }
|
2018-12-30 02:30:51 +00:00
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
addRule(group) {
|
|
|
|
this.group.pageRules.push({
|
2020-04-05 22:51:48 +00:00
|
|
|
id: nanoid(),
|
2018-12-30 02:30:51 +00:00
|
|
|
path: '',
|
|
|
|
roles: [],
|
|
|
|
match: 'START',
|
|
|
|
deny: false,
|
|
|
|
locales: []
|
|
|
|
})
|
|
|
|
},
|
2019-10-04 21:13:03 +00:00
|
|
|
removeRule(ruleId) {
|
|
|
|
this.group.pageRules.splice(_.findIndex(this.group.pageRules, ['id', ruleId]), 1)
|
2018-12-30 02:30:51 +00:00
|
|
|
},
|
|
|
|
comingSoon() {
|
|
|
|
this.$store.commit('showNotification', {
|
|
|
|
style: 'indigo',
|
|
|
|
message: `Coming soon...`,
|
|
|
|
icon: 'directions_boat'
|
|
|
|
})
|
2019-08-11 02:14:53 +00:00
|
|
|
},
|
|
|
|
dude (stuff) {
|
|
|
|
console.info(stuff)
|
2018-12-30 02:30:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss">
|
|
|
|
.rules {
|
|
|
|
background-color: mc('blue-grey', '50');
|
|
|
|
border-radius: 4px;
|
|
|
|
padding: 1rem;
|
|
|
|
position: relative;
|
|
|
|
|
2019-08-11 02:14:53 +00:00
|
|
|
@at-root .v-application.theme--dark & {
|
2018-12-30 02:30:51 +00:00
|
|
|
background-color: mc('grey', '800');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.rule {
|
|
|
|
display: flex;
|
|
|
|
background-color: mc('blue-grey', '100');
|
|
|
|
border-radius: 4px;
|
|
|
|
padding: .5rem;
|
2019-11-02 20:04:43 +00:00
|
|
|
align-items: center;
|
2018-12-30 02:30:51 +00:00
|
|
|
|
|
|
|
&-enter-active, &-leave-active {
|
|
|
|
transition: all .5s ease;
|
|
|
|
}
|
|
|
|
&-enter, &-leave-to {
|
|
|
|
opacity: 0;
|
|
|
|
}
|
|
|
|
|
2019-08-11 02:14:53 +00:00
|
|
|
@at-root .v-application.theme--dark & {
|
2018-12-30 02:30:51 +00:00
|
|
|
background-color: mc('grey', '700');
|
|
|
|
}
|
|
|
|
|
|
|
|
& + .rule {
|
|
|
|
margin-top: .5rem;
|
|
|
|
position: relative;
|
|
|
|
|
|
|
|
&::before {
|
|
|
|
content: '+';
|
|
|
|
position: absolute;
|
|
|
|
width: 2rem;
|
|
|
|
height: 2rem;
|
|
|
|
border-radius: 50%;
|
|
|
|
display: flex;
|
|
|
|
justify-content: center;
|
|
|
|
align-items: center;
|
|
|
|
font-weight: 600;
|
|
|
|
color: mc('blue-grey', '700');
|
|
|
|
font-size: 1.25rem;
|
|
|
|
background-color: mc('blue-grey', '50');
|
|
|
|
left: -2rem;
|
|
|
|
top: -1.3rem;
|
|
|
|
|
2019-08-11 02:14:53 +00:00
|
|
|
@at-root .v-application.theme--dark & {
|
2018-12-30 02:30:51 +00:00
|
|
|
background-color: mc('grey', '800');
|
|
|
|
color: mc('grey', '600');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.input-group + * {
|
|
|
|
margin-left: .5rem;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|