-
-
Notifications
You must be signed in to change notification settings - Fork 492
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
Conversation
…om-request-units-at-organizational-level Conflicts: app/controllers/organizations_controller.rb
…anizational-level
There was a problem hiding this 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.
Thank you for looking -- I'll give it a try to get rid of the extra
drop-down when in this tags mode, but I had some issue with it. I might
have to go back to the more hand-built UI if I can't get it working well
enough.
…On Tue, Jun 11, 2024 at 1:02 PM CL Fisher ***@***.***> wrote:
***@***.**** requested changes on this pull request.
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.
—
Reply to this email directly, view it on GitHub
<#4432 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAACDQWMH5ZJACPD67TJTBTZG4URTAVCNFSM6AAAAABJAPIJMKVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZDCMJRGAYDQNJRGA>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
So this is back to the more manual way, then. That seems to work. |
There was a problem hiding this 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?
@cielf Try again, I switched the target base branch for this PR. Diff is much smaller :) |
@@ -5,17 +5,29 @@ import "select2" | |||
export default class extends Controller { | |||
static values = { | |||
config: { type: Object, default: {} }, | |||
} | |||
hideDropdown: { type: Boolean, default: false } |
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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 :)
There was a problem hiding this 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.
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.
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) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
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
?
spec/models/unit_spec.rb
Outdated
# updated_at :datetime not null | ||
# organization_id :bigint | ||
# | ||
require "rails_helper" |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 :)
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
expect(page).to_not have_content("Custom Request Units") | ||
end | ||
|
||
it "Shows custom request units when enabled", :aggregate_failures do |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
Nice! Excited to get this in! |
@awwaiid: Your PR |
This PR builds on #4415 and works toward #4396.
This adds partner-request-units configuration for Bank Organizations.