From d7cf11751ca6d35ee047a4ddfe9e019bab94fd90 Mon Sep 17 00:00:00 2001 From: Sanne de Vries <65487235+sanne-san@users.noreply.github.com> Date: Fri, 21 Jul 2023 18:03:38 +0200 Subject: [PATCH] Added theme hide title+image incompatibility warning (#17416) Refs https://github.com/TryGhost/Product/issues/3567 --- .../app/components/gh-post-settings-menu.hbs | 6 ++ .../app/components/gh-post-settings-menu.js | 5 ++ ghost/admin/app/models/theme.js | 60 +++++++++++++++++++ ghost/admin/app/styles/patterns/navlist.css | 10 ++++ 4 files changed, 81 insertions(+) diff --git a/ghost/admin/app/components/gh-post-settings-menu.hbs b/ghost/admin/app/components/gh-post-settings-menu.hbs index 8d7092b2c6..f00c317ce6 100644 --- a/ghost/admin/app/components/gh-post-settings-menu.hbs +++ b/ghost/admin/app/components/gh-post-settings-menu.hbs @@ -142,6 +142,12 @@ + {{#liquid-if (and (not this.post.showTitleAndFeatureImage) this.themeMissingShowTitleAndFeatureImage)}} +
+ {{/liquid-if}} {{/if}} diff --git a/ghost/admin/app/components/gh-post-settings-menu.js b/ghost/admin/app/components/gh-post-settings-menu.js index 77cb960e5d..f81954af35 100644 --- a/ghost/admin/app/components/gh-post-settings-menu.js +++ b/ghost/admin/app/components/gh-post-settings-menu.js @@ -20,6 +20,7 @@ export default class GhPostSettingsMenu extends Component { @service slugGenerator; @service session; @service settings; + @service themeManagement; @service ui; @inject config; @@ -163,6 +164,10 @@ export default class GhPostSettingsMenu extends Component { return true; } + get themeMissingShowTitleAndFeatureImage() { + return this.themeManagement.activeTheme.hasPageBuilderFeature('show_title_and_feature_image'); + } + willDestroyElement() { super.willDestroyElement(...arguments); diff --git a/ghost/admin/app/models/theme.js b/ghost/admin/app/models/theme.js index 50c0013f23..94bb355b25 100644 --- a/ghost/admin/app/models/theme.js +++ b/ghost/admin/app/models/theme.js @@ -26,6 +26,66 @@ export default Model.extend({ }); }), + codedWarnings: computed('warnings.[]', function () { + const codedWarnings = {}; + + this.warnings.forEach((warning) => { + if (!codedWarnings[warning.code]) { + codedWarnings[warning.code] = []; + } + + codedWarnings[warning.code].push(warning); + }); + + return codedWarnings; + }), + + codedErrors: computed('errors.[]', function () { + const codedErrors = {}; + + this.errors.forEach((error) => { + if (!codedErrors[error.code]) { + codedErrors[error.code] = []; + } + + codedErrors[error.code].push(error); + }); + + return codedErrors; + }), + + codedErrorsAndWarnings: computed('codedErrors.[]', 'codedWarnings.[]', function () { + const codedErrorsAndWarnings = {}; + + Object.keys(this.codedErrors).forEach((code) => { + if (!codedErrorsAndWarnings[code]) { + codedErrorsAndWarnings[code] = []; + } + codedErrorsAndWarnings[code] = [...codedErrorsAndWarnings[code], ...this.codedErrors[code]]; + }); + + Object.keys(this.codedWarnings).forEach((code) => { + if (!codedErrorsAndWarnings[code]) { + codedErrorsAndWarnings[code] = []; + } + codedErrorsAndWarnings[code] = [...codedErrorsAndWarnings[code], ...this.codedWarnings[code]]; + }); + + return codedErrorsAndWarnings; + }), + + hasPageBuilderFeature(feature) { + const failures = this.codedErrorsAndWarnings; + + if (!failures['GS110-NO-MISSING-PAGE-BUILDER-USAGE']) { + return true; + } + + return !failures['GS110-NO-MISSING-PAGE-BUILDER-USAGE'].some((failure) => { + return !failure.failures.some(({ref}) => ref === `@page.${feature}`); + }); + }, + activate() { let adapter = this.store.adapterFor(this.constructor.modelName); diff --git a/ghost/admin/app/styles/patterns/navlist.css b/ghost/admin/app/styles/patterns/navlist.css index dfab09cf95..75a761e3c7 100644 --- a/ghost/admin/app/styles/patterns/navlist.css +++ b/ghost/admin/app/styles/patterns/navlist.css @@ -76,3 +76,13 @@ li.nav-list-item .arrow-right { li.nav-list-item .arrow-right path { fill: var(--midgrey); } + +.nav-list-item-notification { + margin: 0 2.4rem 2rem; + color: var(--middarkgrey); +} + +.nav-list-item-notification a { + color: var(--green-d1); + font-weight: 500; +}