Browse Source
* WIP * switch to signal * fix ts strict errors * clean up * refactor policy list service * implement vnext component * refactor to include feature flag check in display() * CR feedback * refactor submit to cancel before request is built * clean up * Fix typo --------- Co-authored-by: Thomas Rittson <31796059+eliykat@users.noreply.github.com>pull/15923/head
17 changed files with 276 additions and 76 deletions
@ -1,38 +1,45 @@
@@ -1,38 +1,45 @@
|
||||
<app-header> |
||||
@let organization = organization$ | async; |
||||
<button |
||||
bitBadge |
||||
class="!tw-align-middle" |
||||
(click)="changePlan(organization)" |
||||
*ngIf="isBreadcrumbingEnabled$ | async" |
||||
slot="title-suffix" |
||||
type="button" |
||||
variant="primary" |
||||
> |
||||
{{ "upgrade" | i18n }} |
||||
</button> |
||||
@if (isBreadcrumbingEnabled$ | async) { |
||||
<button |
||||
bitBadge |
||||
class="!tw-align-middle" |
||||
(click)="changePlan(organization)" |
||||
slot="title-suffix" |
||||
type="button" |
||||
variant="primary" |
||||
> |
||||
{{ "upgrade" | i18n }} |
||||
</button> |
||||
} |
||||
</app-header> |
||||
|
||||
<bit-container> |
||||
<ng-container *ngIf="loading"> |
||||
@if (loading) { |
||||
<i |
||||
class="bwi bwi-spinner bwi-spin tw-text-muted" |
||||
title="{{ 'loading' | i18n }}" |
||||
aria-hidden="true" |
||||
></i> |
||||
<span class="tw-sr-only">{{ "loading" | i18n }}</span> |
||||
</ng-container> |
||||
<bit-table *ngIf="!loading"> |
||||
<ng-template body> |
||||
<tr bitRow *ngFor="let p of policies"> |
||||
<td bitCell *ngIf="p.display(organization)" ngPreserveWhitespaces> |
||||
<button type="button" bitLink (click)="edit(p)">{{ p.name | i18n }}</button> |
||||
<span bitBadge variant="success" *ngIf="policiesEnabledMap.get(p.type)">{{ |
||||
"on" | i18n |
||||
}}</span> |
||||
<small class="tw-text-muted tw-block">{{ p.description | i18n }}</small> |
||||
</td> |
||||
</tr> |
||||
</ng-template> |
||||
</bit-table> |
||||
} |
||||
@if (!loading) { |
||||
<bit-table> |
||||
<ng-template body> |
||||
@for (p of policies; track p.name) { |
||||
@if (p.display(organization, configService) | async) { |
||||
<tr bitRow> |
||||
<td bitCell ngPreserveWhitespaces> |
||||
<button type="button" bitLink (click)="edit(p)">{{ p.name | i18n }}</button> |
||||
@if (policiesEnabledMap.get(p.type)) { |
||||
<span bitBadge variant="success">{{ "on" | i18n }}</span> |
||||
} |
||||
<small class="tw-text-muted tw-block">{{ p.description | i18n }}</small> |
||||
</td> |
||||
</tr> |
||||
} |
||||
} |
||||
</ng-template> |
||||
</bit-table> |
||||
} |
||||
</bit-container> |
||||
|
||||
@ -0,0 +1,57 @@
@@ -0,0 +1,57 @@
|
||||
<p> |
||||
{{ "organizationDataOwnershipContent" | i18n }} |
||||
<a |
||||
bitLink |
||||
href="https://bitwarden.com/resources/credential-lifecycle-management/" |
||||
target="_blank" |
||||
> |
||||
{{ "organizationDataOwnershipContentAnchor" | i18n }}. |
||||
</a> |
||||
</p> |
||||
|
||||
<bit-form-control> |
||||
<input type="checkbox" bitCheckbox [formControl]="enabled" id="enabled" /> |
||||
<bit-label>{{ "turnOn" | i18n }}</bit-label> |
||||
</bit-form-control> |
||||
|
||||
<ng-template #dialog> |
||||
<bit-simple-dialog background="alt"> |
||||
<span bitDialogTitle>{{ "organizationDataOwnershipWarningTitle" | i18n }}</span> |
||||
<ng-container bitDialogContent> |
||||
<div class="tw-text-left tw-overflow-hidden"> |
||||
{{ "organizationDataOwnershipWarningContentTop" | i18n }} |
||||
<div class="tw-flex tw-flex-col tw-p-2"> |
||||
<ul class="tw-list-disc tw-pl-5 tw-space-y-2 tw-break-words tw-mb-0"> |
||||
<li> |
||||
{{ "organizationDataOwnershipWarning1" | i18n }} |
||||
</li> |
||||
<li> |
||||
{{ "organizationDataOwnershipWarning2" | i18n }} |
||||
</li> |
||||
<li> |
||||
{{ "organizationDataOwnershipWarning3" | i18n }} |
||||
</li> |
||||
</ul> |
||||
</div> |
||||
{{ "organizationDataOwnershipWarningContentBottom" | i18n }} |
||||
<a |
||||
bitLink |
||||
href="https://bitwarden.com/resources/credential-lifecycle-management/" |
||||
target="_blank" |
||||
> |
||||
{{ "organizationDataOwnershipContentAnchor" | i18n }}. |
||||
</a> |
||||
</div> |
||||
</ng-container> |
||||
<ng-container bitDialogFooter> |
||||
<span class="tw-flex tw-gap-2"> |
||||
<button bitButton buttonType="primary" [bitDialogClose]="true" type="submit"> |
||||
{{ "continue" | i18n }} |
||||
</button> |
||||
<button bitButton buttonType="secondary" [bitDialogClose]="false" type="button"> |
||||
{{ "cancel" | i18n }} |
||||
</button> |
||||
</span> |
||||
</ng-container> |
||||
</bit-simple-dialog> |
||||
</ng-template> |
||||
@ -0,0 +1,50 @@
@@ -0,0 +1,50 @@
|
||||
import { Component, OnInit, TemplateRef, ViewChild } from "@angular/core"; |
||||
import { lastValueFrom, Observable } from "rxjs"; |
||||
|
||||
import { PolicyType } from "@bitwarden/common/admin-console/enums"; |
||||
import { Organization } from "@bitwarden/common/admin-console/models/domain/organization"; |
||||
import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum"; |
||||
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service"; |
||||
import { DialogService } from "@bitwarden/components"; |
||||
|
||||
import { SharedModule } from "../../../shared"; |
||||
|
||||
import { BasePolicy, BasePolicyComponent } from "./base-policy.component"; |
||||
|
||||
export class vNextOrganizationDataOwnershipPolicy extends BasePolicy { |
||||
name = "organizationDataOwnership"; |
||||
description = "organizationDataOwnershipDesc"; |
||||
type = PolicyType.OrganizationDataOwnership; |
||||
component = vNextOrganizationDataOwnershipPolicyComponent; |
||||
showDescription = false; |
||||
|
||||
override display(organization: Organization, configService: ConfigService): Observable<boolean> { |
||||
return configService.getFeatureFlag$(FeatureFlag.CreateDefaultLocation); |
||||
} |
||||
} |
||||
|
||||
@Component({ |
||||
selector: "vnext-policy-organization-data-ownership", |
||||
templateUrl: "vnext-organization-data-ownership.component.html", |
||||
standalone: true, |
||||
imports: [SharedModule], |
||||
}) |
||||
export class vNextOrganizationDataOwnershipPolicyComponent |
||||
extends BasePolicyComponent |
||||
implements OnInit |
||||
{ |
||||
constructor(private dialogService: DialogService) { |
||||
super(); |
||||
} |
||||
|
||||
@ViewChild("dialog", { static: true }) warningContent!: TemplateRef<unknown>; |
||||
|
||||
override async confirm(): Promise<boolean> { |
||||
if (this.policyResponse?.enabled && !this.enabled.value) { |
||||
const dialogRef = this.dialogService.open(this.warningContent); |
||||
const result = await lastValueFrom(dialogRef.closed); |
||||
return Boolean(result); |
||||
} |
||||
return true; |
||||
} |
||||
} |
||||
@ -1,9 +1,7 @@
@@ -1,9 +1,7 @@
|
||||
// FIXME: Update this file to be type safe and remove this and next line
|
||||
// @ts-strict-ignore
|
||||
import { PolicyType } from "../../enums"; |
||||
|
||||
export class PolicyRequest { |
||||
export type PolicyRequest = { |
||||
type: PolicyType; |
||||
enabled: boolean; |
||||
data: any; |
||||
} |
||||
}; |
||||
|
||||
Loading…
Reference in new issue