Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configure bank organization units #4432

Merged
merged 25 commits into from
Jul 16, 2024
Merged

Configure bank organization units #4432

merged 25 commits into from
Jul 16, 2024

Conversation

awwaiid
Copy link
Collaborator

@awwaiid awwaiid commented Jun 9, 2024

This PR builds on #4415 and works toward #4396.

This adds partner-request-units configuration for Bank Organizations.

@cielf cielf self-requested a review June 11, 2024 16:55
cielf
cielf previously requested changes Jun 11, 2024
Copy link
Collaborator

@cielf cielf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the dropdown with the units they have used is not useful, and is potentially confusing. Can we get rid of it, please?
I also notice that if you enter a unit that is a substring of an already entered unit, it won't take it (though it will accept a superstring of an already entered unit) Do I think that's going to be a problem? Probably not.

@awwaiid
Copy link
Collaborator Author

awwaiid commented Jun 11, 2024 via email

@cielf
Copy link
Collaborator

cielf commented Jun 19, 2024

So this is back to the more manual way, then. That seems to work.

Copy link
Collaborator

@cielf cielf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Back to the old way. Seems to work, but when I look at the code, it looks like we're committing a lot of unrelated stuff. I presume in error?

@awwaiid awwaiid changed the base branch from 4396-PACKS-1-add-custom-request-units-at-organizational-level to main June 19, 2024 21:38
@awwaiid
Copy link
Collaborator Author

awwaiid commented Jun 19, 2024

@cielf Try again, I switched the target base branch for this PR. Diff is much smaller :)

@awwaiid awwaiid requested a review from cielf June 19, 2024 21:41
@@ -5,17 +5,29 @@ import "select2"
export default class extends Controller {
static values = {
config: { type: Object, default: {} },
}
hideDropdown: { type: Boolean, default: false }
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes in this file are:

  • Allow for more than one select2 on the same page (this was previously broken)
  • Add a new parameter that can hide the dropdown (for the 'tags' use-case)


<% if Flipper.enabled?(:enable_packs) %>
<%= label_tag "organization[request_unit_names]", 'Custom request units used (please use singular form -- e.g. pack, not packs)' %>
<%= select_tag(
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This whole block is kinda ugly and I welcome feedback. I did a raw select tag so that I could give it a field name that isn't part of the model -- request_unit_names. It also uses the name as both the value and the display text. The rest is configuration for the select2.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would we reuse this type of UI anywhere else? Would it make sense to put it e.g. in ui_helpers?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe but I think not worth it until that happens. I might be biased since I wanna be done with this PR :)

Copy link
Collaborator

@cielf cielf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works nicely. Over to @dorner for any technical comments.

@cielf cielf dismissed their stale review June 20, 2024 20:44

Better now. I don' t think we need to be overly concerned about the substring issue -- there is an obvious workaround if anyone does run into it.

@cielf cielf requested a review from dorner June 20, 2024 20:44
request_unit_ids = params[:request_unit_names].reject(&:blank?).map do |request_unit_name|
Unit.find_or_create_by(organization: organization, name: request_unit_name).id
end
params.delete(:request_unit_names)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not the biggest fan of manipulating the params hash unless it's cloned first. You get confusing logs etc.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK -- I switched to a duplicate and avoided mutating the original. I used dup instead of deep_dup so that it would maintain the params require/permit logic. I think.


<% if Flipper.enabled?(:enable_packs) %>
<%= label_tag "organization[request_unit_names]", 'Custom request units used (please use singular form -- e.g. pack, not packs)' %>
<%= select_tag(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would we reuse this type of UI anywhere else? Would it make sense to put it e.g. in ui_helpers?

# updated_at :datetime not null
# organization_id :bigint
#
require "rails_helper"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this auto-required?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, though it's required in tons of these specs. I'm removing it from here and separately we can bulk-remove it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I created #4529 to get the others

@@ -22,6 +23,14 @@
url: organization.url
)
end

context "when enable_packs flipper is on" do
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we validate that it does not display it when the flag is off?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -58,6 +67,15 @@
url: organization.url
)
end

context "when enable_packs flipper is on" do
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

expect(page).to_not have_content("Custom Request Units")
end

it "Shows custom request units when enabled", :aggregate_failures do
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be converted into a request spec?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like the system spec is still here :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK updated now -- I moved almost all of the system specs over to the request spec, leaving only two that have pop-up interactions.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that several of these tests I moved basically as-is though they are flawed -- like they are looking for the word "Yes" on the page as their success, but all the other fields could have "Yes" visible. Unchanged validation we should address separately.

@awwaiid awwaiid changed the title Configure bank organization units using select2 Configure bank organization units Jun 22, 2024
expect(page).to_not have_content("Custom Request Units")
end

it "Shows custom request units when enabled", :aggregate_failures do
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like the system spec is still here :)

Flipper.disable(:enable_packs)
get edit_organization_path
expect(response.body).to_not include("Custom request units used (please use singular form -- e.g. pack, not packs)")
expect(response.body).to_not include unit.name
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we specify the unit name rather than relying on generated data?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@awwaiid awwaiid requested a review from dorner July 14, 2024 18:55
@dorner
Copy link
Collaborator

dorner commented Jul 16, 2024

Nice! Excited to get this in!

@dorner dorner merged commit d4c64a0 into main Jul 16, 2024
38 checks passed
@dorner dorner deleted the org-units-edit branch July 16, 2024 20:04
@awwaiid awwaiid added this to the Request Units (Packs) milestone Jul 21, 2024
@awwaiid awwaiid linked an issue Jul 21, 2024 that may be closed by this pull request
2 tasks
Copy link
Contributor

@awwaiid: Your PR Configure bank organization units is part of today's Human Essentials production release: 2024.07.21.
Thank you very much for your contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[PACKS] # 1 Add custom request units at organizational level
5 participants