Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AC-1680] Add manage property to collection view and response models #6417

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think hidePasswords should be here, as it 's not actually sent in the response model, so in theory at least it won't ever be set properly. However it's out of scope to mess with here and I don't want to increase the scope of regression testing.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eliykat It's actually missing from the ResponseModel: bitwarden/server#3125

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;
}
}
}