From 679dc3c0d6d4c6bb5e348b56166b83cbc678ce6c Mon Sep 17 00:00:00 2001 From: Peter Zimon Date: Fri, 22 Jan 2021 12:24:45 +0100 Subject: [PATCH] Separate theme design (#1831) * Separated theme and design settings --- .../admin/app/controllers/settings/design.js | 96 +-- ghost/admin/app/controllers/settings/theme.js | 125 ++++ ghost/admin/app/router.js | 3 + ghost/admin/app/routes/settings/design.js | 10 +- ghost/admin/app/routes/settings/theme.js | 44 ++ .../app/routes/settings/theme/uploadtheme.js | 18 + ghost/admin/app/styles/layouts/settings.css | 30 +- ghost/admin/app/templates/settings.hbs | 12 +- ghost/admin/app/templates/settings/design.hbs | 137 ----- ghost/admin/app/templates/settings/theme.hbs | 158 +++++ .../templates/settings/theme/uploadtheme.hbs | 7 + .../tests/acceptance/error-handling-test.js | 2 +- .../tests/acceptance/settings/design-test.js | 502 ---------------- .../tests/acceptance/settings/theme-test.js | 556 ++++++++++++++++++ 14 files changed, 948 insertions(+), 752 deletions(-) create mode 100644 ghost/admin/app/controllers/settings/theme.js create mode 100644 ghost/admin/app/routes/settings/theme.js create mode 100644 ghost/admin/app/routes/settings/theme/uploadtheme.js create mode 100644 ghost/admin/app/templates/settings/theme.hbs create mode 100644 ghost/admin/app/templates/settings/theme/uploadtheme.hbs create mode 100644 ghost/admin/tests/acceptance/settings/theme-test.js diff --git a/ghost/admin/app/controllers/settings/design.js b/ghost/admin/app/controllers/settings/design.js index 0227718a75..0bbef2d920 100644 --- a/ghost/admin/app/controllers/settings/design.js +++ b/ghost/admin/app/controllers/settings/design.js @@ -4,9 +4,6 @@ import Controller from '@ember/controller'; import NavigationItem from 'ghost-admin/models/navigation-item'; import RSVP from 'rsvp'; import {computed} from '@ember/object'; -import {isEmpty} from '@ember/utils'; -import {isThemeValidationError} from 'ghost-admin/services/ajax'; -import {notEmpty} from '@ember/object/computed'; import {inject as service} from '@ember/service'; import {task} from 'ember-concurrency'; @@ -20,17 +17,13 @@ export default Controller.extend({ dirtyAttributes: false, newNavItem: null, newSecondaryNavItem: null, - themes: null, - themeToDelete: null, - + init() { this._super(...arguments); this.set('newNavItem', NavigationItem.create({isNew: true})); this.set('newSecondaryNavItem', NavigationItem.create({isNew: true, isSecondary: true})); }, - showDeleteThemeModal: notEmpty('themeToDelete'), - blogUrl: computed('config.blogUrl', function () { let url = this.get('config.blogUrl'); @@ -128,76 +121,6 @@ export default Controller.extend({ return transition.retry(); }, - activateTheme(theme) { - return theme.activate().then((activatedTheme) => { - if (!isEmpty(activatedTheme.get('warnings'))) { - this.set('themeWarnings', activatedTheme.get('warnings')); - this.set('showThemeWarningsModal', true); - } - - if (!isEmpty(activatedTheme.get('errors'))) { - this.set('themeErrors', activatedTheme.get('errors')); - this.set('showThemeWarningsModal', true); - } - }).catch((error) => { - if (isThemeValidationError(error)) { - let errors = error.payload.errors[0].details.errors; - let fatalErrors = []; - let normalErrors = []; - - // to have a proper grouping of fatal errors and none fatal, we need to check - // our errors for the fatal property - if (errors.length > 0) { - for (let i = 0; i < errors.length; i += 1) { - if (errors[i].fatal) { - fatalErrors.push(errors[i]); - } else { - normalErrors.push(errors[i]); - } - } - } - - this.set('themeErrors', normalErrors); - this.set('themeFatalErrors', fatalErrors); - this.set('showThemeErrorsModal', true); - return; - } - - throw error; - }); - }, - - downloadTheme(theme) { - let downloadURL = `${this.get('ghostPaths.apiRoot')}/themes/${theme.name}/download/`; - let iframe = $('#iframeDownload'); - - if (iframe.length === 0) { - iframe = $('