1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-12-10 14:43:34 +01:00

[PM-15533] Remove isNotClone parameter from updateWithServer method (#12233)

This commit is contained in:
Shane Melton 2024-12-03 15:43:09 -08:00 committed by GitHub
parent f8c4b8afe8
commit a6c905cc1a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 6 additions and 12 deletions

View File

@ -699,7 +699,6 @@ export class AddEditComponent implements OnInit, OnDestroy {
}
protected saveCipher(cipher: Cipher) {
const isNotClone = this.editMode && !this.cloneMode;
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
@ -709,7 +708,7 @@ export class AddEditComponent implements OnInit, OnDestroy {
return this.cipher.id == null
? this.cipherService.createWithServer(cipher, orgAdmin)
: this.cipherService.updateWithServer(cipher, orgAdmin, isNotClone);
: this.cipherService.updateWithServer(cipher, orgAdmin);
}
protected deleteCipher() {

View File

@ -229,11 +229,11 @@ describe("Cipher Service", () => {
});
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
.spyOn(apiService, "putCipherAdmin")
.mockImplementation(() => Promise.resolve<any>(cipherObj.toCipherData()));
await cipherService.updateWithServer(cipherObj, true, true);
await cipherService.updateWithServer(cipherObj, true);
const expectedObj = new CipherRequest(cipherObj);
expect(spy).toHaveBeenCalled();
@ -252,7 +252,7 @@ describe("Cipher Service", () => {
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;
const spy = jest
.spyOn(apiService, "putPartialCipher")

View File

@ -709,13 +709,9 @@ export class CipherService implements CipherServiceAbstraction {
return new Cipher(updated[cipher.id as CipherId]);
}
async updateWithServer(
cipher: Cipher,
orgAdmin?: boolean,
isNotClone?: boolean,
): Promise<Cipher> {
async updateWithServer(cipher: Cipher, orgAdmin?: boolean): Promise<Cipher> {
let response: CipherResponse;
if (orgAdmin && isNotClone) {
if (orgAdmin) {
const request = new CipherRequest(cipher);
response = await this.apiService.putCipherAdmin(cipher.id, request);
const data = new CipherData(response, cipher.collectionIds);

View File

@ -71,7 +71,6 @@ export class DefaultCipherFormService implements CipherFormService {
await this.cipherService.updateWithServer(
encryptedCipher,
config.admin || originalCollectionIds.size === 0,
config.mode !== "clone",
);
// Then save the new collection changes separately