diff --git a/ghost/admin/app/components/gh-nav-menu/design.js b/ghost/admin/app/components/gh-nav-menu/design.js index 038f2b226e..6aef53eb68 100644 --- a/ghost/admin/app/components/gh-nav-menu/design.js +++ b/ghost/admin/app/components/gh-nav-menu/design.js @@ -13,7 +13,8 @@ export default class DesignMenuComponent extends Component { @service themeManagement; @tracked openSection = null; - @tracked themes = this.store.peekAll('theme'); + + themes = this.store.peekAll('theme'); constructor() { super(...arguments); diff --git a/ghost/admin/app/components/modals/design/upload-theme.js b/ghost/admin/app/components/modals/design/upload-theme.js index 6300c7cced..630d3089a4 100644 --- a/ghost/admin/app/components/modals/design/upload-theme.js +++ b/ghost/admin/app/components/modals/design/upload-theme.js @@ -151,6 +151,7 @@ export default class UploadThemeModalComponent extends Component { @action activate() { this.themeManagement.activateTask.perform(this.theme); + this.args.data.onActivationSuccess?.(); this.args.close(); } diff --git a/ghost/admin/app/controllers/settings/design/change-theme.js b/ghost/admin/app/controllers/settings/design/change-theme.js index 55139252e9..53f9fd6a6f 100644 --- a/ghost/admin/app/controllers/settings/design/change-theme.js +++ b/ghost/admin/app/controllers/settings/design/change-theme.js @@ -4,11 +4,13 @@ import {inject as service} from '@ember/service'; import {tracked} from '@glimmer/tracking'; export default class ChangeThemeController extends Controller { + @service router; @service store; @service themeManagement; @tracked showAdvanced = false; - @tracked themes = this.store.peekAll('theme'); + + themes = this.store.peekAll('theme'); officialThemes = [{ name: 'Casper', @@ -154,6 +156,17 @@ export default class ChangeThemeController extends Controller { return themesList; } + @action + startThemeUpload(event) { + event?.preventDefault(); + + this.themeManagement.upload({ + onActivationSuccess: () => { + this.router.transitionTo('settings.design'); + } + }); + } + @action toggleAdvanced(event) { this.showAdvanced = !this.showAdvanced; diff --git a/ghost/admin/app/services/theme-management.js b/ghost/admin/app/services/theme-management.js index acbba52348..4aef96ac1e 100644 --- a/ghost/admin/app/services/theme-management.js +++ b/ghost/admin/app/services/theme-management.js @@ -45,9 +45,7 @@ export default class ThemeManagementService extends Service { } @action - async upload(event) { - event?.preventDefault(); - + async upload(options = {}) { try { // Sending a bad string to make sure it fails (empty string isn't valid) await this.limit.limiter.errorIfWouldGoOverLimit('customThemes', {value: '.'}); @@ -61,7 +59,7 @@ export default class ThemeManagementService extends Service { throw error; } - return this.modals.open('modals/design/upload-theme'); + return this.modals.open('modals/design/upload-theme', options); } @task diff --git a/ghost/admin/app/templates/settings/design/change-theme.hbs b/ghost/admin/app/templates/settings/design/change-theme.hbs index eba468044c..64e7fbad15 100644 --- a/ghost/admin/app/templates/settings/design/change-theme.hbs +++ b/ghost/admin/app/templates/settings/design/change-theme.hbs @@ -3,7 +3,7 @@