Skip to content

Commit

Permalink
Release 3.30.1
Browse files Browse the repository at this point in the history
  • Loading branch information
tomwwinter authored Jan 29, 2024
2 parents a8a4fd8 + 8fd0a47 commit cb5f14e
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 44 deletions.
82 changes: 41 additions & 41 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"@fortawesome/free-regular-svg-icons": "^6.5.1",
"@fortawesome/free-solid-svg-icons": "^6.5.1",
"@ngneat/until-destroy": "^10.0.0",
"@sentry/browser": "^7.91.0",
"@sentry/browser": "^7.92.0",
"angulartics2": "^12.2.1",
"assert": "^2.1.0",
"crypto-es": "^2.1.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ describe("EntityFormComponent", () => {
expect(component).toBeTruthy();
});

it("should remove fields without read permissions", async () => {
it("should remove fields without read permissions when entity is not new", async () => {
component.fieldGroups = [
{ fields: ["foo", "bar"] },
{ fields: ["name"] },
Expand All @@ -67,6 +67,27 @@ describe("EntityFormComponent", () => {
{ subject: "Child", action: "read", fields: ["foo", "name"] },
]);

component.entity._rev = "foo";

component.ngOnChanges({ entity: true, form: true } as any);

expect(component.fieldGroups).toEqual([
{ fields: ["foo"] },
{ fields: ["name"] },
]);
});

it("should remove fields without create permissions when entity is new", async () => {
component.fieldGroups = [
{ fields: ["foo", "bar"] },
{ fields: ["name"] },
{ fields: ["birthday"] },
];

TestBed.inject(EntityAbility).update([
{ subject: "Child", action: "create", fields: ["foo", "name"] },
]);

component.ngOnChanges({ entity: true, form: true } as any);

expect(component.fieldGroups).toEqual([
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,13 @@ export class EntityFormComponent<T extends Entity = Entity>
fieldGroups: FieldGroup[],
entity: Entity,
): FieldGroup[] {
const action = entity.isNew ? "create" : "read";

return fieldGroups
.map((group) => {
group.fields = group.fields.filter((field) =>
this.ability.can(
"read",
action,
entity,
typeof field === "string" ? field : field.id,
),
Expand Down

0 comments on commit cb5f14e

Please sign in to comment.