Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DEV: Add rawTitle property support to modal-tab #10221

Merged
merged 2 commits into from Jul 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 8 additions & 2 deletions app/assets/javascripts/discourse/app/components/modal-tab.js
@@ -1,6 +1,8 @@
import { equal, alias } from "@ember/object/computed";
import I18n from "I18n";
import Component from "@ember/component";
import { equal } from "@ember/object/computed";
import { propertyEqual } from "discourse/lib/computed";
import discourseComputed from "discourse-common/utils/decorators";

export default Component.extend({
tagName: "li",
Expand All @@ -10,9 +12,13 @@ export default Component.extend({
panelsLength: null,
classNameBindings: ["isActive", "singleTab", "panel.id"],
singleTab: equal("panelsLength", 1),
title: alias("panel.title"),
isActive: propertyEqual("panel.id", "selectedPanel.id"),

@discourseComputed("panel.title", "panel.rawTitle")
title(title, rawTitle) {
return title ? I18n.t(title) : rawTitle;
},

click() {
this.onSelectPanel(this.panel);
}
Expand Down
@@ -1 +1 @@
{{i18n title}}
{{title}}
19 changes: 19 additions & 0 deletions test/javascripts/acceptance/modal-test.js
Expand Up @@ -54,6 +54,25 @@ QUnit.skip("modal", async function(assert) {
);
});

QUnit.test("rawTitle in modal panels", async function(assert) {
Ember.TEMPLATES["modal/test-raw-title-panels"] = Ember.HTMLBars.compile("");
const panels = [
{ id: "test1", rawTitle: "Test 1" },
{ id: "test2", rawTitle: "Test 2" }
];

await visit("/");
run(() => showModal("test-raw-title-panels", { panels }));

assert.equal(
find(".d-modal .modal-tab:first-child")
.text()
.trim(),
"Test 1",
"it should display the raw title"
);
});

acceptance("Modal Keyboard Events", { loggedIn: true });

QUnit.test("modal-keyboard-events", async function(assert) {
Expand Down