mirror of
https://github.com/bitwarden/browser.git
synced 2024-11-29 12:55:21 +01:00
[PM-10833] Add cipher types to "new" dropdown in admin console (#10614)
* Add cipher types to "new" dropdown in admin console. * Keep feature flag code consistent.
This commit is contained in:
parent
5b4e4d8f1a
commit
7564c4aa7c
@ -113,10 +113,32 @@
|
|||||||
{{ "new" | i18n }}<i class="bwi bwi-angle-down tw-ml-2" aria-hidden="true"></i>
|
{{ "new" | i18n }}<i class="bwi bwi-angle-down tw-ml-2" aria-hidden="true"></i>
|
||||||
</button>
|
</button>
|
||||||
<bit-menu #addOptions aria-labelledby="newItemDropdown">
|
<bit-menu #addOptions aria-labelledby="newItemDropdown">
|
||||||
<button type="button" bitMenuItem (click)="addCipher()">
|
<ng-container [ngSwitch]="extensionRefreshEnabled">
|
||||||
<i class="bwi bwi-fw bwi-globe" aria-hidden="true"></i>
|
<ng-container *ngSwitchCase="true">
|
||||||
{{ "item" | i18n }}
|
<button type="button" bitMenuItem (click)="addCipher(CipherType.Login)">
|
||||||
</button>
|
<i class="bwi bwi-globe" slot="start" aria-hidden="true"></i>
|
||||||
|
{{ "typeLogin" | i18n }}
|
||||||
|
</button>
|
||||||
|
<button type="button" bitMenuItem (click)="addCipher(CipherType.Card)">
|
||||||
|
<i class="bwi bwi-credit-card" slot="start" aria-hidden="true"></i>
|
||||||
|
{{ "typeCard" | i18n }}
|
||||||
|
</button>
|
||||||
|
<button type="button" bitMenuItem (click)="addCipher(CipherType.Identity)">
|
||||||
|
<i class="bwi bwi-id-card" slot="start" aria-hidden="true"></i>
|
||||||
|
{{ "typeIdentity" | i18n }}
|
||||||
|
</button>
|
||||||
|
<button type="button" bitMenuItem (click)="addCipher(CipherType.SecureNote)">
|
||||||
|
<i class="bwi bwi-sticky-note" slot="start" aria-hidden="true"></i>
|
||||||
|
{{ "note" | i18n }}
|
||||||
|
</button>
|
||||||
|
</ng-container>
|
||||||
|
<ng-container *ngSwitchCase="false">
|
||||||
|
<button type="button" bitMenuItem (click)="addCipher()">
|
||||||
|
<i class="bwi bwi-fw bwi-globe" aria-hidden="true"></i>
|
||||||
|
{{ "item" | i18n }}
|
||||||
|
</button>
|
||||||
|
</ng-container>
|
||||||
|
</ng-container>
|
||||||
<button type="button" bitMenuItem (click)="addCollection()">
|
<button type="button" bitMenuItem (click)="addCollection()">
|
||||||
<i class="bwi bwi-fw bwi-collection" aria-hidden="true"></i>
|
<i class="bwi bwi-fw bwi-collection" aria-hidden="true"></i>
|
||||||
{{ "collection" | i18n }}
|
{{ "collection" | i18n }}
|
||||||
|
@ -10,6 +10,7 @@ import { ProductTierType } from "@bitwarden/common/billing/enums";
|
|||||||
import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum";
|
import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum";
|
||||||
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";
|
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";
|
||||||
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
||||||
|
import { CipherType } from "@bitwarden/common/vault/enums";
|
||||||
import { TreeNode } from "@bitwarden/common/vault/models/domain/tree-node";
|
import { TreeNode } from "@bitwarden/common/vault/models/domain/tree-node";
|
||||||
import {
|
import {
|
||||||
DialogService,
|
DialogService,
|
||||||
@ -67,7 +68,7 @@ export class VaultHeaderComponent implements OnInit {
|
|||||||
@Input() searchText: string;
|
@Input() searchText: string;
|
||||||
|
|
||||||
/** Emits an event when the new item button is clicked in the header */
|
/** Emits an event when the new item button is clicked in the header */
|
||||||
@Output() onAddCipher = new EventEmitter<void>();
|
@Output() onAddCipher = new EventEmitter<CipherType | undefined>();
|
||||||
|
|
||||||
/** Emits an event when the new collection button is clicked in the header */
|
/** Emits an event when the new collection button is clicked in the header */
|
||||||
@Output() onAddCollection = new EventEmitter<void>();
|
@Output() onAddCollection = new EventEmitter<void>();
|
||||||
@ -89,6 +90,14 @@ export class VaultHeaderComponent implements OnInit {
|
|||||||
|
|
||||||
protected restrictProviderAccessFlag = false;
|
protected restrictProviderAccessFlag = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether the extension refresh feature flag is enabled.
|
||||||
|
*/
|
||||||
|
protected extensionRefreshEnabled = false;
|
||||||
|
|
||||||
|
/** The cipher type enum. */
|
||||||
|
protected CipherType = CipherType;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private organizationService: OrganizationService,
|
private organizationService: OrganizationService,
|
||||||
private i18nService: I18nService,
|
private i18nService: I18nService,
|
||||||
@ -102,6 +111,9 @@ export class VaultHeaderComponent implements OnInit {
|
|||||||
this.restrictProviderAccessFlag = await this.configService.getFeatureFlag(
|
this.restrictProviderAccessFlag = await this.configService.getFeatureFlag(
|
||||||
FeatureFlag.RestrictProviderAccess,
|
FeatureFlag.RestrictProviderAccess,
|
||||||
);
|
);
|
||||||
|
this.extensionRefreshEnabled = await this.configService.getFeatureFlag(
|
||||||
|
FeatureFlag.ExtensionRefresh,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
get title() {
|
get title() {
|
||||||
@ -194,8 +206,8 @@ export class VaultHeaderComponent implements OnInit {
|
|||||||
return this.collection.node.canEdit(this.organization);
|
return this.collection.node.canEdit(this.organization);
|
||||||
}
|
}
|
||||||
|
|
||||||
addCipher() {
|
addCipher(cipherType?: CipherType) {
|
||||||
this.onAddCipher.emit();
|
this.onAddCipher.emit(cipherType);
|
||||||
}
|
}
|
||||||
|
|
||||||
async addCollection() {
|
async addCollection() {
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
[organization]="organization"
|
[organization]="organization"
|
||||||
[collection]="selectedCollection"
|
[collection]="selectedCollection"
|
||||||
[searchText]="currentSearchText$ | async"
|
[searchText]="currentSearchText$ | async"
|
||||||
(onAddCipher)="addCipher()"
|
(onAddCipher)="addCipher($event)"
|
||||||
(onAddCollection)="addCollection()"
|
(onAddCollection)="addCollection()"
|
||||||
(onEditCollection)="editCollection(selectedCollection.node, $event.tab, $event.readonly)"
|
(onEditCollection)="editCollection(selectedCollection.node, $event.tab, $event.readonly)"
|
||||||
(onDeleteCollection)="deleteCollection(selectedCollection.node)"
|
(onDeleteCollection)="deleteCollection(selectedCollection.node)"
|
||||||
|
@ -54,6 +54,7 @@ import { OrganizationId } from "@bitwarden/common/types/guid";
|
|||||||
import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service";
|
import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service";
|
||||||
import { CollectionService } from "@bitwarden/common/vault/abstractions/collection.service";
|
import { CollectionService } from "@bitwarden/common/vault/abstractions/collection.service";
|
||||||
import { TotpService } from "@bitwarden/common/vault/abstractions/totp.service";
|
import { TotpService } from "@bitwarden/common/vault/abstractions/totp.service";
|
||||||
|
import { CipherType } from "@bitwarden/common/vault/enums";
|
||||||
import { CipherRepromptType } from "@bitwarden/common/vault/enums/cipher-reprompt-type";
|
import { CipherRepromptType } from "@bitwarden/common/vault/enums/cipher-reprompt-type";
|
||||||
import { TreeNode } from "@bitwarden/common/vault/models/domain/tree-node";
|
import { TreeNode } from "@bitwarden/common/vault/models/domain/tree-node";
|
||||||
import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
|
import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
|
||||||
@ -786,14 +787,14 @@ export class VaultComponent implements OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async addCipher() {
|
async addCipher(cipherType?: CipherType) {
|
||||||
let collections: CollectionView[] = [];
|
let collections: CollectionView[] = [];
|
||||||
|
|
||||||
// Admins limited to only adding items to collections they have access to.
|
// Admins limited to only adding items to collections they have access to.
|
||||||
collections = await firstValueFrom(this.editableCollections$);
|
collections = await firstValueFrom(this.editableCollections$);
|
||||||
|
|
||||||
await this.editCipher(null, (comp) => {
|
await this.editCipher(null, (comp) => {
|
||||||
comp.type = this.activeFilter.cipherType;
|
comp.type = cipherType || this.activeFilter.cipherType;
|
||||||
comp.collections = collections;
|
comp.collections = collections;
|
||||||
if (this.activeFilter.collectionId) {
|
if (this.activeFilter.collectionId) {
|
||||||
comp.collectionIds = [this.activeFilter.collectionId];
|
comp.collectionIds = [this.activeFilter.collectionId];
|
||||||
|
Loading…
Reference in New Issue
Block a user