Skip to content

Commit

Permalink
Merge pull request #16722 from opf/fix/57906/disable-permission-check…
Browse files Browse the repository at this point in the history
…-boxes

Fix/57906/disable permission check boxes
  • Loading branch information
ulferts authored Sep 12, 2024
2 parents d76dc51 + 530fd58 commit 4b98d5d
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,17 @@ export default class RolesController extends Controller {
}

globalRoleValueChanged() {
this.memberAttributesTarget.hidden = this.globalRoleValue;
this.memberPermissionsTarget.hidden = this.globalRoleValue;
this.globalPermissionsTarget.hidden = !this.globalRoleValue;
this.toggleEnabled(this.memberAttributesTarget, !this.globalRoleValue);
this.toggleEnabled(this.memberPermissionsTarget, !this.globalRoleValue);
this.toggleEnabled(this.globalPermissionsTarget, this.globalRoleValue);
}

toggleEnabled(target:HTMLElement, enabled:boolean) {
target.hidden = !enabled;
target
.querySelectorAll('input,select')
.forEach((input:HTMLInputElement) => {
input.disabled = !enabled;
});
}
}
14 changes: 14 additions & 0 deletions spec/features/global_roles/global_role_crud_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,18 @@
# Then I should see "Successful creation."
expect(page).to have_text "Successful creation."
end

context "with a non-member using dependent project permissions" do
let!(:non_member) { create(:non_member, permissions: %i[view_project_attributes]) }

it "can still create it (Regression #57906)" do
# When I go to the new page of "Role"
visit new_role_path
check "Global role"
fill_in "Name", with: "Manager"
click_on "Create"
# Then I should see "Successful creation."
expect(page).to have_text "Successful creation."
end
end
end

0 comments on commit 4b98d5d

Please sign in to comment.