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) {
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() {
const request = new CipherCollectionsRequest(this.cipherDomain.collectionIds);
return this.apiService.putCipherCollectionsAdmin(this.cipherId, request);
if (this.organization.isAdmin) {
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 class="col-9">
<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()">
<i class="fa fa-plus fa-fw"></i>{{'addItem' | i18n}}
</button>

View File

@ -34,6 +34,7 @@ export class CiphersComponent extends BaseCiphersComponent implements OnDestroy
@Output() onCollectionsClicked = new EventEmitter<CipherView>();
cipherType = CipherType;
actionPromise: Promise<any>;
private searchPipe: SearchCiphersPipe;
@ -91,6 +92,9 @@ export class CiphersComponent extends BaseCiphersComponent implements OnDestroy
}
async delete(c: CipherView): Promise<boolean> {
if (this.actionPromise != null) {
return;
}
const confirmed = await this.platformUtilsService.showDialog(
this.i18nService.t('deleteItemConfirmation'), this.i18nService.t('deleteItem'),
this.i18nService.t('yes'), this.i18nService.t('no'), 'warning');
@ -98,10 +102,14 @@ export class CiphersComponent extends BaseCiphersComponent implements OnDestroy
return false;
}
await this.cipherService.deleteWithServer(c.id);
this.analytics.eventTrack.next({ action: 'Deleted Cipher' });
this.toasterService.popAsync('success', null, this.i18nService.t('deletedItem'));
this.refresh();
try {
this.actionPromise = this.deleteCipher(c.id);
await this.actionPromise;
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) {
@ -114,4 +122,8 @@ export class CiphersComponent extends BaseCiphersComponent implements OnDestroy
this.toasterService.popAsync('info', null,
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 class="col-6">
<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="dropdown mr-2" appListDropdown>
<button class="btn btn-sm btn-outline-secondary dropdown-toggle" type="button" id="bulkActionsButton" data-toggle="dropdown"