mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-03-11 02:12:21 -05: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
2 changed files with 22 additions and 28 deletions
|
@ -26,16 +26,16 @@ let currentActiveTheme;
|
||||||
class ActiveTheme {
|
class ActiveTheme {
|
||||||
/**
|
/**
|
||||||
* @TODO this API needs to be simpler, but for now should work!
|
* @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} 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} 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
|
// Assign some data, mark it all as pseudo-private
|
||||||
this._name = loadedTheme.name;
|
this._name = loadedTheme.name;
|
||||||
this._path = loadedTheme.path;
|
this._path = loadedTheme.path;
|
||||||
this._mounted = false;
|
this._mounted = false;
|
||||||
this._error = error;
|
|
||||||
|
|
||||||
// We get passed in a locale
|
// We get passed in a locale
|
||||||
this._locale = settings.locale || 'en';
|
this._locale = settings.locale || 'en';
|
||||||
|
@ -136,13 +136,14 @@ module.exports = {
|
||||||
* At this point we trust that the theme has been validated.
|
* At this point we trust that the theme has been validated.
|
||||||
* Any handling for invalid themes should happen before we get here
|
* 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} 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} checkedTheme - the result of gscan.format for the theme we're activating
|
||||||
* @return {ActiveTheme}
|
* @return {ActiveTheme}
|
||||||
*/
|
*/
|
||||||
set(settings, loadedTheme, checkedTheme, error) {
|
set(settings, loadedTheme, checkedTheme) {
|
||||||
currentActiveTheme = new ActiveTheme(settings, loadedTheme, checkedTheme, error);
|
currentActiveTheme = new ActiveTheme(settings, loadedTheme, checkedTheme);
|
||||||
return currentActiveTheme;
|
return currentActiveTheme;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -32,21 +32,16 @@ module.exports = {
|
||||||
.check(theme)
|
.check(theme)
|
||||||
.then(function validationSuccess(checkedTheme) {
|
.then(function validationSuccess(checkedTheme) {
|
||||||
if (!validate.canActivate(checkedTheme)) {
|
if (!validate.canActivate(checkedTheme)) {
|
||||||
const checkError = new errors.ThemeValidationError({
|
logging.error(new errors.ThemeValidationError({
|
||||||
message: tpl(messages.invalidTheme, {theme: activeThemeName}),
|
message: tpl(messages.invalidTheme, {theme: activeThemeName}),
|
||||||
errorDetails: Object.assign(
|
errorDetails: Object.assign(
|
||||||
_.pick(checkedTheme, ['checkedVersion', 'name', 'path', 'version']), {
|
_.pick(checkedTheme, ['checkedVersion', 'name', 'path', 'version']), {
|
||||||
errors: checkedTheme.results.error
|
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)
|
// CASE: inform that the theme has errors, but not fatal (theme still works)
|
||||||
if (checkedTheme.results.error.length) {
|
} else if (checkedTheme.results.error.length) {
|
||||||
logging.warn(new errors.ThemeValidationError({
|
logging.warn(new errors.ThemeValidationError({
|
||||||
errorType: 'ThemeWorksButHasErrors',
|
errorType: 'ThemeWorksButHasErrors',
|
||||||
message: tpl(messages.themeHasErrors, {theme: activeThemeName}),
|
message: tpl(messages.themeHasErrors, {theme: activeThemeName}),
|
||||||
|
@ -59,9 +54,7 @@ module.exports = {
|
||||||
}
|
}
|
||||||
|
|
||||||
debug('Activating theme (method A on boot)', activeThemeName);
|
debug('Activating theme (method A on boot)', activeThemeName);
|
||||||
|
|
||||||
bridge.activateTheme(theme, checkedTheme);
|
bridge.activateTheme(theme, checkedTheme);
|
||||||
}
|
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.catch(function (err) {
|
.catch(function (err) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue