mirror of
https://github.com/discourse/discourse.git
synced 2025-05-25 00:32:52 +08:00
FIX: Detect installed themes using URLs instead of names (#12201)
Context: https://meta.discourse.org/t/not-all-installed-theme-components-listed-as-installed/179756?u=osama
This commit is contained in:
@ -15,8 +15,8 @@ export default Controller.extend({
|
|||||||
return themes.filter((t) => t.get("component"));
|
return themes.filter((t) => t.get("component"));
|
||||||
},
|
},
|
||||||
|
|
||||||
@discourseComputed("model", "model.@each.component")
|
@discourseComputed("model.content")
|
||||||
installedThemes(themes) {
|
installedThemes(content) {
|
||||||
return themes.map((t) => t.name);
|
return content || [];
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
@ -44,7 +44,9 @@ export default Controller.extend(ModalFunctionality, {
|
|||||||
@discourseComputed("themesController.installedThemes")
|
@discourseComputed("themesController.installedThemes")
|
||||||
themes(installedThemes) {
|
themes(installedThemes) {
|
||||||
return POPULAR_THEMES.map((t) => {
|
return POPULAR_THEMES.map((t) => {
|
||||||
if (installedThemes.includes(t.name)) {
|
if (
|
||||||
|
installedThemes.some((theme) => this.themeHasSameUrl(theme, t.value))
|
||||||
|
) {
|
||||||
set(t, "installed", true);
|
set(t, "installed", true);
|
||||||
}
|
}
|
||||||
return t;
|
return t;
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import { acceptance, query } from "discourse/tests/helpers/qunit-helpers";
|
import { acceptance, query } from "discourse/tests/helpers/qunit-helpers";
|
||||||
import { click, fillIn, visit } from "@ember/test-helpers";
|
import { click, fillIn, visit } from "@ember/test-helpers";
|
||||||
import { test } from "qunit";
|
import { test } from "qunit";
|
||||||
|
import I18n from "I18n";
|
||||||
|
|
||||||
acceptance("Admin - Themes - Install modal", function (needs) {
|
acceptance("Admin - Themes - Install modal", function (needs) {
|
||||||
needs.user();
|
needs.user();
|
||||||
@ -50,4 +51,29 @@ acceptance("Admin - Themes - Install modal", function (needs) {
|
|||||||
"repo url is visible"
|
"repo url is visible"
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("installed themes are matched with the popular list by URL", async function (assert) {
|
||||||
|
await visit("/admin/customize/themes");
|
||||||
|
await click(".create-actions .btn-primary");
|
||||||
|
|
||||||
|
assert.notOk(
|
||||||
|
query(
|
||||||
|
'.popular-theme-item[data-name="Graceful"] .popular-theme-buttons button'
|
||||||
|
),
|
||||||
|
"no install button is shown for installed themes"
|
||||||
|
);
|
||||||
|
assert.equal(
|
||||||
|
query(
|
||||||
|
'.popular-theme-item[data-name="Graceful"] .popular-theme-buttons'
|
||||||
|
).textContent.trim(),
|
||||||
|
I18n.t("admin.customize.theme.installed")
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.ok(
|
||||||
|
query(
|
||||||
|
'.popular-theme-item[data-name="Minima"] .popular-theme-buttons button'
|
||||||
|
),
|
||||||
|
"install button is shown for not installed themes"
|
||||||
|
);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@ -690,7 +690,18 @@ export function applyDefaultHandlers(pretender) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
pretender.get("/admin/themes", () => {
|
pretender.get("/admin/themes", () => {
|
||||||
return response(200, { themes: [], extras: {} });
|
return response(200, {
|
||||||
|
themes: [
|
||||||
|
{
|
||||||
|
id: 1,
|
||||||
|
name: "Graceful Renamed",
|
||||||
|
remote_theme: {
|
||||||
|
remote_url: "https://github.com/discourse/graceful.git",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
extras: {},
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
pretender.post("/admin/themes/generate_key_pair", () => {
|
pretender.post("/admin/themes/generate_key_pair", () => {
|
||||||
|
Reference in New Issue
Block a user