Make DISCOURSE_NO_CONSTANTS work in anon for home page
This commit is contained in:
parent
cf389e0137
commit
09bedfd4c0
|
@ -44,7 +44,7 @@ function loadDraft(store, opts) {
|
|||
export default Ember.Controller.extend({
|
||||
needs: ['modal', 'topic', 'composer-messages', 'application'],
|
||||
|
||||
replyAsNewTopicDraft: Em.computed.equal('model.draftKey', Discourse.Composer.REPLY_AS_NEW_TOPIC_KEY),
|
||||
replyAsNewTopicDraft: Em.computed.equal('model.draftKey', Composer.REPLY_AS_NEW_TOPIC_KEY),
|
||||
checkedMessages: false,
|
||||
|
||||
showEditReason: false,
|
||||
|
@ -166,7 +166,7 @@ export default Ember.Controller.extend({
|
|||
|
||||
openIfDraft() {
|
||||
if (this.get('model.viewDraft')) {
|
||||
this.set('model.composeState', Discourse.Composer.OPEN);
|
||||
this.set('model.composeState', Composer.OPEN);
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -179,17 +179,17 @@ export default Ember.Controller.extend({
|
|||
toggle() {
|
||||
this.closeAutocomplete();
|
||||
switch (this.get('model.composeState')) {
|
||||
case Discourse.Composer.OPEN:
|
||||
case Composer.OPEN:
|
||||
if (Ember.isEmpty(this.get('model.reply')) && Ember.isEmpty(this.get('model.title'))) {
|
||||
this.close();
|
||||
} else {
|
||||
this.shrink();
|
||||
}
|
||||
break;
|
||||
case Discourse.Composer.DRAFT:
|
||||
this.set('model.composeState', Discourse.Composer.OPEN);
|
||||
case Composer.DRAFT:
|
||||
this.set('model.composeState', Composer.OPEN);
|
||||
break;
|
||||
case Discourse.Composer.SAVING:
|
||||
case Composer.SAVING:
|
||||
this.close();
|
||||
}
|
||||
return false;
|
||||
|
@ -413,7 +413,7 @@ export default Ember.Controller.extend({
|
|||
// If we want a different draft than the current composer, close it and clear our model.
|
||||
if (composerModel &&
|
||||
opts.draftKey !== composerModel.draftKey &&
|
||||
composerModel.composeState === Discourse.Composer.DRAFT) {
|
||||
composerModel.composeState === Composer.DRAFT) {
|
||||
this.close();
|
||||
composerModel = null;
|
||||
}
|
||||
|
@ -422,15 +422,15 @@ export default Ember.Controller.extend({
|
|||
if (composerModel && composerModel.get('replyDirty')) {
|
||||
|
||||
// If we're already open, we don't have to do anything
|
||||
if (composerModel.get('composeState') === Discourse.Composer.OPEN &&
|
||||
if (composerModel.get('composeState') === Composer.OPEN &&
|
||||
composerModel.get('draftKey') === opts.draftKey && !opts.action) {
|
||||
return resolve();
|
||||
}
|
||||
|
||||
// If it's the same draft, just open it up again.
|
||||
if (composerModel.get('composeState') === Discourse.Composer.DRAFT &&
|
||||
if (composerModel.get('composeState') === Composer.DRAFT &&
|
||||
composerModel.get('draftKey') === opts.draftKey) {
|
||||
composerModel.set('composeState', Discourse.Composer.OPEN);
|
||||
composerModel.set('composeState', Composer.OPEN);
|
||||
if (!opts.action) return resolve();
|
||||
}
|
||||
|
||||
|
@ -467,7 +467,7 @@ export default Ember.Controller.extend({
|
|||
}
|
||||
|
||||
this.set('model', composerModel);
|
||||
composerModel.set('composeState', Discourse.Composer.OPEN);
|
||||
composerModel.set('composeState', Composer.OPEN);
|
||||
composerModel.set('isWarning', false);
|
||||
|
||||
if (opts.topicTitle && opts.topicTitle.length <= this.siteSettings.max_topic_title_length) {
|
||||
|
@ -567,7 +567,7 @@ export default Ember.Controller.extend({
|
|||
|
||||
collapse() {
|
||||
this._saveDraft();
|
||||
this.set('model.composeState', Discourse.Composer.DRAFT);
|
||||
this.set('model.composeState', Composer.DRAFT);
|
||||
},
|
||||
|
||||
close() {
|
||||
|
|
|
@ -74,6 +74,24 @@ module Tilt
|
|||
rval
|
||||
end
|
||||
|
||||
def whitelisted?(path)
|
||||
|
||||
@@whitelisted ||= Set.new(
|
||||
["discourse/models/nav-item",
|
||||
"discourse/models/user-action",
|
||||
"discourse/routes/discourse",
|
||||
"discourse/models/category",
|
||||
"discourse/models/trust-level",
|
||||
"discourse/models/site",
|
||||
"discourse/models/user",
|
||||
"discourse/models/session",
|
||||
"discourse/models/model",
|
||||
"discourse/views/grouped"]
|
||||
)
|
||||
|
||||
@@whitelisted.include?(path) || path =~ /discourse\/mixins/
|
||||
end
|
||||
|
||||
def evaluate(scope, locals, &block)
|
||||
return @output if @output
|
||||
|
||||
|
@ -86,7 +104,7 @@ module Tilt
|
|||
# For backwards compatibility with plugins, for now export the Global format too.
|
||||
# We should eventually have an upgrade system for plugins to use ES6 or some other
|
||||
# resolve based API.
|
||||
if ENV['DISCOURSE_NO_CONSTANTS'].nil? &&
|
||||
if (ENV['DISCOURSE_NO_CONSTANTS'].nil? || whitelisted?(scope.logical_path)) &&
|
||||
scope.logical_path =~ /(discourse|admin)\/(controllers|components|views|routes|mixins|models)\/(.*)/
|
||||
|
||||
type = Regexp.last_match[2]
|
||||
|
|
Loading…
Reference in New Issue