FIX: Show badge names in query results (#92)

* FIX: Show badge names in query results
This commit is contained in:
Andrew Prigorshnev 2021-02-12 13:01:16 +04:00 committed by GitHub
parent d1ab0e5fbe
commit 9d86b8b653
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 51 additions and 3 deletions

View File

@ -1,5 +1,5 @@
# frozen_string_literal: true
class DataExplorer::SmallBadgeSerializer < ApplicationSerializer
attributes :id, :name, :badge_type, :description, :icon
attributes :id, :name, :display_name, :badge_type, :description, :icon
end

View File

@ -1,6 +1,6 @@
{{! source: badge-button component }}
<a href="{{baseuri}}/badges/{{badge.id}}/{{badge.name}}"
class="user-badge {{badge.badgeTypeClassName}}"
title="{{badge.displayDescription}}"
title="{{badge.display_name}}"
data-badge-name="{{badge.name}}">{{icon-or-image badge.icon}}
<span class="badge-display-name">{{badge.displayName}}</span></a>
<span class="badge-display-name">{{badge.display_name}}</span></a>

View File

@ -0,0 +1,48 @@
import componentTest, {
setupRenderingTest,
} from "discourse/tests/helpers/component-test";
import {
discourseModule,
queryAll,
} from "discourse/tests/helpers/qunit-helpers";
import hbs from "htmlbars-inline-precompile";
discourseModule(
"Data Explorer Plugin | Integration | Component | query-result",
function (hooks) {
setupRenderingTest(hooks);
componentTest("it renders badge names in query results", {
template: hbs`{{query-result content=content}}`,
beforeEach() {
const results = {
colrender: { 0: "badge" },
relations: {
badge: [
{
description: "description",
icon: "fa-user",
id: 1,
name: "badge name",
display_name: "badge display name",
},
],
},
result_count: 1,
columns: ["badge_id"],
rows: [[1]],
};
this.set("content", results);
},
test(assert) {
assert.ok(
queryAll(
"table tbody tr:nth-child(1) td:nth-child(1) span"
).text() === "badge display name"
);
},
});
}
);