diff --git a/app/assets/javascripts/admin/addon/components/admin-embedding-host-form.gjs b/app/assets/javascripts/admin/addon/components/admin-embedding-host-form.gjs index 836f99ed624..06cf3dc9c95 100644 --- a/app/assets/javascripts/admin/addon/components/admin-embedding-host-form.gjs +++ b/app/assets/javascripts/admin/addon/components/admin-embedding-host-form.gjs @@ -24,21 +24,23 @@ export default class AdminEmbeddingHostForm extends Component { } get header() { - return this.isUpdate + return this.isEditing ? "admin.embedding.host_form.edit_header" : "admin.embedding.host_form.add_header"; } get formData() { - if (!this.editing) { return {} } - + if (!this.isEditing) { + return {}; + } + return { - host: this.args.host.host, - allowed_paths: this.args.host.allowed_paths, - category: this.args.host.category_id, - tags: this.args.host.tags, - user: isEmpty(this.args.host.user) ? null : [this.args.host.user], - }; + host: this.args.host.host, + allowed_paths: this.args.host.allowed_paths, + category: this.args.host.category_id, + tags: this.args.host.tags, + user: isEmpty(this.args.host.user) ? null : [this.args.host.user], + }; } @action @@ -51,7 +53,7 @@ export default class AdminEmbeddingHostForm extends Component { user: data.user?.at(0), category_id: data.category, }); - if (!this.isUpdate) { + if (!this.isEditing) { this.adminEmbedding.embedding.embeddable_hosts.push(host); } this.router.transitionTo("adminEmbedding"); diff --git a/app/assets/javascripts/admin/addon/components/embeddable-host.gjs b/app/assets/javascripts/admin/addon/components/embeddable-host.gjs new file mode 100644 index 00000000000..c120060607f --- /dev/null +++ b/app/assets/javascripts/admin/addon/components/embeddable-host.gjs @@ -0,0 +1,76 @@ +import Component from "@glimmer/component"; +import { tracked } from "@glimmer/tracking"; +import { action } from "@ember/object"; +import { service } from "@ember/service"; +import DButton from "discourse/components/d-button"; +import categoryBadge from "discourse/helpers/category-badge"; +import Category from "discourse/models/category"; +import { i18n } from "discourse-i18n"; + +export default class EmbeddableHost extends Component { + @service dialog; + @tracked category = null; + @tracked tags = null; + @tracked user = null; + + constructor() { + super(...arguments); + + this.host = this.args.host; + const categoryId = + this.host.category_id || this.site.uncategorized_category_id; + const category = Category.findById(categoryId); + + this.category = category; + this.tags = (this.host.tags || []).join(", "); + this.user = this.host.user; + } + + @action + delete() { + return this.dialog.confirm({ + message: i18n("admin.embedding.confirm_delete"), + didConfirm: () => { + return this.host.destroyRecord().then(() => { + this.args.deleteHost(this.host); + }); + }, + }); + } + + +} diff --git a/app/assets/javascripts/admin/addon/components/embeddable-host.hbs b/app/assets/javascripts/admin/addon/components/embeddable-host.hbs deleted file mode 100644 index b8a5a87322d..00000000000 --- a/app/assets/javascripts/admin/addon/components/embeddable-host.hbs +++ /dev/null @@ -1,45 +0,0 @@ - - {{this.host.host}} - - - {{this.host.allowed_paths}} - - - {{category-badge this.category allowUncategorized=true}} - - - {{this.tags}} - - - {{this.user}} - - - -
- - - - <:content> - - - - - - - -
- \ No newline at end of file diff --git a/app/assets/javascripts/admin/addon/components/embeddable-host.js b/app/assets/javascripts/admin/addon/components/embeddable-host.js deleted file mode 100644 index 7c5d9ec12f1..00000000000 --- a/app/assets/javascripts/admin/addon/components/embeddable-host.js +++ /dev/null @@ -1,39 +0,0 @@ -import Component from "@ember/component"; -import { action } from "@ember/object"; -import { service } from "@ember/service"; -import { classNames, tagName } from "@ember-decorators/component"; -import Category from "discourse/models/category"; -import { i18n } from "discourse-i18n"; - -@tagName("tr") -@classNames("d-admin-row__content") -export default class EmbeddableHost extends Component { - @service dialog; - category = null; - tags = null; - user = null; - - init() { - super.init(...arguments); - - const host = this.host; - const categoryId = host.category_id || this.site.uncategorized_category_id; - const category = Category.findById(categoryId); - - this.set("category", category); - this.set("tags", (host.tags || []).join(", ")); - this.set("user", host.user); - } - - @action - delete() { - return this.dialog.confirm({ - message: i18n("admin.embedding.confirm_delete"), - didConfirm: () => { - return this.host.destroyRecord().then(() => { - this.deleteHost(this.host); - }); - }, - }); - } -} diff --git a/app/assets/javascripts/admin/addon/routes/admin-embedding-edit.js b/app/assets/javascripts/admin/addon/routes/admin-embedding-edit.js index 0d1f2d364cd..b8dbb630983 100644 --- a/app/assets/javascripts/admin/addon/routes/admin-embedding-edit.js +++ b/app/assets/javascripts/admin/addon/routes/admin-embedding-edit.js @@ -4,7 +4,9 @@ import { i18n } from "discourse-i18n"; export default class AdminEmbeddingEditRoute extends DiscourseRoute { async model(params) { const embedding = await this.store.find("embedding"); - return embedding.embeddable_hosts.find((host) => host.id === parseInt(params.id, 10)); + return embedding.embeddable_hosts.find( + (host) => host.id === parseInt(params.id, 10) + ); } titleToken() { diff --git a/app/assets/stylesheets/common/admin/customize.scss b/app/assets/stylesheets/common/admin/customize.scss index fa15d8c5e84..dc0bdbaf706 100644 --- a/app/assets/stylesheets/common/admin/customize.scss +++ b/app/assets/stylesheets/common/admin/customize.scss @@ -903,9 +903,13 @@ } .admin-embeddable-host-item__delete { - color: var(--danger); + &:hover { + svg.d-icon { + color: var(--primary-medium); + } + } svg.d-icon { - color: var(--danger); + color: var(--primary-low-mid); } } } diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index dd2356d7f6a..949df80d1bc 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -7314,7 +7314,7 @@ en: 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" allowed_paths: "Path Allowlist" - edit: "edit" + edit: "Edit" category: "Post to Category" tags: "Topic Tags" post_author: "Post Author - Defaults to %{author}" @@ -7335,7 +7335,6 @@ en: posts_and_topics_settings_saved: "Posts and Topics settings saved" crawler_settings_saved: "Crawler settings saved." back: "Back to Embedding" - more_options: "More options" configuration_snippet: "Configuration snippet" host_form: add_header: "Add host" diff --git a/config/site_settings.yml b/config/site_settings.yml index 23bc92f7c97..d4fdf87c49f 100644 --- a/config/site_settings.yml +++ b/config/site_settings.yml @@ -1217,7 +1217,7 @@ posting: area: "embedding" allowed_embed_selectors: default: "" - hidden: true + area: "embedding" allowed_href_schemes: client: true default: "" diff --git a/spec/system/admin_embeddable_hosts_spec.rb b/spec/system/admin_embeddable_hosts_spec.rb index 63859cd6f0a..c0bdda9bab6 100644 --- a/spec/system/admin_embeddable_hosts_spec.rb +++ b/spec/system/admin_embeddable_hosts_spec.rb @@ -54,7 +54,6 @@ RSpec.describe "Admin EmbeddableHost Management", type: :system do expect(page).to have_content("#{category_2.name}") expect(page).to have_content("#{author_2.username}") - admin_embedding_page.open_embedding_host_menu admin_embedding_page.click_delete admin_embedding_page.confirm_delete diff --git a/spec/system/page_objects/pages/admin_embedding.rb b/spec/system/page_objects/pages/admin_embedding.rb index b6e94f0376c..50b358034c7 100644 --- a/spec/system/page_objects/pages/admin_embedding.rb +++ b/spec/system/page_objects/pages/admin_embedding.rb @@ -26,11 +26,6 @@ module PageObjects self end - def open_embedding_host_menu - find(".embedding-host-menu-trigger").click - self - end - def click_delete find(".admin-embeddable-host-item__delete").click self