This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/app/assets/javascripts/discourse/components/global-notice.js.es6
Robin Ward af6936cf72 Refactor some deprecations for newer versions of Ember. Also set up
injection for some globals so we can migrate away from them.
2014-09-11 16:16:21 -04:00

37 lines
1.1 KiB
JavaScript

export default Ember.Component.extend({
shouldRerender: Discourse.View.renderIfChanged("site.isReadOnly"),
render: function(buffer) {
var notices = [];
if (this.site.get("isReadOnly")) {
notices.push(I18n.t("read_only_mode.enabled"));
}
if (Discourse.User.currentProp('admin') && this.siteSettings.show_create_topics_notice) {
var topic_count = 0,
post_count = 0;
_.each(this.site.get('categories'), function(c) {
if (!c.get('read_restricted')) {
topic_count += c.get('topic_count');
post_count += c.get('post_count');
}
});
if (topic_count < 5 || post_count < this.siteSettings.tl1_requires_read_posts) {
notices.push(I18n.t("too_few_topics_notice", {posts: this.siteSettings.tl1_requires_read_posts}));
}
}
if (!_.isEmpty(this.siteSettings.global_notice)) {
notices.push(this.siteSettings.global_notice);
}
if (notices.length > 0) {
buffer.push(_.map(notices, function(text) {
return "<div class='row'><div class='alert alert-info'>" + text + "</div></div>";
}).join(""));
}
}
});