discourse/app/assets/javascripts/admin/addon/components/admin-config-areas/look-and-feel-themes.gjs
Martin Brennan a879bcdc35
DEV: Introduce <DPageHeader /> and <DPageSubheader /> components (#30146)
This converts the `<AdminPageHeader />` component and the
`<AdminPageSubheader />` components into new components
that can be used outside of admin, and updates the CSS classes.
Also introduces a `<DPageActionButton />` component and child
components for the header action buttons.

I have to keep the old admin-only components around for
now until plugins are updated, then we can remove it,
and remove the re-exports that are done within
admin-page-action-button.gjs
2024-12-18 08:13:39 +10:00

70 lines
1.9 KiB
Plaintext

import Component from "@glimmer/component";
import { action } from "@ember/object";
import { service } from "@ember/service";
import DPageSubheader from "discourse/components/d-page-subheader";
import { i18n } from "discourse-i18n";
import InstallThemeModal from "admin/components/modal/install-theme";
import ThemesGrid from "admin/components/themes-grid";
export default class AdminConfigAreasLookAndFeelThemes extends Component {
@service modal;
@service router;
@service toasts;
@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: "theme",
userId: null,
content: [],
installedThemes: this.args.themes,
addTheme: this.addTheme,
updateSelectedType: () => {},
};
}
@action
addTheme(theme) {
this.toasts.success({
data: {
message: i18n("admin.customize.theme.install_success", {
theme: theme.name,
}),
},
duration: 2000,
});
this.router.refresh();
}
<template>
<DPageSubheader
@titleLabel={{i18n "admin.config_areas.look_and_feel.themes.title"}}
@descriptionLabel={{i18n "admin.customize.theme.themes_intro_new"}}
@learnMoreUrl="https://meta.discourse.org/t/93648"
>
<:actions as |actions|>
<actions.Primary
@action={{this.installModal}}
@label="admin.customize.install"
@icon="upload"
class="admin-look-and-feel__install-theme"
/>
</:actions>
</DPageSubheader>
<div class="admin-detail">
<ThemesGrid @themes={{@themes}} />
</div>
</template>
}