mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: Badge preview not displaying grant count (#23269)
<img width="510" alt="Screenshot 2023-08-25 at 8 19 38 AM" src="https://github.com/discourse/discourse/assets/50783505/9ebf467e-7b3b-49e2-91d9-43e37b838431">
This commit is contained in:
parent
e7cb417aaf
commit
0496199090
@ -5,15 +5,17 @@
|
|||||||
>
|
>
|
||||||
<:body>
|
<:body>
|
||||||
{{#if @model.badge.errors}}
|
{{#if @model.badge.errors}}
|
||||||
<p class="error-header">{{i18n
|
<p class="error-header">
|
||||||
"admin.badges.preview.sql_error_header"
|
{{i18n "admin.badges.preview.sql_error_header"}}
|
||||||
}}</p>
|
</p>
|
||||||
<pre class="badge-errors">{{@model.badge.errors}}</pre>
|
<pre class="badge-errors">{{@model.badge.errors}}</pre>
|
||||||
{{else}}
|
{{else}}
|
||||||
<p class="grant-count">
|
<p class="grant-count">
|
||||||
{{#if this.count}}
|
{{#if @model.badge.grant_count}}
|
||||||
{{html-safe
|
{{html-safe
|
||||||
(i18n "admin.badges.preview.grant_count" count=@model.badge.count)
|
(i18n
|
||||||
|
"admin.badges.preview.grant_count" count=@model.badge.grant_count
|
||||||
|
)
|
||||||
}}
|
}}
|
||||||
{{else}}
|
{{else}}
|
||||||
{{html-safe (i18n "admin.badges.preview.no_grant_count")}}
|
{{html-safe (i18n "admin.badges.preview.no_grant_count")}}
|
||||||
@ -32,7 +34,7 @@
|
|||||||
</div>
|
</div>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
{{#if this.sample}}
|
{{#if @model.badge.sample}}
|
||||||
<p class="sample">
|
<p class="sample">
|
||||||
{{i18n "admin.badges.preview.sample"}}
|
{{i18n "admin.badges.preview.sample"}}
|
||||||
</p>
|
</p>
|
||||||
|
@ -33,7 +33,7 @@ export default class BadgePreview extends Component {
|
|||||||
this.args.model.badge.grant_count
|
this.args.model.badge.grant_count
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
return this.args.model.badge.sample.length !== 10;
|
return this.args.model.badge.sample?.length !== 10;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -175,11 +175,17 @@
|
|||||||
<a
|
<a
|
||||||
href
|
href
|
||||||
{{on "click" (fn this.showPreview this.buffered "false")}}
|
{{on "click" (fn this.showPreview this.buffered "false")}}
|
||||||
>{{i18n "admin.badges.preview.link_text"}}</a>
|
class="preview-badge"
|
||||||
|
>
|
||||||
|
{{i18n "admin.badges.preview.link_text"}}</a>
|
||||||
|
|
|
|
||||||
<a href {{on "click" (fn this.showPreview this.buffered "true")}}>{{i18n
|
<a
|
||||||
"admin.badges.preview.plan_text"
|
href
|
||||||
}}</a>
|
{{on "click" (fn this.showPreview this.buffered "true")}}
|
||||||
|
class="preview-badge-plan"
|
||||||
|
>
|
||||||
|
{{i18n "admin.badges.preview.plan_text"}}
|
||||||
|
</a>
|
||||||
{{#if this.preview_loading}}
|
{{#if this.preview_loading}}
|
||||||
{{i18n "loading"}}
|
{{i18n "loading"}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
@ -3,11 +3,20 @@ import {
|
|||||||
exists,
|
exists,
|
||||||
query,
|
query,
|
||||||
} from "discourse/tests/helpers/qunit-helpers";
|
} from "discourse/tests/helpers/qunit-helpers";
|
||||||
import { click, fillIn, settled, visit } from "@ember/test-helpers";
|
import { click, fillIn, visit } from "@ember/test-helpers";
|
||||||
import { test } from "qunit";
|
import { test } from "qunit";
|
||||||
|
|
||||||
acceptance("Admin - Badges - Show", function (needs) {
|
acceptance("Admin - Badges - Show", function (needs) {
|
||||||
needs.user();
|
needs.user();
|
||||||
|
needs.settings({
|
||||||
|
enable_badge_sql: true,
|
||||||
|
});
|
||||||
|
needs.pretender((server, helper) => {
|
||||||
|
server.post("/admin/badges/preview.json", () =>
|
||||||
|
helper.response(200, { grant_count: 3, sample: [] })
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
test("new badge page", async function (assert) {
|
test("new badge page", async function (assert) {
|
||||||
await visit("/admin/badges/new");
|
await visit("/admin/badges/new");
|
||||||
assert.ok(
|
assert.ok(
|
||||||
@ -38,11 +47,10 @@ acceptance("Admin - Badges - Show", function (needs) {
|
|||||||
"image uploader becomes visible after clicking the upload image radio button"
|
"image uploader becomes visible after clicking the upload image radio button"
|
||||||
);
|
);
|
||||||
|
|
||||||
// SQL fields
|
assert.true(
|
||||||
assert.false(exists("label[for=query]"), "sql input is hidden by default");
|
exists("label[for=query]"),
|
||||||
this.siteSettings.enable_badge_sql = true;
|
"sql input is visible when enabled"
|
||||||
await settled();
|
);
|
||||||
assert.true(exists("label[for=query]"), "sql input shows when enabled");
|
|
||||||
|
|
||||||
assert.false(
|
assert.false(
|
||||||
exists("input[name=auto_revoke]"),
|
exists("input[name=auto_revoke]"),
|
||||||
@ -112,4 +120,18 @@ acceptance("Admin - Badges - Show", function (needs) {
|
|||||||
assert.ok(!exists(".image-uploader"), "image uploader becomes hidden");
|
assert.ok(!exists(".image-uploader"), "image uploader becomes hidden");
|
||||||
assert.strictEqual(query(".icon-picker").textContent.trim(), "fa-rocket");
|
assert.strictEqual(query(".icon-picker").textContent.trim(), "fa-rocket");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("sql input is hidden by default", async function (assert) {
|
||||||
|
this.siteSettings.enable_badge_sql = false;
|
||||||
|
await visit("/admin/badges/new");
|
||||||
|
assert.dom("label[for=query]").doesNotExist();
|
||||||
|
});
|
||||||
|
|
||||||
|
test("Badge preview displays the grant count", async function (assert) {
|
||||||
|
await visit("/admin/badges/3");
|
||||||
|
await click("a.preview-badge");
|
||||||
|
assert
|
||||||
|
.dom(".badge-query-preview .grant-count")
|
||||||
|
.hasText("3 badges to be assigned.");
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@ -1727,6 +1727,7 @@ export default {
|
|||||||
icon: "fa-rocket",
|
icon: "fa-rocket",
|
||||||
image_url: "/images/avatar.png?3",
|
image_url: "/images/avatar.png?3",
|
||||||
multiple_grant: true,
|
multiple_grant: true,
|
||||||
|
query: "SELECT 1",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user