From 265a19f5502960dd4096e6c6f6f9eacbabe3d58a Mon Sep 17 00:00:00 2001 From: Kevin Ansfield Date: Tue, 12 Oct 2021 14:27:51 +0100 Subject: [PATCH] Added initial view-theme modal for installing from themes list refs https://github.com/TryGhost/Team/issues/1130 - added new route for viewing themes so back/forward buttons can be used - takes theme name as a parameter - opens a fullscreen modal with an iframe containing the theme demo - changed installable themes list to link to new route - swapped `previewUrl` in theme data to point at the real demo rather than the ghost.org demo page --- .../components/modals/design/view-theme.hbs | 15 ++++++++ .../settings/design/change-theme.js | 8 ++--- ghost/admin/app/router.js | 4 ++- .../settings/design/change-theme/view.js | 34 +++++++++++++++++++ ghost/admin/app/services/modals.js | 14 +++++--- .../settings/design/change-theme.hbs | 8 ++--- 6 files changed, 67 insertions(+), 16 deletions(-) create mode 100644 ghost/admin/app/components/modals/design/view-theme.hbs create mode 100644 ghost/admin/app/routes/settings/design/change-theme/view.js diff --git a/ghost/admin/app/components/modals/design/view-theme.hbs b/ghost/admin/app/components/modals/design/view-theme.hbs new file mode 100644 index 0000000000..7f92abb804 --- /dev/null +++ b/ghost/admin/app/components/modals/design/view-theme.hbs @@ -0,0 +1,15 @@ +
+ +

+ All themes + {{svg-jar "arrow-right"}} + {{@data.theme.name}} +

+
+ +
+ + + +
+
\ No newline at end of file diff --git a/ghost/admin/app/controllers/settings/design/change-theme.js b/ghost/admin/app/controllers/settings/design/change-theme.js index 2562b3ae4c..3851856d4f 100644 --- a/ghost/admin/app/controllers/settings/design/change-theme.js +++ b/ghost/admin/app/controllers/settings/design/change-theme.js @@ -14,7 +14,7 @@ export default class ChangeThemeController extends Controller { name: 'Edition', category: 'Newsletter', url: 'https://github.com/TryGhost/Edition', - previewUrl: 'https://ghost.org/themes/edition', + previewUrl: 'https://edition.ghost.io/', ref: 'TryGhost/Edition', image: 'assets/img/themes/Edition.jpg', shortImage: 'assets/img/themes/Edition-cut.jpg' @@ -22,7 +22,7 @@ export default class ChangeThemeController extends Controller { name: 'Alto', category: 'Blog', url: 'https://github.com/TryGhost/Alto', - previewUrl: 'https://ghost.org/themes/alto', + previewUrl: 'https://alto.ghost.io', ref: 'TryGhost/Alto', image: 'assets/img/themes/Alto.jpg', shortImage: 'assets/img/themes/Alto-cut.jpg' @@ -30,7 +30,7 @@ export default class ChangeThemeController extends Controller { name: 'London', category: 'Photography', url: 'https://github.com/TryGhost/London', - previewUrl: 'https://ghost.org/themes/london', + previewUrl: 'https://london.ghost.io', ref: 'TryGhost/London', image: 'assets/img/themes/London.jpg', shortImage: 'assets/img/themes/London-cut.jpg' @@ -38,7 +38,7 @@ export default class ChangeThemeController extends Controller { name: 'Ease', category: 'Documentation', url: 'https://github.com/TryGhost/Ease', - previewUrl: 'https://ghost.org/themes/ease', + previewUrl: 'https://ease.ghost.io', ref: 'TryGhost/Ease', image: 'assets/img/themes/Ease.jpg', shortImage: 'assets/img/themes/Ease-cut.jpg' diff --git a/ghost/admin/app/router.js b/ghost/admin/app/router.js index 064e459fe0..873c25b5ff 100644 --- a/ghost/admin/app/router.js +++ b/ghost/admin/app/router.js @@ -49,7 +49,9 @@ Router.map(function () { this.route('settings.code-injection', {path: '/settings/code-injection'}); this.route('settings.design', {path: '/settings/design'}, function () { - this.route('change-theme'); + this.route('change-theme', function () { + this.route('view', {path: ':theme_name'}); + }); }); // this.route('settings.products', {path: '/settings/products'}); diff --git a/ghost/admin/app/routes/settings/design/change-theme/view.js b/ghost/admin/app/routes/settings/design/change-theme/view.js new file mode 100644 index 0000000000..d7c9bfc0fe --- /dev/null +++ b/ghost/admin/app/routes/settings/design/change-theme/view.js @@ -0,0 +1,34 @@ +import Route from '@ember/routing/route'; +import {inject as service} from '@ember/service'; + +export default class ViewThemeRoute extends Route { + @service modals; + + themeModal = null; + + model(params, transition) { + const changeThemeController = this.controllerFor('settings.design.change-theme'); + const knownThemes = changeThemeController.marketplaceThemes; + + const foundTheme = knownThemes.find(theme => theme.name === params.theme_name); + + if (foundTheme) { + return foundTheme; + } + + const path = transition.intent.url.replace(/^\//, ''); + return this.replaceWith('error404', {path, status: 404}); + } + + setupController(controller, model) { + this.themeModal?.close(); + + this.themeModal = this.modals.open('modals/design/view-theme', { + theme: model + }); + } + + deactivate() { + this.themeModal?.close(); + } +} diff --git a/ghost/admin/app/services/modals.js b/ghost/admin/app/services/modals.js index ae92c63bc8..e13bf16123 100644 --- a/ghost/admin/app/services/modals.js +++ b/ghost/admin/app/services/modals.js @@ -10,6 +10,12 @@ export default class ModalsService extends EPMModalsService { 'modals/confirm-unsaved-changes': { className: 'fullscreen-modal-action fullscreen-modal-wide' }, + 'modals/design/confirm-delete-theme': { + className: 'fullscreen-modal-action fullscreen-modal-wide' + }, + 'modals/design/theme-errors': { + className: 'fullscreen-modal-action fullscreen-modal-wide' + }, 'modals/design/upload-theme': { className: 'fullscreen-modal-action fullscreen-modal-wide', beforeClose: () => { @@ -18,11 +24,9 @@ export default class ModalsService extends EPMModalsService { } } }, - 'modals/design/confirm-delete-theme': { - className: 'fullscreen-modal-action fullscreen-modal-wide' - }, - 'modals/design/theme-errors': { - className: 'fullscreen-modal-action fullscreen-modal-wide' + 'modals/design/view-theme': { + className: 'fullscreen-modal-total-overlay', + omitBackdrop: true }, 'modals/limits/custom-theme': { className: 'fullscreen-modal-action fullscreen-modal-wide' diff --git a/ghost/admin/app/templates/settings/design/change-theme.hbs b/ghost/admin/app/templates/settings/design/change-theme.hbs index 76041e5ea1..d4604634dc 100644 --- a/ghost/admin/app/templates/settings/design/change-theme.hbs +++ b/ghost/admin/app/templates/settings/design/change-theme.hbs @@ -17,19 +17,15 @@
{{#each this.marketplaceThemes as |theme|}} - +
{{theme.name}}
• {{theme.category}}
- + {{/each}}