diff --git a/app/assets/javascripts/admin/controllers/modals/admin-badge-preview.js.es6 b/app/assets/javascripts/admin/controllers/modals/admin-badge-preview.js.es6 index 27023621569..045a96c2aa6 100644 --- a/app/assets/javascripts/admin/controllers/modals/admin-badge-preview.js.es6 +++ b/app/assets/javascripts/admin/controllers/modals/admin-badge-preview.js.es6 @@ -1,3 +1,4 @@ +import { default as computed } from "ember-addons/ember-computed-decorators"; import { escapeExpression } from "discourse/lib/utilities"; export default Ember.Controller.extend({ @@ -5,43 +6,42 @@ export default Ember.Controller.extend({ errors: Ember.computed.alias("model.errors"), count: Ember.computed.alias("model.grant_count"), - count_warning: function() { - if (this.get("count") <= 10) { - return this.get("sample.length") !== this.get("count"); + @computed("count", "sample.length") + countWarning(count, sampleLength) { + if (count <= 10) { + return sampleLength !== count; } else { - return this.get("sample.length") !== 10; + return sampleLength !== 10; } - }.property("count", "sample.length"), + }, - has_query_plan: function() { - return !!this.get("model.query_plan"); - }.property("model.query_plan"), + @computed("model.query_plan") + hasQueryPlan(queryPlan) { + return !!queryPlan; + }, - query_plan_html: function() { - var raw = this.get("model.query_plan"), - returned = "
"; + @computed("model.query_plan") + queryPlanHtml(queryPlan) { + let output = `"; + return output; + }, - processed_sample: Ember.computed.map("model.sample", function(grant) { - var i18nKey = "admin.badges.preview.grant.with", - i18nParams = { username: escapeExpression(grant.username) }; + processedSample: Ember.computed.map("model.sample", grant => { + let i18nKey = "admin.badges.preview.grant.with"; + const i18nParams = { username: escapeExpression(grant.username) }; if (grant.post_id) { i18nKey += "_post"; - i18nParams.link = - "" + - Handlebars.Utils.escapeExpression(grant.title) + - ""; + i18nParams.link = ` + ${Handlebars.Utils.escapeExpression(grant.title)} + `; } if (grant.granted_at) { diff --git a/app/assets/javascripts/admin/templates/modal/admin-badge-preview.hbs b/app/assets/javascripts/admin/templates/modal/admin-badge-preview.hbs index 70b0c1c3fc2..7911b91ab8f 100644 --- a/app/assets/javascripts/admin/templates/modal/admin-badge-preview.hbs +++ b/app/assets/javascripts/admin/templates/modal/admin-badge-preview.hbs @@ -1,49 +1,55 @@ {{#d-modal-body title="admin.badges.preview.modal_title" class="badge-query-preview"}} {{#if errors}} -`; - raw.forEach(linehash => { - returned += escapeExpression(linehash["QUERY PLAN"]); - returned += ""; - return returned; - }.property("model.query_plan"), + output += "
"; + queryPlan.forEach(linehash => { + output += escapeExpression(linehash["QUERY PLAN"]); + output += "
"; }); - returned += "
{{i18n 'admin.badges.preview.sql_error_header'}}
+{{i18n "admin.badges.preview.sql_error_header"}}
{{errors}}+ {{else}}
{{#if count}} - {{{i18n 'admin.badges.preview.grant_count' count=count}}} + {{{i18n "admin.badges.preview.grant_count" count=count}}} {{else}} - {{{i18n 'admin.badges.preview.no_grant_count'}}} + {{{i18n "admin.badges.preview.no_grant_count"}}} {{/if}}
- {{#if count_warning}} + {{#if countWarning}}{{d-icon "warning"}} {{i18n 'admin.badges.preview.bad_count_warning.header'}}
-{{i18n 'admin.badges.preview.bad_count_warning.text'}}
++ {{d-icon "warning"}} + {{i18n "admin.badges.preview.bad_count_warning.header"}} +
++ {{i18n "admin.badges.preview.bad_count_warning.text"}} +
- {{i18n 'admin.badges.preview.sample'}} + {{i18n "admin.badges.preview.sample"}}