Skip to content

Commit

Permalink
Check for fieldValue to be existent before relying on it
Browse files Browse the repository at this point in the history
  • Loading branch information
HDinger committed Oct 21, 2024
1 parent a78cb2d commit a70a3ae
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ export class PrincipalComponent implements OnInit {
const fieldSchema = fieldsSchema[fieldKey];
let fieldValue = this.customFields[fieldKey];

if (fieldSchema.location === '_links') {
if (fieldSchema.location === '_links' && !!fieldValue) {

Check failure on line 247 in frontend/src/app/features/invite-user-modal/principal/principal.component.ts

View workflow job for this annotation

GitHub Actions / eslint

[eslint] frontend/src/app/features/invite-user-modal/principal/principal.component.ts#L247 <@typescript-eslint/no-unsafe-member-access>(https://typescript-eslint.io/rules/no-unsafe-member-access)

Unsafe member access .location on an `any` value.
Raw output
{"ruleId":"@typescript-eslint/no-unsafe-member-access","severity":2,"message":"Unsafe member access .location on an `any` value.","line":247,"column":25,"nodeType":"Identifier","messageId":"unsafeMemberExpression","endLine":247,"endColumn":33}
fieldValue = Array.isArray(fieldValue)
? fieldValue.map((opt:any) => (opt._links ? opt._links.self : opt))
: (fieldValue._links ? fieldValue._links.self : fieldValue);
Expand Down
21 changes: 21 additions & 0 deletions spec/features/users/invite_user_modal/invite_user_modal_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,27 @@
let(:mail_membership_recipients) { [principal] }
end
end

context "with a required list user CF (regression #58429)" do
let(:current_user) { create(:admin) }
let(:list_cf) do
create(:user_custom_field,
:list,
name: "List",
is_required: true,
editable: false,
default_option: "A")
end

before do
list_cf
end

it_behaves_like "invites the principal to the project" do
let(:added_principal) { principal }
let(:mail_membership_recipients) { [principal] }
end
end
end

context "with a user to be invited" do
Expand Down

0 comments on commit a70a3ae

Please sign in to comment.