High performance, self-hosted, newsletter and mailing list manager with a modern dashboard. Single binary app.
JavaScript campaigncampaign-managementemail-marketingemail-subscriptionlistmonkmailing-listnewsletternewsletter-managementnewsletter-softwareself-hostedsms-gatewaysmtptransactional-emails
Add individual list permission checks on admin UI.
Kailash Nadh3fdf6fe31e6a
diff --git a/frontend/src/main.js b/frontend/src/main.jsindex 108a446b..e75d00fb 100644--- a/frontend/src/main.js+++ b/frontend/src/main.js@@ -42,7 +42,7 @@ async function initConfig(app) {Vue.prototype.$utils = new Utils(i18n);Vue.prototype.$api = api;- // $can('permission:name') is used in the UI to chekc whether the logged in user+ // $can('permission:name') is used in the UI to check whether the logged in user// has a certain permission to toggle visibility of UI objects and UI functionality.Vue.prototype.$can = (...perms) => {if (profile.userRole.id === 1) {@@ -62,6 +62,14 @@ async function initConfig(app) {});};+ Vue.prototype.$canList = (id, perm) => {+ if (profile.userRole.id === 1) {+ return true;+ }++ return profile.listRole.lists.some((list) => list.id === id && list.permissions.includes(perm));+ };+// Set the page title after i18n has loaded.const to = router.history.current;const title = to.meta.title ? `${i18n.tc(to.meta.title, 0)} /` : '';diff --git a/frontend/src/views/ListForm.vue b/frontend/src/views/ListForm.vueindex 199597df..054bf102 100644--- a/frontend/src/views/ListForm.vue+++ b/frontend/src/views/ListForm.vue@@ -58,7 +58,8 @@<b-button @click="$parent.close()">{{ $t('globals.buttons.close') }}</b-button>- <b-button v-if="canManage" native-type="submit" type="is-primary" :loading="loading.lists" data-cy="btn-save">+ <b-button v-if="$can('lists:manage_all') || $canList(data.id, 'list:manage')" native-type="submit"+ type="is-primary" :loading="loading.lists" data-cy="btn-save">{{ $t('globals.buttons.save') }}</b-button></footer>@@ -124,15 +125,6 @@ export default Vue.extend({computed: {...mapState(['loading', 'profile']),-- canManage() {- if (this.$can('lists:manage_all')) {- return true;- }-- const list = this.profile.userRole.lists.find((l) => l.id === this.$props.data.id);- return list && list.permissions.includes('list:manage');- },},mounted() {diff --git a/frontend/src/views/Lists.vue b/frontend/src/views/Lists.vueindex 1b200567..2feff9e6 100644--- a/frontend/src/views/Lists.vue+++ b/frontend/src/views/Lists.vue@@ -119,8 +119,8 @@</b-tooltip></router-link>- <a v-if="$can('lists:manage')" href="#" @click.prevent="showEditForm(props.row)" data-cy="btn-edit"- :aria-label="$t('globals.buttons.edit')">+ <a v-if="$can('lists:manage') || $canList(props.row.id, 'list:manage')" href="#"+ @click.prevent="showEditForm(props.row)" data-cy="btn-edit" :aria-label="$t('globals.buttons.edit')"><b-tooltip :label="$t('globals.buttons.edit')" type="is-dark"><b-icon icon="pencil-outline" size="is-small" /></b-tooltip>@@ -133,8 +133,8 @@</b-tooltip></router-link>- <a v-if="$can('lists:manage')" href="#" @click.prevent="deleteList(props.row)" data-cy="btn-delete"- :aria-label="$t('globals.buttons.delete')">+ <a v-if="$can('lists:manage') || $canList(props.row.id, 'list:manage')" href="#"+ @click.prevent="deleteList(props.row)" data-cy="btn-delete" :aria-label="$t('globals.buttons.delete')"><b-tooltip :label="$t('globals.buttons.delete')" type="is-dark"><b-icon icon="trash-can-outline" size="is-small" /></b-tooltip>