Skip to content

Commit

Permalink
FIX: regressions from modernization (#642)
Browse files Browse the repository at this point in the history
When converting widgets to Glimmer and modernizing the plugin, there were some small leftovers.

status wasn’t tracked, so the UI didn’t update

raw_invitees should be camelCase now

custom_fields should be camelCase, and setting it was not working
  • Loading branch information
renato authored Nov 7, 2024
1 parent 588052f commit b2fb2e4
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
<GroupSelector
@fullWidthWrap={{true}}
@groupFinder={{this.groupFinder}}
@groupNames={{@model.event.raw_invitees}}
@groupNames={{@model.event.rawInvitees}}
@onChangeCallback={{this.setRawInvitees}}
@placeholderKey="topic.invite_private.group_name"
/>
Expand Down Expand Up @@ -232,7 +232,7 @@
<Input
class="custom-field-input"
@value={{readonly
(get @model.event.custom_fields allowedCustomField)
(get @model.event.customFields allowedCustomField)
}}
placeholder={{i18n
"discourse_post_event.builder_modal.custom_fields.placeholder"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ export default class PostEventBuilder extends Component {
@action
setCustomField(field, e) {
this.event[field] = e.target.value;
this.event.customFields[field] = e.target.value;
}
@action
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export default class DiscoursePostEventEvent {
@tracked rawInvitees;
@tracked url;
@tracked timezone;
@tracked status;
@tracked post;
@tracked minimal;
@tracked canUpdateAttendance;
Expand Down
33 changes: 33 additions & 0 deletions spec/system/post_event_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
describe "Post event", type: :system do
fab!(:admin)
fab!(:user) { Fabricate(:admin, username: "jane") }
fab!(:group) { Fabricate(:group, name: "test_group") }
let(:composer) { PageObjects::Components::Composer.new }

before do
SiteSetting.calendar_enabled = true
SiteSetting.discourse_post_event_enabled = true
SiteSetting.discourse_post_event_allowed_custom_fields = "custom"
sign_in(admin)
end

Expand Down Expand Up @@ -68,4 +70,35 @@

expect(event.invitees.count).to eq(2)
end

it "can update fields and invitees and they are kept when re-opening" do
visit "/new-topic"
title = "Test event with updates"

composer.fill_title(title)

page.find(".toolbar-popup-menu-options .dropdown-select-box-header").click

page.find(
".toolbar-popup-menu-options [data-name='#{I18n.t("js.discourse_post_event.builder_modal.attach")}']",
).click

page.find(".d-modal input[name=status][value=private]").click

page.find(".d-modal input.group-selector").fill_in(with: "test_")
page.find(".autocomplete.ac-group").click

page.find(".d-modal .custom-field-input").fill_in(with: "custom value")

page.find(".d-modal .btn-primary").click

composer.submit

page.find(".discourse-post-event-more-menu-trigger").click
page.find(".edit-event").click

expect(page.find(".d-modal input[name=status][value=private]").checked?).to eq(true)
expect(page.find(".d-modal")).to have_text("test_group")
expect(page.find(".d-modal .custom-field-input").value).to eq("custom value")
end
end

0 comments on commit b2fb2e4

Please sign in to comment.