From 6707072ef126b222fbc6d3d75d32d5269a4807e1 Mon Sep 17 00:00:00 2001 From: Blake Erickson Date: Sat, 11 Jan 2020 06:04:14 -0700 Subject: [PATCH] FIX: Remove buffered-render reference Buffered-render has been removed from core, so this change allows us to keep the same functionality without using the render buffer. --- .../components/query-row-content.js.es6 | 112 +++++++++--------- .../components/query-row-content.hbs | 1 + 2 files changed, 56 insertions(+), 57 deletions(-) create mode 100644 assets/javascripts/discourse/templates/components/query-row-content.hbs diff --git a/assets/javascripts/discourse/components/query-row-content.js.es6 b/assets/javascripts/discourse/components/query-row-content.js.es6 index 48c922d..b2f2545 100644 --- a/assets/javascripts/discourse/components/query-row-content.js.es6 +++ b/assets/javascripts/discourse/components/query-row-content.js.es6 @@ -1,6 +1,5 @@ import { categoryLinkHTML } from "discourse/helpers/category-link"; import { autoUpdatingRelativeAge } from "discourse/lib/formatter"; -import { bufferedRender } from "discourse-common/lib/buffered-render"; import { iconHTML, convertIconClass } from "discourse-common/lib/icon-library"; function icon_or_image_replacement(str, ctx) { @@ -47,69 +46,68 @@ function guessUrl(t) { return [dest, name]; } -const QueryRowContentComponent = Ember.Component.extend( - bufferedRender({ - tagName: "tr", +const QueryRowContentComponent = Ember.Component.extend({ + tagName: "tr", + rowContents: null, - buildBuffer(buffer) { - const row = this.row; - const parentView = this.parentView; - const fallback = this.fallbackTemplate; - const helpers = { - "icon-or-image": icon_or_image_replacement, - "category-link": category_badge_replacement, - reltime: bound_date_replacement + didReceiveAttrs() { + const row = this.row; + const parentView = this.parentView; + const fallback = this.fallbackTemplate; + const helpers = { + "icon-or-image": icon_or_image_replacement, + "category-link": category_badge_replacement, + reltime: bound_date_replacement + }; + + const parts = this.columnTemplates.map((t, idx) => { + const value = row[idx], + id = parseInt(value, 10); + + const ctx = { + value, + id, + baseuri: Discourse.BaseUri === "/" ? "" : Discourse.BaseUri }; + const params = {}; - const parts = this.columnTemplates.map((t, idx) => { - const value = row[idx], - id = parseInt(value, 10); + if (row[idx] === null) { + return "NULL"; + } else if (t.name === "text") { + return esc(row[idx]); + } - const ctx = { - value, - id, - baseuri: Discourse.BaseUri === "/" ? "" : Discourse.BaseUri - }; - const params = {}; + const lookupFunc = parentView[`lookup${t.name.capitalize()}`]; + if (lookupFunc) { + ctx[t.name] = parentView[`lookup${t.name.capitalize()}`](id); + } - if (row[idx] === null) { - return "NULL"; - } else if (t.name === "text") { - return esc(row[idx]); - } + if (t.name === "url") { + let [url, name] = guessUrl(value); + ctx["href"] = url; + ctx["target"] = name; + } - const lookupFunc = parentView[`lookup${t.name.capitalize()}`]; - if (lookupFunc) { - ctx[t.name] = parentView[`lookup${t.name.capitalize()}`](id); - } + if ( + t.name === "category" || + t.name === "badge" || + t.name === "reltime" + ) { + // only replace helpers if needed + params.helpers = helpers; + } - if (t.name === "url") { - let [url, name] = guessUrl(value); - ctx["href"] = url; - ctx["target"] = name; - } + try { + return new Handlebars.SafeString( + (t.template || fallback)(ctx, params) + ); + } catch (e) { + return "error"; + } + }); - if ( - t.name === "category" || - t.name === "badge" || - t.name === "reltime" - ) { - // only replace helpers if needed - params.helpers = helpers; - } - - try { - return new Handlebars.SafeString( - (t.template || fallback)(ctx, params) - ); - } catch (e) { - return "error"; - } - }); - - buffer.push(`${parts.join("")}`); - } - }) -); + this.set("rowContents", `${parts.join("")}`.htmlSafe()); + } +}); export default QueryRowContentComponent; diff --git a/assets/javascripts/discourse/templates/components/query-row-content.hbs b/assets/javascripts/discourse/templates/components/query-row-content.hbs new file mode 100644 index 0000000..46e90d1 --- /dev/null +++ b/assets/javascripts/discourse/templates/components/query-row-content.hbs @@ -0,0 +1 @@ +{{rowContents}}