mirror of
https://github.com/bitwarden/browser.git
synced 2024-12-11 14:48:46 +01:00
[PM-15533] Remove isNotClone parameter from updateWithServer method (#12233)
This commit is contained in:
parent
f8c4b8afe8
commit
a6c905cc1a
@ -699,7 +699,6 @@ export class AddEditComponent implements OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected saveCipher(cipher: Cipher) {
|
protected saveCipher(cipher: Cipher) {
|
||||||
const isNotClone = this.editMode && !this.cloneMode;
|
|
||||||
let orgAdmin = this.organization?.canEditAllCiphers;
|
let orgAdmin = this.organization?.canEditAllCiphers;
|
||||||
|
|
||||||
// if a cipher is unassigned we want to check if they are an admin or have permission to edit any collection
|
// if a cipher is unassigned we want to check if they are an admin or have permission to edit any collection
|
||||||
@ -709,7 +708,7 @@ export class AddEditComponent implements OnInit, OnDestroy {
|
|||||||
|
|
||||||
return this.cipher.id == null
|
return this.cipher.id == null
|
||||||
? this.cipherService.createWithServer(cipher, orgAdmin)
|
? this.cipherService.createWithServer(cipher, orgAdmin)
|
||||||
: this.cipherService.updateWithServer(cipher, orgAdmin, isNotClone);
|
: this.cipherService.updateWithServer(cipher, orgAdmin);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected deleteCipher() {
|
protected deleteCipher() {
|
||||||
|
@ -229,11 +229,11 @@ describe("Cipher Service", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe("updateWithServer()", () => {
|
describe("updateWithServer()", () => {
|
||||||
it("should call apiService.putCipherAdmin when orgAdmin and isNotClone params are true", async () => {
|
it("should call apiService.putCipherAdmin when orgAdmin param is true", async () => {
|
||||||
const spy = jest
|
const spy = jest
|
||||||
.spyOn(apiService, "putCipherAdmin")
|
.spyOn(apiService, "putCipherAdmin")
|
||||||
.mockImplementation(() => Promise.resolve<any>(cipherObj.toCipherData()));
|
.mockImplementation(() => Promise.resolve<any>(cipherObj.toCipherData()));
|
||||||
await cipherService.updateWithServer(cipherObj, true, true);
|
await cipherService.updateWithServer(cipherObj, true);
|
||||||
const expectedObj = new CipherRequest(cipherObj);
|
const expectedObj = new CipherRequest(cipherObj);
|
||||||
|
|
||||||
expect(spy).toHaveBeenCalled();
|
expect(spy).toHaveBeenCalled();
|
||||||
@ -252,7 +252,7 @@ describe("Cipher Service", () => {
|
|||||||
expect(spy).toHaveBeenCalledWith(cipherObj.id, expectedObj);
|
expect(spy).toHaveBeenCalledWith(cipherObj.id, expectedObj);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should call apiService.putPartialCipher when orgAdmin, isNotClone, and edit are false", async () => {
|
it("should call apiService.putPartialCipher when orgAdmin, and edit are false", async () => {
|
||||||
cipherObj.edit = false;
|
cipherObj.edit = false;
|
||||||
const spy = jest
|
const spy = jest
|
||||||
.spyOn(apiService, "putPartialCipher")
|
.spyOn(apiService, "putPartialCipher")
|
||||||
|
@ -709,13 +709,9 @@ export class CipherService implements CipherServiceAbstraction {
|
|||||||
return new Cipher(updated[cipher.id as CipherId]);
|
return new Cipher(updated[cipher.id as CipherId]);
|
||||||
}
|
}
|
||||||
|
|
||||||
async updateWithServer(
|
async updateWithServer(cipher: Cipher, orgAdmin?: boolean): Promise<Cipher> {
|
||||||
cipher: Cipher,
|
|
||||||
orgAdmin?: boolean,
|
|
||||||
isNotClone?: boolean,
|
|
||||||
): Promise<Cipher> {
|
|
||||||
let response: CipherResponse;
|
let response: CipherResponse;
|
||||||
if (orgAdmin && isNotClone) {
|
if (orgAdmin) {
|
||||||
const request = new CipherRequest(cipher);
|
const request = new CipherRequest(cipher);
|
||||||
response = await this.apiService.putCipherAdmin(cipher.id, request);
|
response = await this.apiService.putCipherAdmin(cipher.id, request);
|
||||||
const data = new CipherData(response, cipher.collectionIds);
|
const data = new CipherData(response, cipher.collectionIds);
|
||||||
|
@ -71,7 +71,6 @@ export class DefaultCipherFormService implements CipherFormService {
|
|||||||
await this.cipherService.updateWithServer(
|
await this.cipherService.updateWithServer(
|
||||||
encryptedCipher,
|
encryptedCipher,
|
||||||
config.admin || originalCollectionIds.size === 0,
|
config.admin || originalCollectionIds.size === 0,
|
||||||
config.mode !== "clone",
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// Then save the new collection changes separately
|
// Then save the new collection changes separately
|
||||||
|
Loading…
Reference in New Issue
Block a user