Skip to content

Commit

Permalink
DEV: Add rawTitle property support to modal-tab (#10221)
Browse files Browse the repository at this point in the history
```js
const panels = [
  { id: "test1", rawTitle: "Test 1" },
  { id: "test2", rawTitle: "Test 2" }
];

showModal("a-modal", { panels }));
```
  • Loading branch information
CvX committed Jul 12, 2020
1 parent 544a986 commit 942cc9b
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 3 deletions.
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

0 comments on commit 942cc9b

Please sign in to comment.