Revert "Fixed frontend require in labs"

This reverts commit 6fb8736560.
This commit is contained in:
Hannah Wolfe 2021-07-08 07:10:11 +01:00
parent 8d38957bd7
commit 4481b51992
No known key found for this signature in database
GPG Key ID: 9F8C7532D0A6BA55

View File

@ -1,19 +1,12 @@
const _ = require('lodash');
const Promise = require('bluebird');
const SafeString = require('express-hbs').SafeString;
const SafeString = require('../../frontend/services/theme-engine/engine').SafeString;
const errors = require('@tryghost/errors');
const i18n = require('../../shared/i18n');
const logging = require('@tryghost/logging');
const tpl = require('@tryghost/tpl');
const settingsCache = require('../../shared/settings-cache');
const config = require('../../shared/config');
const messages = {
errorMessage: 'The \\{\\{{helperName}\\}\\} helper is not available.',
errorContext: 'The {flagName} flag must be enabled in labs if you wish to use the \\{\\{{helperName}\\}\\} helper.',
errorHelp: 'See {url}'
};
// NOTE: this allowlist is meant to be used to filter out any unexpected
// input for the "labs" setting value
const BETA_FEATURES = [
@ -53,20 +46,6 @@ module.exports.isSet = function isSet(flag) {
return !!(labsConfig && labsConfig[flag] && labsConfig[flag] === true);
};
/**
*
* @param {object} options
* @param {string} options.flagKey the interal lookup key of the flag e.g. labs.isSet(matchHelper)
* @param {string} options.flagName the user-facing name of the flag e.g. Match helper
* @param {string} options.helperName Name of the helper to be enabled/disabled
* @param {string} [options.errorMessage] Optional replacement error message
* @param {string} [options.errorContext] Optional replacement context message
* @param {string} [options.errorHelp] Optional replacement help message
* @param {string} [options.helpUrl] Url to show in the help message
* @param {string} [options.async] is the helper async?
* @param {function} callback
* @returns {Promise<Handlebars.SafeString>|Handlebars.SafeString}
*/
module.exports.enabledHelper = function enabledHelper(options, callback) {
const errDetails = {};
let errString;
@ -77,12 +56,12 @@ module.exports.enabledHelper = function enabledHelper(options, callback) {
}
// Else, the helper is not active and we need to handle this as an error
errDetails.message = tpl(options.errorMessage || messages.errorMessage, {helperName: options.helperName}),
errDetails.context = tpl(options.errorContext || messages.errorContext, {
errDetails.message = i18n.t(options.errMessagePath || 'warnings.helpers.helperNotAvailable', {helperName: options.helperName}),
errDetails.context = i18n.t(options.errContextPath || 'warnings.helpers.flagMustBeEnabled', {
helperName: options.helperName,
flagName: options.flagName
});
errDetails.help = tpl(options.errorHelp || messages.errorHelp, {url: options.helpUrl});
errDetails.help = i18n.t(options.errHelpPath || 'warnings.helpers.seeLink', {url: options.helpUrl});
logging.error(new errors.DisabledFeatureError(errDetails));