discourse/app/assets/javascripts/admin/addon/components/admin-config-areas/themes.gjs
Martin Brennan 62f6ee0b1f
Some checks failed
Licenses / run (push) Has been cancelled
Linting / run (push) Has been cancelled
Migration Tests / Tests (push) Has been cancelled
Publish Assets / publish-assets (push) Has been cancelled
Tests / core backend (push) Has been cancelled
Tests / plugins backend (push) Has been cancelled
Tests / core frontend (Chrome) (push) Has been cancelled
Tests / plugins frontend (push) Has been cancelled
Tests / themes frontend (push) Has been cancelled
Tests / core system (push) Has been cancelled
Tests / plugins system (push) Has been cancelled
Tests / themes system (push) Has been cancelled
Tests / core frontend (Firefox ESR) (push) Has been cancelled
Tests / core frontend (Firefox Evergreen) (push) Has been cancelled
Tests / chat system (push) Has been cancelled
Tests / merge (push) Has been cancelled
FEATURE: Move theme site settings config page to a tab in the customize page (#34376)
This commit moves the /admin/config/theme-site-settings page to a tab in
the "Themes and components" config page. This will make it easier to
find
for admins.

Also add a `AdminFilterControls` component to the page to filter by
setting name, description, or theme name.
2025-08-20 12:03:47 +10:00

112 lines
3.1 KiB
Text
Vendored

import Component from "@glimmer/component";
import { action } from "@ember/object";
import { next } from "@ember/runloop";
import { service } from "@ember/service";
import { isPresent } from "@ember/utils";
import DPageSubheader from "discourse/components/d-page-subheader";
import PluginOutlet from "discourse/components/plugin-outlet";
import lazyHash from "discourse/helpers/lazy-hash";
import getURL from "discourse/lib/get-url";
import { i18n } from "discourse-i18n";
import InstallThemeModal from "admin/components/modal/install-theme";
import ThemesGrid from "admin/components/themes-grid";
import { THEMES } from "admin/models/theme";
export default class AdminConfigAreasThemes extends Component {
@service modal;
@service router;
@service toasts;
constructor() {
super(...arguments);
if (isPresent(this.args.repoName) && isPresent(this.args.repoUrl)) {
next(() => {
this.modal.show(InstallThemeModal, {
model: {
uploadUrl: this.args.repoUrl,
uploadName: this.args.repoName,
selection: "directRepoInstall",
clearParams: this.clearParams,
...this.installThemeOptions(),
},
});
});
}
}
@action
installModal() {
this.modal.show(InstallThemeModal, {
model: { ...this.installThemeOptions() },
});
}
// TODO (martin) These install methods may not belong here and they
// are incomplete or have stubbed or omitted properties. We may want
// to move this to the new config route or a dedicated component
// that sits in the route.
installThemeOptions() {
return {
selectedType: THEMES,
userId: null,
content: this.args.themes,
installedThemes: this.args.themes,
addTheme: this.addTheme,
updateSelectedType: () => {},
showThemesOnly: true,
};
}
@action
addTheme(theme) {
this.toasts.success({
data: {
message: i18n("admin.customize.theme.install_success", {
theme: theme.name,
}),
},
duration: "short",
});
this.router.transitionTo(
"adminCustomizeThemes.show.index",
"themes",
theme.id
);
}
@action
clearParams() {
this.router.transitionTo(this.router.currentRouteName, {
queryParams: { repoUrl: null, repoName: null },
});
}
<template>
<DPageSubheader
@titleLabel={{i18n
"admin.config_areas.themes_and_components.themes.title"
}}
@descriptionLabel={{i18n
"admin.config_areas.themes_and_components.themes.description"
themeSiteSettingsUrl=(getURL
"/admin/config/customize/theme-site-settings"
)
}}
>
<:actions as |actions|>
<PluginOutlet
@name="admin-config-area-themes-new-button"
@outletArgs={{lazyHash actions=actions}}
>
<actions.Primary
@label="admin.config_areas.themes_and_components.themes.install"
@action={{this.installModal}}
/>
</PluginOutlet>
</:actions>
</DPageSubheader>
<ThemesGrid @themes={{@themes}} />
</template>
}