1
0
mirror of https://github.com/bitwarden/web synced 2025-12-15 07:43:16 +00:00

fixes for non-admin actions on org vault list

This commit is contained in:
Kyle Spearrin
2018-07-27 22:36:25 -04:00
parent 7c882ed40c
commit dc69887628
5 changed files with 41 additions and 8 deletions

View File

@@ -76,4 +76,11 @@ export class CiphersComponent extends BaseCiphersComponent {
events(c: CipherView) { events(c: CipherView) {
this.onEventsClicked.emit(c); this.onEventsClicked.emit(c);
} }
protected deleteCipher(id: string) {
if (!this.organization.isAdmin) {
return super.deleteCipher(id);
}
return this.apiService.deleteCipherAdmin(id);
}
} }

View File

@@ -51,7 +51,11 @@ export class CollectionsComponent extends BaseCollectionsComponent {
} }
protected saveCollections() { protected saveCollections() {
const request = new CipherCollectionsRequest(this.cipherDomain.collectionIds); if (this.organization.isAdmin) {
return this.apiService.putCipherCollectionsAdmin(this.cipherId, request); const request = new CipherCollectionsRequest(this.cipherDomain.collectionIds);
return this.apiService.putCipherCollectionsAdmin(this.cipherId, request);
} else {
return super.saveCollections();
}
} }
} }

View File

@@ -7,7 +7,12 @@
</div> </div>
<div class="col-9"> <div class="col-9">
<div class="page-header d-flex"> <div class="page-header d-flex">
<h1>{{'vault' | i18n}}</h1> <h1>
{{'vault' | i18n}}
<small #actionSpinner [appApiAction]="ciphersComponent.actionPromise">
<i *ngIf="actionSpinner.loading" class="fa fa-spinner fa-spin text-muted" title="{{'loading' | i18n}}"></i>
</small>
</h1>
<button type="button" class="btn btn-outline-primary btn-sm ml-auto" (click)="addCipher()"> <button type="button" class="btn btn-outline-primary btn-sm ml-auto" (click)="addCipher()">
<i class="fa fa-plus fa-fw"></i>{{'addItem' | i18n}} <i class="fa fa-plus fa-fw"></i>{{'addItem' | i18n}}
</button> </button>

View File

@@ -34,6 +34,7 @@ export class CiphersComponent extends BaseCiphersComponent implements OnDestroy
@Output() onCollectionsClicked = new EventEmitter<CipherView>(); @Output() onCollectionsClicked = new EventEmitter<CipherView>();
cipherType = CipherType; cipherType = CipherType;
actionPromise: Promise<any>;
private searchPipe: SearchCiphersPipe; private searchPipe: SearchCiphersPipe;
@@ -91,6 +92,9 @@ export class CiphersComponent extends BaseCiphersComponent implements OnDestroy
} }
async delete(c: CipherView): Promise<boolean> { async delete(c: CipherView): Promise<boolean> {
if (this.actionPromise != null) {
return;
}
const confirmed = await this.platformUtilsService.showDialog( const confirmed = await this.platformUtilsService.showDialog(
this.i18nService.t('deleteItemConfirmation'), this.i18nService.t('deleteItem'), this.i18nService.t('deleteItemConfirmation'), this.i18nService.t('deleteItem'),
this.i18nService.t('yes'), this.i18nService.t('no'), 'warning'); this.i18nService.t('yes'), this.i18nService.t('no'), 'warning');
@@ -98,10 +102,14 @@ export class CiphersComponent extends BaseCiphersComponent implements OnDestroy
return false; return false;
} }
await this.cipherService.deleteWithServer(c.id); try {
this.analytics.eventTrack.next({ action: 'Deleted Cipher' }); this.actionPromise = this.deleteCipher(c.id);
this.toasterService.popAsync('success', null, this.i18nService.t('deletedItem')); await this.actionPromise;
this.refresh(); this.analytics.eventTrack.next({ action: 'Deleted Cipher' });
this.toasterService.popAsync('success', null, this.i18nService.t('deletedItem'));
this.refresh();
} catch { }
this.actionPromise = null;
} }
copy(value: string, typeI18nKey: string, aType: string) { copy(value: string, typeI18nKey: string, aType: string) {
@@ -114,4 +122,8 @@ export class CiphersComponent extends BaseCiphersComponent implements OnDestroy
this.toasterService.popAsync('info', null, this.toasterService.popAsync('info', null,
this.i18nService.t('valueCopied', this.i18nService.t(typeI18nKey))); this.i18nService.t('valueCopied', this.i18nService.t(typeI18nKey)));
} }
protected deleteCipher(id: string) {
return this.cipherService.deleteWithServer(id);
}
} }

View File

@@ -8,7 +8,12 @@
</div> </div>
<div class="col-6"> <div class="col-6">
<div class="page-header d-flex"> <div class="page-header d-flex">
<h1>{{'myVault' | i18n}}</h1> <h1>
{{'myVault' | i18n}}
<small #actionSpinner [appApiAction]="ciphersComponent.actionPromise">
<i *ngIf="actionSpinner.loading" class="fa fa-spinner fa-spin text-muted" title="{{'loading' | i18n}}"></i>
</small>
</h1>
<div class="ml-auto d-flex"> <div class="ml-auto d-flex">
<div class="dropdown mr-2" appListDropdown> <div class="dropdown mr-2" appListDropdown>
<button class="btn btn-sm btn-outline-secondary dropdown-toggle" type="button" id="bulkActionsButton" data-toggle="dropdown" <button class="btn btn-sm btn-outline-secondary dropdown-toggle" type="button" id="bulkActionsButton" data-toggle="dropdown"