Some arguments for UI components are optional, so we don't have to provide all of them when using them. I had added a `defined?(name)` check to use default values when an argument is not provided. Jeremy pointed out that it was working by accident. In the code `name = defined?(name)`, `defined?(name)` always returns `local-variable` because it’s on the right-hand side of the assignment, while the local variable is on the left-hand side. When we remove the `defined?` calls, the remaining code is equivalent to `||=`.
22 lines
624 B
Text
22 lines
624 B
Text
<% name ||= nil
|
|
selected = flash.dig("old", name) || selected %>
|
|
|
|
<div class="">
|
|
<%== render(
|
|
"components/form/select",
|
|
locals: {
|
|
name: name,
|
|
options: [
|
|
["", "No policy", nil, { title: "Can't access any resources, need advanced access policy" }],
|
|
[
|
|
Authorization::ManagedPolicy::Member.name,
|
|
"Member",
|
|
nil,
|
|
{ title: "Can perform all actions except managing users and billing" }
|
|
],
|
|
[Authorization::ManagedPolicy::Admin.name, "Admin", nil, { title: "Can perform all actions" }]
|
|
],
|
|
selected: selected
|
|
}
|
|
) %>
|
|
</div>
|