From dc1caf0b29a7c0018bfd24694ea8d40e2e8058a5 Mon Sep 17 00:00:00 2001 From: Kevin Ansfield Date: Thu, 17 Jun 2021 16:42:34 +0100 Subject: [PATCH] Removed usage of SettingsMenuMixin in post settings menu no issue - the post settings menu is the only component that uses the mixin so it makes sense to inline it, especially as mixins are deprecated and the mixin's utility is minimal and already overridden in places --- .../components/gh-post-settings-menu-labs.js | 21 +++++++++++--- .../app/components/gh-post-settings-menu.js | 21 +++++++++++--- .../app/mixins/settings-menu-component.js | 29 ------------------- 3 files changed, 34 insertions(+), 37 deletions(-) delete mode 100644 ghost/admin/app/mixins/settings-menu-component.js diff --git a/ghost/admin/app/components/gh-post-settings-menu-labs.js b/ghost/admin/app/components/gh-post-settings-menu-labs.js index 7f85813742..33b5c983b6 100644 --- a/ghost/admin/app/components/gh-post-settings-menu-labs.js +++ b/ghost/admin/app/components/gh-post-settings-menu-labs.js @@ -1,12 +1,11 @@ import Component from '@ember/component'; -import SettingsMenuMixin from 'ghost-admin/mixins/settings-menu-component'; import boundOneWay from 'ghost-admin/utils/bound-one-way'; import moment from 'moment'; import {alias, or} from '@ember/object/computed'; import {computed} from '@ember/object'; import {inject as service} from '@ember/service'; -export default Component.extend(SettingsMenuMixin, { +export default Component.extend({ feature: service(), store: service(), config: service(), @@ -20,6 +19,7 @@ export default Component.extend(SettingsMenuMixin, { post: null, + showSettingsMenu: false, _showSettingsMenu: false, canonicalUrlScratch: alias('post.canonicalUrlScratch'), @@ -66,6 +66,19 @@ export default Component.extend(SettingsMenuMixin, { return urlParts.join(' > '); }), + isViewingSubview: computed('showSettingsMenu', { + get() { + return false; + }, + set(key, value) { + // Not viewing a subview if we can't even see the PSM + if (!this.showSettingsMenu) { + return false; + } + return value; + } + }), + didReceiveAttrs() { this._super(...arguments); @@ -86,12 +99,12 @@ export default Component.extend(SettingsMenuMixin, { actions: { showSubview(subview) { - this._super(...arguments); + this.set('isViewingSubview', true); this.set('subview', subview); }, closeSubview() { - this._super(...arguments); + this.set('isViewingSubview', false); this.set('subview', null); }, diff --git a/ghost/admin/app/components/gh-post-settings-menu.js b/ghost/admin/app/components/gh-post-settings-menu.js index 7f85813742..33b5c983b6 100644 --- a/ghost/admin/app/components/gh-post-settings-menu.js +++ b/ghost/admin/app/components/gh-post-settings-menu.js @@ -1,12 +1,11 @@ import Component from '@ember/component'; -import SettingsMenuMixin from 'ghost-admin/mixins/settings-menu-component'; import boundOneWay from 'ghost-admin/utils/bound-one-way'; import moment from 'moment'; import {alias, or} from '@ember/object/computed'; import {computed} from '@ember/object'; import {inject as service} from '@ember/service'; -export default Component.extend(SettingsMenuMixin, { +export default Component.extend({ feature: service(), store: service(), config: service(), @@ -20,6 +19,7 @@ export default Component.extend(SettingsMenuMixin, { post: null, + showSettingsMenu: false, _showSettingsMenu: false, canonicalUrlScratch: alias('post.canonicalUrlScratch'), @@ -66,6 +66,19 @@ export default Component.extend(SettingsMenuMixin, { return urlParts.join(' > '); }), + isViewingSubview: computed('showSettingsMenu', { + get() { + return false; + }, + set(key, value) { + // Not viewing a subview if we can't even see the PSM + if (!this.showSettingsMenu) { + return false; + } + return value; + } + }), + didReceiveAttrs() { this._super(...arguments); @@ -86,12 +99,12 @@ export default Component.extend(SettingsMenuMixin, { actions: { showSubview(subview) { - this._super(...arguments); + this.set('isViewingSubview', true); this.set('subview', subview); }, closeSubview() { - this._super(...arguments); + this.set('isViewingSubview', false); this.set('subview', null); }, diff --git a/ghost/admin/app/mixins/settings-menu-component.js b/ghost/admin/app/mixins/settings-menu-component.js deleted file mode 100644 index a173af343e..0000000000 --- a/ghost/admin/app/mixins/settings-menu-component.js +++ /dev/null @@ -1,29 +0,0 @@ -import Mixin from '@ember/object/mixin'; -import {computed} from '@ember/object'; - -export default Mixin.create({ - showSettingsMenu: false, - - isViewingSubview: computed('showSettingsMenu', { - get() { - return false; - }, - set(key, value) { - // Not viewing a subview if we can't even see the PSM - if (!this.showSettingsMenu) { - return false; - } - return value; - } - }), - - actions: { - showSubview() { - this.set('isViewingSubview', true); - }, - - closeSubview() { - this.set('isViewingSubview', false); - } - } -});