mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
DEV: Show active categories in form templates customize table (#20498)
This commit is contained in:
parent
666b4a7e6b
commit
bb0ef4c7b4
@ -1,5 +1,10 @@
|
|||||||
<tr class="admin-list-item">
|
<tr class="admin-list-item">
|
||||||
<td class="col first">{{@template.name}}</td>
|
<td class="col first">{{@template.name}}</td>
|
||||||
|
<td class="col categories">
|
||||||
|
{{#each this.activeCategories as |category|}}
|
||||||
|
{{category-link category}}
|
||||||
|
{{/each}}
|
||||||
|
</td>
|
||||||
<td class="col action">
|
<td class="col action">
|
||||||
<DButton
|
<DButton
|
||||||
@title="admin.form_templates.list_table.actions.view"
|
@title="admin.form_templates.list_table.actions.view"
|
||||||
|
@ -9,6 +9,13 @@ import I18n from "I18n";
|
|||||||
export default class FormTemplateRowItem extends Component {
|
export default class FormTemplateRowItem extends Component {
|
||||||
@service router;
|
@service router;
|
||||||
@service dialog;
|
@service dialog;
|
||||||
|
@service site;
|
||||||
|
|
||||||
|
get activeCategories() {
|
||||||
|
return this.site?.categories?.filter((c) =>
|
||||||
|
c["form_template_ids"].includes(this.args.template.id)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@action
|
@action
|
||||||
viewTemplate() {
|
viewTemplate() {
|
||||||
|
@ -7,6 +7,9 @@
|
|||||||
<th class="col heading">
|
<th class="col heading">
|
||||||
{{i18n "admin.form_templates.list_table.headings.name"}}
|
{{i18n "admin.form_templates.list_table.headings.name"}}
|
||||||
</th>
|
</th>
|
||||||
|
<th class="col heading">
|
||||||
|
{{i18n "admin.form_templates.list_table.headings.active_categories"}}
|
||||||
|
</th>
|
||||||
<th class="col heading sr-only">
|
<th class="col heading sr-only">
|
||||||
{{i18n "admin.form_templates.list_table.headings.actions"}}
|
{{i18n "admin.form_templates.list_table.headings.actions"}}
|
||||||
</th>
|
</th>
|
||||||
|
@ -5538,6 +5538,7 @@ en:
|
|||||||
list_table:
|
list_table:
|
||||||
headings:
|
headings:
|
||||||
name: "Name"
|
name: "Name"
|
||||||
|
active_categories: "Active Categories"
|
||||||
actions: "Actions"
|
actions: "Actions"
|
||||||
actions:
|
actions:
|
||||||
view: "View Template"
|
view: "View Template"
|
||||||
|
@ -5,6 +5,9 @@ describe "Admin Customize Form Templates", type: :system, js: true do
|
|||||||
let(:ace_editor) { PageObjects::Components::AceEditor.new }
|
let(:ace_editor) { PageObjects::Components::AceEditor.new }
|
||||||
fab!(:admin) { Fabricate(:admin) }
|
fab!(:admin) { Fabricate(:admin) }
|
||||||
fab!(:form_template) { Fabricate(:form_template) }
|
fab!(:form_template) { Fabricate(:form_template) }
|
||||||
|
fab!(:category) do
|
||||||
|
Fabricate(:category, name: "Cool Category", slug: "cool-cat", topic_count: 3234)
|
||||||
|
end
|
||||||
|
|
||||||
before do
|
before do
|
||||||
SiteSetting.experimental_form_templates = true
|
SiteSetting.experimental_form_templates = true
|
||||||
@ -12,12 +15,20 @@ describe "Admin Customize Form Templates", type: :system, js: true do
|
|||||||
end
|
end
|
||||||
|
|
||||||
describe "when visiting the page to customize form templates" do
|
describe "when visiting the page to customize form templates" do
|
||||||
|
before { category.update(form_template_ids: [form_template.id]) }
|
||||||
|
|
||||||
it "should show the existing form templates in a table" do
|
it "should show the existing form templates in a table" do
|
||||||
visit("/admin/customize/form-templates")
|
visit("/admin/customize/form-templates")
|
||||||
expect(form_template_page).to have_form_template_table
|
expect(form_template_page).to have_form_template_table
|
||||||
expect(form_template_page).to have_form_template(form_template.name)
|
expect(form_template_page).to have_form_template(form_template.name)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "should show the categories the form template is used in" do
|
||||||
|
visit("/admin/customize/form-templates")
|
||||||
|
expect(form_template_page).to have_form_template_table
|
||||||
|
expect(form_template_page).to have_category_in_template_row(category.name)
|
||||||
|
end
|
||||||
|
|
||||||
it "should show the form template structure in a modal" do
|
it "should show the form template structure in a modal" do
|
||||||
visit("/admin/customize/form-templates")
|
visit("/admin/customize/form-templates")
|
||||||
form_template_page.click_view_form_template
|
form_template_page.click_view_form_template
|
||||||
|
@ -21,6 +21,10 @@ module PageObjects
|
|||||||
find(".form-templates__table tbody tr td", text: name).present?
|
find(".form-templates__table tbody tr td", text: name).present?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def has_category_in_template_row?(category_name)
|
||||||
|
find(".form-templates__table .categories .category-name", text: category_name).present?
|
||||||
|
end
|
||||||
|
|
||||||
def has_template_structure?(structure)
|
def has_template_structure?(structure)
|
||||||
find("code", text: structure).present?
|
find("code", text: structure).present?
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user