mirror of
https://github.com/bitwarden/browser
synced 2026-02-26 09:33:22 +00:00
[PM-32717] Individual Vault - Edit Cipher permissions (#19228)
* bypass cipher edit permissions for individual vault * replace bypassCipherEditPermission with form configuration mode * allow partial edit to view cipher form * remove old comment
This commit is contained in:
@@ -374,6 +374,29 @@ describe("VaultItemDialogComponent", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("disableEdit", () => {
|
||||
it("returns false when formConfig mode is partial-edit even if canEdit is false", () => {
|
||||
component["canEdit"] = false;
|
||||
component.setTestFormConfig({ ...baseFormConfig, mode: "partial-edit" });
|
||||
|
||||
expect(component["disableEdit"]).toBe(false);
|
||||
});
|
||||
|
||||
it("returns true when canEdit is false and formConfig mode is not partial-edit", () => {
|
||||
component["canEdit"] = false;
|
||||
component.setTestFormConfig({ ...baseFormConfig, mode: "edit" });
|
||||
|
||||
expect(component["disableEdit"]).toBe(true);
|
||||
});
|
||||
|
||||
it("returns false when canEdit is true regardless of formConfig mode", () => {
|
||||
component["canEdit"] = true;
|
||||
component.setTestFormConfig({ ...baseFormConfig, mode: "edit" });
|
||||
|
||||
expect(component["disableEdit"]).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("changeMode", () => {
|
||||
beforeEach(() => {
|
||||
component.setTestCipher({ type: CipherType.Login, id: "cipher-id" });
|
||||
|
||||
@@ -273,7 +273,7 @@ export class VaultItemDialogComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
protected get disableEdit() {
|
||||
return !this.canEdit;
|
||||
return !this.canEdit && this.formConfig.mode !== "partial-edit";
|
||||
}
|
||||
|
||||
protected get showEdit() {
|
||||
@@ -396,7 +396,7 @@ export class VaultItemDialogComponent implements OnInit, OnDestroy {
|
||||
);
|
||||
|
||||
// If user cannot edit and dialog opened in form mode, force to view mode
|
||||
if (!this.canEdit && this.params.mode === "form") {
|
||||
if (!this.canEdit && this.formConfig.mode !== "partial-edit" && this.params.mode === "form") {
|
||||
this.params.mode = "view";
|
||||
this.loadForm = false;
|
||||
this.updateTitle();
|
||||
|
||||
@@ -135,7 +135,7 @@ export class DefaultCipherAuthorizationService implements CipherAuthorizationSer
|
||||
*
|
||||
* {@link CipherAuthorizationService.canEditCipher$}
|
||||
*/
|
||||
canEditCipher$(cipher: CipherLike, isAdminConsoleAction?: boolean): Observable<boolean> {
|
||||
canEditCipher$(cipher: CipherLike, isAdminConsoleAction: boolean = false): Observable<boolean> {
|
||||
return this.organization$(cipher).pipe(
|
||||
map((organization) => {
|
||||
if (isAdminConsoleAction) {
|
||||
|
||||
Reference in New Issue
Block a user