Skip to content

Commit

Permalink
[AC-1680] Add manage property to collection view and response models (#…
Browse files Browse the repository at this point in the history
…6417)

* Add manage property to synced Collection data

* Update tests
  • Loading branch information
eliykat authored Sep 28, 2023
1 parent a2dfe5a commit 31d48a2
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 1 deletion.
2 changes: 2 additions & 0 deletions libs/common/src/vault/models/data/collection.data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ export class CollectionData {
name: string;
externalId: string;
readOnly: boolean;
manage: boolean;

constructor(response: CollectionDetailsResponse) {
this.id = response.id;
this.organizationId = response.organizationId;
this.name = response.name;
this.externalId = response.externalId;
this.readOnly = response.readOnly;
this.manage = response.manage;
}
}
5 changes: 5 additions & 0 deletions libs/common/src/vault/models/domain/collection.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ describe("Collection", () => {
name: "encName",
externalId: "extId",
readOnly: true,
manage: true,
};
});

Expand All @@ -27,6 +28,7 @@ describe("Collection", () => {
name: null,
organizationId: null,
readOnly: null,
manage: null,
});
});

Expand All @@ -40,6 +42,7 @@ describe("Collection", () => {
externalId: "extId",
readOnly: true,
hidePasswords: null,
manage: true,
});
});

Expand All @@ -51,6 +54,7 @@ describe("Collection", () => {
collection.externalId = "extId";
collection.readOnly = false;
collection.hidePasswords = false;
collection.manage = true;

const view = await collection.decrypt();

Expand All @@ -61,6 +65,7 @@ describe("Collection", () => {
name: "encName",
organizationId: "orgId",
readOnly: false,
manage: true,
});
});
});
4 changes: 3 additions & 1 deletion libs/common/src/vault/models/domain/collection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export class Collection extends Domain {
externalId: string;
readOnly: boolean;
hidePasswords: boolean;
manage: boolean;

constructor(obj?: CollectionData) {
super();
Expand All @@ -27,8 +28,9 @@ export class Collection extends Domain {
externalId: null,
readOnly: null,
hidePasswords: null,
manage: null,
},
["id", "organizationId", "externalId", "readOnly", "hidePasswords"]
["id", "organizationId", "externalId", "readOnly", "hidePasswords", "manage"]
);
}

Expand Down
2 changes: 2 additions & 0 deletions libs/common/src/vault/models/response/collection.response.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ export class CollectionResponse extends BaseResponse {

export class CollectionDetailsResponse extends CollectionResponse {
readOnly: boolean;
manage: boolean;

constructor(response: any) {
super(response);
this.readOnly = this.getResponseProperty("ReadOnly") || false;
this.manage = this.getResponseProperty("Manage") || false;
}
}

Expand Down
2 changes: 2 additions & 0 deletions libs/common/src/vault/models/view/collection.view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export class CollectionView implements View, ITreeNodeObject {
externalId: string = null;
readOnly: boolean = null;
hidePasswords: boolean = null;
manage: boolean = null;

constructor(c?: Collection | CollectionAccessDetailsResponse) {
if (!c) {
Expand All @@ -24,6 +25,7 @@ export class CollectionView implements View, ITreeNodeObject {
if (c instanceof Collection) {
this.readOnly = c.readOnly;
this.hidePasswords = c.hidePasswords;
this.manage = c.manage;
}
}
}

0 comments on commit 31d48a2

Please sign in to comment.