DEV: Migrate about config area to Form Kit (#28021)

Form Kit is our new form library/framework for unifying the way forms look across Discourse. The admin config area for the /about page is a new form that isn't currently used, so it makes sense for it to be one of the first forms to be migrated to Form Kit to test the library.

Co-authored-by: Joffrey JAFFEUX <j.jaffeux@gmail.com>
This commit is contained in:
Osama Sayegh 2024-07-25 19:07:38 +03:00 committed by GitHub
parent 45f6bc0093
commit 7cc0f26292
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
15 changed files with 360 additions and 267 deletions

View File

@ -1,11 +1,9 @@
import Component from "@glimmer/component";
import { tracked } from "@glimmer/tracking";
import { fn, hash } from "@ember/helper";
import { on } from "@ember/modifier";
import { cached, tracked } from "@glimmer/tracking";
import { hash } from "@ember/helper";
import { action } from "@ember/object";
import { service } from "@ember/service";
import DButton from "discourse/components/d-button";
import withEventValue from "discourse/helpers/with-event-value";
import Form from "discourse/components/form";
import { ajax } from "discourse/lib/ajax";
import { popupAjaxError } from "discourse/lib/ajax-error";
import i18n from "discourse-common/helpers/i18n";
@ -17,42 +15,50 @@ export default class AdminConfigAreasAboutContactInformation extends Component {
@service site;
@service toasts;
@tracked
contactUsername = this.args.contactInformation.contactUsername.value || null;
@tracked
contactGroupId = this.site.groups.find(
(group) => group.name === this.contactGroupName
(group) => group.name === this.data.contactGroupName
)?.id;
communityOwner = this.args.contactInformation.communityOwner.value;
contactEmail = this.args.contactInformation.contactEmail.value;
contactURL = this.args.contactInformation.contactURL.value;
contactGroupName = this.args.contactInformation.contactGroupName.value;
@action
onContactUsernameChange(usernames) {
this.contactUsername = usernames[0];
@cached
get data() {
return {
communityOwner: this.args.contactInformation.communityOwner.value,
contactEmail: this.args.contactInformation.contactEmail.value,
contactURL: this.args.contactInformation.contactURL.value,
contactGroupName: this.args.contactInformation.contactGroupName.value,
contactUsername:
this.args.contactInformation.contactUsername.value || null,
};
}
@action
onContactGroupIdChange(ids, groups) {
this.contactGroupId = ids[0];
this.contactGroupName = groups[0]?.name;
setContactUsername(usernames, { set }) {
set("contactUsername", usernames[0] || null);
}
@action
async save() {
setContactGroup(groupIds, { set }) {
this.contactGroupId = groupIds[0];
set(
"contactGroupName",
this.site.groups.find((group) => group.id === groupIds[0])?.name
);
}
@action
async save(data) {
try {
this.args.setGlobalSavingStatus(true);
await ajax("/admin/config/about.json", {
type: "PUT",
data: {
contact_information: {
community_owner: this.communityOwner,
contact_email: this.contactEmail,
contact_url: this.contactURL,
contact_username: this.contactUsername,
contact_group_name: this.contactGroupName,
community_owner: data.communityOwner,
contact_email: data.contactEmail,
contact_url: data.contactURL,
contact_username: data.contactUsername,
contact_group_name: data.contactGroupName,
},
},
});
@ -72,92 +78,90 @@ export default class AdminConfigAreasAboutContactInformation extends Component {
}
<template>
<div class="control-group community-owner-input">
<label>
<span>{{i18n "admin.config_areas.about.community_owner"}}</span>
<span class="admin-config-area-card__label-optional">{{i18n
"admin.config_areas.about.optional"
}}</span>
</label>
<p class="admin-config-area-card__additional-help">
{{i18n "admin.config_areas.about.community_owner_help"}}
</p>
<input
{{on "input" (withEventValue (fn (mut this.communityOwner)))}}
type="text"
value={{this.communityOwner}}
<Form @data={{this.data}} @onSubmit={{this.save}} as |form|>
<form.Field
@name="communityOwner"
@title={{i18n "admin.config_areas.about.community_owner"}}
@subtitle={{i18n "admin.config_areas.about.community_owner_help"}}
@format="large"
as |field|
>
<field.Input
placeholder={{i18n
"admin.config_areas.about.community_owner_placeholder"
}}
/>
</form.Field>
<form.Field
@name="contactEmail"
@title={{i18n "admin.config_areas.about.contact_email"}}
@subtitle={{i18n "admin.config_areas.about.contact_email_help"}}
@type="email"
@format="large"
as |field|
>
<field.Input
placeholder={{i18n
"admin.config_areas.about.contact_email_placeholder"
}}
/>
</form.Field>
<form.Field
@name="contactURL"
@title={{i18n "admin.config_areas.about.contact_url"}}
@subtitle={{i18n "admin.config_areas.about.contact_url_help"}}
@type="url"
@format="large"
as |field|
>
<field.Input
placeholder={{i18n
"admin.config_areas.about.contact_url_placeholder"
}}
/>
</form.Field>
<form.Field
@name="contactUsername"
@title={{i18n "admin.config_areas.about.site_contact_name"}}
@subtitle={{i18n "admin.config_areas.about.site_contact_group_help"}}
@onSet={{this.setContactUsername}}
@format="large"
as |field|
>
<field.Custom>
<UserChooser
@value={{field.value}}
@options={{hash maximum=1}}
@onChange={{field.set}}
/>
</field.Custom>
</form.Field>
<form.Field
@name="contactGroupName"
@title={{i18n "admin.config_areas.about.site_contact_group"}}
@subtitle={{i18n "admin.config_areas.about.site_contact_group_help"}}
@onSet={{this.setContactGroup}}
@format="large"
as |field|
>
<field.Custom>
<GroupChooser
@content={{this.site.groups}}
@value={{this.contactGroupId}}
@options={{hash maximum=1}}
@onChange={{field.set}}
/>
</field.Custom>
</form.Field>
<form.Submit
@label="admin.config_areas.about.update"
@disabled={{@globalSavingStatus}}
/>
</div>
<div class="control-group contact-email-input">
<label>
<span>{{i18n "admin.config_areas.about.contact_email"}}</span>
<span class="admin-config-area-card__label-optional">{{i18n
"admin.config_areas.about.optional"
}}</span>
</label>
<p class="admin-config-area-card__additional-help">
{{i18n "admin.config_areas.about.contact_email_help"}}
</p>
<input
{{on "input" (withEventValue (fn (mut this.contactEmail)))}}
type="text"
value={{this.contactEmail}}
/>
</div>
<div class="control-group contact-url-input">
<label>
<span>{{i18n "admin.config_areas.about.contact_url"}}</span>
<span class="admin-config-area-card__label-optional">{{i18n
"admin.config_areas.about.optional"
}}</span>
</label>
<p class="admin-config-area-card__additional-help">
{{i18n "admin.config_areas.about.contact_url_help"}}
</p>
<input
{{on "input" (withEventValue (fn (mut this.contactURL)))}}
type="text"
value={{this.contactURL}}
/>
</div>
<div class="control-group site-contact-username-input">
<label>
<span>{{i18n "admin.config_areas.about.site_contact_name"}}</span>
<span class="admin-config-area-card__label-optional">{{i18n
"admin.config_areas.about.optional"
}}</span>
</label>
<p class="admin-config-area-card__additional-help">
{{i18n "admin.config_areas.about.site_contact_name_help"}}
</p>
<UserChooser
@value={{this.contactUsername}}
@onChange={{this.onContactUsernameChange}}
@options={{hash maximum=1}}
/>
</div>
<div class="control-group site-contact-group-input">
<label>
<span>{{i18n "admin.config_areas.about.site_contact_group"}}</span>
<span class="admin-config-area-card__label-optional">{{i18n
"admin.config_areas.about.optional"
}}</span>
</label>
<p class="admin-config-area-card__additional-help">
{{i18n "admin.config_areas.about.site_contact_group_help"}}
</p>
<GroupChooser
@content={{this.site.groups}}
@value={{this.contactGroupId}}
@onChange={{this.onContactGroupIdChange}}
@options={{hash maximum=1}}
/>
</div>
<DButton
@label="admin.config_areas.about.update"
@action={{this.save}}
@disabled={{@globalSavingStatus}}
class="btn-primary admin-config-area-card__btn-save"
/>
</Form>
</template>
}

View File

@ -1,12 +1,8 @@
import Component from "@glimmer/component";
import { fn } from "@ember/helper";
import { on } from "@ember/modifier";
import { cached } from "@glimmer/tracking";
import { action } from "@ember/object";
import { service } from "@ember/service";
import DButton from "discourse/components/d-button";
import DEditor from "discourse/components/d-editor";
import UppyImageUploader from "discourse/components/uppy-image-uploader";
import withEventValue from "discourse/helpers/with-event-value";
import Form from "discourse/components/form";
import { ajax } from "discourse/lib/ajax";
import { popupAjaxError } from "discourse/lib/ajax-error";
import i18n from "discourse-common/helpers/i18n";
@ -20,18 +16,29 @@ export default class AdminConfigAreasAboutGeneralSettings extends Component {
extendedDescription = this.args.generalSettings.extendedSiteDescription.value;
aboutBannerImage = this.args.generalSettings.aboutBannerImage.value;
@cached
get data() {
return {
name: this.args.generalSettings.title.value,
summary: this.args.generalSettings.siteDescription.value,
extendedDescription:
this.args.generalSettings.extendedSiteDescription.value,
aboutBannerImage: this.args.generalSettings.aboutBannerImage.value,
};
}
@action
async save() {
async save(data) {
try {
this.args.setGlobalSavingStatus(true);
await ajax("/admin/config/about.json", {
type: "PUT",
data: {
general_settings: {
name: this.name,
summary: this.summary,
extended_description: this.extendedDescription,
about_banner_image: this.aboutBannerImage,
name: data.name,
summary: data.summary,
extended_description: data.extendedDescription,
about_banner_image: data.aboutBannerImage,
},
},
});
@ -50,52 +57,58 @@ export default class AdminConfigAreasAboutGeneralSettings extends Component {
}
}
@action
setImage(upload, { set }) {
set("aboutBannerImage", upload.url);
}
<template>
<div class="control-group community-name-input">
<label>{{i18n "admin.config_areas.about.community_name"}}</label>
<input
{{on "input" (withEventValue (fn (mut this.name)))}}
type="text"
value={{this.name}}
<Form @data={{this.data}} @onSubmit={{this.save}} as |form|>
<form.Field
@name="name"
@title={{i18n "admin.config_areas.about.community_name"}}
@validation="required"
@format="large"
as |field|
>
<field.Input
placeholder={{i18n
"admin.config_areas.about.community_name_placeholder"
}}
/>
</form.Field>
<form.Field
@name="summary"
@title={{i18n "admin.config_areas.about.community_summary"}}
@format="large"
as |field|
>
<field.Input />
</form.Field>
<form.Field
@name="extendedDescription"
@title={{i18n "admin.config_areas.about.community_description"}}
as |field|
>
<field.Composer />
</form.Field>
<form.Field
@name="aboutBannerImage"
@title={{i18n "admin.config_areas.about.banner_image"}}
@subtitle={{i18n "admin.config_areas.about.banner_image_help"}}
@onSet={{this.setImage}}
as |field|
>
<field.Image />
</form.Field>
<form.Submit
@label="admin.config_areas.about.update"
@disabled={{@globalSavingStatus}}
/>
</div>
<div class="control-group community-summary-input">
<label>{{i18n "admin.config_areas.about.community_summary"}}</label>
<input
{{on "input" (withEventValue (fn (mut this.summary)))}}
type="text"
value={{this.summary}}
/>
</div>
<div class="control-group community-description-input">
<label>
<span>{{i18n "admin.config_areas.about.community_description"}}</span>
<span class="admin-config-area-card__label-optional">{{i18n
"admin.config_areas.about.optional"
}}</span>
</label>
<DEditor @value={{this.extendedDescription}} />
</div>
<div class="control-group banner-image-uploader">
<label>
<span>{{i18n "admin.config_areas.about.banner_image"}}</span>
<span class="admin-config-area-card__label-optional">{{i18n
"admin.config_areas.about.optional"
}}</span>
</label>
<p class="admin-config-area-card__additional-help">
{{i18n "admin.config_areas.about.banner_image_help"}}
</p>
<UppyImageUploader
@type="site_setting"
@imageUrl={{this.aboutBannerImage}}
/>
</div>
<DButton
@label="admin.config_areas.about.update"
@action={{this.save}}
@disabled={{@globalSavingStatus}}
class="btn-primary admin-config-area-card__btn-save"
/>
</Form>
</template>
}

View File

@ -1,10 +1,8 @@
import Component from "@glimmer/component";
import { fn } from "@ember/helper";
import { on } from "@ember/modifier";
import { cached } from "@glimmer/tracking";
import { action } from "@ember/object";
import { service } from "@ember/service";
import DButton from "discourse/components/d-button";
import withEventValue from "discourse/helpers/with-event-value";
import Form from "discourse/components/form";
import { ajax } from "discourse/lib/ajax";
import { popupAjaxError } from "discourse/lib/ajax-error";
import i18n from "discourse-common/helpers/i18n";
@ -17,17 +15,26 @@ export default class AdminConfigAreasAboutYourOrganization extends Component {
governingLaw = this.args.yourOrganization.governingLaw.value;
cityForDisputes = this.args.yourOrganization.cityForDisputes.value;
@cached
get data() {
return {
companyName: this.args.yourOrganization.companyName.value,
governingLaw: this.args.yourOrganization.governingLaw.value,
cityForDisputes: this.args.yourOrganization.cityForDisputes.value,
};
}
@action
async save() {
async save(data) {
this.args.setGlobalSavingStatus(true);
try {
await ajax("/admin/config/about.json", {
type: "PUT",
data: {
your_organization: {
company_name: this.companyName,
governing_law: this.governingLaw,
city_for_disputes: this.cityForDisputes,
company_name: data.companyName,
governing_law: data.governingLaw,
city_for_disputes: data.cityForDisputes,
},
},
});
@ -47,62 +54,56 @@ export default class AdminConfigAreasAboutYourOrganization extends Component {
}
<template>
<div class="control-group company-name-input">
<label>
<span>{{i18n "admin.config_areas.about.company_name"}}</span>
<span class="admin-config-area-card__label-optional">{{i18n
"admin.config_areas.about.optional"
}}</span>
</label>
<p class="admin-config-area-card__additional-help">
{{i18n "admin.config_areas.about.company_name_help"}}
</p>
<p class="admin-config-area-card__warning-banner">
<Form @data={{this.data}} @onSubmit={{this.save}} as |form|>
<form.Field
@name="companyName"
@title={{i18n "admin.config_areas.about.company_name"}}
@subtitle={{i18n "admin.config_areas.about.company_name_help"}}
@format="large"
as |field|
>
<field.Input
placeholder={{i18n
"admin.config_areas.about.company_name_placeholder"
}}
/>
</form.Field>
<form.Alert @type="error">
{{i18n "admin.config_areas.about.company_name_warning"}}
</p>
<input
{{on "input" (withEventValue (fn (mut this.companyName)))}}
type="text"
value={{this.companyName}}
</form.Alert>
<form.Field
@name="governingLaw"
@title={{i18n "admin.config_areas.about.governing_law"}}
@subtitle={{i18n "admin.config_areas.about.governing_law_help"}}
@format="large"
as |field|
>
<field.Input
placeholder={{i18n
"admin.config_areas.about.governing_law_placeholder"
}}
/>
</form.Field>
<form.Field
@name="cityForDisputes"
@title={{i18n "admin.config_areas.about.city_for_disputes"}}
@subtitle={{i18n "admin.config_areas.about.city_for_disputes_help"}}
@format="large"
as |field|
>
<field.Input
placeholder={{i18n
"admin.config_areas.about.city_for_disputes_placeholder"
}}
/>
</form.Field>
<form.Submit
@label="admin.config_areas.about.update"
@disabled={{@globalSavingStatus}}
/>
</div>
<div class="control-group governing-law-input">
<label>
<span>{{i18n "admin.config_areas.about.governing_law"}}</span>
<span class="admin-config-area-card__label-optional">{{i18n
"admin.config_areas.about.optional"
}}</span>
</label>
<p class="admin-config-area-card__additional-help">
{{i18n "admin.config_areas.about.governing_law_help"}}
</p>
<input
{{on "input" (withEventValue (fn (mut this.governingLaw)))}}
type="text"
value={{this.governingLaw}}
/>
</div>
<div class="control-group city-for-disputes-input">
<label>
<span>{{i18n "admin.config_areas.about.city_for_disputes"}}</span>
<span class="admin-config-area-card__label-optional">{{i18n
"admin.config_areas.about.optional"
}}</span>
</label>
<p class="admin-config-area-card__additional-help">
{{i18n "admin.config_areas.about.city_for_disputes_help"}}
</p>
<input
{{on "input" (withEventValue (fn (mut this.cityForDisputes)))}}
type="text"
value={{this.cityForDisputes}}
/>
</div>
<DButton
@label="admin.config_areas.about.update"
@action={{this.save}}
@disabled={{@globalSavingStatus}}
class="btn-primary admin-config-area-card__btn-save"
/>
</Form>
</template>
}

View File

@ -0,0 +1,11 @@
import Component from "@glimmer/component";
export default class FKControlCustom extends Component {
static controlType = "custom";
<template>
<div class="form-kit__control-custom">
{{yield}}
</div>
</template>
}

View File

@ -4,6 +4,7 @@ import { hash } from "@ember/helper";
import FKControlCheckbox from "discourse/form-kit/components/fk/control/checkbox";
import FKControlCode from "discourse/form-kit/components/fk/control/code";
import FKControlComposer from "discourse/form-kit/components/fk/control/composer";
import FKControlCustom from "discourse/form-kit/components/fk/control/custom";
import FKControlIcon from "discourse/form-kit/components/fk/control/icon";
import FKControlImage from "discourse/form-kit/components/fk/control/image";
import FKControlInput from "discourse/form-kit/components/fk/control/input";
@ -92,6 +93,14 @@ export default class FKField extends Component {
<this.wrapper @size={{@size}}>
{{yield
(hash
Custom=(component
FKControlWrapper
errors=@errors
component=FKControlCustom
value=this.value
field=this.field
format=@format
)
Code=(component
FKControlWrapper
errors=@errors

View File

@ -0,0 +1,26 @@
import { render } from "@ember/test-helpers";
import { module, test } from "qunit";
import Form from "discourse/components/form";
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
module(
"Integration | Component | FormKit | Controls | Custom",
function (hooks) {
setupRenderingTest(hooks);
test("default", async function (assert) {
await render(<template>
<Form as |form|>
<form.Field @name="foo" @title="Foo" @subtitle="Bar" as |field|>
<field.Custom>
<input class="custom-test" />
</field.Custom>
</form.Field>
</Form>
</template>);
assert.dom(".form-kit__container-title").hasText("Foo (optional)");
assert.dom(".form-kit__container-subtitle").hasText("Bar");
});
}
);

View File

@ -13,7 +13,6 @@
color: var(--primary-high);
font-weight: bold;
padding-bottom: 0.25em;
width: max-content;
}
&-subtitle {
@ -24,7 +23,6 @@
font-size: var(--font-down-1-rem);
color: var(--primary-high);
padding-bottom: 0.25em;
width: max-content;
}
&-optional {

View File

@ -0,0 +1,12 @@
.form-kit__field-custom {
width: auto !important;
min-width: var(--form-kit-small-input);
.form-kit__control-custom {
width: 100%;
}
.form-kit__control-custom > * {
width: 100% !important;
}
}

View File

@ -17,6 +17,7 @@
@import "_control-radio";
@import "_control-radio-group";
@import "_control-select";
@import "_control-custom";
@import "_control-textarea";
@import "_errors";
@import "_errors-summary";

View File

@ -5494,6 +5494,7 @@ en:
header: "About your site"
general_settings: "General settings"
community_name: "Community name"
community_name_placeholder: "Example Community"
community_summary: "Community summary"
community_description: "Community description"
banner_image: "Banner image"
@ -5501,12 +5502,15 @@ en:
This will be used on your About page. Recommended size: 800x300px. Accepted types: JPG, PNG, and SVG up to 10MB.
contact_information: "Contact information"
community_owner: "Community owner"
community_owner_placeholder: "Johnny Smith"
community_owner_help: |
Name of key contact responsible for this site. Used for critical notifications, and also displayed on /about. Visible to anonymous users on public sites.
contact_email: "Contact email"
contact_email_placeholder: "contact@johnny-smith.com"
contact_email_help: |
Email address of key contact responsible for this site. Used for critical notifications, and also displayed on /about. Visible to anonymous users on public sites.
contact_url: "Contact URL"
contact_url_placeholder: "https://johnny-smith.com/contact"
contact_url_help: |
Contact URL for this site. When present, replaces contact email address on /about and visible to anonymous users on public sites.
site_contact_name: "Site contact name"
@ -5517,14 +5521,17 @@ en:
A valid name of a group that gets invited to all automatically sent private messages.
your_organization: "Your organization"
company_name: "Company name"
company_name_placeholder: "Sample Company Inc."
company_name_help: |
Name of your company or organization.
company_name_warning: |
If left blank, no boilerplate Terms of Service or Privacy Notice will be provided.
governing_law: "Governing law"
governing_law_placeholder: "State of New York"
governing_law_help: |
Specify the jurisdiction that governs the legal aspects of the site, including Terms of Service and Privacy Notice. This is typically the country or state where the company operating the site is registered or conducts business.
city_for_disputes: "City for disputes"
city_for_disputes_placeholder: "New York City"
city_for_disputes_help: |
Specify the city that will be used as the jurisdiction for resolving any disputes related to the use of this forum. This information is typically included in legal documents such as the forum's Terms of Service.
optional: "(optional)"

View File

@ -71,17 +71,18 @@ describe "Admin About Config Area Page", type: :system do
config_area.visit
image_file = file_from_fixtures("logo.png", "images")
config_area.general_settings_section.community_name_input.fill_in(with: "my community name")
config_area.general_settings_section.community_name_input.fill_in("my community name")
config_area.general_settings_section.community_summary_input.fill_in(
with: "here's a bit of a summary",
"here's a bit of a summary",
)
config_area.general_settings_section.community_description_editor.fill_in(
with: "here's an extended description for the **community**",
"here's an extended description for the **community**",
)
config_area.general_settings_section.banner_image_uploader.select_image(image_file.path)
expect(config_area.general_settings_section.banner_image_uploader).to have_uploaded_image
config_area.general_settings_section.save_button.click
config_area.general_settings_section.submit
expect(config_area.general_settings_section).to have_saved_successfully
expect(SiteSetting.title).to eq("my community name")
@ -100,12 +101,10 @@ describe "Admin About Config Area Page", type: :system do
it "can saves its fields to their corresponding site settings" do
config_area.visit
config_area.contact_information_section.community_owner_input.fill_in(with: "awesome owner")
config_area.contact_information_section.contact_email_input.fill_in(
with: "owneremail@owner.com",
)
config_area.contact_information_section.community_owner_input.fill_in("awesome owner")
config_area.contact_information_section.contact_email_input.fill_in("owneremail@owner.com")
config_area.contact_information_section.contact_url_input.fill_in(
with: "https://website.owner.com/blah",
"https://website.owner.com/blah",
)
user_select_kit = config_area.contact_information_section.site_contact_user_selector
@ -121,7 +120,7 @@ describe "Admin About Config Area Page", type: :system do
group_select_kit.select_row_by_value(group.id)
group_select_kit.collapse
config_area.contact_information_section.save_button.click
config_area.contact_information_section.submit
expect(config_area.contact_information_section).to have_saved_successfully
expect(SiteSetting.community_owner).to eq("awesome owner")
@ -136,11 +135,11 @@ describe "Admin About Config Area Page", type: :system do
it "can saves its fields to their corresponding site settings" do
config_area.visit
config_area.your_organization_section.company_name_input.fill_in(with: "lil' company")
config_area.your_organization_section.governing_law_input.fill_in(with: "wild west law")
config_area.your_organization_section.city_for_disputes_input.fill_in(with: "teeb el shouq")
config_area.your_organization_section.company_name_input.fill_in("lil' company")
config_area.your_organization_section.governing_law_input.fill_in("wild west law")
config_area.your_organization_section.city_for_disputes_input.fill_in("teeb el shouq")
config_area.your_organization_section.save_button.click
config_area.your_organization_section.submit
expect(config_area.your_organization_section).to have_saved_successfully
expect(SiteSetting.company_name).to eq("lil' company")

View File

@ -4,31 +4,31 @@ module PageObjects
module Components
class AdminAboutConfigAreaContactInformationCard < PageObjects::Components::Base
def community_owner_input
card.find(".community-owner-input input")
form.field("communityOwner")
end
def contact_email_input
card.find(".contact-email-input input")
form.field("contactEmail")
end
def contact_url_input
card.find(".contact-url-input input")
form.field("contactURL")
end
def site_contact_user_selector
PageObjects::Components::SelectKit.new(
".admin-config-area-about__contact-information-section .site-contact-username-input .user-chooser",
".admin-config-area-about__contact-information-section .user-chooser",
)
end
def site_contact_group_selector
PageObjects::Components::SelectKit.new(
".admin-config-area-about__contact-information-section .site-contact-group-input .group-chooser",
".admin-config-area-about__contact-information-section .group-chooser",
)
end
def save_button
card.find(".btn-primary.admin-config-area-card__btn-save")
def submit
form.submit
end
def has_saved_successfully?
@ -37,8 +37,10 @@ module PageObjects
)
end
def card
find(".admin-config-area-about__contact-information-section")
def form
PageObjects::Components::FormKit.new(
".admin-config-area-about__contact-information-section .form-kit",
)
end
end
end

View File

@ -4,23 +4,23 @@ module PageObjects
module Components
class AdminAboutConfigAreaGeneralSettingsCard < PageObjects::Components::Base
def community_name_input
card.find(".community-name-input input")
form.field("name")
end
def community_summary_input
card.find(".community-summary-input input")
form.field("summary")
end
def community_description_editor
card.find(".community-description-input .d-editor-input")
form.field("extendedDescription")
end
def banner_image_uploader
PageObjects::Components::UppyImageUploader.new(card.find(".image-uploader"))
end
def save_button
card.find(".btn-primary.admin-config-area-card__btn-save")
def submit
form.submit
end
def has_saved_successfully?
@ -32,6 +32,12 @@ module PageObjects
def card
find(".admin-config-area-about__general-settings-section")
end
def form
PageObjects::Components::FormKit.new(
".admin-config-area-about__general-settings-section .form-kit",
)
end
end
end
end

View File

@ -4,19 +4,19 @@ module PageObjects
module Components
class AdminAboutConfigAreaYourOrganizationCard < PageObjects::Components::Base
def company_name_input
card.find(".company-name-input input")
form.field("companyName")
end
def governing_law_input
card.find(".governing-law-input input")
form.field("governingLaw")
end
def city_for_disputes_input
card.find(".city-for-disputes-input input")
form.field("cityForDisputes")
end
def save_button
card.find(".btn-primary.admin-config-area-card__btn-save")
def submit
form.submit
end
def has_saved_successfully?
@ -25,8 +25,10 @@ module PageObjects
)
end
def card
find(".admin-config-area-about__your-organization-section")
def form
PageObjects::Components::FormKit.new(
".admin-config-area-about__your-organization-section .form-kit",
)
end
end
end

View File

@ -26,6 +26,8 @@ module PageObjects
component.find(".fk-d-menu__trigger")["data-value"]
when "select"
component.find("select").value
when "composer"
component.find("textarea").value
end
end