mirror of
https://github.com/bitwarden/browser
synced 2025-12-14 23:33:31 +00:00
make manage the initial permission when clicking the add access badge (#16165)
This commit is contained in:
@@ -125,6 +125,7 @@ import { VaultFilter } from "../../../vault/individual-vault/vault-filter/shared
|
|||||||
import { AdminConsoleCipherFormConfigService } from "../../../vault/org-vault/services/admin-console-cipher-form-config.service";
|
import { AdminConsoleCipherFormConfigService } from "../../../vault/org-vault/services/admin-console-cipher-form-config.service";
|
||||||
import { GroupApiService, GroupView } from "../core";
|
import { GroupApiService, GroupView } from "../core";
|
||||||
import { openEntityEventsDialog } from "../manage/entity-events.component";
|
import { openEntityEventsDialog } from "../manage/entity-events.component";
|
||||||
|
import { CollectionPermission } from "../shared/components/access-selector";
|
||||||
import {
|
import {
|
||||||
CollectionDialogAction,
|
CollectionDialogAction,
|
||||||
CollectionDialogTabType,
|
CollectionDialogTabType,
|
||||||
@@ -879,6 +880,7 @@ export class vNextVaultComponent implements OnInit, OnDestroy {
|
|||||||
event.item as CollectionAdminView,
|
event.item as CollectionAdminView,
|
||||||
CollectionDialogTabType.Access,
|
CollectionDialogTabType.Access,
|
||||||
event.readonly,
|
event.readonly,
|
||||||
|
event.initialPermission,
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
case "bulkEditCollectionAccess":
|
case "bulkEditCollectionAccess":
|
||||||
@@ -1372,6 +1374,7 @@ export class vNextVaultComponent implements OnInit, OnDestroy {
|
|||||||
c: CollectionAdminView,
|
c: CollectionAdminView,
|
||||||
tab: CollectionDialogTabType,
|
tab: CollectionDialogTabType,
|
||||||
readonly: boolean,
|
readonly: boolean,
|
||||||
|
initialPermission?: CollectionPermission,
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const organization = await firstValueFrom(this.organization$);
|
const organization = await firstValueFrom(this.organization$);
|
||||||
const dialog = openCollectionDialog(this.dialogService, {
|
const dialog = openCollectionDialog(this.dialogService, {
|
||||||
@@ -1383,6 +1386,7 @@ export class vNextVaultComponent implements OnInit, OnDestroy {
|
|||||||
isAddAccessCollection: c.unmanaged,
|
isAddAccessCollection: c.unmanaged,
|
||||||
limitNestedCollections: !organization.canEditAnyCollection,
|
limitNestedCollections: !organization.canEditAnyCollection,
|
||||||
isAdminConsoleActive: true,
|
isAdminConsoleActive: true,
|
||||||
|
initialPermission,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -126,7 +126,6 @@ export class AccessSelectorComponent implements ControlValueAccessor, OnInit, On
|
|||||||
|
|
||||||
protected itemType = AccessItemType;
|
protected itemType = AccessItemType;
|
||||||
protected permissionList: Permission[];
|
protected permissionList: Permission[];
|
||||||
protected initialPermission = CollectionPermission.View;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* When disabled, the access selector will make the assumption that a readonly state is desired.
|
* When disabled, the access selector will make the assumption that a readonly state is desired.
|
||||||
@@ -208,6 +207,12 @@ export class AccessSelectorComponent implements ControlValueAccessor, OnInit, On
|
|||||||
*/
|
*/
|
||||||
@Input() hideMultiSelect = false;
|
@Input() hideMultiSelect = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The initial permission that will be selected in the dialog, defaults to View.
|
||||||
|
*/
|
||||||
|
@Input()
|
||||||
|
protected initialPermission: CollectionPermission = CollectionPermission.View;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private readonly formBuilder: FormBuilder,
|
private readonly formBuilder: FormBuilder,
|
||||||
private readonly i18nService: I18nService,
|
private readonly i18nService: I18nService,
|
||||||
|
|||||||
@@ -103,6 +103,7 @@
|
|||||||
[selectorLabelText]="'selectGroupsAndMembers' | i18n"
|
[selectorLabelText]="'selectGroupsAndMembers' | i18n"
|
||||||
[selectorHelpText]="'userPermissionOverrideHelperDesc' | i18n"
|
[selectorHelpText]="'userPermissionOverrideHelperDesc' | i18n"
|
||||||
[emptySelectionText]="'noMembersOrGroupsAdded' | i18n"
|
[emptySelectionText]="'noMembersOrGroupsAdded' | i18n"
|
||||||
|
[initialPermission]="initialPermission"
|
||||||
></bit-access-selector>
|
></bit-access-selector>
|
||||||
<bit-access-selector
|
<bit-access-selector
|
||||||
*ngIf="!organization.useGroups"
|
*ngIf="!organization.useGroups"
|
||||||
|
|||||||
@@ -92,6 +92,7 @@ export interface CollectionDialogParams {
|
|||||||
initialTab?: CollectionDialogTabType;
|
initialTab?: CollectionDialogTabType;
|
||||||
parentCollectionId?: string;
|
parentCollectionId?: string;
|
||||||
showOrgSelector?: boolean;
|
showOrgSelector?: boolean;
|
||||||
|
initialPermission?: CollectionPermission;
|
||||||
/**
|
/**
|
||||||
* Flag to limit the nested collections to only those the user has explicit CanManage access too.
|
* Flag to limit the nested collections to only those the user has explicit CanManage access too.
|
||||||
*/
|
*/
|
||||||
@@ -142,6 +143,7 @@ export class CollectionDialogComponent implements OnInit, OnDestroy {
|
|||||||
protected showDeleteButton = false;
|
protected showDeleteButton = false;
|
||||||
protected showAddAccessWarning = false;
|
protected showAddAccessWarning = false;
|
||||||
protected buttonDisplayName: ButtonType = ButtonType.Save;
|
protected buttonDisplayName: ButtonType = ButtonType.Save;
|
||||||
|
protected initialPermission: CollectionPermission;
|
||||||
private orgExceedingCollectionLimit!: Organization;
|
private orgExceedingCollectionLimit!: Organization;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
@@ -161,6 +163,7 @@ export class CollectionDialogComponent implements OnInit, OnDestroy {
|
|||||||
private configService: ConfigService,
|
private configService: ConfigService,
|
||||||
) {
|
) {
|
||||||
this.tabIndex = params.initialTab ?? CollectionDialogTabType.Info;
|
this.tabIndex = params.initialTab ?? CollectionDialogTabType.Info;
|
||||||
|
this.initialPermission = params.initialPermission ?? CollectionPermission.View;
|
||||||
}
|
}
|
||||||
|
|
||||||
async ngOnInit() {
|
async ngOnInit() {
|
||||||
|
|||||||
@@ -17,23 +17,32 @@
|
|||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td bitCell [ngClass]="RowHeightClass">
|
<td bitCell [ngClass]="RowHeightClass">
|
||||||
<button
|
<div class="tw-flex">
|
||||||
bitLink
|
<button
|
||||||
[disabled]="disabled"
|
bitLink
|
||||||
type="button"
|
[disabled]="disabled"
|
||||||
class="tw-flex tw-w-full tw-text-start tw-leading-snug"
|
type="button"
|
||||||
linkType="secondary"
|
class="tw-flex tw-text-start tw-leading-snug"
|
||||||
title="{{ 'viewCollectionWithName' | i18n: collection.name }}"
|
linkType="secondary"
|
||||||
[routerLink]="[]"
|
title="{{ 'viewCollectionWithName' | i18n: collection.name }}"
|
||||||
[queryParams]="{ collectionId: collection.id }"
|
[routerLink]="[]"
|
||||||
queryParamsHandling="merge"
|
[queryParams]="{ collectionId: collection.id }"
|
||||||
appStopProp
|
queryParamsHandling="merge"
|
||||||
>
|
appStopProp
|
||||||
<span class="tw-truncate tw-mr-1">{{ collection.name }}</span>
|
>
|
||||||
<div>
|
<span class="tw-truncate tw-mr-1">{{ collection.name }}</span>
|
||||||
<span *ngIf="showAddAccess" bitBadge variant="warning">{{ "addAccess" | i18n }}</span>
|
</button>
|
||||||
</div>
|
@if (showAddAccess) {
|
||||||
</button>
|
<button
|
||||||
|
bitBadge
|
||||||
|
type="button"
|
||||||
|
(click)="addAccess(CollectionPermission.Manage)"
|
||||||
|
variant="warning"
|
||||||
|
>
|
||||||
|
{{ "addAccess" | i18n }}
|
||||||
|
</button>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td bitCell [ngClass]="RowHeightClass" *ngIf="showOwner" class="tw-hidden lg:tw-table-cell">
|
<td bitCell [ngClass]="RowHeightClass" *ngIf="showOwner" class="tw-hidden lg:tw-table-cell">
|
||||||
<app-org-badge
|
<app-org-badge
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import { CipherViewLike } from "@bitwarden/common/vault/utils/cipher-view-like-u
|
|||||||
import { GroupView } from "../../../admin-console/organizations/core";
|
import { GroupView } from "../../../admin-console/organizations/core";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
CollectionPermission,
|
||||||
convertToPermission,
|
convertToPermission,
|
||||||
getPermissionList,
|
getPermissionList,
|
||||||
} from "./../../../admin-console/organizations/shared/components/access-selector/access-selector.models";
|
} from "./../../../admin-console/organizations/shared/components/access-selector/access-selector.models";
|
||||||
@@ -24,6 +25,7 @@ import { RowHeightClass } from "./vault-items.component";
|
|||||||
export class VaultCollectionRowComponent<C extends CipherViewLike> {
|
export class VaultCollectionRowComponent<C extends CipherViewLike> {
|
||||||
protected RowHeightClass = RowHeightClass;
|
protected RowHeightClass = RowHeightClass;
|
||||||
protected Unassigned = "unassigned";
|
protected Unassigned = "unassigned";
|
||||||
|
protected CollectionPermission = CollectionPermission;
|
||||||
|
|
||||||
@Input() disabled: boolean;
|
@Input() disabled: boolean;
|
||||||
@Input() collection: CollectionView;
|
@Input() collection: CollectionView;
|
||||||
@@ -102,6 +104,15 @@ export class VaultCollectionRowComponent<C extends CipherViewLike> {
|
|||||||
this.onEvent.next({ type: "viewCollectionAccess", item: this.collection, readonly: readonly });
|
this.onEvent.next({ type: "viewCollectionAccess", item: this.collection, readonly: readonly });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected addAccess(initialPermission: CollectionPermission) {
|
||||||
|
this.onEvent.next({
|
||||||
|
type: "viewCollectionAccess",
|
||||||
|
item: this.collection,
|
||||||
|
readonly: false,
|
||||||
|
initialPermission,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
protected deleteCollection() {
|
protected deleteCollection() {
|
||||||
this.onEvent.next({ type: "delete", items: [{ collection: this.collection }] });
|
this.onEvent.next({ type: "delete", items: [{ collection: this.collection }] });
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,18 @@
|
|||||||
import { CollectionView } from "@bitwarden/admin-console/common";
|
import { CollectionView } from "@bitwarden/admin-console/common";
|
||||||
import { CipherViewLike } from "@bitwarden/common/vault/utils/cipher-view-like-utils";
|
import { CipherViewLike } from "@bitwarden/common/vault/utils/cipher-view-like-utils";
|
||||||
|
import { CollectionPermission } from "@bitwarden/web-vault/app/admin-console/organizations/shared/components/access-selector";
|
||||||
|
|
||||||
import { VaultItem } from "./vault-item";
|
import { VaultItem } from "./vault-item";
|
||||||
|
|
||||||
export type VaultItemEvent<C extends CipherViewLike> =
|
export type VaultItemEvent<C extends CipherViewLike> =
|
||||||
| { type: "viewAttachments"; item: C }
|
| { type: "viewAttachments"; item: C }
|
||||||
| { type: "bulkEditCollectionAccess"; items: CollectionView[] }
|
| { type: "bulkEditCollectionAccess"; items: CollectionView[] }
|
||||||
| { type: "viewCollectionAccess"; item: CollectionView; readonly: boolean }
|
| {
|
||||||
|
type: "viewCollectionAccess";
|
||||||
|
item: CollectionView;
|
||||||
|
readonly: boolean;
|
||||||
|
initialPermission?: CollectionPermission;
|
||||||
|
}
|
||||||
| { type: "viewEvents"; item: C }
|
| { type: "viewEvents"; item: C }
|
||||||
| { type: "editCollection"; item: CollectionView; readonly: boolean }
|
| { type: "editCollection"; item: CollectionView; readonly: boolean }
|
||||||
| { type: "clone"; item: C }
|
| { type: "clone"; item: C }
|
||||||
|
|||||||
Reference in New Issue
Block a user