FIX: hidden improvements

This commit is contained in:
Krzysztof Kotlarek 2024-12-20 12:25:25 +11:00
parent 138a230850
commit 7134beeb4c
5 changed files with 38 additions and 24 deletions

View File

@ -6,7 +6,7 @@ import icon from "discourse-common/helpers/d-icon";
import { i18n } from "discourse-i18n"; import { i18n } from "discourse-i18n";
export default class AdminConfigAreaCard extends Component { export default class AdminConfigAreaCard extends Component {
@tracked collapsed = false; @tracked collapsed = this.args.collapsed;
get computedHeading() { get computedHeading() {
if (this.args.heading) { if (this.args.heading) {

View File

@ -10,11 +10,6 @@ export default class AdminEmbeddingIndexController extends Controller {
@controller adminEmbedding; @controller adminEmbedding;
@alias("adminEmbedding.embedding") embedding; @alias("adminEmbedding.embedding") embedding;
get showEmbeddingCode() {
const hosts = this.get("embedding.embeddable_hosts");
return hosts.length > 0 && !this.site.isMobileDevice;
}
@discourseComputed("embedding.base_url") @discourseComputed("embedding.base_url")
embeddingCode(baseUrl) { embeddingCode(baseUrl) {
const html = `<div id='discourse-comments'></div> const html = `<div id='discourse-comments'></div>

View File

@ -1,4 +1,18 @@
{{#if this.embedding.embeddable_hosts}} {{#if this.embedding.embeddable_hosts}}
<AdminConfigAreaCard
@heading="admin.embedding.configuration_snippet"
@collapsable={{true}}
@collapsed={{true}}
>
<:content>
<div class="admin-embedding-index__code">
{{html-safe (i18n "admin.embedding.sample")}}
<HighlightedCode @code={{this.embeddingCode}} @lang="html" />
</div>
</:content>
</AdminConfigAreaCard>
<table class="d-admin-table"> <table class="d-admin-table">
<thead> <thead>
<th>{{i18n "admin.embedding.host"}}</th> <th>{{i18n "admin.embedding.host"}}</th>
@ -7,7 +21,7 @@
<th>{{i18n "admin.embedding.tags"}}</th> <th>{{i18n "admin.embedding.tags"}}</th>
{{#if this.embedding.embed_by_username}} {{#if this.embedding.embed_by_username}}
<th>{{i18n <th>{{i18n
"admin.embedding.post_author" "admin.embedding.post_author_with_default"
author=this.embedding.embed_by_username author=this.embedding.embed_by_username
}}</th> }}</th>
{{else}} {{else}}
@ -33,13 +47,3 @@
@name="after-embeddable-hosts-table" @name="after-embeddable-hosts-table"
@outletArgs={{hash embedding=this.embedding}} @outletArgs={{hash embedding=this.embedding}}
/> />
{{#if this.showEmbeddingCode}}
<div class="admin-embedding-index__code">
<details>
<summary>{{i18n "admin.embedding.configuration_snippet"}}</summary>
{{html-safe (i18n "admin.embedding.sample")}}
<HighlightedCode @code={{this.embeddingCode}} @lang="html" />
</details>
</div>
{{/if}}

View File

@ -36,6 +36,20 @@ module("Integration | Component | AdminConfigAreaCard", function (hooks) {
assert.dom(".admin-config-area-card__content").exists(); assert.dom(".admin-config-area-card__content").exists();
}); });
test("renders admin config area card with toggle button and collapsed by default", async function (assert) {
await render(<template>
<AdminConfigAreaCard
@translatedHeading="test heading"
@collapsable={{true}}
@collapsed={{true}}
><:content>test</:content></AdminConfigAreaCard>
</template>);
assert.dom(".admin-config-area-card__title").exists();
assert.dom(".admin-config-area-card__toggle-button").exists();
assert.dom(".admin-config-area-card__content").doesNotExist();
});
test("renders admin config area card with header action", async function (assert) { test("renders admin config area card with header action", async function (assert) {
await render(<template> await render(<template>
<AdminConfigAreaCard <AdminConfigAreaCard

View File

@ -7312,13 +7312,14 @@ en:
<p>Replace <b>DISCOURSE_USERNAME</b> with the Discourse username of the author that should create the topic. Discourse will automatically lookup the user by the <code>content</code> attribute of the <code>&lt;meta&gt;</code> tags with <code>name</code> attribute set to <code>discourse-username</code> or <code>author</code>. The <code>discourseUserName</code> parameter has been deprecated and will be removed in Discourse 3.2.</p> <p>Replace <b>DISCOURSE_USERNAME</b> with the Discourse username of the author that should create the topic. Discourse will automatically lookup the user by the <code>content</code> attribute of the <code>&lt;meta&gt;</code> tags with <code>name</code> attribute set to <code>discourse-username</code> or <code>author</code>. The <code>discourseUserName</code> parameter has been deprecated and will be removed in Discourse 3.2.</p>
title: "Embedding" title: "Embedding"
description: "Discourse has the ability to embed the comments from a topic in a remote site using a Javascript API that creates an IFRAME" description: "Discourse has the ability to embed the comments from a topic in a remote site using a Javascript API that creates an IFRAME"
host: "Allowed Hosts" host: "Allowed hosts"
allowed_paths: "Path Allowlist" allowed_paths: "Path allowlist"
edit: "Edit" edit: "Edit"
category: "Post to Category" category: "Post to category"
tags: "Topic Tags" tags: "Topic tags"
post_author: "Post Author - Defaults to %{author}" post_author: "Post author"
add_host: "Add Host" post_author_with_default: "Post author (defaults to %{author})"
add_host: "Add host"
posts_and_topics: "Posts and Topics configuration" posts_and_topics: "Posts and Topics configuration"
crawlers: "Crawlers configuration" crawlers: "Crawlers configuration"
crawlers_description: "When Discourse creates topics for your posts, if no RSS/ATOM feed is present it will attempt to parse your content out of your HTML. Sometimes it can be challenging to extract your content, so we provide the ability to specify CSS rules to make extraction easier." crawlers_description: "When Discourse creates topics for your posts, if no RSS/ATOM feed is present it will attempt to parse your content out of your HTML. Sometimes it can be challenging to extract your content, so we provide the ability to specify CSS rules to make extraction easier."