mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-05-24 21:51:41 +08:00
Previously, the only way to author js/hbs via the admin panel was to use `<script>` tags. This strategy is not pretty, and doesn't provide access to proper ES module imports or gjs `<template>` syntax. Our recommendation for most themes is still that they should be authored using a proper IDE, the `discourse_theme` CLI, and version-controlled using git. However, we understand that this isn't a good fit for everyone, and that there's still a place for simple admin-panel-ui-authored themes. This commit introduces a "JS" tab in the admin theme editor, which corresponds to a file named `discourse/api-initializers/theme-initializer.gjs` in the theme. This means that everyone will be able to move towards the more modern syntaxes, and away from the old `<script>` patterns.
60 lines
No EOL
1.6 KiB
Handlebars
Vendored
60 lines
No EOL
1.6 KiB
Handlebars
Vendored
<div class="current-style {{if this.maximized 'maximized'}}">
|
|
<div class="wrapper">
|
|
<div class="editor-information">
|
|
<DButton
|
|
@title="go_back"
|
|
@action={{this.goBack}}
|
|
@icon="chevron-left"
|
|
class="btn-small editor-back-button"
|
|
/>
|
|
|
|
<span class="editor-theme-name-wrapper">
|
|
{{i18n "admin.customize.theme.edit_css_html"}}
|
|
<LinkTo
|
|
@route={{this.showRouteName}}
|
|
@model={{this.model.id}}
|
|
@replace={{true}}
|
|
class="editor-theme-name"
|
|
>
|
|
{{this.model.name}}
|
|
</LinkTo>
|
|
</span>
|
|
</div>
|
|
|
|
<AdminThemeEditor
|
|
@theme={{this.model}}
|
|
@editRouteName={{this.editRouteName}}
|
|
@currentTargetName={{this.currentTargetName}}
|
|
@fieldName={{this.fieldName}}
|
|
@fieldAdded={{action "fieldAdded"}}
|
|
@maximized={{this.maximized}}
|
|
@onlyOverriddenChanged={{action "onlyOverriddenChanged"}}
|
|
@save={{action "save"}}
|
|
/>
|
|
|
|
<div class="admin-footer">
|
|
<div class="status-actions">
|
|
{{#unless this.model.changed}}
|
|
<a
|
|
href={{this.previewUrl}}
|
|
rel="noopener noreferrer"
|
|
title={{i18n "admin.customize.explain_preview"}}
|
|
class="preview-link"
|
|
target="_blank"
|
|
>
|
|
{{i18n "admin.customize.preview"}}
|
|
</a>
|
|
{{/unless}}
|
|
</div>
|
|
|
|
<div class="buttons">
|
|
<DButton
|
|
@action={{this.save}}
|
|
@disabled={{this.saveDisabled}}
|
|
@translatedLabel={{this.saveButtonText}}
|
|
class="btn-primary save-theme"
|
|
/>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div> |