From 0b9ad5c395f72d13cfda1ba49c6738c576b8c99c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Sch=C3=A4fer?= Date: Sun, 10 Mar 2019 13:36:44 +0100 Subject: [PATCH] Refactor `context` => `resourceType` @appinteractive `context` is probably the broadest term you can think of. If possible avoid and prefer a descriptive name. --- components/ContentMenu.vue | 29 +++++++++++++++-------------- components/PostCard.vue | 2 +- pages/post/_slug/index.vue | 4 ++-- pages/profile/_slug.vue | 2 +- 4 files changed, 19 insertions(+), 18 deletions(-) diff --git a/components/ContentMenu.vue b/components/ContentMenu.vue index 5e614c476..14dfb0148 100644 --- a/components/ContentMenu.vue +++ b/components/ContentMenu.vue @@ -55,7 +55,7 @@ export default { itemId: { type: String, required: true }, name: { type: String, required: true }, isOwner: { type: Boolean, default: false }, - context: { + resourceType: { type: String, required: true, validator: value => { @@ -67,7 +67,7 @@ export default { routes() { let routes = [] - if (this.isOwner && this.context === 'contribution') { + if (this.isOwner && this.resourceType === 'contribution') { routes.push({ name: this.$t(`contribution.edit`), path: this.$router.resolve({ @@ -79,7 +79,7 @@ export default { icon: 'edit' }) } - if (this.isOwner && this.context === 'comment') { + if (this.isOwner && this.resourceType === 'comment') { routes.push({ name: this.$t(`comment.edit`), callback: () => { @@ -91,21 +91,25 @@ export default { if (!this.isOwner) { routes.push({ - name: this.$t(`report.${this.context}.title`), - callback: this.openReportDialog, + name: this.$t(`report.${this.resourceType}.title`), + callback: () => { + this.openModal('report') + }, icon: 'flag' }) } if (!this.isOwner && this.isModerator) { routes.push({ - name: this.$t(`disable.${this.context}.title`), - callback: () => {}, + name: this.$t(`disable.${this.resourceType}.title`), + callback: () => { + this.openModal('disable') + }, icon: 'eye-slash' }) } - if (this.isOwner && this.context === 'user') { + if (this.isOwner && this.resourceType === 'user') { routes.push({ name: this.$t(`settings.data.name`), // eslint-disable-next-line vue/no-side-effects-in-computed-properties @@ -128,18 +132,15 @@ export default { } toggleMenu() }, - openReportDialog() { + openModal(dialog) { this.$store.commit('modal/SET_OPEN', { - name: 'report', + name: dialog, data: { - context: this.context, + type: this.resourceType, id: this.itemId, name: this.name } }) - }, - openDisableDialog() { - this.$toast.error('NOT IMPLEMENTED!') } } } diff --git a/components/PostCard.vue b/components/PostCard.vue index 090517a37..403990748 100644 --- a/components/PostCard.vue +++ b/components/PostCard.vue @@ -52,7 +52,7 @@