mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-29 22:01:49 +03:00
Removed passing of error to active theme
refs:076ad99593
- as of076ad99593
we no longer use the error property of the active theme anywhere - cleaning up and removing this usage reduces the code pathways and makes the init fn a bit clearer
This commit is contained in:
parent
9987bdbe17
commit
362140b31e
@ -26,16 +26,16 @@ let currentActiveTheme;
|
||||
class ActiveTheme {
|
||||
/**
|
||||
* @TODO this API needs to be simpler, but for now should work!
|
||||
* @param {object} settings
|
||||
* @param {string} settings.locale - the active locale for i18n
|
||||
* @param {object} loadedTheme - the loaded theme object from the theme list
|
||||
* @param {object} checkedTheme - the result of gscan.format for the theme we're activating
|
||||
* @param {object} error - bootstrap validates the active theme, we would like to remember this error
|
||||
*/
|
||||
constructor(settings, loadedTheme, checkedTheme, error) {
|
||||
constructor(settings, loadedTheme, checkedTheme) {
|
||||
// Assign some data, mark it all as pseudo-private
|
||||
this._name = loadedTheme.name;
|
||||
this._path = loadedTheme.path;
|
||||
this._mounted = false;
|
||||
this._error = error;
|
||||
|
||||
// We get passed in a locale
|
||||
this._locale = settings.locale || 'en';
|
||||
@ -136,13 +136,14 @@ module.exports = {
|
||||
* At this point we trust that the theme has been validated.
|
||||
* Any handling for invalid themes should happen before we get here
|
||||
*
|
||||
* @TODO this API needs to be simpler, but for now should work!
|
||||
* @param {object} settings
|
||||
* @param {string} settings.locale - the active locale for i18n
|
||||
* @param {object} loadedTheme - the loaded theme object from the theme list
|
||||
* @param {object} checkedTheme - the result of gscan.format for the theme we're activating
|
||||
* @return {ActiveTheme}
|
||||
*/
|
||||
set(settings, loadedTheme, checkedTheme, error) {
|
||||
currentActiveTheme = new ActiveTheme(settings, loadedTheme, checkedTheme, error);
|
||||
set(settings, loadedTheme, checkedTheme) {
|
||||
currentActiveTheme = new ActiveTheme(settings, loadedTheme, checkedTheme);
|
||||
return currentActiveTheme;
|
||||
}
|
||||
};
|
||||
|
@ -32,36 +32,29 @@ module.exports = {
|
||||
.check(theme)
|
||||
.then(function validationSuccess(checkedTheme) {
|
||||
if (!validate.canActivate(checkedTheme)) {
|
||||
const checkError = new errors.ThemeValidationError({
|
||||
logging.error(new errors.ThemeValidationError({
|
||||
message: tpl(messages.invalidTheme, {theme: activeThemeName}),
|
||||
errorDetails: Object.assign(
|
||||
_.pick(checkedTheme, ['checkedVersion', 'name', 'path', 'version']), {
|
||||
errors: checkedTheme.results.error
|
||||
}
|
||||
)
|
||||
});
|
||||
|
||||
logging.error(checkError);
|
||||
|
||||
bridge.activateTheme(theme, checkedTheme, checkError);
|
||||
} else {
|
||||
}));
|
||||
// CASE: inform that the theme has errors, but not fatal (theme still works)
|
||||
if (checkedTheme.results.error.length) {
|
||||
logging.warn(new errors.ThemeValidationError({
|
||||
errorType: 'ThemeWorksButHasErrors',
|
||||
message: tpl(messages.themeHasErrors, {theme: activeThemeName}),
|
||||
errorDetails: Object.assign(
|
||||
_.pick(checkedTheme, ['checkedVersion', 'name', 'path', 'version']), {
|
||||
errors: checkedTheme.results.error
|
||||
}
|
||||
)
|
||||
}));
|
||||
}
|
||||
|
||||
debug('Activating theme (method A on boot)', activeThemeName);
|
||||
|
||||
bridge.activateTheme(theme, checkedTheme);
|
||||
} else if (checkedTheme.results.error.length) {
|
||||
logging.warn(new errors.ThemeValidationError({
|
||||
errorType: 'ThemeWorksButHasErrors',
|
||||
message: tpl(messages.themeHasErrors, {theme: activeThemeName}),
|
||||
errorDetails: Object.assign(
|
||||
_.pick(checkedTheme, ['checkedVersion', 'name', 'path', 'version']), {
|
||||
errors: checkedTheme.results.error
|
||||
}
|
||||
)
|
||||
}));
|
||||
}
|
||||
|
||||
debug('Activating theme (method A on boot)', activeThemeName);
|
||||
bridge.activateTheme(theme, checkedTheme);
|
||||
});
|
||||
})
|
||||
.catch(function (err) {
|
||||
|
Loading…
Reference in New Issue
Block a user