mirror of
https://github.com/bitwarden/browser.git
synced 2024-11-30 13:03:53 +01:00
add ownership and collection assignment from add/edit
This commit is contained in:
parent
726c323fe1
commit
5e7c9a7278
2
jslib
2
jslib
@ -1 +1 @@
|
|||||||
Subproject commit d1f7a97011f043a6225f603e71f0565acbe7dcdd
|
Subproject commit c946f01b5fbe5b84b928ae8dd4ad54a15dd1803d
|
@ -1,11 +1,9 @@
|
|||||||
import {
|
import { Component } from '@angular/core';
|
||||||
Component,
|
|
||||||
OnInit,
|
|
||||||
} from '@angular/core';
|
|
||||||
|
|
||||||
import { ApiService } from 'jslib/abstractions/api.service';
|
import { ApiService } from 'jslib/abstractions/api.service';
|
||||||
import { AuditService } from 'jslib/abstractions/audit.service';
|
import { AuditService } from 'jslib/abstractions/audit.service';
|
||||||
import { CipherService } from 'jslib/abstractions/cipher.service';
|
import { CipherService } from 'jslib/abstractions/cipher.service';
|
||||||
|
import { CollectionService } from 'jslib/abstractions/collection.service';
|
||||||
import { FolderService } from 'jslib/abstractions/folder.service';
|
import { FolderService } from 'jslib/abstractions/folder.service';
|
||||||
import { I18nService } from 'jslib/abstractions/i18n.service';
|
import { I18nService } from 'jslib/abstractions/i18n.service';
|
||||||
import { MessagingService } from 'jslib/abstractions/messaging.service';
|
import { MessagingService } from 'jslib/abstractions/messaging.service';
|
||||||
@ -18,6 +16,7 @@ import { UserService } from 'jslib/abstractions/user.service';
|
|||||||
import { CipherData } from 'jslib/models/data/cipherData';
|
import { CipherData } from 'jslib/models/data/cipherData';
|
||||||
import { Cipher } from 'jslib/models/domain/cipher';
|
import { Cipher } from 'jslib/models/domain/cipher';
|
||||||
import { Organization } from 'jslib/models/domain/organization';
|
import { Organization } from 'jslib/models/domain/organization';
|
||||||
|
import { CipherCreateRequest } from 'jslib/models/request/cipherCreateRequest';
|
||||||
import { CipherRequest } from 'jslib/models/request/cipherRequest';
|
import { CipherRequest } from 'jslib/models/request/cipherRequest';
|
||||||
|
|
||||||
import { AddEditComponent as BaseAddEditComponent } from '../../vault/add-edit.component';
|
import { AddEditComponent as BaseAddEditComponent } from '../../vault/add-edit.component';
|
||||||
@ -26,18 +25,27 @@ import { AddEditComponent as BaseAddEditComponent } from '../../vault/add-edit.c
|
|||||||
selector: 'app-org-vault-add-edit',
|
selector: 'app-org-vault-add-edit',
|
||||||
templateUrl: '../../vault/add-edit.component.html',
|
templateUrl: '../../vault/add-edit.component.html',
|
||||||
})
|
})
|
||||||
export class AddEditComponent extends BaseAddEditComponent implements OnInit {
|
export class AddEditComponent extends BaseAddEditComponent {
|
||||||
organization: Organization;
|
organization: Organization;
|
||||||
originalCipher: Cipher = null;
|
originalCipher: Cipher = null;
|
||||||
|
|
||||||
constructor(cipherService: CipherService, folderService: FolderService,
|
constructor(cipherService: CipherService, folderService: FolderService,
|
||||||
i18nService: I18nService, platformUtilsService: PlatformUtilsService,
|
i18nService: I18nService, platformUtilsService: PlatformUtilsService,
|
||||||
auditService: AuditService, stateService: StateService,
|
auditService: AuditService, stateService: StateService,
|
||||||
userService: UserService, totpService: TotpService,
|
userService: UserService, collectionService: CollectionService,
|
||||||
passwordGenerationService: PasswordGenerationService, private apiService: ApiService,
|
totpService: TotpService, passwordGenerationService: PasswordGenerationService,
|
||||||
|
private apiService: ApiService,
|
||||||
messagingService: MessagingService) {
|
messagingService: MessagingService) {
|
||||||
super(cipherService, folderService, i18nService, platformUtilsService, auditService, stateService,
|
super(cipherService, folderService, i18nService, platformUtilsService, auditService, stateService,
|
||||||
userService, totpService, passwordGenerationService, messagingService);
|
userService, collectionService, totpService, passwordGenerationService, messagingService);
|
||||||
|
}
|
||||||
|
|
||||||
|
async load() {
|
||||||
|
await super.load();
|
||||||
|
if (!this.editMode) {
|
||||||
|
this.cipher.organizationId = this.organization.id;
|
||||||
|
}
|
||||||
|
await this.organizationChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected async loadCipher() {
|
protected async loadCipher() {
|
||||||
@ -51,9 +59,6 @@ export class AddEditComponent extends BaseAddEditComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected encryptCipher() {
|
protected encryptCipher() {
|
||||||
if (!this.editMode) {
|
|
||||||
this.cipher.organizationId = this.organization.id;
|
|
||||||
}
|
|
||||||
if (!this.organization.isAdmin) {
|
if (!this.organization.isAdmin) {
|
||||||
return super.encryptCipher();
|
return super.encryptCipher();
|
||||||
}
|
}
|
||||||
@ -64,10 +69,11 @@ export class AddEditComponent extends BaseAddEditComponent implements OnInit {
|
|||||||
if (!this.organization.isAdmin) {
|
if (!this.organization.isAdmin) {
|
||||||
return super.saveCipher(cipher);
|
return super.saveCipher(cipher);
|
||||||
}
|
}
|
||||||
const request = new CipherRequest(cipher);
|
|
||||||
if (this.editMode) {
|
if (this.editMode) {
|
||||||
|
const request = new CipherRequest(cipher);
|
||||||
return this.apiService.putCipherAdmin(this.cipherId, request);
|
return this.apiService.putCipherAdmin(this.cipherId, request);
|
||||||
} else {
|
} else {
|
||||||
|
const request = new CipherCreateRequest(cipher);
|
||||||
return this.apiService.postCipherAdmin(request);
|
return this.apiService.postCipherAdmin(request);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -83,7 +83,7 @@
|
|||||||
<a href="#" appStopClick class="badge badge-primary ml-3" (click)="premiumRequired()" *ngIf="!organization && !cipher.organizationId && !canAccessPremium">
|
<a href="#" appStopClick class="badge badge-primary ml-3" (click)="premiumRequired()" *ngIf="!organization && !cipher.organizationId && !canAccessPremium">
|
||||||
{{'premium' | i18n}}
|
{{'premium' | i18n}}
|
||||||
</a>
|
</a>
|
||||||
<a href="#" appStopClick class="badge badge-primary ml-3" (click)="upgradeOrganization()" *ngIf="(organization && !organization.useTotp) || (cipher.organizationId && !cipher.organizationUseTotp)">
|
<a href="#" appStopClick class="badge badge-primary ml-3" (click)="upgradeOrganization()" *ngIf="(organization && !organization.useTotp) || (!organization && !canAccessPremium && cipher.organizationId && !cipher.organizationUseTotp)">
|
||||||
{{'upgrade' | i18n}}
|
{{'upgrade' | i18n}}
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
@ -366,6 +366,30 @@
|
|||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<ng-container *ngIf="!editMode && !organization && ownershipOptions && ownershipOptions.length > 1">
|
||||||
|
<h3 class="mt-4">{{'ownership' | i18n}}</h3>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-5">
|
||||||
|
<label for="organizationId">{{'whoOwnsThisItem' | i18n}}</label>
|
||||||
|
<select id="organizationId" class="form-control" name="OrganizationId" [(ngModel)]="cipher.organizationId"
|
||||||
|
(change)="organizationChanged()">
|
||||||
|
<option *ngFor="let o of ownershipOptions" [ngValue]="o.value">{{o.name}}</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</ng-container>
|
||||||
|
<ng-container *ngIf="!editMode && cipher.organizationId">
|
||||||
|
<h3 class="mt-4">{{'collections' | i18n}}</h3>
|
||||||
|
<div *ngIf="!collections || !collections.length">
|
||||||
|
{{'noCollectionsInList' | i18n}}
|
||||||
|
</div>
|
||||||
|
<ng-container *ngIf="collections && collections.length">
|
||||||
|
<div class="form-check" *ngFor="let c of collections; let i = index">
|
||||||
|
<input class="form-check-input" type="checkbox" [(ngModel)]="c.checked" id="collection-{{i}}" name="Collection[{{i}}].Checked">
|
||||||
|
<label class="form-check-label" for="collection-{{i}}">{{c.name}}</label>
|
||||||
|
</div>
|
||||||
|
</ng-container>
|
||||||
|
</ng-container>
|
||||||
<ng-container *ngIf="editMode">
|
<ng-container *ngIf="editMode">
|
||||||
<div class="small text-muted mt-4">
|
<div class="small text-muted mt-4">
|
||||||
<div>
|
<div>
|
||||||
|
@ -1,12 +1,10 @@
|
|||||||
import {
|
import { Component } from '@angular/core';
|
||||||
Component,
|
|
||||||
OnInit,
|
|
||||||
} from '@angular/core';
|
|
||||||
|
|
||||||
import { CipherType } from 'jslib/enums/cipherType';
|
import { CipherType } from 'jslib/enums/cipherType';
|
||||||
|
|
||||||
import { AuditService } from 'jslib/abstractions/audit.service';
|
import { AuditService } from 'jslib/abstractions/audit.service';
|
||||||
import { CipherService } from 'jslib/abstractions/cipher.service';
|
import { CipherService } from 'jslib/abstractions/cipher.service';
|
||||||
|
import { CollectionService } from 'jslib/abstractions/collection.service';
|
||||||
import { FolderService } from 'jslib/abstractions/folder.service';
|
import { FolderService } from 'jslib/abstractions/folder.service';
|
||||||
import { I18nService } from 'jslib/abstractions/i18n.service';
|
import { I18nService } from 'jslib/abstractions/i18n.service';
|
||||||
import { MessagingService } from 'jslib/abstractions/messaging.service';
|
import { MessagingService } from 'jslib/abstractions/messaging.service';
|
||||||
@ -23,7 +21,7 @@ import { LoginUriView } from 'jslib/models/view/loginUriView';
|
|||||||
selector: 'app-vault-add-edit',
|
selector: 'app-vault-add-edit',
|
||||||
templateUrl: 'add-edit.component.html',
|
templateUrl: 'add-edit.component.html',
|
||||||
})
|
})
|
||||||
export class AddEditComponent extends BaseAddEditComponent implements OnInit {
|
export class AddEditComponent extends BaseAddEditComponent {
|
||||||
canAccessPremium: boolean;
|
canAccessPremium: boolean;
|
||||||
totpCode: string;
|
totpCode: string;
|
||||||
totpCodeFormatted: string;
|
totpCodeFormatted: string;
|
||||||
@ -39,13 +37,16 @@ export class AddEditComponent extends BaseAddEditComponent implements OnInit {
|
|||||||
constructor(cipherService: CipherService, folderService: FolderService,
|
constructor(cipherService: CipherService, folderService: FolderService,
|
||||||
i18nService: I18nService, platformUtilsService: PlatformUtilsService,
|
i18nService: I18nService, platformUtilsService: PlatformUtilsService,
|
||||||
auditService: AuditService, stateService: StateService,
|
auditService: AuditService, stateService: StateService,
|
||||||
protected userService: UserService, protected totpService: TotpService,
|
userService: UserService, collectionService: CollectionService,
|
||||||
protected passwordGenerationService: PasswordGenerationService, protected messagingService: MessagingService) {
|
protected totpService: TotpService, protected passwordGenerationService: PasswordGenerationService,
|
||||||
super(cipherService, folderService, i18nService, platformUtilsService, auditService, stateService);
|
protected messagingService: MessagingService) {
|
||||||
|
super(cipherService, folderService, i18nService, platformUtilsService, auditService, stateService,
|
||||||
|
userService, collectionService);
|
||||||
}
|
}
|
||||||
|
|
||||||
async ngOnInit() {
|
async ngOnInit() {
|
||||||
await super.load();
|
await super.ngOnInit();
|
||||||
|
await this.load();
|
||||||
this.showRevisionDate = this.cipher.passwordRevisionDisplayDate != null;
|
this.showRevisionDate = this.cipher.passwordRevisionDisplayDate != null;
|
||||||
this.hasPasswordHistory = this.cipher.hasPasswordHistory;
|
this.hasPasswordHistory = this.cipher.hasPasswordHistory;
|
||||||
this.cleanUp();
|
this.cleanUp();
|
||||||
|
@ -2498,5 +2498,11 @@
|
|||||||
},
|
},
|
||||||
"selected": {
|
"selected": {
|
||||||
"message": "Selected"
|
"message": "Selected"
|
||||||
|
},
|
||||||
|
"ownership": {
|
||||||
|
"message": "Ownership"
|
||||||
|
},
|
||||||
|
"whoOwnsThisItem": {
|
||||||
|
"message": "Who owns this item?"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user