mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-03 23:00:14 -05:00
refs https://github.com/TryGhost/Team/issues/1104 - bumped `@tryghost/custom-theme-settings-service` so it throws a more appropriate `ValidationError` when setting keys don't exist or a select value is not known - changed the custom theme settings service to have a `.init()` method which creates an instance of the service under `.api` so that we're able to create the instance at a particular point in the boot process when we know the models have been initialised - there were problems in tests because the service was being initialised through the require chain before models were initialised through the boot process - fixed incorrect `camelCase` of resource name in API responses
35 lines
1.6 KiB
JavaScript
35 lines
1.6 KiB
JavaScript
const debug = require('@tryghost/debug')('themes');
|
|
const bridge = require('../../../bridge');
|
|
const labs = require('../../../shared/labs');
|
|
const customThemeSettings = require('../custom-theme-settings');
|
|
|
|
/**
|
|
* These helper methods mean that the bridge is only required in one place
|
|
* And also adds a little debug statement, which is very handy when debugging theme logic
|
|
*/
|
|
module.exports = {
|
|
activateFromBoot: (themeName, theme, checkedTheme) => {
|
|
debug('Activating theme (method A on boot)', themeName);
|
|
// TODO: probably a better place for this to happen - after successful activation / when reloading site?
|
|
if (labs.isSet('customThemeSettings')) {
|
|
customThemeSettings.api.activateTheme(checkedTheme);
|
|
}
|
|
bridge.activateTheme(theme, checkedTheme);
|
|
},
|
|
activateFromAPI: (themeName, theme, checkedTheme) => {
|
|
debug('Activating theme (method B on API "activate")', themeName);
|
|
// TODO: probably a better place for this to happen - after successful activation / when reloading site?
|
|
if (labs.isSet('customThemeSettings')) {
|
|
customThemeSettings.api.activateTheme(checkedTheme);
|
|
}
|
|
bridge.activateTheme(theme, checkedTheme);
|
|
},
|
|
activateFromAPIOverride: (themeName, theme, checkedTheme) => {
|
|
debug('Activating theme (method C on API "override")', themeName);
|
|
// TODO: probably a better place for this to happen - after successful activation / when reloading site?
|
|
if (labs.isSet('customThemeSettings')) {
|
|
customThemeSettings.api.activateTheme(checkedTheme);
|
|
}
|
|
bridge.activateTheme(theme, checkedTheme);
|
|
}
|
|
};
|