discourse/app/assets/javascripts/admin/addon/components/themes-grid.gjs
Osama Sayegh f87e5aab0b
UX: Tweaks to the theme/component pages when using admin sidebar (#30953)
There are a number of minor changes in this commit :

1. Combine the "Themes" and "Components" links in the admin sidebar into
a single tab labelled "Themes and components"
2. The combined tab links to the `/admin/config/customize/themes` page
(titled as "Themes and components")
3. Add a new "Components" tab to the "Themes and components" page.
There's already an existing "Themes" tab
4. Add a "back to" link at the top of individual theme/component page to
navigate back to the respective tab in the "Themes and components" page
5. Remove the themes/components list/sidebar that currently serves for
navigating between themes/components
6. Remove the header in the theme/component page

Changes 4–6 apply only if the admin sidebar is enabled; they have no
effect otherwise.

Internal topic: t/146006.
2025-03-13 15:34:17 +03:00

44 lines
1.5 KiB
Text

import Component from "@glimmer/component";
import { service } from "@ember/service";
import ThemesGridCard from "./themes-grid-card";
// NOTE (martin): Much of the JS code in this component is placeholder code. Much
// of the existing theme logic in /admin/customize/themes has old patterns
// and technical debt, so anything copied from there to here is subject
// to change as we improve this incrementally.
export default class ThemesGrid extends Component {
@service modal;
@service router;
sortedThemes;
constructor() {
super(...arguments);
// Show default theme at the top of the list on page load,
// but don't move it around dynamically if the admin changes the default.
//
// TODO (martin) Figure out how to make it so we can sort default to the
// top but also allow the list of themes to change if an additional theme is
// installed. Basically don't want .get("default") to affect the sort after
// the first time, but if the whole array changes this needs to be recalculated.
this.sortedThemes = this.args.themes.sort((a, b) => {
if (a.get("default")) {
return -1;
} else if (b.get("default")) {
return 1;
}
});
}
<template>
<div class="themes-cards-container">
{{#each @themes as |theme|}}
<ThemesGridCard @theme={{theme}} @allThemes={{@themes}} />
{{/each}}
{{#if (has-block "specialCard")}}
{{yield to="specialCard"}}
{{/if}}
</div>
</template>
}