mirror of
https://github.com/bitwarden/clients.git
synced 2026-11-16 07:03:29 +00:00
[PAM] (3-A9) Bring the access connectors tab to its pam/uat state (#24632)
Takes the access connectors list, detail page and dialogs from pam/uat byte for byte, deletes rotation/skeleton-delay.ts now that no tab reads it, and moves the web strings: 27 added, 30 removed, and a corrected description on pamAccessConnectorAssignmentsNone.
This commit is contained in:
@@ -20587,20 +20587,17 @@
|
||||
"pamTargetSystemNotFound": {
|
||||
"message": "Target system not found."
|
||||
},
|
||||
"pamAccessConnectorSearch": {
|
||||
"message": "Search access connectors"
|
||||
},
|
||||
"pamAccessConnectorNew": {
|
||||
"message": "New access connector"
|
||||
},
|
||||
"pamAccessConnectorRegister": {
|
||||
"message": "Register access connector"
|
||||
},
|
||||
"pamAccessConnectorEmptyStateTitle": {
|
||||
"message": "No access connectors registered"
|
||||
"pamAccessConnectorsEmptyTitle": {
|
||||
"message": "No access connectors yet"
|
||||
},
|
||||
"pamAccessConnectorEmptyStateDescription": {
|
||||
"message": "Register an access connector to start rotating credentials."
|
||||
"pamAccessConnectorsEmptyDescription": {
|
||||
"message": "Access connectors run inside your network and change passwords on your target systems. Register one to get started."
|
||||
},
|
||||
"pamAccessConnectorTargetSystems": {
|
||||
"message": "Target systems"
|
||||
},
|
||||
"pamAccessConnectorConnection": {
|
||||
"message": "Connection"
|
||||
@@ -20620,14 +20617,11 @@
|
||||
"pamAccessConnectorAssignTargetSystemsDisabled": {
|
||||
"message": "Activate this access connector to assign target systems."
|
||||
},
|
||||
"pamAccessConnectorAssignTargetDisabled": {
|
||||
"message": "Target systems can only be assigned while the access connector is active."
|
||||
"pamAccessConnectorEdit": {
|
||||
"message": "Edit access connector"
|
||||
},
|
||||
"pamAccessConnectorViewDetails": {
|
||||
"message": "View details"
|
||||
},
|
||||
"pamAccessConnectorAssignTargets": {
|
||||
"message": "Assign targets"
|
||||
"pamAccessConnectorAssignTargetSystems": {
|
||||
"message": "Assign target systems"
|
||||
},
|
||||
"pamAccessConnectorDeleteAccessConnector": {
|
||||
"message": "Delete access connector"
|
||||
@@ -20644,9 +20638,6 @@
|
||||
"pamAccessConnectorTargetSystemsHint": {
|
||||
"message": "Choose the target systems this access connector can rotate passwords on. Only target systems that use automatic rotation can be assigned."
|
||||
},
|
||||
"pamAccessConnectorAssignSelectHint": {
|
||||
"message": "Only target systems set to automatic rotation can be assigned."
|
||||
},
|
||||
"pamAccessConnectorAssignNoOptions": {
|
||||
"message": "All automatic target systems are already assigned to this access connector."
|
||||
},
|
||||
@@ -20677,77 +20668,62 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"pamAccessConnectorUnassignConfirmTitle": {
|
||||
"message": "Remove assignment?"
|
||||
},
|
||||
"pamAccessConnectorUnassignConfirmContent": {
|
||||
"message": "Remove $NAME$ from this access connector? Active rotation jobs claimed by this access connector will continue to completion.",
|
||||
"placeholders": {
|
||||
"name": {
|
||||
"content": "$1",
|
||||
"example": "Production database"
|
||||
}
|
||||
}
|
||||
},
|
||||
"pamAccessConnectorUnassigned": {
|
||||
"message": "Target system removed."
|
||||
},
|
||||
"pamAccessConnectorDeactivate": {
|
||||
"message": "Deactivate"
|
||||
},
|
||||
"pamAccessConnectorActivate": {
|
||||
"message": "Activate"
|
||||
},
|
||||
"pamAccessConnectorDeactivateConfirmTitle": {
|
||||
"message": "Deactivate access connector?"
|
||||
"pamAccessConnectorDeactivateDialogTitle": {
|
||||
"message": "Deactivate access connector"
|
||||
},
|
||||
"pamAccessConnectorDeactivateConfirmContent": {
|
||||
"message": "Deactivate $NAME$? It stops claiming new rotation jobs and any jobs it is currently running are released. You can activate it again later.",
|
||||
"placeholders": {
|
||||
"name": {
|
||||
"content": "$1",
|
||||
"example": "On-prem production server"
|
||||
}
|
||||
}
|
||||
"pamAccessConnectorDeactivateDialogContent": {
|
||||
"message": "This access connector won't take new rotations. Rotations in progress are released."
|
||||
},
|
||||
"pamAccessConnectorDeactivated": {
|
||||
"message": "Access connector deactivated."
|
||||
},
|
||||
"pamAccessConnectorDeactivateFailed": {
|
||||
"message": "Couldn't deactivate. Try again."
|
||||
},
|
||||
"pamAccessConnectorActivated": {
|
||||
"message": "Access connector activated."
|
||||
},
|
||||
"pamAccessConnectorDeleteConfirmTitle": {
|
||||
"message": "Delete access connector?"
|
||||
"pamAccessConnectorDeleteDialogTitle": {
|
||||
"message": "Delete access connector"
|
||||
},
|
||||
"pamAccessConnectorDeleteConfirmContent": {
|
||||
"message": "Deleting $NAME$ is permanent and invalidates its credentials. This access connector held the organization key in memory. If you suspect a compromise, rotate the organization key as a remediation. Running rotation jobs are released. Register a new access connector to resume rotation.",
|
||||
"placeholders": {
|
||||
"name": {
|
||||
"content": "$1",
|
||||
"example": "On-prem production server"
|
||||
}
|
||||
}
|
||||
"pamAccessConnectorDeleteDialogContent": {
|
||||
"message": "Its token stops working, and rotations in progress are released. This can't be undone."
|
||||
},
|
||||
"pamAccessConnectorDeleted": {
|
||||
"message": "Access connector deleted."
|
||||
},
|
||||
"pamAccessConnectorDeleteFailed": {
|
||||
"message": "Couldn't delete. Try again."
|
||||
},
|
||||
"pamAccessConnectorSaved": {
|
||||
"message": "Access connector saved."
|
||||
},
|
||||
"pamAccessConnectorSaveFailed": {
|
||||
"message": "Access connector wasn't saved. Try again."
|
||||
},
|
||||
"pamAccessConnectorSaveFailedCallout": {
|
||||
"message": "Access connector wasn't saved. Check your connection, then select Save again."
|
||||
},
|
||||
"pamAccessConnectorRegisterTitle": {
|
||||
"message": "Register access connector"
|
||||
},
|
||||
"pamAccessConnectorNamePlaceholder": {
|
||||
"message": "e.g. On-prem production server"
|
||||
"pamAccessConnectorRegisterDescription": {
|
||||
"message": "You'll get a token to add to the access connector's configuration. It's shown only once."
|
||||
},
|
||||
"pamAccessConnectorNameHint": {
|
||||
"message": "A descriptive name to identify this access connector. Max 200 characters."
|
||||
"pamAccessConnectorNameRecognizableHint": {
|
||||
"message": "Use a name your team will recognize, for example East datacenter."
|
||||
},
|
||||
"pamAccessConnectorRegistered": {
|
||||
"message": "Access connector registered."
|
||||
},
|
||||
"pamAccessConnectorNoResults": {
|
||||
"message": "No access connectors match your filters."
|
||||
"pamAccessConnectorRegisterFailed": {
|
||||
"message": "Access connector wasn't registered. Try again."
|
||||
},
|
||||
"pamAccessConnectorDetailTitle": {
|
||||
"message": "Access connector"
|
||||
@@ -20758,35 +20734,38 @@
|
||||
"pamAccessConnectorTabConfiguration": {
|
||||
"message": "Configuration"
|
||||
},
|
||||
"pamAccessConnectorTabHistory": {
|
||||
"message": "History"
|
||||
"pamAccessConnectorTabRotationHistory": {
|
||||
"message": "Rotation history"
|
||||
},
|
||||
"pamAccessConnectorActivityEmpty": {
|
||||
"message": "No rotation activity yet."
|
||||
"pamAccessConnectorRotationHeading": {
|
||||
"message": "Rotation"
|
||||
},
|
||||
"pamAccessConnectorActiveHint": {
|
||||
"message": "When inactive, the access connector does not claim new rotation jobs and any jobs it is running are released."
|
||||
"pamAccessConnectorTargetSystemsPlaceholder": {
|
||||
"message": "Choose target systems"
|
||||
},
|
||||
"pamAccessConnectorDisconnectedCallout": {
|
||||
"message": "This access connector isn't connected, so it can't rotate passwords. Check that it's running on its machine and can reach Bitwarden."
|
||||
},
|
||||
"pamAccessConnectorNeverConnectedCallout": {
|
||||
"message": "Finish setting up. Add the token and each target system's connection details to this access connector's configuration, then start it."
|
||||
},
|
||||
"pamAccessConnectorTokenTitle": {
|
||||
"message": "Access connector token"
|
||||
},
|
||||
"pamAccessConnectorTokenWarningTitle": {
|
||||
"message": "Save this token now"
|
||||
"pamAccessConnectorTokenShownOnceWarning": {
|
||||
"message": "Copy this token now, since you can't see it again after you close this."
|
||||
},
|
||||
"pamAccessConnectorTokenWarningBody": {
|
||||
"message": "This token is shown only once and cannot be retrieved later. Copy it and deliver it out of band to the operator who will run this access connector, then paste it into the connector's configuration file. If the token is lost, delete this access connector and register a new one."
|
||||
"pamAccessConnectorTokenConfigurationHint": {
|
||||
"message": "Add it to the access connector's configuration to connect it."
|
||||
},
|
||||
"pamAccessConnectorTokenLabel": {
|
||||
"message": "Access connector token"
|
||||
},
|
||||
"pamAccessConnectorTokenHint": {
|
||||
"message": "This token will not be shown again."
|
||||
"pamAccessConnectorTokenStored": {
|
||||
"message": "I stored this token securely"
|
||||
},
|
||||
"pamAccessConnectorTokenCopy": {
|
||||
"message": "Copy token"
|
||||
},
|
||||
"pamAccessConnectorTokenCopied": {
|
||||
"message": "Access connector token copied."
|
||||
"pamTokenCopied": {
|
||||
"message": "Token copied."
|
||||
},
|
||||
"pamRotationConfigSearch": {
|
||||
"message": "Search managed credentials"
|
||||
@@ -21268,12 +21247,6 @@
|
||||
"pamRotationJobStatusUnknown": {
|
||||
"message": "Unknown"
|
||||
},
|
||||
"pamRotationAssignmentPendingAssign": {
|
||||
"message": "Pending assignment"
|
||||
},
|
||||
"pamRotationAssignmentPendingUnassign": {
|
||||
"message": "Pending removal"
|
||||
},
|
||||
"pamRotationAttemptStatusExecuting": {
|
||||
"message": "Executing"
|
||||
},
|
||||
@@ -21489,9 +21462,9 @@
|
||||
"pamAuditAccessConnector": {
|
||||
"message": "Access connector"
|
||||
},
|
||||
"pamAccessConnectorAssignmentCountSingular": {
|
||||
"message": "$COUNT$ target",
|
||||
"description": "Count of target systems assigned to an access connector. Activating the count reveals their names.",
|
||||
"pamAccessConnectorTargetSystemCountSingular": {
|
||||
"message": "$COUNT$ target system",
|
||||
"description": "Count of target systems assigned to an access connector, in the access connectors table.",
|
||||
"placeholders": {
|
||||
"count": {
|
||||
"content": "$1",
|
||||
@@ -21499,9 +21472,9 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"pamAccessConnectorAssignmentCount": {
|
||||
"message": "$COUNT$ targets",
|
||||
"description": "Count of target systems assigned to an access connector. Activating the count reveals their names.",
|
||||
"pamAccessConnectorTargetSystemCount": {
|
||||
"message": "$COUNT$ target systems",
|
||||
"description": "Count of target systems assigned to an access connector, in the access connectors table.",
|
||||
"placeholders": {
|
||||
"count": {
|
||||
"content": "$1",
|
||||
@@ -21511,7 +21484,7 @@
|
||||
},
|
||||
"pamAccessConnectorAssignmentsNone": {
|
||||
"message": "None",
|
||||
"description": "Shown in the assigned targets column when an access connector has no target systems assigned."
|
||||
"description": "Shown in the target systems column when an access connector has no target systems assigned."
|
||||
},
|
||||
"pamRotationConfigNoActiveTargetSystems": {
|
||||
"message": "No active target systems to choose from."
|
||||
|
||||
@@ -1,20 +1,21 @@
|
||||
import { SimpleDialogOptions } from "@bitwarden/components";
|
||||
|
||||
export function accessConnectorDeactivateConfirmOptions(name: string): SimpleDialogOptions {
|
||||
/** Shared by the access connectors table and the detail page, so both ask the same question. */
|
||||
export function accessConnectorDeactivateConfirmOptions(): SimpleDialogOptions {
|
||||
return {
|
||||
title: { key: "pamAccessConnectorDeactivateConfirmTitle" },
|
||||
content: { key: "pamAccessConnectorDeactivateConfirmContent", placeholders: [name] },
|
||||
title: { key: "pamAccessConnectorDeactivateDialogTitle" },
|
||||
content: { key: "pamAccessConnectorDeactivateDialogContent" },
|
||||
acceptButtonText: { key: "pamAccessConnectorDeactivate" },
|
||||
cancelButtonText: { key: "cancel" },
|
||||
type: "warning",
|
||||
};
|
||||
}
|
||||
|
||||
export function accessConnectorDeleteConfirmOptions(name: string): SimpleDialogOptions {
|
||||
export function accessConnectorDeleteConfirmOptions(): SimpleDialogOptions {
|
||||
return {
|
||||
title: { key: "pamAccessConnectorDeleteConfirmTitle" },
|
||||
content: { key: "pamAccessConnectorDeleteConfirmContent", placeholders: [name] },
|
||||
acceptButtonText: { key: "delete" },
|
||||
title: { key: "pamAccessConnectorDeleteDialogTitle" },
|
||||
content: { key: "pamAccessConnectorDeleteDialogContent" },
|
||||
acceptButtonText: { key: "pamAccessConnectorDeleteAccessConnector" },
|
||||
cancelButtonText: { key: "cancel" },
|
||||
type: "danger",
|
||||
};
|
||||
|
||||
@@ -6,28 +6,106 @@
|
||||
parentIcon="bwi-access-connector"
|
||||
[current]="titleText()"
|
||||
/>
|
||||
<span slot="title-suffix" class="tw-flex tw-h-full tw-items-center tw-ms-2">
|
||||
@if (accessConnector()) {
|
||||
<!-- Named-slot projection through control flow only works when the block has a single root
|
||||
element, so the title suffix keeps its own block, apart from the actions. -->
|
||||
@if (statusBadge(); as badge) {
|
||||
<span slot="title-suffix" class="tw-flex tw-h-full tw-items-center tw-ms-1">
|
||||
<span class="tw-sr-only">{{ "status" | i18n }}:</span>
|
||||
<span
|
||||
bitBadge
|
||||
[variant]="enabled() ? 'success' : 'secondary'"
|
||||
size="small"
|
||||
[variant]="badge.variant"
|
||||
[startIcon]="badge.icon"
|
||||
id="access-connector-detail_badge_status"
|
||||
>{{ (enabled() ? "active" : "inactive") | i18n }}</span
|
||||
>{{ badge.labelKey | i18n }}</span
|
||||
>
|
||||
</span>
|
||||
}
|
||||
|
||||
@if (accessConnector() && activeTab() === "configuration") {
|
||||
@if (!enabled()) {
|
||||
<button
|
||||
type="button"
|
||||
bitButton
|
||||
buttonType="primary"
|
||||
[bitAction]="activate"
|
||||
[disabled]="statusBusy()"
|
||||
id="access-connector-detail_button_activate"
|
||||
>
|
||||
{{ "pamAccessConnectorActivate" | i18n }}
|
||||
</button>
|
||||
}
|
||||
</span>
|
||||
<button
|
||||
type="button"
|
||||
bitIconButton="bwi-ellipsis-v"
|
||||
[bitMenuTriggerFor]="moreMenu"
|
||||
[label]="'moreOptions' | i18n"
|
||||
id="access-connector-detail_button_more"
|
||||
></button>
|
||||
<bit-menu #moreMenu>
|
||||
@if (enabled()) {
|
||||
<button
|
||||
type="button"
|
||||
bitMenuItem
|
||||
[disabled]="statusBusy()"
|
||||
(click)="deactivate()"
|
||||
id="access-connector-detail_button_deactivate"
|
||||
>
|
||||
<bit-icon slot="start" name="bwi-minus-circle" class="tw-text-muted"></bit-icon>
|
||||
{{ "pamAccessConnectorDeactivate" | i18n }}
|
||||
</button>
|
||||
}
|
||||
<button
|
||||
type="button"
|
||||
bitMenuItem
|
||||
variant="danger"
|
||||
[disabled]="statusBusy()"
|
||||
(click)="deleteAccessConnector()"
|
||||
id="access-connector-detail_button_delete"
|
||||
>
|
||||
<bit-icon slot="start" name="bwi-trash"></bit-icon>
|
||||
{{ "pamAccessConnectorDeleteAccessConnector" | i18n }}
|
||||
</button>
|
||||
</bit-menu>
|
||||
}
|
||||
|
||||
<bit-tab-nav-bar slot="tabs" [label]="'pamAccessConnectorDetailTitle' | i18n">
|
||||
<bit-tab-link [route]="configurationTabRoute">{{
|
||||
"pamAccessConnectorTabConfiguration" | i18n
|
||||
}}</bit-tab-link>
|
||||
<bit-tab-link [route]="historyTabRoute">{{
|
||||
"pamAccessConnectorTabHistory" | i18n
|
||||
"pamAccessConnectorTabRotationHistory" | i18n
|
||||
}}</bit-tab-link>
|
||||
</bit-tab-nav-bar>
|
||||
</bit-header>
|
||||
|
||||
<!-- Pinned to the layout's footer region by the component while an assignment change is unsaved. -->
|
||||
<ng-template #footer>
|
||||
<div
|
||||
class="tw-pointer-events-auto tw-absolute tw-inset-x-0 tw-bottom-0 tw-flex tw-items-center tw-gap-2 tw-border-0 tw-border-t tw-border-solid tw-border-border-base tw-bg-bg-primary tw-px-10 tw-py-4"
|
||||
data-testid="access-connector-detail-footer"
|
||||
>
|
||||
<button
|
||||
type="button"
|
||||
bitButton
|
||||
buttonType="primary"
|
||||
[bitAction]="submit"
|
||||
id="access-connector-detail_button_save"
|
||||
>
|
||||
{{ "save" | i18n }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
bitButton
|
||||
buttonType="secondary"
|
||||
(click)="discardEdits()"
|
||||
id="access-connector-detail_button_cancel"
|
||||
>
|
||||
{{ "cancel" | i18n }}
|
||||
</button>
|
||||
</div>
|
||||
</ng-template>
|
||||
|
||||
<pam-rotation-loading-announcer
|
||||
[loading]="loading()"
|
||||
[failed]="loadError() != null"
|
||||
@@ -36,41 +114,19 @@
|
||||
|
||||
@if (loadError()) {
|
||||
<pam-rotation-load-error [focusRetry]="retried()" (retry)="retryLoad()" />
|
||||
} @else if (loadingVisible()) {
|
||||
<div
|
||||
aria-hidden="true"
|
||||
data-testid="access-connector-detail-loading"
|
||||
[class.tw-max-w-4xl]="activeTab() !== 'history'"
|
||||
>
|
||||
@if (showSkeleton()) {
|
||||
@switch (activeTab()) {
|
||||
@case ("history") {
|
||||
} @else if (loading()) {
|
||||
<div aria-hidden="true" data-testid="access-connector-detail-loading">
|
||||
@switch (activeTab()) {
|
||||
@case ("history") {
|
||||
<app-rotation-history-skeleton [showCredential]="true" />
|
||||
}
|
||||
@default {
|
||||
<div class="tw-max-w-4xl">
|
||||
<bit-section>
|
||||
<bit-section-header>
|
||||
<h2 bitTypography="h5">{{ "pamAccessConnectorTabHistory" | i18n }}</h2>
|
||||
</bit-section-header>
|
||||
<app-rotation-history-skeleton [showCredential]="true" />
|
||||
</bit-section>
|
||||
}
|
||||
@default {
|
||||
<bit-section>
|
||||
<bit-section-header>
|
||||
<h2 bitTypography="h5">{{ "status" | i18n }}</h2>
|
||||
<h2 bitTypography="h4">{{ "pamAccessConnectorDetailsHeading" | i18n }}</h2>
|
||||
</bit-section-header>
|
||||
<bit-card>
|
||||
<bit-skeleton-text [lines]="2" class="tw-w-72"></bit-skeleton-text>
|
||||
</bit-card>
|
||||
</bit-section>
|
||||
|
||||
<bit-section>
|
||||
<bit-section-header>
|
||||
<h2 bitTypography="h5">{{ "pamAccessConnectorDetailsHeading" | i18n }}</h2>
|
||||
</bit-section-header>
|
||||
<bit-card>
|
||||
<div class="tw-mb-4">
|
||||
<bit-skeleton-text class="tw-mb-2 tw-w-24"></bit-skeleton-text>
|
||||
<bit-skeleton class="tw-h-6 tw-w-24" edgeShape="circle"></bit-skeleton>
|
||||
</div>
|
||||
<div class="tw-mb-4">
|
||||
<bit-skeleton-text class="tw-mb-2 tw-w-24"></bit-skeleton-text>
|
||||
<bit-skeleton-text class="tw-w-48"></bit-skeleton-text>
|
||||
@@ -84,96 +140,99 @@
|
||||
|
||||
<bit-section>
|
||||
<bit-section-header>
|
||||
<h2 bitTypography="h5">{{ "pamAccessConnectorAssignments" | i18n }}</h2>
|
||||
<h2 bitTypography="h4">{{ "pamAccessConnectorRotationHeading" | i18n }}</h2>
|
||||
</bit-section-header>
|
||||
<bit-card>
|
||||
<bit-skeleton-text class="tw-mb-2 tw-w-24"></bit-skeleton-text>
|
||||
<bit-skeleton class="tw-mb-4 tw-h-10 tw-w-full"></bit-skeleton>
|
||||
<bit-skeleton-text [lines]="3" class="tw-w-full"></bit-skeleton-text>
|
||||
</bit-card>
|
||||
</bit-section>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
}
|
||||
</div>
|
||||
} @else if (accessConnector(); as d) {
|
||||
<form [formGroup]="formGroup" [bitSubmit]="submit">
|
||||
<div [class.tw-max-w-4xl]="activeTab() !== 'history'">
|
||||
@switch (activeTab()) {
|
||||
@case ("history") {
|
||||
<bit-section>
|
||||
<bit-section-header>
|
||||
<h2 bitTypography="h5">{{ "pamAccessConnectorTabHistory" | i18n }}</h2>
|
||||
</bit-section-header>
|
||||
@if (d.jobs.length > 0) {
|
||||
<app-rotation-history
|
||||
[jobs]="d.jobs"
|
||||
[showCredential]="true"
|
||||
[credentialNames]="credentialNames()"
|
||||
></app-rotation-history>
|
||||
} @else {
|
||||
<bit-card>
|
||||
<p bitTypography="body2" class="tw-m-0 tw-text-muted">
|
||||
{{ "pamAccessConnectorActivityEmpty" | i18n }}
|
||||
</p>
|
||||
</bit-card>
|
||||
@switch (activeTab()) {
|
||||
@case ("history") {
|
||||
<app-rotation-history
|
||||
[jobs]="d.jobs"
|
||||
[showCredential]="true"
|
||||
[credentialNames]="credentialNames()"
|
||||
></app-rotation-history>
|
||||
}
|
||||
@default {
|
||||
<div [class.tw-pb-20]="showFooter()">
|
||||
<!-- Spaces the callouts from the sections like the sections from each other. -->
|
||||
<div class="tw-mb-12 empty:tw-hidden">
|
||||
@if (saveFailed()) {
|
||||
<bit-callout
|
||||
type="danger"
|
||||
[title]="null"
|
||||
[accessibleName]="'pamAccessConnectorSaveFailed' | i18n"
|
||||
id="access-connector-detail_callout_save-failed"
|
||||
>
|
||||
{{ "pamAccessConnectorSaveFailedCallout" | i18n }}
|
||||
</bit-callout>
|
||||
}
|
||||
@switch (callout()) {
|
||||
@case ("never-connected") {
|
||||
<bit-callout
|
||||
type="warning"
|
||||
[title]="null"
|
||||
[icon]="null"
|
||||
[accessibleName]="'pamAccessConnectorDisconnected' | i18n"
|
||||
id="access-connector-detail_callout_never-connected"
|
||||
>
|
||||
{{ "pamAccessConnectorNeverConnectedCallout" | i18n }}
|
||||
</bit-callout>
|
||||
}
|
||||
</bit-section>
|
||||
}
|
||||
@default {
|
||||
@case ("disconnected") {
|
||||
<bit-callout
|
||||
type="warning"
|
||||
[title]="null"
|
||||
[icon]="null"
|
||||
[accessibleName]="'pamAccessConnectorDisconnected' | i18n"
|
||||
id="access-connector-detail_callout_disconnected"
|
||||
>
|
||||
{{ "pamAccessConnectorDisconnectedCallout" | i18n }}
|
||||
</bit-callout>
|
||||
}
|
||||
}
|
||||
</div>
|
||||
|
||||
<div class="tw-max-w-4xl">
|
||||
<bit-section>
|
||||
<bit-section-header>
|
||||
<h2 bitTypography="h5">{{ "status" | i18n }}</h2>
|
||||
<h2 bitTypography="h4">{{ "pamAccessConnectorDetailsHeading" | i18n }}</h2>
|
||||
</bit-section-header>
|
||||
<bit-card>
|
||||
<bit-form-control disableMargin>
|
||||
<input
|
||||
type="checkbox"
|
||||
bitCheckbox
|
||||
id="access-connector-detail_checkbox_active"
|
||||
formControlName="active"
|
||||
/>
|
||||
<bit-label>{{ "active" | i18n }}</bit-label>
|
||||
<bit-hint>{{ "pamAccessConnectorActiveHint" | i18n }}</bit-hint>
|
||||
</bit-form-control>
|
||||
</bit-card>
|
||||
</bit-section>
|
||||
|
||||
<bit-section>
|
||||
<bit-section-header>
|
||||
<h2 bitTypography="h5">{{ "pamAccessConnectorDetailsHeading" | i18n }}</h2>
|
||||
</bit-section-header>
|
||||
<bit-card>
|
||||
<div class="tw-mb-4">
|
||||
<p bitTypography="helper" class="tw-mb-1 tw-font-semibold">
|
||||
{{ "pamAccessConnectorConnection" | i18n }}
|
||||
</p>
|
||||
<span bitBadge [variant]="d.connector.isConnected ? 'success' : 'secondary'">{{
|
||||
(d.connector.isConnected
|
||||
? "pamAccessConnectorConnected"
|
||||
: "pamAccessConnectorDisconnected"
|
||||
) | i18n
|
||||
}}</span>
|
||||
</div>
|
||||
|
||||
<div class="tw-mb-4">
|
||||
<p bitTypography="helper" class="tw-mb-1 tw-font-semibold">
|
||||
<div class="tw-mb-6">
|
||||
<p bitTypography="body2" class="tw-mb-1 tw-font-medium tw-text-fg-body">
|
||||
{{ "pamAccessConnectorLastSeen" | i18n }}
|
||||
</p>
|
||||
<p bitTypography="body1" class="tw-m-0" data-testid="connector-last-seen">
|
||||
@if (d.connector.lastHeartbeatAt) {
|
||||
{{ d.connector.lastHeartbeatAt | date: "medium" }}
|
||||
@if (lastSeenAtMs() != null) {
|
||||
<span
|
||||
tabindex="0"
|
||||
[bitTooltip]="lastSeenAtMs() | timestamp"
|
||||
[addTooltipToDescribedby]="true"
|
||||
>
|
||||
{{ lastSeenLabel() ?? (lastSeenAtMs() | timestamp) }}
|
||||
</span>
|
||||
} @else {
|
||||
<span class="tw-text-muted">{{ "never" | i18n }}</span>
|
||||
{{ "never" | i18n }}
|
||||
}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<p bitTypography="helper" class="tw-mb-1 tw-font-semibold">
|
||||
<p bitTypography="body2" class="tw-mb-1 tw-font-medium tw-text-fg-body">
|
||||
{{ "dateCreated" | i18n }}
|
||||
</p>
|
||||
<p bitTypography="body1" class="tw-m-0" data-testid="connector-created">
|
||||
@if (d.connector.creationDate) {
|
||||
{{ d.connector.creationDate | date: "medium" }}
|
||||
{{ d.connector.creationDate | timestamp }}
|
||||
} @else {
|
||||
<span class="tw-text-muted">—</span>
|
||||
}
|
||||
@@ -182,94 +241,102 @@
|
||||
</bit-card>
|
||||
</bit-section>
|
||||
|
||||
<pam-assignment-picker
|
||||
idPrefix="access-connector-detail"
|
||||
headingKey="pamAccessConnectorAssignments"
|
||||
selectLabelKey="pamAccessConnectorAssignSelectLabel"
|
||||
unassignLabelKey="pamAccessConnectorUnassign"
|
||||
emptyKey="pamAccessConnectorAssignmentsEmpty"
|
||||
goToLabelKey="pamAccessConnectorAssignGoToTargetSystems"
|
||||
disabledTooltipKey="pamAccessConnectorAssignTargetDisabled"
|
||||
[options]="assignOptions()"
|
||||
[assignments]="assignments()"
|
||||
[columns]="assignmentColumns"
|
||||
[rowTemplate]="assignmentRow"
|
||||
[hints]="assignmentHints"
|
||||
[assign]="assignTargets"
|
||||
[unassign]="unassignTarget"
|
||||
[disabled]="!stagedActive()"
|
||||
[loadError]="targetSystemsLoadError() != null"
|
||||
[noneEligible]="noEligibleTargetSystems()"
|
||||
[goToRoute]="targetSystemsRoute"
|
||||
/>
|
||||
<bit-section>
|
||||
<bit-section-header>
|
||||
<h2 bitTypography="h4">{{ "pamAccessConnectorRotationHeading" | i18n }}</h2>
|
||||
</bit-section-header>
|
||||
<bit-card>
|
||||
<bit-form-field disableMargin>
|
||||
<bit-label>{{ "pamAccessConnectorAssignTargetLabel" | i18n }}</bit-label>
|
||||
<bit-multi-select
|
||||
class="tw-w-full"
|
||||
id="access-connector-detail_multi-select_target-systems"
|
||||
[baseItems]="selectOptions()"
|
||||
[removeSelectedItems]="false"
|
||||
[placeholder]="'pamAccessConnectorTargetSystemsPlaceholder' | i18n"
|
||||
[disabled]="targetSystemsLoadError() != null"
|
||||
[ngModel]="selectedItems()"
|
||||
(ngModelChange)="onSelectionChanged($event)"
|
||||
/>
|
||||
<bit-hint>{{ pickerHintKey() | i18n }}</bit-hint>
|
||||
</bit-form-field>
|
||||
|
||||
<ng-template #assignmentRow let-assignment>
|
||||
<bit-cell>
|
||||
<span
|
||||
[class.tw-line-through]="assignment.pending === 'remove'"
|
||||
[class.tw-text-muted]="assignment.pending === 'remove'"
|
||||
>{{ assignment.name }}</span
|
||||
>
|
||||
@switch (assignment.pending) {
|
||||
@case ("add") {
|
||||
<span slot="end" bitBadge variant="subtle">{{
|
||||
"pamRotationAssignmentPendingAssign" | i18n
|
||||
}}</span>
|
||||
}
|
||||
@case ("remove") {
|
||||
<span slot="end" bitBadge variant="subtle">{{
|
||||
"pamRotationAssignmentPendingUnassign" | i18n
|
||||
}}</span>
|
||||
}
|
||||
@if (assignments().length > 0) {
|
||||
<bit-table-v2
|
||||
class="tw-mt-4 tw-block"
|
||||
data-testid="access-connector-assignments"
|
||||
[tableDef]="assignmentsTable"
|
||||
>
|
||||
<bit-column width="minmax(10rem, 2fr)">
|
||||
<bit-header-cell>{{
|
||||
"pamAccessConnectorAssignTargetLabel" | i18n
|
||||
}}</bit-header-cell>
|
||||
<bit-cell *bitCellDef="assignmentsTable.columns.name; let a">
|
||||
<span class="tw-text-base tw-font-medium tw-text-fg-heading">{{
|
||||
a.name
|
||||
}}</span>
|
||||
</bit-cell>
|
||||
</bit-column>
|
||||
<bit-column width="minmax(7rem, 1fr)">
|
||||
<bit-header-cell>{{ "pamTargetSystemSystemTypeLabel" | i18n }}</bit-header-cell>
|
||||
<bit-cell *bitCellDef="assignmentsTable.columns.typeKey; let a">
|
||||
@if (a.typeKey) {
|
||||
<span class="tw-text-sm">{{ a.typeKey | i18n }}</span>
|
||||
}
|
||||
</bit-cell>
|
||||
</bit-column>
|
||||
<bit-column width="minmax(9.5rem, 1fr)">
|
||||
<bit-header-cell>{{ "status" | i18n }}</bit-header-cell>
|
||||
<bit-cell
|
||||
*bitCellDef="assignmentsTable.columns.statusBadge; let a"
|
||||
[truncate]="false"
|
||||
>
|
||||
@if (a.statusBadge; as badge) {
|
||||
<span
|
||||
bitBadge
|
||||
size="small"
|
||||
[variant]="badge.variant"
|
||||
[startIcon]="badge.icon"
|
||||
>{{ badge.labelKey | i18n }}</span
|
||||
>
|
||||
}
|
||||
</bit-cell>
|
||||
</bit-column>
|
||||
<bit-column width="minmax(8rem, 1.5fr)">
|
||||
<bit-header-cell>{{ "pamTargetSystemIdLabel" | i18n }}</bit-header-cell>
|
||||
<bit-cell *bitCellDef="assignmentsTable.columns.idText; let a">
|
||||
<span class="tw-font-mono tw-text-sm">{{ a.idText }}</span>
|
||||
</bit-cell>
|
||||
</bit-column>
|
||||
<bit-column width="7.5rem">
|
||||
<bit-header-cell>{{ "options" | i18n }}</bit-header-cell>
|
||||
<bit-cell *bitCellDef="assignmentsTable.columns.actions; let a">
|
||||
<div slot="end" class="tw-flex tw-items-center tw-gap-1">
|
||||
<button
|
||||
type="button"
|
||||
bitIconButton="bwi-clone"
|
||||
[appCopyClick]="a.idText"
|
||||
showToast
|
||||
[valueLabel]="'pamTargetSystemIdLabel' | i18n"
|
||||
[label]="'pamTargetSystemCopyId' | i18n"
|
||||
id="access-connector-detail_button_copy-target-id-{{ a.id }}"
|
||||
></button>
|
||||
<button
|
||||
type="button"
|
||||
bitIconButton="bwi-close"
|
||||
label="{{ 'pamAccessConnectorUnassign' | i18n: a.label }}"
|
||||
(click)="unassignTarget(a)"
|
||||
id="access-connector-detail_button_unassign-{{ a.id }}"
|
||||
></button>
|
||||
</div>
|
||||
</bit-cell>
|
||||
</bit-column>
|
||||
</bit-table-v2>
|
||||
}
|
||||
</bit-cell>
|
||||
<bit-cell class="tw-text-muted">
|
||||
@if (assignment.qualifierKey) {
|
||||
{{ assignment.qualifierKey | i18n }}
|
||||
}
|
||||
</bit-cell>
|
||||
<bit-cell [truncate]="false">
|
||||
<div class="tw-flex tw-items-center tw-gap-1">
|
||||
<span class="tw-font-mono tw-text-sm tw-break-all">{{ assignment.id }}</span>
|
||||
<button
|
||||
type="button"
|
||||
bitIconButton="bwi-clone"
|
||||
buttonType="subtleGhost"
|
||||
size="small"
|
||||
[appCopyClick]="assignment.id"
|
||||
showToast
|
||||
[valueLabel]="'pamTargetSystemIdLabel' | i18n"
|
||||
[label]="'pamTargetSystemCopyId' | i18n"
|
||||
id="access-connector-detail_button_copy-target-id-{{ assignment.id }}"
|
||||
></button>
|
||||
</div>
|
||||
</bit-cell>
|
||||
</ng-template>
|
||||
}
|
||||
}
|
||||
|
||||
<div class="tw-flex tw-max-w-4xl tw-items-center tw-gap-2">
|
||||
<button
|
||||
type="submit"
|
||||
bitButton
|
||||
buttonType="primary"
|
||||
bitFormButton
|
||||
id="access-connector-detail_button_save"
|
||||
>
|
||||
{{ "save" | i18n }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
bitButton
|
||||
buttonType="danger"
|
||||
bitFormButton
|
||||
[bitAction]="deleteAccessConnector"
|
||||
class="tw-ms-auto"
|
||||
id="access-connector-detail_button_delete"
|
||||
>
|
||||
{{ "delete" | i18n }}
|
||||
</button>
|
||||
</bit-card>
|
||||
</bit-section>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -8,9 +8,11 @@ import {
|
||||
StoryObj,
|
||||
} from "@storybook/angular";
|
||||
import { of } from "rxjs";
|
||||
import { userEvent, within } from "storybook/test";
|
||||
|
||||
import { OrganizationService } from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction";
|
||||
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
|
||||
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";
|
||||
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
|
||||
import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service";
|
||||
import { CipherType } from "@bitwarden/common/vault/enums/cipher-type";
|
||||
@@ -18,7 +20,8 @@ import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
|
||||
import { DialogService, ToastService } from "@bitwarden/components";
|
||||
import { PreloadedEnglishI18nModule } from "@bitwarden/web-vault/app/core/tests";
|
||||
|
||||
import { AccessConnectorStatus } from "../rotation";
|
||||
import { AccessConnectorStatus, TargetSystemKind, TargetSystemStatus } from "../rotation";
|
||||
import type { AccessConnectorDetail } from "../rotation";
|
||||
import { RotationSdkService } from "../rotation-sdk.service";
|
||||
import {
|
||||
accessConnector,
|
||||
@@ -33,13 +36,148 @@ import {
|
||||
rotationJob,
|
||||
sysId,
|
||||
targetSystem,
|
||||
targetSystemSealedFields,
|
||||
} from "../testing/rotation-builders";
|
||||
import { atUrl } from "../testing/story-helpers";
|
||||
|
||||
import { AccessConnectorDetailComponent } from "./access-connector-detail.component";
|
||||
|
||||
const SAMPLE_DETAIL = accessConnectorDetail({
|
||||
connector: accessConnector({ name: "Prod on-prem connector" }),
|
||||
const HOUR_MS = 60 * 60 * 1000;
|
||||
const hoursAgo = (hours: number): string => new Date(Date.now() - hours * HOUR_MS).toISOString();
|
||||
|
||||
// The builders hash labels onto 16 ids, so these labels are picked to stay distinct per type.
|
||||
const LEGACY_REPORTING_DB = targetSystem({
|
||||
id: sysId("legacy-reporting"),
|
||||
name: "Legacy Reporting DB",
|
||||
status: TargetSystemStatus.Disabled,
|
||||
sealed: targetSystemSealedFields({ kind: TargetSystemKind.CustomScript }),
|
||||
});
|
||||
const DATA_WAREHOUSE = targetSystem({
|
||||
id: sysId("warehouse"),
|
||||
name: "Data Warehouse",
|
||||
sealed: targetSystemSealedFields({ kind: TargetSystemKind.CustomScript }),
|
||||
});
|
||||
const OKTA_IDENTITY = targetSystem({
|
||||
id: sysId("okta-identity"),
|
||||
name: "Okta Identity",
|
||||
sealed: targetSystemSealedFields({ kind: TargetSystemKind.CustomScript }),
|
||||
});
|
||||
const SIEM_CLUSTER = targetSystem({
|
||||
id: sysId("siem"),
|
||||
name: "SIEM Cluster",
|
||||
sealed: targetSystemSealedFields({ kind: TargetSystemKind.CustomScript }),
|
||||
});
|
||||
const NETWORK_FIREWALL = targetSystem({
|
||||
id: sysId("firewall"),
|
||||
name: "Network Firewall",
|
||||
sealed: targetSystemSealedFields({ kind: TargetSystemKind.CustomScript }),
|
||||
});
|
||||
const LEGACY_ERP_ADMIN = targetSystem({
|
||||
id: sysId("legacy-erp"),
|
||||
name: "Legacy ERP admin",
|
||||
sealed: targetSystemSealedFields({ kind: TargetSystemKind.CustomScript }),
|
||||
});
|
||||
const AWS_PRODUCTION = targetSystem({
|
||||
id: sysId("aws-production"),
|
||||
name: "AWS Production",
|
||||
sealed: targetSystemSealedFields({ kind: TargetSystemKind.CustomScript }),
|
||||
});
|
||||
const ENTRA_PRODUCTION = targetSystem({
|
||||
id: sysId("entra-production"),
|
||||
name: "Entra ID production",
|
||||
});
|
||||
|
||||
const TARGET_SYSTEMS = [
|
||||
LEGACY_REPORTING_DB,
|
||||
DATA_WAREHOUSE,
|
||||
OKTA_IDENTITY,
|
||||
SIEM_CLUSTER,
|
||||
NETWORK_FIREWALL,
|
||||
LEGACY_ERP_ADMIN,
|
||||
AWS_PRODUCTION,
|
||||
ENTRA_PRODUCTION,
|
||||
];
|
||||
|
||||
/** 1a: connected, four targets, one of them deactivated. */
|
||||
const CONNECTED_DETAIL = accessConnectorDetail({
|
||||
connector: accessConnector({
|
||||
id: connectorId("east"),
|
||||
name: "East datacenter",
|
||||
lastHeartbeatAt: new Date().toISOString(),
|
||||
assignedTargetSystemIds: [
|
||||
LEGACY_REPORTING_DB.id,
|
||||
DATA_WAREHOUSE.id,
|
||||
OKTA_IDENTITY.id,
|
||||
SIEM_CLUSTER.id,
|
||||
],
|
||||
}),
|
||||
});
|
||||
|
||||
/** 1b: disconnected after being seen earlier today; Network Firewall has no one else. */
|
||||
const DISCONNECTED_DETAIL = accessConnectorDetail({
|
||||
connector: accessConnector({
|
||||
id: connectorId("west"),
|
||||
name: "West datacenter",
|
||||
isConnected: false,
|
||||
lastHeartbeatAt: hoursAgo(3),
|
||||
assignedTargetSystemIds: [
|
||||
NETWORK_FIREWALL.id,
|
||||
DATA_WAREHOUSE.id,
|
||||
OKTA_IDENTITY.id,
|
||||
SIEM_CLUSTER.id,
|
||||
],
|
||||
}),
|
||||
});
|
||||
|
||||
/** 1c and B: registered but never connected, with nothing assigned. */
|
||||
const NEVER_CONNECTED_DETAIL = accessConnectorDetail({
|
||||
connector: accessConnector({
|
||||
id: connectorId("stage"),
|
||||
name: "Staging datacenter",
|
||||
isConnected: false,
|
||||
lastHeartbeatAt: undefined,
|
||||
assignedTargetSystemIds: [],
|
||||
}),
|
||||
});
|
||||
|
||||
/** 1d: deactivated, its only target left with no connector to serve it. */
|
||||
const INACTIVE_DETAIL = accessConnectorDetail({
|
||||
connector: accessConnector({
|
||||
id: connectorId("legacy"),
|
||||
name: "Legacy datacenter",
|
||||
status: AccessConnectorStatus.Disabled,
|
||||
lastHeartbeatAt: hoursAgo(24 * 30),
|
||||
assignedTargetSystemIds: [LEGACY_ERP_ADMIN.id],
|
||||
}),
|
||||
});
|
||||
|
||||
/** C2: connected, with nothing assigned yet. */
|
||||
const NO_TARGETS_DETAIL = accessConnectorDetail({
|
||||
connector: accessConnector({
|
||||
id: connectorId("aws-vpc"),
|
||||
name: "AWS production VPC",
|
||||
lastHeartbeatAt: new Date().toISOString(),
|
||||
assignedTargetSystemIds: [],
|
||||
}),
|
||||
});
|
||||
|
||||
/** C3, C4 and C5: connected, serving Entra ID production, with rotations to show. */
|
||||
const AZURE_DETAIL = accessConnectorDetail({
|
||||
connector: accessConnector({
|
||||
id: connectorId("azure"),
|
||||
name: "Azure production",
|
||||
lastHeartbeatAt: new Date().toISOString(),
|
||||
assignedTargetSystemIds: [ENTRA_PRODUCTION.id],
|
||||
}),
|
||||
jobs: [
|
||||
rotationJob(),
|
||||
rotationJob({ id: jobId("job-2"), rotationConfigId: configId("cfg-2"), status: "failed" }),
|
||||
],
|
||||
});
|
||||
|
||||
const AZURE_NO_HISTORY_DETAIL = accessConnectorDetail({
|
||||
connector: { ...AZURE_DETAIL.connector, id: connectorId("azure-quiet") },
|
||||
jobs: [],
|
||||
});
|
||||
|
||||
const LONG_NAME_DETAIL = accessConnectorDetail({
|
||||
@@ -49,73 +187,42 @@ const LONG_NAME_DETAIL = accessConnectorDetail({
|
||||
}),
|
||||
});
|
||||
|
||||
const OFFLINE_DETAIL = accessConnectorDetail({
|
||||
connector: accessConnector({
|
||||
id: connectorId("offline"),
|
||||
name: "Offline connector",
|
||||
isConnected: false,
|
||||
}),
|
||||
});
|
||||
|
||||
const NEVER_SEEN_DETAIL = accessConnectorDetail({
|
||||
connector: accessConnector({
|
||||
id: connectorId("never-seen"),
|
||||
name: "Never seen connector",
|
||||
isConnected: false,
|
||||
lastHeartbeatAt: undefined,
|
||||
}),
|
||||
});
|
||||
|
||||
const DISABLED_DETAIL = accessConnectorDetail({
|
||||
connector: accessConnector({
|
||||
id: connectorId("disabled"),
|
||||
name: "Disabled connector",
|
||||
status: AccessConnectorStatus.Disabled,
|
||||
}),
|
||||
});
|
||||
|
||||
const TARGET_SYSTEM_A = targetSystem({ id: sysId("a"), name: "Prod Entra" });
|
||||
const TARGET_SYSTEM_B = targetSystem({ id: sysId("b"), name: "Staging Postgres" });
|
||||
|
||||
const POPULATED_DETAIL = accessConnectorDetail({
|
||||
connector: accessConnector({
|
||||
id: connectorId("populated"),
|
||||
name: "Populated connector",
|
||||
assignedTargetSystemIds: [TARGET_SYSTEM_A.id, TARGET_SYSTEM_B.id],
|
||||
}),
|
||||
jobs: [
|
||||
rotationJob(),
|
||||
rotationJob({ id: jobId("job-2"), rotationConfigId: configId("cfg-2"), status: "failed" }),
|
||||
],
|
||||
});
|
||||
|
||||
const SECOND_CIPHER_ID = id("9") as CipherView["id"];
|
||||
|
||||
/** The two configs behind POPULATED_DETAIL's jobs, so the History tab can name each credential. */
|
||||
/** The two configs behind AZURE_DETAIL's jobs, so the history tab can name each credential. */
|
||||
const ROTATION_CONFIGS = [
|
||||
rotationConfig(),
|
||||
rotationConfig({ id: configId("cfg-2"), cipherId: SECOND_CIPHER_ID as never }),
|
||||
];
|
||||
|
||||
const CIPHERS = [
|
||||
{ id: CIPHER_ID, name: "svc-entra-admin", type: CipherType.Login, isDeleted: false },
|
||||
{ id: SECOND_CIPHER_ID, name: "svc-postgres-owner", type: CipherType.Login, isDeleted: false },
|
||||
{ id: CIPHER_ID, name: "Splunk forwarder account", type: CipherType.Login, isDeleted: false },
|
||||
{
|
||||
id: SECOND_CIPHER_ID,
|
||||
name: "Salesforce integration user",
|
||||
type: CipherType.Login,
|
||||
isDeleted: false,
|
||||
},
|
||||
] as unknown as CipherView[];
|
||||
|
||||
const CONNECTORS_BY_ID = new Map(
|
||||
[
|
||||
SAMPLE_DETAIL,
|
||||
LONG_NAME_DETAIL,
|
||||
OFFLINE_DETAIL,
|
||||
NEVER_SEEN_DETAIL,
|
||||
DISABLED_DETAIL,
|
||||
POPULATED_DETAIL,
|
||||
].map((detail) => [detail.connector.id, detail]),
|
||||
);
|
||||
const DETAILS = [
|
||||
CONNECTED_DETAIL,
|
||||
DISCONNECTED_DETAIL,
|
||||
NEVER_CONNECTED_DETAIL,
|
||||
INACTIVE_DETAIL,
|
||||
NO_TARGETS_DETAIL,
|
||||
AZURE_DETAIL,
|
||||
AZURE_NO_HISTORY_DETAIL,
|
||||
LONG_NAME_DETAIL,
|
||||
];
|
||||
|
||||
const CONNECTORS_BY_ID = new Map(DETAILS.map((detail) => [detail.connector.id, detail]));
|
||||
|
||||
const rotationSdk: Partial<RotationSdkService> = {
|
||||
listTargetSystems: () => Promise.resolve([TARGET_SYSTEM_A, TARGET_SYSTEM_B]),
|
||||
getConnector: (_organizationId, id) => Promise.resolve(CONNECTORS_BY_ID.get(id) ?? SAMPLE_DETAIL),
|
||||
listTargetSystems: () => Promise.resolve(TARGET_SYSTEMS),
|
||||
listConnectors: () => Promise.resolve(DETAILS.map((detail) => detail.connector)),
|
||||
getConnector: (_organizationId, id) =>
|
||||
Promise.resolve(CONNECTORS_BY_ID.get(id) ?? CONNECTED_DETAIL),
|
||||
enableConnector: () => Promise.resolve(),
|
||||
disableConnector: () => Promise.resolve(),
|
||||
deleteConnector: () => Promise.resolve(),
|
||||
@@ -159,6 +266,8 @@ export default {
|
||||
},
|
||||
provideRouter(routes, withHashLocation()),
|
||||
{ provide: RotationSdkService, useValue: rotationSdk },
|
||||
// Turns on VFO1Foundation, so bit-header renders its current layout.
|
||||
{ provide: ConfigService, useValue: { getFeatureFlag$: () => of(true) } },
|
||||
{ provide: ToastService, useValue: { showToast: () => {} } },
|
||||
{ provide: DialogService, useValue: { openSimpleDialog: () => Promise.resolve(false) } },
|
||||
{
|
||||
@@ -182,65 +291,95 @@ export default {
|
||||
|
||||
type Story = StoryObj<AccessConnectorDetailComponent>;
|
||||
|
||||
/** The breadcrumb trail ends in the connector's own name. */
|
||||
export const Default: Story = {
|
||||
decorators: [
|
||||
atUrl(
|
||||
`/organizations/${ORGANIZATION_ID}/pam/rotation/access-connectors/${SAMPLE_DETAIL.connector.id}`,
|
||||
),
|
||||
],
|
||||
const at = (detail: AccessConnectorDetail, tab = "configuration") =>
|
||||
atUrl(
|
||||
`/organizations/${ORGANIZATION_ID}/pam/rotation/access-connectors/${detail.connector.id}/${tab}`,
|
||||
);
|
||||
|
||||
async function openMoreMenu(canvasElement: HTMLElement): Promise<void> {
|
||||
await userEvent.click(await within(canvasElement).findByRole("button", { name: "More options" }));
|
||||
}
|
||||
|
||||
/** Figma 1092:45241 (1a): Connected; the header holds only the More menu. */
|
||||
export const Connected: Story = {
|
||||
decorators: [at(CONNECTED_DETAIL)],
|
||||
};
|
||||
|
||||
export const LongName: Story = {
|
||||
decorators: [
|
||||
atUrl(
|
||||
`/organizations/${ORGANIZATION_ID}/pam/rotation/access-connectors/${LONG_NAME_DETAIL.connector.id}`,
|
||||
),
|
||||
],
|
||||
};
|
||||
|
||||
/** The Connection field's badge reads "Disconnected". */
|
||||
export const Offline: Story = {
|
||||
decorators: [
|
||||
atUrl(
|
||||
`/organizations/${ORGANIZATION_ID}/pam/rotation/access-connectors/${OFFLINE_DETAIL.connector.id}`,
|
||||
),
|
||||
],
|
||||
};
|
||||
|
||||
export const NeverSeen: Story = {
|
||||
decorators: [
|
||||
atUrl(
|
||||
`/organizations/${ORGANIZATION_ID}/pam/rotation/access-connectors/${NEVER_SEEN_DETAIL.connector.id}`,
|
||||
),
|
||||
],
|
||||
/** Figma 1094:51410 (1b): Disconnected after being seen, with the warning callout. */
|
||||
export const DisconnectedLastSeen: Story = {
|
||||
decorators: [at(DISCONNECTED_DETAIL)],
|
||||
};
|
||||
|
||||
/**
|
||||
* The status badge reads "Inactive", and the target picker stays visible but disabled with a
|
||||
* tooltip saying why.
|
||||
* Figma 1094:51917 (1c) and 1084:58384 (B, the page Close opens after registering): never
|
||||
* connected, with the setup callout and an empty picker.
|
||||
*/
|
||||
export const Disabled: Story = {
|
||||
decorators: [
|
||||
atUrl(
|
||||
`/organizations/${ORGANIZATION_ID}/pam/rotation/access-connectors/${DISABLED_DETAIL.connector.id}`,
|
||||
),
|
||||
],
|
||||
export const NeverConnected: Story = {
|
||||
decorators: [at(NEVER_CONNECTED_DETAIL)],
|
||||
};
|
||||
|
||||
/** Two assigned targets with their own Remove buttons, so the picker has nothing to offer. */
|
||||
export const Populated: Story = {
|
||||
decorators: [
|
||||
atUrl(
|
||||
`/organizations/${ORGANIZATION_ID}/pam/rotation/access-connectors/${POPULATED_DETAIL.connector.id}/configuration`,
|
||||
),
|
||||
],
|
||||
/** Figma 1094:52481 (1d): Inactive; Activate beside the More menu. */
|
||||
export const Inactive: Story = {
|
||||
decorators: [at(INACTIVE_DETAIL)],
|
||||
};
|
||||
|
||||
export const History: Story = {
|
||||
decorators: [
|
||||
atUrl(
|
||||
`/organizations/${ORGANIZATION_ID}/pam/rotation/access-connectors/${POPULATED_DETAIL.connector.id}/history`,
|
||||
),
|
||||
],
|
||||
/** Figma 1096:54287 (1e): an active connector's More menu, Deactivate and Delete. */
|
||||
export const MoreMenuActive: Story = {
|
||||
decorators: [at(CONNECTED_DETAIL)],
|
||||
play: async ({ canvasElement }) => openMoreMenu(canvasElement),
|
||||
};
|
||||
|
||||
/** Figma 1096:54286 (1e): an inactive connector's More menu, Delete only. */
|
||||
export const MoreMenuInactive: Story = {
|
||||
decorators: [at(INACTIVE_DETAIL)],
|
||||
play: async ({ canvasElement }) => openMoreMenu(canvasElement),
|
||||
};
|
||||
|
||||
async function openTargetSystemPicker(canvasElement: HTMLElement): Promise<void> {
|
||||
const picker = canvasElement.querySelector<HTMLElement>(
|
||||
"#access-connector-detail_multi-select_target-systems input",
|
||||
);
|
||||
if (picker != null) {
|
||||
await userEvent.click(picker);
|
||||
}
|
||||
}
|
||||
|
||||
/** Figma 1096:54324 (C2 step 1): a connected connector with no target systems yet, picker open. */
|
||||
export const ChooseTargetSystems: Story = {
|
||||
decorators: [at(NO_TARGETS_DETAIL)],
|
||||
play: async ({ canvasElement }) => openTargetSystemPicker(canvasElement),
|
||||
};
|
||||
|
||||
/**
|
||||
* Figma 1096:55159 (C2 step 2): AWS Production staged, listed with its status. Save and Cancel
|
||||
* pin to the layout's footer, which only renders inside `bit-layout`.
|
||||
*/
|
||||
export const TargetSystemStaged: Story = {
|
||||
decorators: [at(NO_TARGETS_DETAIL)],
|
||||
play: async ({ canvasElement }) => {
|
||||
await openTargetSystemPicker(canvasElement);
|
||||
await userEvent.click(
|
||||
await within(document.body).findByRole("option", { name: /^AWS Production/ }),
|
||||
);
|
||||
await userEvent.keyboard("{Tab}");
|
||||
},
|
||||
};
|
||||
|
||||
/** Figma 1096:56430 (C3 step 1) and 1096:57558 (C4 step 1): Azure production. */
|
||||
export const AzureProduction: Story = {
|
||||
decorators: [at(AZURE_DETAIL)],
|
||||
};
|
||||
|
||||
/** Figma 1096:60098 (5a): Rotation history with no rotations yet; no header actions. */
|
||||
export const RotationHistoryEmpty: Story = {
|
||||
decorators: [at(AZURE_NO_HISTORY_DETAIL, "history")],
|
||||
};
|
||||
|
||||
/** Figma 1096:60429 (5b): Rotation history naming each job's managed credential. */
|
||||
export const RotationHistory: Story = {
|
||||
decorators: [at(AZURE_DETAIL, "history")],
|
||||
};
|
||||
|
||||
export const LongName: Story = {
|
||||
decorators: [at(LONG_NAME_DETAIL)],
|
||||
};
|
||||
|
||||
@@ -1,30 +1,51 @@
|
||||
import { CommonModule } from "@angular/common";
|
||||
import { ChangeDetectionStrategy, Component, computed, inject, signal } from "@angular/core";
|
||||
import { takeUntilDestroyed, toSignal } from "@angular/core/rxjs-interop";
|
||||
import { FormBuilder, ReactiveFormsModule } from "@angular/forms";
|
||||
import { TemplatePortal } from "@angular/cdk/portal";
|
||||
import {
|
||||
ChangeDetectionStrategy,
|
||||
Component,
|
||||
DestroyRef,
|
||||
TemplateRef,
|
||||
ViewContainerRef,
|
||||
computed,
|
||||
effect,
|
||||
inject,
|
||||
signal,
|
||||
viewChild,
|
||||
} from "@angular/core";
|
||||
import { toSignal } from "@angular/core/rxjs-interop";
|
||||
import { FormsModule } from "@angular/forms";
|
||||
import { ActivatedRoute, Router } from "@angular/router";
|
||||
import { map } from "rxjs";
|
||||
|
||||
import {
|
||||
accessConnectorDeactivateConfirmOptions,
|
||||
accessConnectorDeleteConfirmOptions,
|
||||
TimestampPipe,
|
||||
} from "@bitwarden/bit-pam-components";
|
||||
import { ErrorResponse } from "@bitwarden/common/models/response/error.response";
|
||||
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
||||
import { asUuid } from "@bitwarden/common/platform/abstractions/sdk/sdk.service";
|
||||
import { asUuid, uuidAsString } from "@bitwarden/common/platform/abstractions/sdk/sdk.service";
|
||||
import { OrganizationId } from "@bitwarden/common/types/guid";
|
||||
import {
|
||||
AsyncActionsModule,
|
||||
BadgeModule,
|
||||
BitCellComponent,
|
||||
BitCellDefDirective,
|
||||
BitColumnComponent,
|
||||
BitHeaderCellComponent,
|
||||
BitTableV2Component,
|
||||
ButtonModule,
|
||||
CalloutModule,
|
||||
CardComponent,
|
||||
CheckboxModule,
|
||||
CopyClickDirective,
|
||||
defineTable,
|
||||
DialogService,
|
||||
FormFieldModule,
|
||||
HeaderComponent,
|
||||
IconButtonModule,
|
||||
IconModule,
|
||||
LayoutFooterService,
|
||||
MenuModule,
|
||||
MultiSelectModule,
|
||||
SectionComponent,
|
||||
SectionHeaderComponent,
|
||||
SelectItemView,
|
||||
@@ -32,24 +53,20 @@ import {
|
||||
SkeletonTextComponent,
|
||||
TabsModule,
|
||||
ToastService,
|
||||
TooltipDirective,
|
||||
TypographyModule,
|
||||
} from "@bitwarden/components";
|
||||
import type { CipherId } from "@bitwarden/sdk-internal";
|
||||
import { I18nPipe } from "@bitwarden/ui-common";
|
||||
|
||||
import { HasUnsavedChangesDialog } from "../../unsaved-changes.guard";
|
||||
import {
|
||||
AssignmentPickerColumn,
|
||||
AssignmentPickerComponent,
|
||||
AssignmentPickerHints,
|
||||
AssignmentPickerRow,
|
||||
} from "../assignment-picker/assignment-picker.component";
|
||||
import { DetailBreadcrumbComponent } from "../detail-breadcrumb.component";
|
||||
import { tabFromSegment } from "../detail-tab";
|
||||
import { RotationHistorySkeletonComponent } from "../managed-credentials/rotation-history-skeleton.component";
|
||||
import { RotationHistoryComponent } from "../managed-credentials/rotation-history.component";
|
||||
import { OrgCiphersService } from "../org-ciphers.service";
|
||||
import {
|
||||
AccessConnector,
|
||||
AccessConnectorDetail,
|
||||
AccessConnectorId,
|
||||
AccessConnectorStatus,
|
||||
@@ -62,45 +79,67 @@ import { rotationErrorMessage } from "../rotation-error";
|
||||
import { ROTATION_TABS, rotationLink } from "../rotation-links";
|
||||
import { RotationLoadErrorComponent } from "../rotation-load-error.component";
|
||||
import { RotationLoadingAnnouncerComponent } from "../rotation-loading-announcer.component";
|
||||
import { lastSeenText, relativeTimeLabel } from "../rotation-relative-time";
|
||||
import { RotationSdkService } from "../rotation-sdk.service";
|
||||
import { showSkeletonWhile } from "../skeleton-delay";
|
||||
import { TargetSystemLabel, targetSystemLabel } from "../target-systems/target-system-label";
|
||||
import { targetSystemLabel } from "../target-systems/target-system-label";
|
||||
import {
|
||||
TargetSystemStatusBadge,
|
||||
resolveTargetSystemStatus,
|
||||
targetSystemStatusBadge,
|
||||
} from "../target-systems/target-system-status";
|
||||
import { TargetSystemsService } from "../target-systems/target-systems.service";
|
||||
|
||||
import { accessConnectorDisplayStatus, accessConnectorStatusBadge } from "./access-connector-label";
|
||||
|
||||
const ACCESS_CONNECTOR_DETAIL_TABS = ["configuration", "history"] as const;
|
||||
|
||||
/** `null` for a saved assignment, otherwise the staged change not yet saved. */
|
||||
export type AccessConnectorAssignmentPending = "add" | "remove" | null;
|
||||
/** One row of the assigned target systems table, which lists the staged assignments. */
|
||||
export type AccessConnectorAssignment = {
|
||||
readonly id: string;
|
||||
readonly targetSystemId: TargetSystemId;
|
||||
readonly idText: string;
|
||||
readonly name: string;
|
||||
/** The target system's name with its type, for the row's control labels. */
|
||||
readonly label: string;
|
||||
/** i18n key for the System type column, or null when there is none to state. */
|
||||
readonly typeKey: string | null;
|
||||
/** Null while the target system is unknown. */
|
||||
readonly statusBadge: TargetSystemStatusBadge | null;
|
||||
};
|
||||
|
||||
export type AccessConnectorAssignment = Omit<TargetSystemLabel, "id"> &
|
||||
AssignmentPickerRow & {
|
||||
readonly targetSystemId: TargetSystemId;
|
||||
readonly pending: AccessConnectorAssignmentPending;
|
||||
};
|
||||
/** Which notice tops the Configuration tab, if any. */
|
||||
export type AccessConnectorCallout = "never-connected" | "disconnected" | null;
|
||||
|
||||
/**
|
||||
* Detail page for one access connector, a sibling of the rotation shell. It provides its own
|
||||
* {@link TargetSystemsService} and {@link OrgCiphersService}, since the shell's don't reach it.
|
||||
* Activate, Deactivate and Delete take effect at once; target system assignments are staged in
|
||||
* the picker and written by the pinned footer's Save.
|
||||
*/
|
||||
@Component({
|
||||
templateUrl: "./access-connector-detail.component.html",
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
providers: [TargetSystemsService, OrgCiphersService],
|
||||
imports: [
|
||||
CommonModule,
|
||||
ReactiveFormsModule,
|
||||
AssignmentPickerComponent,
|
||||
FormsModule,
|
||||
AsyncActionsModule,
|
||||
BadgeModule,
|
||||
BitCellComponent,
|
||||
DetailBreadcrumbComponent,
|
||||
BitCellDefDirective,
|
||||
BitColumnComponent,
|
||||
BitHeaderCellComponent,
|
||||
BitTableV2Component,
|
||||
ButtonModule,
|
||||
CalloutModule,
|
||||
CardComponent,
|
||||
CheckboxModule,
|
||||
CopyClickDirective,
|
||||
DetailBreadcrumbComponent,
|
||||
FormFieldModule,
|
||||
HeaderComponent,
|
||||
IconButtonModule,
|
||||
IconModule,
|
||||
MenuModule,
|
||||
MultiSelectModule,
|
||||
RotationHistoryComponent,
|
||||
RotationHistorySkeletonComponent,
|
||||
RotationLoadErrorComponent,
|
||||
@@ -110,8 +149,10 @@ export type AccessConnectorAssignment = Omit<TargetSystemLabel, "id"> &
|
||||
SkeletonComponent,
|
||||
SkeletonTextComponent,
|
||||
TabsModule,
|
||||
TooltipDirective,
|
||||
TypographyModule,
|
||||
I18nPipe,
|
||||
TimestampPipe,
|
||||
],
|
||||
})
|
||||
export class AccessConnectorDetailComponent implements HasUnsavedChangesDialog {
|
||||
@@ -123,7 +164,8 @@ export class AccessConnectorDetailComponent implements HasUnsavedChangesDialog {
|
||||
private readonly dialogService = inject(DialogService);
|
||||
private readonly toastService = inject(ToastService);
|
||||
private readonly i18nService = inject(I18nService);
|
||||
private readonly formBuilder = inject(FormBuilder);
|
||||
private readonly viewContainerRef = inject(ViewContainerRef);
|
||||
private readonly layoutFooter = inject(LayoutFooterService);
|
||||
|
||||
private readonly organizationId = this.route.snapshot.params.organizationId as OrganizationId;
|
||||
private readonly accessConnectorId = asUuid<AccessConnectorId>(
|
||||
@@ -132,30 +174,17 @@ export class AccessConnectorDetailComponent implements HasUnsavedChangesDialog {
|
||||
|
||||
protected readonly loading = signal(true);
|
||||
|
||||
/** Whether the placeholder is drawn, which trails {@link loading} by the skeleton delay. */
|
||||
protected readonly showSkeleton = showSkeletonWhile(this.loading);
|
||||
|
||||
protected readonly loadingVisible = computed(() => this.loading() || this.showSkeleton());
|
||||
|
||||
protected readonly loadError = signal<unknown | null>(null);
|
||||
protected readonly accessConnector = signal<AccessConnectorDetail | null>(null);
|
||||
|
||||
/**
|
||||
* The staged connector, which the page renders and {@link submit} diffs against the saved one.
|
||||
*/
|
||||
protected readonly formGroup = this.formBuilder.nonNullable.group({
|
||||
active: false,
|
||||
assignedTargetSystemIds: this.formBuilder.nonNullable.control<TargetSystemId[]>([]),
|
||||
});
|
||||
/** The assignments the picker holds, which {@link submit} diffs against the saved ones. */
|
||||
private readonly stagedAssignmentIds = signal<readonly TargetSystemId[]>([]);
|
||||
|
||||
private readonly staged = toSignal(
|
||||
this.formGroup.valueChanges.pipe(map(() => this.formGroup.getRawValue())),
|
||||
{ initialValue: this.formGroup.getRawValue() },
|
||||
);
|
||||
/** Holds the header's status actions while one is running. */
|
||||
protected readonly statusBusy = signal(false);
|
||||
|
||||
protected readonly stagedActive = computed(() => this.staged().active);
|
||||
|
||||
private readonly stagedAssignmentIds = computed(() => this.staged().assignedTargetSystemIds);
|
||||
/** Set by a failed Save, which the Configuration tab states until the next attempt. */
|
||||
protected readonly saveFailed = signal(false);
|
||||
|
||||
protected readonly activeTab = toSignal(
|
||||
this.route.paramMap.pipe(
|
||||
@@ -169,12 +198,6 @@ export class AccessConnectorDetailComponent implements HasUnsavedChangesDialog {
|
||||
},
|
||||
);
|
||||
|
||||
/** Route to the Target systems tab, offered when the org has nothing eligible to assign. */
|
||||
protected readonly targetSystemsRoute = rotationLink(
|
||||
this.organizationId,
|
||||
ROTATION_TABS.targetSystems,
|
||||
);
|
||||
|
||||
/** Route to the Access connectors list, behind the breadcrumb and every exit. */
|
||||
protected readonly connectorsListRoute = rotationLink(
|
||||
this.organizationId,
|
||||
@@ -199,6 +222,12 @@ export class AccessConnectorDetailComponent implements HasUnsavedChangesDialog {
|
||||
/** The org's rotation configs, loaded only when there is job history to label. */
|
||||
private readonly rotationConfigs = signal<RotationConfigView[]>([]);
|
||||
|
||||
/**
|
||||
* Every access connector in the org, for the target systems' Not connected status. `null` while
|
||||
* unread or failed, which never reads as Not connected.
|
||||
*/
|
||||
private readonly orgConnectors = signal<readonly AccessConnector[] | null>(null);
|
||||
|
||||
private readonly cipherNameById = toSignal(this.orgCiphers.cipherNameById$, {
|
||||
initialValue: new Map<CipherId, string>(),
|
||||
});
|
||||
@@ -226,207 +255,309 @@ export class AccessConnectorDetailComponent implements HasUnsavedChangesDialog {
|
||||
|
||||
private readonly connector = computed(() => this.accessConnector()?.connector ?? null);
|
||||
|
||||
/** `null` when the design shows no wording for the span, so the template shows the date. */
|
||||
protected readonly lastSeenAtMs = computed(() => {
|
||||
const heartbeat = this.connector()?.lastHeartbeatAt;
|
||||
const ms = heartbeat ? Date.parse(heartbeat) : NaN;
|
||||
return Number.isNaN(ms) ? null : ms;
|
||||
});
|
||||
|
||||
protected readonly lastSeenLabel = computed(() => {
|
||||
const ms = this.lastSeenAtMs();
|
||||
return ms == null ? null : relativeTimeLabel(this.i18nService, lastSeenText(ms, Date.now()));
|
||||
});
|
||||
|
||||
/** The saved assignments, which the staged list is diffed against. */
|
||||
private readonly savedAssignmentIds = computed<readonly TargetSystemId[]>(
|
||||
() => this.connector()?.assignedTargetSystemIds ?? [],
|
||||
);
|
||||
|
||||
/** Every target the table lists: what is saved, then what has been staged on top of it. */
|
||||
protected readonly assignments = computed<AccessConnectorAssignment[]>(() => {
|
||||
const systemById = this.systemById();
|
||||
const saved = this.savedAssignmentIds();
|
||||
const stagedIds = this.stagedAssignmentIds();
|
||||
const savedSet = new Set<string>(saved.map(String));
|
||||
const stagedSet = new Set<string>(stagedIds.map(String));
|
||||
|
||||
const listed = [...saved, ...stagedIds.filter((id) => !savedSet.has(String(id)))];
|
||||
return listed.map((id) => {
|
||||
const label = targetSystemLabel(this.i18nService, id, systemById.get(id));
|
||||
const pending: AccessConnectorAssignmentPending = !savedSet.has(String(id))
|
||||
? "add"
|
||||
: !stagedSet.has(String(id))
|
||||
? "remove"
|
||||
: null;
|
||||
return {
|
||||
...label,
|
||||
id: String(id),
|
||||
targetSystemId: id,
|
||||
label: label.qualified,
|
||||
pending,
|
||||
};
|
||||
});
|
||||
});
|
||||
|
||||
protected readonly titleText = computed(() => this.connector()?.name ?? "");
|
||||
|
||||
/** The saved status, which the header badge states; the checkbox states the staged one. */
|
||||
protected readonly enabled = computed(
|
||||
() => this.connector()?.status === AccessConnectorStatus.Enabled,
|
||||
);
|
||||
|
||||
/** The automatic target systems the staged list does not hold, as picker rows. */
|
||||
protected readonly assignOptions = computed<SelectItemView[]>(() => {
|
||||
const staged = new Set<string>(this.stagedAssignmentIds().map(String));
|
||||
return this.automaticSystems()
|
||||
.filter((system) => !staged.has(String(system.id)))
|
||||
.map((system) => {
|
||||
const { qualified } = targetSystemLabel(this.i18nService, system.id, system);
|
||||
return { id: String(system.id), listName: qualified, labelName: qualified };
|
||||
});
|
||||
/** The header badge: Inactive, else Connected or Disconnected. */
|
||||
protected readonly statusBadge = computed(() => {
|
||||
const connector = this.connector();
|
||||
return connector == null
|
||||
? null
|
||||
: accessConnectorStatusBadge(accessConnectorDisplayStatus(connector));
|
||||
});
|
||||
|
||||
/** True when the org has nothing eligible at all, rather than having assigned it all. */
|
||||
protected readonly noEligibleTargetSystems = computed(
|
||||
() => this.targetSystemsLoadError() == null && this.automaticSystems().length === 0,
|
||||
/** An active connector that isn't connected says why; one never seen still needs setting up. */
|
||||
protected readonly callout = computed<AccessConnectorCallout>(() => {
|
||||
const connector = this.connector();
|
||||
if (connector == null || !this.enabled() || connector.isConnected) {
|
||||
return null;
|
||||
}
|
||||
return this.lastSeenAtMs() == null ? "never-connected" : "disconnected";
|
||||
});
|
||||
|
||||
/** The org's connectors with this one as saved here, so its own changes show at once. */
|
||||
private readonly connectorsForStatus = computed<readonly AccessConnector[] | null>(() => {
|
||||
const connectors = this.orgConnectors();
|
||||
const connector = this.connector();
|
||||
if (connectors == null || connector == null) {
|
||||
return connectors;
|
||||
}
|
||||
return [...connectors.filter((other) => other.id !== connector.id), connector];
|
||||
});
|
||||
|
||||
/** Every target the picker holds, in the order it was staged. */
|
||||
protected readonly assignments = computed<AccessConnectorAssignment[]>(() => {
|
||||
const systemById = this.systemById();
|
||||
const connectors = this.connectorsForStatus();
|
||||
return this.stagedAssignmentIds().map((id) => {
|
||||
const system = systemById.get(id);
|
||||
const label = targetSystemLabel(this.i18nService, id, system);
|
||||
return {
|
||||
id: String(id),
|
||||
targetSystemId: id,
|
||||
idText: uuidAsString(id),
|
||||
name: label.name,
|
||||
label: label.qualified,
|
||||
typeKey: label.qualifierKey,
|
||||
statusBadge:
|
||||
system == null
|
||||
? null
|
||||
: targetSystemStatusBadge(resolveTargetSystemStatus(system, connectors)),
|
||||
};
|
||||
});
|
||||
});
|
||||
|
||||
protected readonly assignmentsTable = defineTable<AccessConnectorAssignment, "actions">(
|
||||
this.assignments,
|
||||
);
|
||||
|
||||
protected readonly assignmentColumns: readonly AssignmentPickerColumn[] = [
|
||||
{ headerKey: "pamAccessConnectorAssignTargetLabel" },
|
||||
{ headerKey: "pamTargetSystemTypeColumn" },
|
||||
{ headerKey: "pamTargetSystemIdLabel" },
|
||||
];
|
||||
/**
|
||||
* The picker's options: the automatic target systems, plus anything staged that isn't one, so
|
||||
* every chip has an option behind it. An inactive connector offers only what it holds, since
|
||||
* the server assigns only to an enabled one.
|
||||
*/
|
||||
protected readonly selectOptions = computed<SelectItemView[]>(() => {
|
||||
const staged = this.stagedAssignmentIds();
|
||||
const stagedSet = new Set<string>(staged.map(String));
|
||||
const systemById = this.systemById();
|
||||
const offered = this.enabled()
|
||||
? this.automaticSystems()
|
||||
: this.automaticSystems().filter((system) => stagedSet.has(String(system.id)));
|
||||
const offeredSet = new Set<string>(offered.map((system) => String(system.id)));
|
||||
const extra = staged.filter((id) => !offeredSet.has(String(id)));
|
||||
return [
|
||||
...offered.map((system) => this.selectItem(system.id, system)),
|
||||
...extra.map((id) => this.selectItem(id, systemById.get(id))),
|
||||
];
|
||||
});
|
||||
|
||||
protected readonly assignmentHints: AssignmentPickerHints = {
|
||||
default: "pamAccessConnectorAssignSelectHint",
|
||||
noneEligible: "pamAccessConnectorAssignNoTargetSystems",
|
||||
loadError: "pamAccessConnectorTargetSystemsLoadError",
|
||||
disabled: "pamAccessConnectorAssignTargetDisabled",
|
||||
};
|
||||
/** The staged assignments as picker items, which the multi-select shows as chips. */
|
||||
protected readonly selectedItems = computed<SelectItemView[]>(() => {
|
||||
const byId = new Map(this.selectOptions().map((item) => [item.id, item]));
|
||||
return this.stagedAssignmentIds()
|
||||
.map((id) => byId.get(String(id)))
|
||||
.filter((item): item is SelectItemView => item != null);
|
||||
});
|
||||
|
||||
/** The i18n key for the hint under the picker. */
|
||||
protected readonly pickerHintKey = computed(() => {
|
||||
if (this.targetSystemsLoadError() != null) {
|
||||
return "pamAccessConnectorTargetSystemsLoadError";
|
||||
}
|
||||
if (!this.enabled()) {
|
||||
return "pamAccessConnectorAssignTargetSystemsDisabled";
|
||||
}
|
||||
return "pamAccessConnectorTargetSystemsHint";
|
||||
});
|
||||
|
||||
/** True when the staged assignments differ from the saved ones. */
|
||||
protected readonly hasUnsavedChanges = computed(() => {
|
||||
const saved = new Set<string>(this.savedAssignmentIds().map(String));
|
||||
const staged = this.stagedAssignmentIds();
|
||||
return staged.length !== saved.size || staged.some((id) => !saved.has(String(id)));
|
||||
});
|
||||
|
||||
protected readonly showFooter = computed(
|
||||
() =>
|
||||
!this.loading() &&
|
||||
this.loadError() == null &&
|
||||
this.activeTab() === "configuration" &&
|
||||
this.hasUnsavedChanges(),
|
||||
);
|
||||
|
||||
private readonly footerTemplate = viewChild<TemplateRef<unknown>>("footer");
|
||||
|
||||
constructor() {
|
||||
this.formGroup.controls.active.valueChanges.pipe(takeUntilDestroyed()).subscribe((active) => {
|
||||
if (!active) {
|
||||
this.dropStagedAssignmentAdditions();
|
||||
}
|
||||
});
|
||||
this.pinFooter();
|
||||
void this.initialize();
|
||||
}
|
||||
|
||||
/** Stage every picked target; nothing is written until Save. */
|
||||
protected readonly assignTargets = async (
|
||||
selected: SelectItemView[],
|
||||
): Promise<readonly string[]> => {
|
||||
if (!this.stagedActive() || selected.length === 0) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const staged = new Set<string>(this.stagedAssignmentIds().map(String));
|
||||
const added = selected
|
||||
.filter((item) => !staged.has(item.id))
|
||||
/** Mirrors the picker's selection into the staged list; nothing is written until Save. */
|
||||
protected onSelectionChanged(items: SelectItemView[] | null): void {
|
||||
const selected = new Set((items ?? []).map((item) => item.id));
|
||||
const kept = this.stagedAssignmentIds().filter((id) => selected.has(String(id)));
|
||||
const keptSet = new Set<string>(kept.map(String));
|
||||
const added = (items ?? [])
|
||||
.filter((item) => !keptSet.has(item.id))
|
||||
.map((item) => asUuid<TargetSystemId>(item.id));
|
||||
this.stageAssignments((ids) => [...ids, ...added]);
|
||||
return selected.map((item) => item.id);
|
||||
};
|
||||
this.stagedAssignmentIds.set([...kept, ...added]);
|
||||
}
|
||||
|
||||
/** Stage one target's removal. */
|
||||
protected readonly unassignTarget = async (
|
||||
assignment: AccessConnectorAssignment,
|
||||
): Promise<boolean> => {
|
||||
const targetSystemId = assignment.targetSystemId;
|
||||
if (!this.stagedAssignmentIds().some((id) => id === targetSystemId)) {
|
||||
return false;
|
||||
}
|
||||
this.stageAssignments((ids) => ids.filter((id) => id !== targetSystemId));
|
||||
return true;
|
||||
};
|
||||
/** Stages one target's removal. */
|
||||
protected unassignTarget(assignment: AccessConnectorAssignment): void {
|
||||
this.stagedAssignmentIds.update((ids) => ids.filter((id) => id !== assignment.targetSystemId));
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables before writing assignments and disables after, since only an enabled connector can be
|
||||
* assigned.
|
||||
*/
|
||||
protected discardEdits(): void {
|
||||
this.saveFailed.set(false);
|
||||
this.stagedAssignmentIds.set([...this.savedAssignmentIds()]);
|
||||
}
|
||||
|
||||
/** Writes the staged assignments, then returns to the list. */
|
||||
protected readonly submit = async (): Promise<void> => {
|
||||
const connector = this.connector();
|
||||
if (connector == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
const active = this.stagedActive();
|
||||
const statusChange = active === this.enabled() ? null : active;
|
||||
if (statusChange === false && !(await this.confirmDeactivate(connector.name))) {
|
||||
return;
|
||||
}
|
||||
|
||||
const saved = this.savedAssignmentIds();
|
||||
const staged = this.stagedAssignmentIds();
|
||||
const toAssign = staged.filter((id) => !saved.includes(id));
|
||||
const toUnassign = saved.filter((id) => !staged.includes(id));
|
||||
|
||||
this.saveFailed.set(false);
|
||||
try {
|
||||
if (statusChange === true) {
|
||||
await this.writeStatus(connector.id, true);
|
||||
}
|
||||
await this.writeAssignments(connector.id, toAssign, toUnassign);
|
||||
if (statusChange === false) {
|
||||
await this.writeStatus(connector.id, false);
|
||||
}
|
||||
} catch (e) {
|
||||
this.showError(e);
|
||||
this.saveFailed.set(true);
|
||||
this.showError(e, "pamAccessConnectorSaveFailed");
|
||||
return;
|
||||
}
|
||||
|
||||
this.formGroup.markAsPristine();
|
||||
this.toastService.showToast({
|
||||
variant: "success",
|
||||
message: this.i18nService.t("pamAccessConnectorSaved"),
|
||||
});
|
||||
await this.navigateToList();
|
||||
};
|
||||
|
||||
protected readonly deleteAccessConnector = async (): Promise<void> => {
|
||||
protected readonly activate = async (): Promise<void> => {
|
||||
const connector = this.connector();
|
||||
if (connector == null) {
|
||||
if (connector == null || this.statusBusy()) {
|
||||
return;
|
||||
}
|
||||
this.statusBusy.set(true);
|
||||
try {
|
||||
await this.rotationSdk.enableConnector(this.organizationId, connector.id);
|
||||
this.patchStatus(AccessConnectorStatus.Enabled);
|
||||
this.toastService.showToast({
|
||||
variant: "success",
|
||||
message: this.i18nService.t("pamAccessConnectorActivated"),
|
||||
});
|
||||
} catch (e) {
|
||||
this.showError(e, "unexpectedError");
|
||||
} finally {
|
||||
this.statusBusy.set(false);
|
||||
}
|
||||
};
|
||||
|
||||
/** Bound to a menu item, so it confirms and reports its own failure. */
|
||||
protected async deactivate(): Promise<void> {
|
||||
const connector = this.connector();
|
||||
if (connector == null || this.statusBusy()) {
|
||||
return;
|
||||
}
|
||||
if (!(await this.dialogService.openSimpleDialog(accessConnectorDeactivateConfirmOptions()))) {
|
||||
return;
|
||||
}
|
||||
this.statusBusy.set(true);
|
||||
try {
|
||||
await this.rotationSdk.disableConnector(this.organizationId, connector.id);
|
||||
this.patchStatus(AccessConnectorStatus.Disabled);
|
||||
this.dropStagedAssignmentAdditions();
|
||||
this.toastService.showToast({
|
||||
variant: "success",
|
||||
message: this.i18nService.t("pamAccessConnectorDeactivated"),
|
||||
});
|
||||
} catch (e) {
|
||||
this.showError(e, "pamAccessConnectorDeactivateFailed");
|
||||
} finally {
|
||||
this.statusBusy.set(false);
|
||||
}
|
||||
}
|
||||
|
||||
/** Bound to a menu item, so it confirms and reports its own failure. */
|
||||
protected async deleteAccessConnector(): Promise<void> {
|
||||
const connector = this.connector();
|
||||
if (connector == null || this.statusBusy()) {
|
||||
return;
|
||||
}
|
||||
const confirmed = await this.dialogService.openSimpleDialog(
|
||||
accessConnectorDeleteConfirmOptions(connector.name),
|
||||
accessConnectorDeleteConfirmOptions(),
|
||||
);
|
||||
if (!confirmed) {
|
||||
return;
|
||||
}
|
||||
this.statusBusy.set(true);
|
||||
try {
|
||||
await this.rotationSdk.deleteConnector(this.organizationId, connector.id);
|
||||
this.toastService.showToast({
|
||||
variant: "success",
|
||||
message: this.i18nService.t("pamAccessConnectorDeleted"),
|
||||
});
|
||||
await this.navigateToList();
|
||||
this.discardEdits();
|
||||
await this.router.navigate(this.connectorsListRoute);
|
||||
} catch (e) {
|
||||
this.showError(e);
|
||||
this.showError(e, "pamAccessConnectorDeleteFailed");
|
||||
} finally {
|
||||
this.statusBusy.set(false);
|
||||
}
|
||||
};
|
||||
|
||||
unsavedChanges(): boolean {
|
||||
return this.formGroup.dirty;
|
||||
}
|
||||
|
||||
private confirmDeactivate(name: string): Promise<boolean> {
|
||||
return this.dialogService.openSimpleDialog(accessConnectorDeactivateConfirmOptions(name));
|
||||
}
|
||||
|
||||
/**
|
||||
* The server assigns only to an enabled connector, so unchecking Active drops staged additions.
|
||||
* Read by the CanDeactivate guard, which a `:tab` change doesn't trigger. Nothing is unsaved
|
||||
* while loading, since nothing has been staged yet.
|
||||
*/
|
||||
unsavedChanges(): boolean {
|
||||
return !this.loading() && this.hasUnsavedChanges();
|
||||
}
|
||||
|
||||
private selectItem(id: TargetSystemId, system: TargetSystemView | undefined): SelectItemView {
|
||||
const { qualified } = targetSystemLabel(this.i18nService, id, system);
|
||||
return { id: String(id), listName: qualified, labelName: qualified };
|
||||
}
|
||||
|
||||
/**
|
||||
* Pins Save and Cancel to the layout's footer region, outside the scrolling content, while an
|
||||
* assignment change is unsaved.
|
||||
*/
|
||||
private pinFooter(): void {
|
||||
let portal: TemplatePortal | null = null;
|
||||
const detach = () => {
|
||||
if (portal != null) {
|
||||
this.layoutFooter.detach(portal);
|
||||
portal = null;
|
||||
}
|
||||
};
|
||||
effect(() => {
|
||||
const template = this.footerTemplate();
|
||||
if (template == null || !this.showFooter()) {
|
||||
detach();
|
||||
} else if (portal == null) {
|
||||
portal = new TemplatePortal(template, this.viewContainerRef);
|
||||
this.layoutFooter.attach(portal);
|
||||
}
|
||||
});
|
||||
inject(DestroyRef).onDestroy(detach);
|
||||
}
|
||||
|
||||
/**
|
||||
* The server assigns only to an enabled connector, so deactivating drops staged additions.
|
||||
* Staged removals survive, since the server still honours them for an inactive connector.
|
||||
*/
|
||||
private dropStagedAssignmentAdditions(): void {
|
||||
const saved = new Set<string>(this.savedAssignmentIds().map(String));
|
||||
if (this.stagedAssignmentIds().every((id) => saved.has(String(id)))) {
|
||||
return;
|
||||
}
|
||||
this.stageAssignments((ids) => ids.filter((id) => saved.has(String(id))));
|
||||
}
|
||||
|
||||
private stageAssignments(update: (ids: TargetSystemId[]) => TargetSystemId[]): void {
|
||||
const control = this.formGroup.controls.assignedTargetSystemIds;
|
||||
control.setValue(update(control.value));
|
||||
control.markAsDirty();
|
||||
}
|
||||
|
||||
private async writeStatus(id: AccessConnectorId, active: boolean): Promise<void> {
|
||||
if (active) {
|
||||
await this.rotationSdk.enableConnector(this.organizationId, id);
|
||||
} else {
|
||||
await this.rotationSdk.disableConnector(this.organizationId, id);
|
||||
}
|
||||
this.patchStatus(active ? AccessConnectorStatus.Enabled : AccessConnectorStatus.Disabled);
|
||||
this.stagedAssignmentIds.update((ids) => ids.filter((id) => saved.has(String(id))));
|
||||
}
|
||||
|
||||
/** One call at a time; a refusal stops the rest and leaves earlier writes saved. */
|
||||
@@ -464,7 +595,8 @@ export class AccessConnectorDetailComponent implements HasUnsavedChangesDialog {
|
||||
]);
|
||||
if (accessConnector != null) {
|
||||
this.accessConnector.set(accessConnector);
|
||||
this.resetForm();
|
||||
this.stagedAssignmentIds.set([...this.savedAssignmentIds()]);
|
||||
void this.loadOrgConnectors();
|
||||
if (accessConnector.jobs.length > 0) {
|
||||
void this.loadCredentialNames();
|
||||
}
|
||||
@@ -474,12 +606,13 @@ export class AccessConnectorDetailComponent implements HasUnsavedChangesDialog {
|
||||
}
|
||||
}
|
||||
|
||||
private resetForm(): void {
|
||||
this.formGroup.setValue({
|
||||
active: this.enabled(),
|
||||
assignedTargetSystemIds: [...this.savedAssignmentIds()],
|
||||
});
|
||||
this.formGroup.markAsPristine();
|
||||
/** Not awaited; a failure only costs the target systems their Not connected status. */
|
||||
private async loadOrgConnectors(): Promise<void> {
|
||||
try {
|
||||
this.orgConnectors.set(await this.rotationSdk.listConnectors(this.organizationId));
|
||||
} catch {
|
||||
this.orgConnectors.set(null);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -509,7 +642,6 @@ export class AccessConnectorDetailComponent implements HasUnsavedChangesDialog {
|
||||
}
|
||||
|
||||
private navigateToList(): Promise<boolean> {
|
||||
this.formGroup.markAsPristine();
|
||||
return this.router.navigate(this.connectorsListRoute);
|
||||
}
|
||||
|
||||
@@ -538,11 +670,12 @@ export class AccessConnectorDetailComponent implements HasUnsavedChangesDialog {
|
||||
});
|
||||
}
|
||||
|
||||
private showError(e: unknown): void {
|
||||
/** The SDK's or server's reason when there is one, else the action's own failure copy. */
|
||||
private showError(e: unknown, fallbackKey: string): void {
|
||||
const message =
|
||||
rotationErrorMessage(e) ??
|
||||
(e instanceof ErrorResponse ? e.message : undefined) ??
|
||||
this.i18nService.t("unexpectedError");
|
||||
this.i18nService.t(fallbackKey);
|
||||
this.toastService.showToast({ variant: "error", message });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import { AccessConnectorStatus } from "../rotation";
|
||||
import type { BadgeVariant, BitwardenIcon, IconTileVariant } from "@bitwarden/components";
|
||||
|
||||
import { AccessConnector, AccessConnectorStatus } from "../rotation";
|
||||
|
||||
/** How an access connector's two states are named and badged, wherever one is shown. */
|
||||
export function accessConnectorStatusLabelKey(
|
||||
@@ -12,3 +14,78 @@ export function accessConnectorConnectionLabelKey(
|
||||
): "pamAccessConnectorConnected" | "pamAccessConnectorDisconnected" {
|
||||
return isConnected ? "pamAccessConnectorConnected" : "pamAccessConnectorDisconnected";
|
||||
}
|
||||
|
||||
/** The one status an access connector shows. See {@link accessConnectorDisplayStatus}. */
|
||||
export const AccessConnectorDisplayStatus = Object.freeze({
|
||||
Disconnected: "disconnected",
|
||||
Inactive: "inactive",
|
||||
Connected: "connected",
|
||||
} as const);
|
||||
export type AccessConnectorDisplayStatus =
|
||||
(typeof AccessConnectorDisplayStatus)[keyof typeof AccessConnectorDisplayStatus];
|
||||
|
||||
/** How a status renders as a badge, and as a filter option's icon tile. */
|
||||
export type AccessConnectorStatusBadge = {
|
||||
readonly status: AccessConnectorDisplayStatus;
|
||||
readonly labelKey: string;
|
||||
readonly variant: BadgeVariant;
|
||||
readonly icon: BitwardenIcon;
|
||||
readonly tileVariant: IconTileVariant;
|
||||
/** Ascending position by urgency, which differs from the precedence that picks the status. */
|
||||
readonly sortOrder: number;
|
||||
};
|
||||
|
||||
const STATUS_BADGES: Readonly<
|
||||
Record<AccessConnectorDisplayStatus, Readonly<AccessConnectorStatusBadge>>
|
||||
> = Object.freeze({
|
||||
[AccessConnectorDisplayStatus.Disconnected]: {
|
||||
status: AccessConnectorDisplayStatus.Disconnected,
|
||||
labelKey: "pamAccessConnectorDisconnected",
|
||||
variant: "warning",
|
||||
icon: "bwi-warning",
|
||||
tileVariant: "warning",
|
||||
sortOrder: 1,
|
||||
},
|
||||
[AccessConnectorDisplayStatus.Inactive]: {
|
||||
status: AccessConnectorDisplayStatus.Inactive,
|
||||
labelKey: "inactive",
|
||||
variant: "subtle",
|
||||
icon: "bwi-minus-circle",
|
||||
tileVariant: "gray",
|
||||
sortOrder: 2,
|
||||
},
|
||||
[AccessConnectorDisplayStatus.Connected]: {
|
||||
status: AccessConnectorDisplayStatus.Connected,
|
||||
labelKey: "pamAccessConnectorConnected",
|
||||
variant: "success",
|
||||
icon: "bwi-check-circle",
|
||||
tileVariant: "success",
|
||||
sortOrder: 3,
|
||||
},
|
||||
} as const);
|
||||
|
||||
/** Every status, in urgency order, as the status filter offers them. */
|
||||
export const ACCESS_CONNECTOR_STATUS_BADGES: readonly AccessConnectorStatusBadge[] = Object.freeze(
|
||||
Object.values(STATUS_BADGES).sort((a, b) => a.sortOrder - b.sortOrder),
|
||||
);
|
||||
|
||||
/**
|
||||
* The first true of Inactive, Disconnected, Connected. An inactive connector may still be
|
||||
* connected, but it takes no rotations, so Inactive wins.
|
||||
*/
|
||||
export function accessConnectorDisplayStatus(
|
||||
connector: Pick<AccessConnector, "status" | "isConnected">,
|
||||
): AccessConnectorDisplayStatus {
|
||||
if (connector.status !== AccessConnectorStatus.Enabled) {
|
||||
return AccessConnectorDisplayStatus.Inactive;
|
||||
}
|
||||
return connector.isConnected
|
||||
? AccessConnectorDisplayStatus.Connected
|
||||
: AccessConnectorDisplayStatus.Disconnected;
|
||||
}
|
||||
|
||||
export function accessConnectorStatusBadge(
|
||||
status: AccessConnectorDisplayStatus,
|
||||
): AccessConnectorStatusBadge {
|
||||
return STATUS_BADGES[status];
|
||||
}
|
||||
|
||||
@@ -4,15 +4,13 @@
|
||||
</ng-container>
|
||||
|
||||
<div bitDialogContent>
|
||||
<bit-form-field>
|
||||
<p bitTypography="body1" class="tw-text-fg-body">
|
||||
{{ "pamAccessConnectorRegisterDescription" | i18n }}
|
||||
</p>
|
||||
<bit-form-field disableMargin>
|
||||
<bit-label>{{ "name" | i18n }}</bit-label>
|
||||
<input
|
||||
bitInput
|
||||
formControlName="name"
|
||||
id="access-connector-register-dialog_input_name"
|
||||
[placeholder]="'pamAccessConnectorNamePlaceholder' | i18n"
|
||||
/>
|
||||
<bit-hint>{{ "pamAccessConnectorNameHint" | i18n }}</bit-hint>
|
||||
<input bitInput formControlName="name" id="access-connector-register-dialog_input_name" />
|
||||
<bit-hint>{{ "pamAccessConnectorNameRecognizableHint" | i18n }}</bit-hint>
|
||||
</bit-form-field>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import { ComponentFixture, TestBed } from "@angular/core/testing";
|
||||
import { Router } from "@angular/router";
|
||||
import { mock } from "jest-mock-extended";
|
||||
import { Subject, of } from "rxjs";
|
||||
|
||||
import { ErrorResponse } from "@bitwarden/common/models/response/error.response";
|
||||
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
||||
@@ -28,6 +30,7 @@ describe("AccessConnectorRegisterDialogComponent", () => {
|
||||
let dialogRef: jest.Mocked<DialogRef>;
|
||||
let toastService: jest.Mocked<ToastService>;
|
||||
let i18nService: jest.Mocked<I18nService>;
|
||||
let router: { navigate: jest.Mock };
|
||||
/** The component's own DialogService, which DialogModule may provide over the test's. */
|
||||
let injectedDialogService: DialogService;
|
||||
|
||||
@@ -58,6 +61,8 @@ describe("AccessConnectorRegisterDialogComponent", () => {
|
||||
t: (id: string) => id,
|
||||
} as unknown as jest.Mocked<I18nService>;
|
||||
|
||||
router = { navigate: jest.fn().mockResolvedValue(true) };
|
||||
|
||||
await TestBed.configureTestingModule({
|
||||
imports: [AccessConnectorRegisterDialogComponent],
|
||||
providers: [
|
||||
@@ -65,6 +70,7 @@ describe("AccessConnectorRegisterDialogComponent", () => {
|
||||
{ provide: DialogRef, useValue: dialogRef },
|
||||
{ provide: ToastService, useValue: toastService },
|
||||
{ provide: I18nService, useValue: i18nService },
|
||||
{ provide: Router, useValue: router },
|
||||
],
|
||||
})
|
||||
.overrideComponent(AccessConnectorRegisterDialogComponent, {
|
||||
@@ -111,22 +117,45 @@ describe("AccessConnectorRegisterDialogComponent", () => {
|
||||
it("opens the token dialog after successful registration", async () => {
|
||||
const openSpy = jest
|
||||
.spyOn(injectedDialogService, "open")
|
||||
.mockReturnValue({ closed: { toPromise: jest.fn() } } as any);
|
||||
.mockReturnValue({ closed: new Subject() } as any);
|
||||
|
||||
(component as any).form.controls.name.setValue("Good access connector");
|
||||
await (component as any).submit();
|
||||
|
||||
expect(openSpy).toHaveBeenCalledWith(
|
||||
AccessConnectorTokenDialogComponent,
|
||||
expect.objectContaining({
|
||||
data: expect.objectContaining({
|
||||
token: fakeRegistration.token,
|
||||
accessConnectorName: "Good access connector",
|
||||
}),
|
||||
}),
|
||||
expect.objectContaining({ data: { token: fakeRegistration.token } }),
|
||||
);
|
||||
});
|
||||
|
||||
it("opens the new access connector's page once the token dialog closes", async () => {
|
||||
const closed = new Subject<void>();
|
||||
jest.spyOn(injectedDialogService, "open").mockReturnValue({ closed } as any);
|
||||
|
||||
(component as any).form.controls.name.setValue("Good access connector");
|
||||
await (component as any).submit();
|
||||
expect(router.navigate).not.toHaveBeenCalled();
|
||||
expect(toastService.showToast).not.toHaveBeenCalled();
|
||||
|
||||
closed.next();
|
||||
closed.complete();
|
||||
await new Promise((resolve) => setTimeout(resolve, 0));
|
||||
|
||||
expect(router.navigate).toHaveBeenCalledWith([
|
||||
"/organizations",
|
||||
orgId,
|
||||
"pam",
|
||||
"rotation",
|
||||
"access-connectors",
|
||||
String(fakeRegistration.id),
|
||||
]);
|
||||
expect(toastService.showToast).toHaveBeenCalledTimes(1);
|
||||
expect(toastService.showToast).toHaveBeenCalledWith({
|
||||
variant: "success",
|
||||
message: "pamAccessConnectorRegistered",
|
||||
});
|
||||
});
|
||||
|
||||
it("does not open the token dialog until the register dialog has closed", async () => {
|
||||
let resolveClose!: (value: DialogCloseRef) => void;
|
||||
dialogRef.close.mockReturnValue(
|
||||
@@ -134,7 +163,7 @@ describe("AccessConnectorRegisterDialogComponent", () => {
|
||||
);
|
||||
const openSpy = jest
|
||||
.spyOn(injectedDialogService, "open")
|
||||
.mockReturnValue({ closed: { toPromise: jest.fn() } } as any);
|
||||
.mockReturnValue({ closed: of(undefined) } as any);
|
||||
|
||||
(component as any).form.controls.name.setValue("Good access connector");
|
||||
const submitted = (component as any).submit();
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { importProvidersFrom } from "@angular/core";
|
||||
import { provideRouter, withHashLocation } from "@angular/router";
|
||||
import { Meta, StoryObj, applicationConfig, moduleMetadata } from "@storybook/angular";
|
||||
import { userEvent } from "storybook/test";
|
||||
|
||||
@@ -37,7 +38,10 @@ export default {
|
||||
],
|
||||
}),
|
||||
applicationConfig({
|
||||
providers: [importProvidersFrom(PreloadedEnglishI18nModule)],
|
||||
providers: [
|
||||
importProvidersFrom(PreloadedEnglishI18nModule),
|
||||
provideRouter([], withHashLocation()),
|
||||
],
|
||||
}),
|
||||
],
|
||||
render: () => ({ template: `<app-access-connector-register-dialog />` }),
|
||||
@@ -45,12 +49,13 @@ export default {
|
||||
|
||||
type Story = StoryObj<AccessConnectorRegisterDialogComponent>;
|
||||
|
||||
/** Figma 1092:43725: the empty form. */
|
||||
export const Default: Story = {};
|
||||
|
||||
export const Completed: Story = {
|
||||
play: async ({ canvasElement }) => {
|
||||
const name = canvasElement.querySelector<HTMLInputElement>(NAME_INPUT)!;
|
||||
await userEvent.type(name, "eu-west-rotator");
|
||||
await userEvent.type(name, "East datacenter");
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import { ChangeDetectionStrategy, Component, inject } from "@angular/core";
|
||||
import { ReactiveFormsModule, Validators, FormBuilder } from "@angular/forms";
|
||||
import { Router } from "@angular/router";
|
||||
import { firstValueFrom } from "rxjs";
|
||||
|
||||
import { ErrorResponse } from "@bitwarden/common/models/response/error.response";
|
||||
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
||||
@@ -14,10 +16,12 @@ import {
|
||||
DialogService,
|
||||
FormFieldModule,
|
||||
ToastService,
|
||||
TypographyModule,
|
||||
} from "@bitwarden/components";
|
||||
import { I18nPipe } from "@bitwarden/ui-common";
|
||||
|
||||
import { rotationErrorMessage } from "../rotation-error";
|
||||
import { ROTATION_TABS, rotationLink } from "../rotation-links";
|
||||
import { RotationSdkService } from "../rotation-sdk.service";
|
||||
|
||||
import { AccessConnectorTokenDialogComponent } from "./access-connector-token-dialog.component";
|
||||
@@ -31,7 +35,8 @@ export type AccessConnectorRegisterDialogResult = { registered: true } | undefin
|
||||
|
||||
/**
|
||||
* Name-entry dialog for a new access connector. On success it closes itself, then opens
|
||||
* {@link AccessConnectorTokenDialogComponent} to show the one-time token.
|
||||
* {@link AccessConnectorTokenDialogComponent} to show the one-time token, and once that is closed
|
||||
* opens the new connector's page and confirms the registration there. Callers only refresh.
|
||||
*/
|
||||
@Component({
|
||||
selector: "app-access-connector-register-dialog",
|
||||
@@ -43,6 +48,7 @@ export type AccessConnectorRegisterDialogResult = { registered: true } | undefin
|
||||
ButtonModule,
|
||||
DialogModule,
|
||||
FormFieldModule,
|
||||
TypographyModule,
|
||||
I18nPipe,
|
||||
],
|
||||
})
|
||||
@@ -54,6 +60,7 @@ export class AccessConnectorRegisterDialogComponent {
|
||||
private readonly toastService = inject(ToastService);
|
||||
private readonly i18nService = inject(I18nService);
|
||||
private readonly fb = inject(FormBuilder);
|
||||
private readonly router = inject(Router);
|
||||
|
||||
protected readonly form = this.fb.nonNullable.group({
|
||||
name: ["", [Validators.required, Validators.maxLength(200)]],
|
||||
@@ -68,18 +75,30 @@ export class AccessConnectorRegisterDialogComponent {
|
||||
const name = this.form.controls.name.value;
|
||||
|
||||
try {
|
||||
const { token } = await this.rotationSdk.registerConnector(this.params.organizationId, name);
|
||||
const { id, token } = await this.rotationSdk.registerConnector(
|
||||
this.params.organizationId,
|
||||
name,
|
||||
);
|
||||
|
||||
await this.dialogRef.close({ registered: true });
|
||||
|
||||
AccessConnectorTokenDialogComponent.open(this.dialogService, {
|
||||
data: { accessConnectorName: name, token },
|
||||
const tokenDialog = AccessConnectorTokenDialogComponent.open(this.dialogService, {
|
||||
data: { token },
|
||||
});
|
||||
void firstValueFrom(tokenDialog.closed, { defaultValue: undefined }).then(async () => {
|
||||
await this.router.navigate(
|
||||
rotationLink(this.params.organizationId, ROTATION_TABS.accessConnectors, String(id)),
|
||||
);
|
||||
this.toastService.showToast({
|
||||
variant: "success",
|
||||
message: this.i18nService.t("pamAccessConnectorRegistered"),
|
||||
});
|
||||
});
|
||||
} catch (e) {
|
||||
const message =
|
||||
rotationErrorMessage(e) ??
|
||||
(e instanceof ErrorResponse ? e.message : undefined) ??
|
||||
this.i18nService.t("unexpectedError");
|
||||
this.i18nService.t("pamAccessConnectorRegisterFailed");
|
||||
this.toastService.showToast({ variant: "error", message });
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,33 +1,50 @@
|
||||
<bit-dialog
|
||||
[title]="'pamAccessConnectorTokenTitle' | i18n"
|
||||
[subtitle]="params.accessConnectorName"
|
||||
dialogSize="large"
|
||||
>
|
||||
<bit-dialog [title]="'pamAccessConnectorTokenTitle' | i18n">
|
||||
<ng-container bitDialogContent>
|
||||
<bit-callout type="warning" [title]="'pamAccessConnectorTokenWarningTitle' | i18n">
|
||||
{{ "pamAccessConnectorTokenWarningBody" | i18n }}
|
||||
<bit-callout
|
||||
type="warning"
|
||||
[title]="null"
|
||||
[accessibleName]="'pamAccessConnectorTokenTitle' | i18n"
|
||||
id="access-connector-token-dialog_callout_warning"
|
||||
>
|
||||
{{ "pamAccessConnectorTokenShownOnceWarning" | i18n }}
|
||||
</bit-callout>
|
||||
|
||||
<bit-form-field class="tw-mb-0">
|
||||
<bit-label>{{ "pamAccessConnectorTokenLabel" | i18n }}</bit-label>
|
||||
<div class="tw-mb-4">
|
||||
<div class="tw-flex tw-items-center tw-gap-2">
|
||||
<span
|
||||
class="tw-min-w-0 tw-flex-1 tw-truncate tw-font-mono tw-text-base tw-text-main"
|
||||
id="access-connector-token-dialog_text_token"
|
||||
aria-describedby="access-connector-token-dialog_hint_token"
|
||||
>{{ params.token }}</span
|
||||
>
|
||||
<button
|
||||
type="button"
|
||||
bitIconButton="bwi-clone"
|
||||
buttonType="primary"
|
||||
[label]="'pamAccessConnectorTokenCopy' | i18n"
|
||||
(click)="copyToken()"
|
||||
id="access-connector-token-dialog_button_copy"
|
||||
></button>
|
||||
</div>
|
||||
<p
|
||||
bitTypography="helper"
|
||||
class="tw-mb-0 tw-mt-2 tw-text-muted"
|
||||
id="access-connector-token-dialog_hint_token"
|
||||
>
|
||||
{{ "pamAccessConnectorTokenConfigurationHint" | i18n }}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<bit-form-control disableMargin>
|
||||
<input
|
||||
bitInput
|
||||
type="text"
|
||||
readonly
|
||||
class="tw-font-mono tw-text-sm"
|
||||
id="access-connector-token-dialog_input_token"
|
||||
[value]="params.token"
|
||||
type="checkbox"
|
||||
bitCheckbox
|
||||
[checked]="stored()"
|
||||
(change)="onStoredChange($event)"
|
||||
id="access-connector-token-dialog_checkbox_stored"
|
||||
/>
|
||||
<button
|
||||
type="button"
|
||||
bitIconButton="bwi-clone"
|
||||
bitSuffix
|
||||
[label]="'pamAccessConnectorTokenCopy' | i18n"
|
||||
(click)="copyToken()"
|
||||
id="access-connector-token-dialog_button_copy"
|
||||
></button>
|
||||
<bit-hint>{{ "pamAccessConnectorTokenHint" | i18n }}</bit-hint>
|
||||
</bit-form-field>
|
||||
<bit-label>{{ "pamAccessConnectorTokenStored" | i18n }}</bit-label>
|
||||
</bit-form-control>
|
||||
</ng-container>
|
||||
|
||||
<ng-container bitDialogFooter>
|
||||
@@ -35,6 +52,7 @@
|
||||
type="button"
|
||||
bitButton
|
||||
buttonType="secondary"
|
||||
[disabled]="!stored()"
|
||||
(click)="close()"
|
||||
id="access-connector-token-dialog_button_close"
|
||||
>
|
||||
|
||||
@@ -19,7 +19,6 @@ describe("AccessConnectorTokenDialogComponent", () => {
|
||||
let i18nService: jest.Mocked<I18nService>;
|
||||
|
||||
const params: AccessConnectorTokenDialogParams = {
|
||||
accessConnectorName: "Prod access connector",
|
||||
token: "0.access-connector.api-id.secret:keyb64==",
|
||||
};
|
||||
|
||||
@@ -49,13 +48,37 @@ describe("AccessConnectorTokenDialogComponent", () => {
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it("renders the token in a readonly input", () => {
|
||||
const input = fixture.nativeElement.querySelector(
|
||||
"#access-connector-token-dialog_input_token",
|
||||
) as HTMLInputElement;
|
||||
expect(input).toBeTruthy();
|
||||
expect(input.readOnly).toBe(true);
|
||||
expect(input.value).toBe(params.token);
|
||||
const el = (): HTMLElement => fixture.nativeElement as HTMLElement;
|
||||
const closeButton = (): HTMLButtonElement =>
|
||||
el().querySelector("#access-connector-token-dialog_button_close") as HTMLButtonElement;
|
||||
const storedCheckbox = (): HTMLInputElement =>
|
||||
el().querySelector("#access-connector-token-dialog_checkbox_stored") as HTMLInputElement;
|
||||
|
||||
function checkStored(checked = true): void {
|
||||
storedCheckbox().checked = checked;
|
||||
storedCheckbox().dispatchEvent(new Event("change"));
|
||||
fixture.detectChanges();
|
||||
}
|
||||
|
||||
it("renders the token as text", () => {
|
||||
const token = el().querySelector("#access-connector-token-dialog_text_token");
|
||||
expect(token?.textContent?.trim()).toBe(params.token);
|
||||
});
|
||||
|
||||
it("starts with the stored checkbox unchecked and Close disabled", () => {
|
||||
expect(storedCheckbox().checked).toBe(false);
|
||||
expect(closeButton().getAttribute("aria-disabled")).toBe("true");
|
||||
});
|
||||
|
||||
it("enables Close once the admin confirms they stored the token", () => {
|
||||
checkStored();
|
||||
expect(closeButton().getAttribute("aria-disabled")).not.toBe("true");
|
||||
});
|
||||
|
||||
it("disables Close again when the box is unchecked", () => {
|
||||
checkStored();
|
||||
checkStored(false);
|
||||
expect(closeButton().getAttribute("aria-disabled")).toBe("true");
|
||||
});
|
||||
|
||||
it("copies the token to clipboard on copyToken", () => {
|
||||
@@ -75,8 +98,14 @@ describe("AccessConnectorTokenDialogComponent", () => {
|
||||
expect(dialogRef.close).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("closes the dialog on close()", () => {
|
||||
it("does not close before the token is confirmed stored", () => {
|
||||
(component as any).close();
|
||||
expect(dialogRef.close).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("closes the dialog on Close once the token is confirmed stored", () => {
|
||||
checkStored();
|
||||
closeButton().click();
|
||||
expect(dialogRef.close).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { importProvidersFrom } from "@angular/core";
|
||||
import { Meta, StoryObj, applicationConfig, moduleMetadata } from "@storybook/angular";
|
||||
import { userEvent } from "storybook/test";
|
||||
|
||||
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
|
||||
import { DIALOG_DATA, DialogRef, ToastService } from "@bitwarden/components";
|
||||
@@ -21,7 +22,8 @@ function withParams(params: AccessConnectorTokenDialogParams) {
|
||||
imports: [AccessConnectorTokenDialogComponent],
|
||||
providers: [
|
||||
{ provide: DIALOG_DATA, useValue: params },
|
||||
{ provide: DialogRef, useValue: { close: () => {} } },
|
||||
// Opened with disableClose, which hides the header's close button.
|
||||
{ provide: DialogRef, useValue: { close: () => {}, disableClose: true } },
|
||||
{ provide: PlatformUtilsService, useValue: { copyToClipboard: () => {} } },
|
||||
{ provide: ToastService, useValue: { showToast: () => {} } },
|
||||
],
|
||||
@@ -41,16 +43,19 @@ export default {
|
||||
|
||||
type Story = StoryObj<AccessConnectorTokenDialogComponent>;
|
||||
|
||||
/** Figma 1092:44630: the token just issued, Close disabled until the box is checked. */
|
||||
export const Default: Story = {
|
||||
decorators: [withParams({ accessConnectorName: "eu-west-rotator", token: TOKEN })],
|
||||
decorators: [withParams({ token: TOKEN })],
|
||||
};
|
||||
|
||||
export const LongName: Story = {
|
||||
decorators: [
|
||||
withParams({
|
||||
accessConnectorName:
|
||||
"Primary datacenter rotation connector for the production directory and its replicas",
|
||||
token: TOKEN,
|
||||
}),
|
||||
],
|
||||
/** Figma 1092:44688: the admin confirmed they stored the token, so Close is enabled. */
|
||||
export const Stored: Story = {
|
||||
decorators: [withParams({ token: TOKEN })],
|
||||
play: async ({ canvasElement }) => {
|
||||
await userEvent.click(
|
||||
canvasElement.querySelector<HTMLInputElement>(
|
||||
"#access-connector-token-dialog_checkbox_stored",
|
||||
)!,
|
||||
);
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import { ChangeDetectionStrategy, Component, inject } from "@angular/core";
|
||||
import { ChangeDetectionStrategy, Component, inject, signal } from "@angular/core";
|
||||
|
||||
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
||||
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
|
||||
import {
|
||||
ButtonModule,
|
||||
CalloutModule,
|
||||
CheckboxModule,
|
||||
DIALOG_DATA,
|
||||
DialogConfig,
|
||||
DialogModule,
|
||||
@@ -13,11 +14,11 @@ import {
|
||||
FormFieldModule,
|
||||
IconButtonModule,
|
||||
ToastService,
|
||||
TypographyModule,
|
||||
} from "@bitwarden/components";
|
||||
import { I18nPipe } from "@bitwarden/ui-common";
|
||||
|
||||
export type AccessConnectorTokenDialogParams = {
|
||||
accessConnectorName: string;
|
||||
/**
|
||||
* Shown once; never log it. Format:
|
||||
* `0.access-connector.{apiKeyId}.{clientSecret}:{keyMaterialBase64}`.
|
||||
@@ -27,13 +28,23 @@ export type AccessConnectorTokenDialogParams = {
|
||||
|
||||
/**
|
||||
* Shows the registration token once; a lost token means deleting and re-registering the access
|
||||
* connector. Opened with `disableClose`, so only the footer Close button dismisses it.
|
||||
* connector. Opened with `disableClose`, so only the footer Close button dismisses it, and that
|
||||
* stays disabled until the admin confirms they stored the token.
|
||||
*/
|
||||
@Component({
|
||||
selector: "app-access-connector-token-dialog",
|
||||
templateUrl: "./access-connector-token-dialog.component.html",
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
imports: [ButtonModule, CalloutModule, DialogModule, FormFieldModule, IconButtonModule, I18nPipe],
|
||||
imports: [
|
||||
ButtonModule,
|
||||
CalloutModule,
|
||||
CheckboxModule,
|
||||
DialogModule,
|
||||
FormFieldModule,
|
||||
IconButtonModule,
|
||||
TypographyModule,
|
||||
I18nPipe,
|
||||
],
|
||||
})
|
||||
export class AccessConnectorTokenDialogComponent {
|
||||
protected readonly params = inject<AccessConnectorTokenDialogParams>(DIALOG_DATA);
|
||||
@@ -42,15 +53,24 @@ export class AccessConnectorTokenDialogComponent {
|
||||
private readonly toastService = inject(ToastService);
|
||||
private readonly i18nService = inject(I18nService);
|
||||
|
||||
protected readonly stored = signal(false);
|
||||
|
||||
protected onStoredChange(event: Event): void {
|
||||
this.stored.set((event.target as HTMLInputElement).checked);
|
||||
}
|
||||
|
||||
protected copyToken(): void {
|
||||
this.platformUtilsService.copyToClipboard(this.params.token);
|
||||
this.toastService.showToast({
|
||||
variant: "success",
|
||||
message: this.i18nService.t("pamAccessConnectorTokenCopied"),
|
||||
message: this.i18nService.t("pamTokenCopied"),
|
||||
});
|
||||
}
|
||||
|
||||
protected close(): void {
|
||||
if (!this.stored()) {
|
||||
return;
|
||||
}
|
||||
void this.dialogRef.close();
|
||||
}
|
||||
|
||||
|
||||
@@ -6,125 +6,65 @@
|
||||
|
||||
@if (loadError()) {
|
||||
<pam-rotation-load-error [focusRetry]="retried()" (retry)="retryLoad()" />
|
||||
} @else if (loadingVisible()) {
|
||||
<div aria-hidden="true" data-testid="access-connectors-loading">
|
||||
<bit-table-v2
|
||||
[tableDef]="loadingTable"
|
||||
[loading]="showSkeleton()"
|
||||
[loadingRows]="skeletonRows.length"
|
||||
>
|
||||
<!-- The real toolbar, disabled, so the header row sits where it will once rows land. -->
|
||||
<bit-table-toolbar inert>
|
||||
<bit-search
|
||||
class="tw-flex-1"
|
||||
[placeholder]="'pamAccessConnectorSearch' | i18n"
|
||||
[disabled]="true"
|
||||
></bit-search>
|
||||
<bit-filter-menu
|
||||
key="status"
|
||||
[placeholderText]="'status' | i18n"
|
||||
[unsetLabel]="'all' | i18n"
|
||||
[disabled]="true"
|
||||
></bit-filter-menu>
|
||||
<bit-filter-menu
|
||||
key="connection"
|
||||
[placeholderText]="'pamAccessConnectorConnection' | i18n"
|
||||
[unsetLabel]="'all' | i18n"
|
||||
[disabled]="true"
|
||||
></bit-filter-menu>
|
||||
</bit-table-toolbar>
|
||||
<div slot="empty"></div>
|
||||
<bit-column width="minmax(12rem, 2fr)">
|
||||
<bit-header-cell>{{ "name" | i18n }}</bit-header-cell>
|
||||
<bit-cell *bitCellDef="loadingTable.columns.name"></bit-cell>
|
||||
<bit-cell *bitCellLoading><bit-skeleton-text class="tw-w-40"></bit-skeleton-text></bit-cell>
|
||||
</bit-column>
|
||||
<bit-column>
|
||||
<bit-header-cell>{{ "status" | i18n }}</bit-header-cell>
|
||||
<bit-cell *bitCellDef="loadingTable.columns.statusLabelKey"></bit-cell>
|
||||
<bit-cell *bitCellLoading>
|
||||
<bit-skeleton class="tw-h-6 tw-w-16" edgeShape="circle"></bit-skeleton>
|
||||
</bit-cell>
|
||||
</bit-column>
|
||||
<bit-column>
|
||||
<bit-header-cell>{{ "pamAccessConnectorConnection" | i18n }}</bit-header-cell>
|
||||
<bit-cell *bitCellDef="loadingTable.columns.isConnected"></bit-cell>
|
||||
<bit-cell *bitCellLoading>
|
||||
<bit-skeleton class="tw-h-6 tw-w-24" edgeShape="circle"></bit-skeleton>
|
||||
</bit-cell>
|
||||
</bit-column>
|
||||
<bit-column>
|
||||
<bit-header-cell>{{ "pamAccessConnectorAssignments" | i18n }}</bit-header-cell>
|
||||
<bit-cell *bitCellDef="loadingTable.columns.assignmentNames"></bit-cell>
|
||||
<bit-cell *bitCellLoading><bit-skeleton-text class="tw-w-24"></bit-skeleton-text></bit-cell>
|
||||
</bit-column>
|
||||
<bit-column width="72px">
|
||||
<bit-header-cell></bit-header-cell>
|
||||
<bit-cell *bitCellDef="loadingTable.columns.actions"></bit-cell>
|
||||
<bit-cell *bitCellLoading></bit-cell>
|
||||
</bit-column>
|
||||
</bit-table-v2>
|
||||
</div>
|
||||
} @else if (totalRows() === 0) {
|
||||
<bit-status-lockup>
|
||||
<bit-svg slot="graphic" [content]="noItemsIcon"></bit-svg>
|
||||
<span slot="title">{{ "pamAccessConnectorEmptyStateTitle" | i18n }}</span>
|
||||
<span slot="description">{{ "pamAccessConnectorEmptyStateDescription" | i18n }}</span>
|
||||
<button
|
||||
slot="button"
|
||||
type="button"
|
||||
bitButton
|
||||
buttonType="primary"
|
||||
[bitAction]="registerAccessConnector"
|
||||
id="access-connectors-tab_button_register-empty"
|
||||
>
|
||||
{{ "pamAccessConnectorNew" | i18n }}
|
||||
</button>
|
||||
</bit-status-lockup>
|
||||
} @else {
|
||||
<bit-table-v2 [tableDef]="table" [filter]="rowMatchesFilter">
|
||||
<bit-table-v2 [tableDef]="table" [filter]="rowMatchesFilter" [loading]="loading()">
|
||||
<bit-table-toolbar>
|
||||
<bit-search
|
||||
class="tw-flex-1"
|
||||
[placeholder]="'pamAccessConnectorSearch' | i18n"
|
||||
[placeholder]="'search' | i18n"
|
||||
[formControl]="searchControl"
|
||||
></bit-search>
|
||||
<button
|
||||
slot="end"
|
||||
type="button"
|
||||
bitButton
|
||||
buttonType="primary"
|
||||
[bitAction]="registerAccessConnector"
|
||||
id="rotation-shell_button_new-access-connector"
|
||||
<bit-filter-menu key="status" [placeholderText]="'status' | i18n" multiple>
|
||||
@for (badge of statusBadges; track badge.status) {
|
||||
<bit-filter-option [value]="badge.status" [iconTile]="badge.iconTile">{{
|
||||
badge.labelKey | i18n
|
||||
}}</bit-filter-option>
|
||||
}
|
||||
</bit-filter-menu>
|
||||
<bit-filter-menu
|
||||
key="targetSystem"
|
||||
[placeholderText]="'pamRotationConfigColumnTargetSystem' | i18n"
|
||||
multiple
|
||||
>
|
||||
{{ "pamAccessConnectorNew" | i18n }}
|
||||
</button>
|
||||
@if (statusOptions().length > 0) {
|
||||
<bit-filter-menu
|
||||
key="status"
|
||||
[placeholderText]="'status' | i18n"
|
||||
[unsetLabel]="'all' | i18n"
|
||||
>
|
||||
@for (option of statusOptions(); track option.value) {
|
||||
<bit-filter-option [value]="option.value">{{ option.label }}</bit-filter-option>
|
||||
}
|
||||
</bit-filter-menu>
|
||||
}
|
||||
@if (connectionOptions().length > 0) {
|
||||
<bit-filter-menu
|
||||
key="connection"
|
||||
[placeholderText]="'pamAccessConnectorConnection' | i18n"
|
||||
[unsetLabel]="'all' | i18n"
|
||||
>
|
||||
@for (option of connectionOptions(); track option.value) {
|
||||
<bit-filter-option [value]="option.value">{{ option.label }}</bit-filter-option>
|
||||
}
|
||||
</bit-filter-menu>
|
||||
}
|
||||
@for (option of targetSystemOptions(); track option.value) {
|
||||
<bit-filter-option [value]="option.value">{{ option.label }}</bit-filter-option>
|
||||
}
|
||||
</bit-filter-menu>
|
||||
</bit-table-toolbar>
|
||||
|
||||
<div slot="empty" class="tw-py-6 tw-text-center tw-text-muted">
|
||||
{{ "pamAccessConnectorNoResults" | i18n }}
|
||||
<div slot="empty" class="tw-py-4">
|
||||
@if (totalRows() === 0) {
|
||||
<bit-status-lockup>
|
||||
<span slot="title">{{ "pamAccessConnectorsEmptyTitle" | i18n }}</span>
|
||||
<span slot="description">{{ "pamAccessConnectorsEmptyDescription" | i18n }}</span>
|
||||
<button
|
||||
slot="button"
|
||||
type="button"
|
||||
bitButton
|
||||
buttonType="primary"
|
||||
startIcon="bwi-plus"
|
||||
[bitAction]="registerAccessConnector"
|
||||
id="access-connectors-tab_button_register-empty"
|
||||
>
|
||||
{{ "pamAccessConnectorRegister" | i18n }}
|
||||
</button>
|
||||
</bit-status-lockup>
|
||||
} @else {
|
||||
<bit-status-lockup>
|
||||
<span slot="title">{{ "noItemsMatchSelectedFilters" | i18n }}</span>
|
||||
<button
|
||||
slot="button"
|
||||
type="button"
|
||||
bitButton
|
||||
buttonType="secondary"
|
||||
startIcon="bwi-clear"
|
||||
id="access-connectors-tab_button_clear-all"
|
||||
(click)="clearFilters()"
|
||||
>
|
||||
{{ "clearAll" | i18n }}
|
||||
</button>
|
||||
</bit-status-lockup>
|
||||
}
|
||||
</div>
|
||||
|
||||
<bit-column sortable width="minmax(12rem, 2fr)">
|
||||
@@ -133,7 +73,8 @@
|
||||
<button
|
||||
type="button"
|
||||
bitLink
|
||||
linkType="primary"
|
||||
linkType="secondary"
|
||||
class="!tw-font-medium"
|
||||
(click)="openDetail(r)"
|
||||
id="access-connectors-tab_button_detail-{{ r.id }}"
|
||||
>
|
||||
@@ -142,67 +83,52 @@
|
||||
</bit-cell>
|
||||
</bit-column>
|
||||
|
||||
<bit-column>
|
||||
<bit-column sortable defaultSort="asc" [sortFn]="sortByStatus" width="minmax(9.5rem, 1fr)">
|
||||
<bit-header-cell>{{ "status" | i18n }}</bit-header-cell>
|
||||
<bit-cell *bitCellDef="table.columns.statusLabelKey; let r" [truncate]="false">
|
||||
@if (r.enabled) {
|
||||
<span bitBadge variant="success">{{ r.statusLabelKey | i18n }}</span>
|
||||
} @else {
|
||||
<span bitBadge variant="secondary">{{ r.statusLabelKey | i18n }}</span>
|
||||
}
|
||||
<span
|
||||
bitBadge
|
||||
[variant]="r.statusBadge.variant"
|
||||
[startIcon]="r.statusBadge.icon"
|
||||
id="access-connectors-tab_status_{{ r.id }}"
|
||||
>{{ r.statusBadge.labelKey | i18n }}</span
|
||||
>
|
||||
</bit-cell>
|
||||
</bit-column>
|
||||
|
||||
<bit-column>
|
||||
<bit-header-cell>{{ "pamAccessConnectorConnection" | i18n }}</bit-header-cell>
|
||||
<bit-cell *bitCellDef="table.columns.isConnected; let r" [truncate]="false">
|
||||
<span bitBadge [variant]="r.isConnected ? 'success' : 'secondary'">{{
|
||||
(r.isConnected ? "pamAccessConnectorConnected" : "pamAccessConnectorDisconnected") | i18n
|
||||
}}</span>
|
||||
</bit-cell>
|
||||
</bit-column>
|
||||
|
||||
<bit-column>
|
||||
<bit-header-cell>{{ "pamAccessConnectorAssignments" | i18n }}</bit-header-cell>
|
||||
<bit-column sortable [sortFn]="sortByAssignments">
|
||||
<bit-header-cell>{{ "pamAccessConnectorTargetSystems" | i18n }}</bit-header-cell>
|
||||
<bit-cell *bitCellDef="table.columns.assignmentNames; let r" [truncate]="false">
|
||||
@if (r.assignmentNames.length === 0) {
|
||||
<span class="tw-text-muted">{{ "pamAccessConnectorAssignmentsNone" | i18n }}</span>
|
||||
<span class="tw-text-sm" data-testid="target-system-count">{{ r.targetSystemsLabel }}</span>
|
||||
</bit-cell>
|
||||
</bit-column>
|
||||
|
||||
<bit-column sortable [sortFn]="sortByLastSeen">
|
||||
<bit-header-cell>{{ "pamAccessConnectorLastSeen" | i18n }}</bit-header-cell>
|
||||
<bit-cell *bitCellDef="table.columns.lastSeenAtMs; let r" [truncate]="false">
|
||||
@if (r.lastSeenAtMs != null) {
|
||||
<span
|
||||
class="tw-text-sm"
|
||||
data-testid="last-seen"
|
||||
tabindex="0"
|
||||
[bitTooltip]="r.lastSeenAtMs | timestamp"
|
||||
[addTooltipToDescribedby]="true"
|
||||
>
|
||||
{{ r.lastSeenLabel ?? (r.lastSeenAtMs | timestamp) }}
|
||||
</span>
|
||||
} @else {
|
||||
<button
|
||||
type="button"
|
||||
bit-chip-action
|
||||
variant="primary"
|
||||
startIcon="bwi-desktop"
|
||||
[label]="
|
||||
(r.assignmentNames.length === 1
|
||||
? 'pamAccessConnectorAssignmentCountSingular'
|
||||
: 'pamAccessConnectorAssignmentCount'
|
||||
) | i18n: r.assignmentNames.length
|
||||
"
|
||||
[bitPopoverTriggerFor]="assignmentsPopover"
|
||||
position="below-start"
|
||||
id="access-connectors-tab_button_assignments-{{ r.id }}"
|
||||
></button>
|
||||
<bit-popover #assignmentsPopover [title]="'pamAccessConnectorAssignments' | i18n">
|
||||
<div class="tw-flex tw-flex-wrap tw-gap-1">
|
||||
@for (name of r.assignmentNames; track $index) {
|
||||
<span bitBadge variant="subtle">{{ name }}</span>
|
||||
}
|
||||
</div>
|
||||
</bit-popover>
|
||||
<span class="tw-text-sm" data-testid="last-seen">{{ "never" | i18n }}</span>
|
||||
}
|
||||
</bit-cell>
|
||||
</bit-column>
|
||||
|
||||
<bit-column width="72px">
|
||||
<bit-header-cell>
|
||||
<span class="tw-sr-only">{{ "options" | i18n }}</span>
|
||||
</bit-header-cell>
|
||||
<bit-column width="96px">
|
||||
<bit-header-cell>{{ "options" | i18n }}</bit-header-cell>
|
||||
<bit-cell *bitCellDef="table.columns.actions; let r">
|
||||
<button
|
||||
slot="end"
|
||||
type="button"
|
||||
bitIconButton="bwi-ellipsis-h"
|
||||
bitIconButton="bwi-ellipsis-v"
|
||||
[bitMenuTriggerFor]="rowMenu"
|
||||
label="{{ 'options' | i18n }}"
|
||||
id="access-connectors-tab_button_menu-{{ r.id }}"
|
||||
@@ -212,23 +138,32 @@
|
||||
type="button"
|
||||
bitMenuItem
|
||||
(click)="openDetail(r)"
|
||||
id="access-connectors-tab_button_view-{{ r.id }}"
|
||||
id="access-connectors-tab_button_edit-{{ r.id }}"
|
||||
>
|
||||
<bit-icon name="bwi-eye" class="tw-text-muted"></bit-icon>
|
||||
{{ "pamAccessConnectorViewDetails" | i18n }}
|
||||
<bit-icon slot="start" name="bwi-pencil-square" class="tw-text-muted"></bit-icon>
|
||||
{{ "pamAccessConnectorEdit" | i18n }}
|
||||
</button>
|
||||
@if (r.assignTargetsBlockedKey; as blockedKey) {
|
||||
<button
|
||||
type="button"
|
||||
bitMenuItem
|
||||
[attr.aria-disabled]="true"
|
||||
[bitTooltip]="blockedKey | i18n"
|
||||
[addTooltipToDescribedby]="true"
|
||||
[attr.aria-describedby]="'access-connectors-tab_reason_assign-' + r.id"
|
||||
(click)="$event.stopPropagation()"
|
||||
id="access-connectors-tab_button_assign-locked-{{ r.id }}"
|
||||
>
|
||||
<bit-icon name="bwi-plus-circle" class="tw-text-muted"></bit-icon>
|
||||
{{ "pamAccessConnectorAssignTargets" | i18n }}
|
||||
<bit-icon slot="start" name="bwi-target-system"></bit-icon>
|
||||
<!-- w-min wraps the hint to the title's width. -->
|
||||
<span class="tw-flex tw-w-min tw-flex-col">
|
||||
<span class="tw-whitespace-nowrap">{{
|
||||
"pamAccessConnectorAssignTargetSystems" | i18n
|
||||
}}</span>
|
||||
<span
|
||||
class="tw-whitespace-normal tw-text-xs tw-font-normal"
|
||||
id="access-connectors-tab_reason_assign-{{ r.id }}"
|
||||
>{{ blockedKey | i18n }}</span
|
||||
>
|
||||
</span>
|
||||
</button>
|
||||
} @else {
|
||||
<button
|
||||
@@ -238,24 +173,8 @@
|
||||
(click)="openAssignDialog(r)"
|
||||
id="access-connectors-tab_button_assign-{{ r.id }}"
|
||||
>
|
||||
<bit-icon name="bwi-plus-circle" class="tw-text-muted"></bit-icon>
|
||||
{{ "pamAccessConnectorAssignTargets" | i18n }}
|
||||
</button>
|
||||
}
|
||||
@for (
|
||||
assignmentId of r.accessConnector.assignedTargetSystemIds;
|
||||
track assignmentId;
|
||||
let i = $index
|
||||
) {
|
||||
<button
|
||||
type="button"
|
||||
bitMenuItem
|
||||
[disabled]="isRowBusy(r.id)"
|
||||
(click)="unassign(r, assignmentId, r.assignmentNames[i])"
|
||||
id="access-connectors-tab_button_unassign-{{ r.id }}-{{ assignmentId }}"
|
||||
>
|
||||
<bit-icon name="bwi-close" class="tw-text-muted"></bit-icon>
|
||||
{{ "pamAccessConnectorUnassign" | i18n: r.assignmentNames[i] }}
|
||||
<bit-icon slot="start" name="bwi-target-system" class="tw-text-muted"></bit-icon>
|
||||
{{ "pamAccessConnectorAssignTargetSystems" | i18n }}
|
||||
</button>
|
||||
}
|
||||
@if (r.enabled) {
|
||||
@@ -266,7 +185,7 @@
|
||||
(click)="disable(r)"
|
||||
id="access-connectors-tab_button_deactivate-{{ r.id }}"
|
||||
>
|
||||
<bit-icon name="bwi-minus-circle" class="tw-text-muted"></bit-icon>
|
||||
<bit-icon slot="start" name="bwi-minus-circle" class="tw-text-muted"></bit-icon>
|
||||
{{ "pamAccessConnectorDeactivate" | i18n }}
|
||||
</button>
|
||||
} @else {
|
||||
@@ -277,22 +196,20 @@
|
||||
(click)="enable(r)"
|
||||
id="access-connectors-tab_button_activate-{{ r.id }}"
|
||||
>
|
||||
<bit-icon name="bwi-check-circle" class="tw-text-muted"></bit-icon>
|
||||
<bit-icon slot="start" name="bwi-check-circle" class="tw-text-muted"></bit-icon>
|
||||
{{ "pamAccessConnectorActivate" | i18n }}
|
||||
</button>
|
||||
}
|
||||
<bit-menu-divider />
|
||||
<button
|
||||
type="button"
|
||||
bitMenuItem
|
||||
variant="danger"
|
||||
[disabled]="isRowBusy(r.id)"
|
||||
(click)="confirmDelete(r)"
|
||||
id="access-connectors-tab_button_delete-{{ r.id }}"
|
||||
>
|
||||
<bit-icon name="bwi-trash" class="tw-text-danger"></bit-icon>
|
||||
<span class="tw-text-danger">{{
|
||||
"pamAccessConnectorDeleteAccessConnector" | i18n
|
||||
}}</span>
|
||||
<bit-icon slot="start" name="bwi-trash"></bit-icon>
|
||||
{{ "pamAccessConnectorDeleteAccessConnector" | i18n }}
|
||||
</button>
|
||||
</bit-menu>
|
||||
</bit-cell>
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,84 +1,116 @@
|
||||
import { importProvidersFrom } from "@angular/core";
|
||||
import { ActivatedRoute, RouterModule } from "@angular/router";
|
||||
import { provideNoopAnimations } from "@angular/platform-browser/animations";
|
||||
import { provideRouter, RouterOutlet, Routes, withHashLocation } from "@angular/router";
|
||||
import { applicationConfig, Meta, moduleMetadata, StoryObj } from "@storybook/angular";
|
||||
import { of } from "rxjs";
|
||||
import { NEVER, of } from "rxjs";
|
||||
import { userEvent } from "storybook/test";
|
||||
|
||||
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
||||
import { DialogService, I18nMockService, ToastService } from "@bitwarden/components";
|
||||
import { DialogService, ToastService } from "@bitwarden/components";
|
||||
import { DAY, fromNow, startClockAtStoryNow } from "@bitwarden/storybook";
|
||||
import { PreloadedEnglishI18nModule } from "@bitwarden/web-vault/app/core/tests";
|
||||
|
||||
import { AccessConnector, TargetSystemView } from "../rotation";
|
||||
import { TargetSystemsService } from "../target-systems/target-systems.service";
|
||||
import { ORGANIZATION_ID, accessConnector, connectorId, sysId } from "../testing/rotation-builders";
|
||||
import {
|
||||
ORGANIZATION_ID,
|
||||
accessConnector,
|
||||
connectorId,
|
||||
sysId,
|
||||
targetSystem,
|
||||
} from "../testing/rotation-builders";
|
||||
import { atUrl } from "../testing/story-helpers";
|
||||
|
||||
import { AccessConnectorsTabComponent } from "./access-connectors-tab.component";
|
||||
import { AccessConnectorRow, AccessConnectorsService } from "./access-connectors.service";
|
||||
|
||||
function row(accessConnector: AccessConnector, assignmentNames: string[] = []): AccessConnectorRow {
|
||||
// The builders hash labels onto 16 ids, so these labels are picked to stay distinct per type.
|
||||
const TARGET_SYSTEMS: TargetSystemView[] = [
|
||||
targetSystem({ id: sysId("aws"), name: "AWS Production" }),
|
||||
targetSystem({ id: sysId("warehouse"), name: "Data Warehouse" }),
|
||||
targetSystem({ id: sysId("entra"), name: "Entra ID production" }),
|
||||
targetSystem({ id: sysId("entra-staging"), name: "Entra ID staging" }),
|
||||
targetSystem({ id: sysId("okta"), name: "Okta" }),
|
||||
targetSystem({ id: sysId("sql"), name: "Reporting SQL" }),
|
||||
];
|
||||
|
||||
const nameById = new Map(TARGET_SYSTEMS.map((s) => [s.id, s.name]));
|
||||
|
||||
function row(connector: AccessConnector): AccessConnectorRow {
|
||||
return {
|
||||
id: accessConnector.id,
|
||||
name: accessConnector.name,
|
||||
statusLabelKey: accessConnector.status === "enabled" ? "active" : "inactive",
|
||||
isConnected: accessConnector.isConnected,
|
||||
assignmentNames,
|
||||
enabled: accessConnector.status === "enabled",
|
||||
canAssign: accessConnector.status === "enabled",
|
||||
accessConnector,
|
||||
id: connector.id,
|
||||
name: connector.name,
|
||||
statusLabelKey: connector.status === "enabled" ? "active" : "inactive",
|
||||
isConnected: connector.isConnected,
|
||||
assignmentNames: connector.assignedTargetSystemIds.map((id) => nameById.get(id) ?? String(id)),
|
||||
enabled: connector.status === "enabled",
|
||||
canAssign: connector.status === "enabled",
|
||||
lastSeenAtMs: connector.lastHeartbeatAt ? Date.parse(connector.lastHeartbeatAt) : null,
|
||||
accessConnector: connector,
|
||||
};
|
||||
}
|
||||
|
||||
const CONNECTOR_PROD = accessConnector({
|
||||
id: connectorId("connector-prod"),
|
||||
name: "Prod on-prem connector",
|
||||
assignedTargetSystemIds: [sysId("1")],
|
||||
});
|
||||
const ago = (ms: number) => fromNow(-ms);
|
||||
const assigned = (...labels: string[]) => labels.map((label) => sysId(label));
|
||||
|
||||
const CONNECTOR_EU = accessConnector({
|
||||
id: connectorId("connector-eu"),
|
||||
name: "EU region connector",
|
||||
isConnected: false,
|
||||
});
|
||||
/** The six connectors of the Figma table, one per status and assignment shape. */
|
||||
const CONNECTORS: AccessConnector[] = [
|
||||
accessConnector({
|
||||
id: connectorId("west"),
|
||||
name: "West datacenter",
|
||||
isConnected: false,
|
||||
lastHeartbeatAt: ago(400 * DAY),
|
||||
assignedTargetSystemIds: assigned("aws", "warehouse", "okta", "sql"),
|
||||
}),
|
||||
accessConnector({
|
||||
id: connectorId("stage"),
|
||||
name: "Staging datacenter",
|
||||
isConnected: false,
|
||||
lastHeartbeatAt: undefined,
|
||||
assignedTargetSystemIds: [],
|
||||
}),
|
||||
accessConnector({
|
||||
id: connectorId("legacy"),
|
||||
name: "Legacy datacenter",
|
||||
status: "disabled",
|
||||
isConnected: true,
|
||||
lastHeartbeatAt: ago(420 * DAY),
|
||||
assignedTargetSystemIds: assigned("warehouse"),
|
||||
}),
|
||||
accessConnector({
|
||||
id: connectorId("east"),
|
||||
name: "East datacenter",
|
||||
lastHeartbeatAt: ago(10_000),
|
||||
assignedTargetSystemIds: assigned("aws", "warehouse", "entra-staging", "okta", "sql"),
|
||||
}),
|
||||
accessConnector({
|
||||
id: connectorId("azure"),
|
||||
name: "Azure production",
|
||||
lastHeartbeatAt: ago(10_000),
|
||||
assignedTargetSystemIds: assigned("entra-staging"),
|
||||
}),
|
||||
accessConnector({
|
||||
id: connectorId("aws-vpc"),
|
||||
name: "AWS production VPC",
|
||||
lastHeartbeatAt: ago(10_000),
|
||||
assignedTargetSystemIds: [],
|
||||
}),
|
||||
] as AccessConnector[];
|
||||
|
||||
const CONNECTOR_STAGING = accessConnector({
|
||||
id: connectorId("connector-staging"),
|
||||
name: "Staging connector",
|
||||
status: "disabled",
|
||||
isConnected: false,
|
||||
});
|
||||
const ROWS = CONNECTORS.map(row);
|
||||
|
||||
const CONNECTOR_SHARED = accessConnector({
|
||||
id: connectorId("connector-shared"),
|
||||
name: "Shared services connector",
|
||||
assignedTargetSystemIds: [sysId("1")],
|
||||
});
|
||||
|
||||
const ROWS: AccessConnectorRow[] = [
|
||||
row(CONNECTOR_PROD, ["Prod Entra"]),
|
||||
row(CONNECTOR_EU, ["Prod Entra", "Reporting SQL"]),
|
||||
row(CONNECTOR_STAGING, []),
|
||||
row(CONNECTOR_SHARED, [
|
||||
"Prod Entra",
|
||||
"Reporting SQL",
|
||||
"Billing MSSQL",
|
||||
"Partner API script",
|
||||
"Legacy LDAP",
|
||||
"Warehouse Postgres",
|
||||
]),
|
||||
];
|
||||
|
||||
function rotationServices(rows: AccessConnectorRow[]) {
|
||||
function rotationServices(rows: AccessConnectorRow[], loading = false) {
|
||||
return moduleMetadata({
|
||||
providers: [
|
||||
{
|
||||
provide: AccessConnectorsService,
|
||||
useValue: {
|
||||
loading$: of(false),
|
||||
loading$: of(loading),
|
||||
loadError$: of(null),
|
||||
rows$: of(rows),
|
||||
rows$: loading ? NEVER : of(rows),
|
||||
accessConnectors$: of(rows.map((r) => r.accessConnector)),
|
||||
load: () => Promise.resolve(),
|
||||
registerCompleted: () => Promise.resolve(),
|
||||
assign: () => Promise.resolve(),
|
||||
unassign: () => Promise.resolve(),
|
||||
setEnabled: () => Promise.resolve(),
|
||||
delete: () => Promise.resolve(),
|
||||
},
|
||||
@@ -86,7 +118,7 @@ function rotationServices(rows: AccessConnectorRow[]) {
|
||||
{
|
||||
provide: TargetSystemsService,
|
||||
useValue: {
|
||||
automaticSystems$: of([{ id: sysId("1") }] as TargetSystemView[]),
|
||||
automaticSystems$: of(TARGET_SYSTEMS),
|
||||
loading$: of(false),
|
||||
loadError$: of(null),
|
||||
load: () => Promise.resolve(),
|
||||
@@ -96,60 +128,36 @@ function rotationServices(rows: AccessConnectorRow[]) {
|
||||
});
|
||||
}
|
||||
|
||||
async function openRowMenu(canvasElement: HTMLElement, label: string): Promise<void> {
|
||||
await userEvent.click(
|
||||
canvasElement.querySelector<HTMLButtonElement>(
|
||||
`#access-connectors-tab_button_menu-${connectorId(label)}`,
|
||||
)!,
|
||||
);
|
||||
}
|
||||
|
||||
/** Mirrors `rotation.routes.ts`, minus its guards, since the component declares no selector. */
|
||||
const routes: Routes = [
|
||||
{
|
||||
path: "organizations/:organizationId/pam/rotation",
|
||||
children: [{ path: "access-connectors", component: AccessConnectorsTabComponent }],
|
||||
},
|
||||
];
|
||||
|
||||
export default {
|
||||
title: "Web/PAM/Rotation/Access Connectors Tab",
|
||||
component: AccessConnectorsTabComponent,
|
||||
render: () => ({ template: `<router-outlet></router-outlet>` }),
|
||||
// The last-seen labels are relative to `Date.now()`, so the clock starts where the dates do.
|
||||
beforeEach: startClockAtStoryNow,
|
||||
decorators: [
|
||||
moduleMetadata({ imports: [RouterOutlet] }),
|
||||
atUrl(`/organizations/${ORGANIZATION_ID}/pam/rotation/access-connectors`),
|
||||
applicationConfig({
|
||||
providers: [
|
||||
importProvidersFrom(RouterModule.forRoot([])),
|
||||
{
|
||||
provide: ActivatedRoute,
|
||||
useValue: { params: of({ organizationId: ORGANIZATION_ID }) },
|
||||
},
|
||||
{
|
||||
provide: I18nService,
|
||||
useFactory: () =>
|
||||
new I18nMockService({
|
||||
delete: "Delete",
|
||||
name: "Name",
|
||||
status: "Status",
|
||||
all: "All",
|
||||
options: "Options",
|
||||
removeItem: "Remove __$1__",
|
||||
search: "Search",
|
||||
resetSearch: "Reset search",
|
||||
itemCount: "__$1__ items",
|
||||
clearAll: "Clear all",
|
||||
filters: "Filters",
|
||||
pamAccessConnectorSearch: "Search access connectors",
|
||||
pamAccessConnectorEmptyStateTitle: "No access connectors registered",
|
||||
pamAccessConnectorEmptyStateDescription:
|
||||
"Register an access connector to start rotating credentials.",
|
||||
pamAccessConnectorNew: "New access connector",
|
||||
pamAccessConnectorConnection: "Connection",
|
||||
pamAccessConnectorAssignments: "Assigned targets",
|
||||
pamAccessConnectorAssignmentCountSingular: "__$1__ target",
|
||||
pamAccessConnectorAssignmentCount: "__$1__ targets",
|
||||
pamAccessConnectorAssignmentsNone: "None",
|
||||
close: "Close",
|
||||
pamAccessConnectorConnected: "Connected",
|
||||
pamAccessConnectorDisconnected: "Disconnected",
|
||||
pamAccessConnectorViewDetails: "View details",
|
||||
pamAccessConnectorAssignTargets: "Assign targets",
|
||||
pamAccessConnectorAssignNoOptions:
|
||||
"All active automatic target systems are already assigned to this access connector.",
|
||||
pamAccessConnectorAssignNoTargetSystems:
|
||||
"There are no active automatic target systems to assign. Create one on the Target systems tab, or activate an existing one.",
|
||||
pamAccessConnectorUnassign: "Remove __$1__",
|
||||
pamAccessConnectorDeactivate: "Deactivate",
|
||||
pamAccessConnectorActivate: "Activate",
|
||||
pamAccessConnectorDeleteAccessConnector: "Delete access connector",
|
||||
pamAccessConnectorNoResults: "No access connectors match your search.",
|
||||
active: "Active",
|
||||
inactive: "Inactive",
|
||||
}),
|
||||
},
|
||||
importProvidersFrom(PreloadedEnglishI18nModule),
|
||||
provideRouter(routes, withHashLocation()),
|
||||
provideNoopAnimations(),
|
||||
{ provide: DialogService, useValue: { openSimpleDialog: () => Promise.resolve(false) } },
|
||||
{ provide: ToastService, useValue: { showToast: () => {} } },
|
||||
],
|
||||
@@ -159,10 +167,52 @@ export default {
|
||||
|
||||
type Story = StoryObj<AccessConnectorsTabComponent>;
|
||||
|
||||
export const Default: Story = {
|
||||
/** A1: opens sorted by urgency, Disconnected, Inactive, Connected, most target systems first. */
|
||||
export const Table: Story = {
|
||||
decorators: [rotationServices(ROWS)],
|
||||
};
|
||||
|
||||
/** A4: a connected or disconnected connector's row menu. */
|
||||
export const RowMenuActive: Story = {
|
||||
...Table,
|
||||
play: async ({ canvasElement }) => openRowMenu(canvasElement, "east"),
|
||||
};
|
||||
|
||||
/** A4: an inactive connector's row menu, with Assign target systems disabled and the reason. */
|
||||
export const RowMenuInactive: Story = {
|
||||
...Table,
|
||||
play: async ({ canvasElement }) => openRowMenu(canvasElement, "legacy"),
|
||||
};
|
||||
|
||||
/** A5: the status filter, one option per badge, in urgency order. */
|
||||
export const StatusFilter: Story = {
|
||||
...Table,
|
||||
play: async ({ canvasElement }) => {
|
||||
await userEvent.click(
|
||||
canvasElement.querySelector<HTMLButtonElement>(
|
||||
'bit-filter-menu[key="status"] button[bit-chip-content]',
|
||||
)!,
|
||||
);
|
||||
},
|
||||
};
|
||||
|
||||
/** A5: the target system filter, every automatic target system with its connector count. */
|
||||
export const TargetSystemFilter: Story = {
|
||||
...Table,
|
||||
play: async ({ canvasElement }) => {
|
||||
await userEvent.click(
|
||||
canvasElement.querySelector<HTMLButtonElement>(
|
||||
'bit-filter-menu[key="targetSystem"] button[bit-chip-content]',
|
||||
)!,
|
||||
);
|
||||
},
|
||||
};
|
||||
|
||||
/** D3: no connectors registered yet. */
|
||||
export const Empty: Story = {
|
||||
decorators: [rotationServices([])],
|
||||
};
|
||||
|
||||
export const Loading: Story = {
|
||||
decorators: [rotationServices([], true)],
|
||||
};
|
||||
|
||||
@@ -6,16 +6,17 @@ import {
|
||||
effect,
|
||||
inject,
|
||||
signal,
|
||||
viewChildren,
|
||||
} from "@angular/core";
|
||||
import { takeUntilDestroyed, toSignal } from "@angular/core/rxjs-interop";
|
||||
import { FormControl, ReactiveFormsModule } from "@angular/forms";
|
||||
import { ActivatedRoute, Router } from "@angular/router";
|
||||
import { filter, firstValueFrom, map } from "rxjs";
|
||||
|
||||
import { NoResults } from "@bitwarden/assets/svg";
|
||||
import {
|
||||
accessConnectorDeactivateConfirmOptions,
|
||||
accessConnectorDeleteConfirmOptions,
|
||||
TimestampPipe,
|
||||
} from "@bitwarden/bit-pam-components";
|
||||
import { ErrorResponse } from "@bitwarden/common/models/response/error.response";
|
||||
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
||||
@@ -26,25 +27,20 @@ import {
|
||||
BadgeModule,
|
||||
BitCellComponent,
|
||||
BitCellDefDirective,
|
||||
BitCellLoadingDirective,
|
||||
BitColumnComponent,
|
||||
BitHeaderCellComponent,
|
||||
BitTableToolbarComponent,
|
||||
BitTableV2Component,
|
||||
ButtonModule,
|
||||
ChipActionComponent,
|
||||
DialogService,
|
||||
FilterMenuComponent,
|
||||
FilterMenuModule,
|
||||
IconButtonModule,
|
||||
IconModule,
|
||||
LinkModule,
|
||||
MenuModule,
|
||||
PopoverModule,
|
||||
SearchModule,
|
||||
SkeletonComponent,
|
||||
SkeletonTextComponent,
|
||||
StatusLockupComponent,
|
||||
SvgComponent,
|
||||
ToastService,
|
||||
TooltipDirective,
|
||||
defineTable,
|
||||
@@ -54,21 +50,33 @@ import { I18nPipe } from "@bitwarden/ui-common";
|
||||
import { assignableTargetSystems } from "../assignable";
|
||||
import { filterOptions } from "../filter-options";
|
||||
import { AccessConnectorId, TargetSystemId, TargetSystemView } from "../rotation";
|
||||
import { rotationErrorMessage } from "../rotation-error";
|
||||
import { rotationActionErrorMessage, rotationErrorMessage } from "../rotation-error";
|
||||
import { RotationLoadErrorComponent } from "../rotation-load-error.component";
|
||||
import { RotationLoadingAnnouncerComponent } from "../rotation-loading-announcer.component";
|
||||
import { lastSeenText, relativeTimeLabel } from "../rotation-relative-time";
|
||||
import { RowBusyTracker } from "../row-busy-tracker";
|
||||
import { showSkeletonWhile } from "../skeleton-delay";
|
||||
import { TargetSystemsService } from "../target-systems/target-systems.service";
|
||||
|
||||
import { accessConnectorConnectionLabelKey } from "./access-connector-label";
|
||||
import {
|
||||
ACCESS_CONNECTOR_STATUS_BADGES,
|
||||
AccessConnectorDisplayStatus,
|
||||
AccessConnectorStatusBadge,
|
||||
accessConnectorDisplayStatus,
|
||||
accessConnectorStatusBadge,
|
||||
} from "./access-connector-label";
|
||||
import { AccessConnectorRegisterDialogComponent } from "./access-connector-register-dialog.component";
|
||||
import { AccessConnectorRow, AccessConnectorsService } from "./access-connectors.service";
|
||||
import { AssignTargetDialogComponent } from "./assign-target-dialog.component";
|
||||
|
||||
export type AccessConnectorTabRow = AccessConnectorRow & {
|
||||
/** The one status badge the row shows: Inactive, else Disconnected, else Connected. */
|
||||
readonly statusBadge: AccessConnectorStatusBadge;
|
||||
/** The target systems cell: "None", or how many are assigned. */
|
||||
readonly targetSystemsLabel: string;
|
||||
/** The i18n key for why the menu can't assign a target system now, or null when it can. */
|
||||
readonly assignTargetsBlockedKey: string | null;
|
||||
/** The relative last-seen wording, or null when the design shows none and the cell shows a date. */
|
||||
readonly lastSeenLabel: string | null;
|
||||
};
|
||||
|
||||
@Component({
|
||||
@@ -76,29 +84,24 @@ export type AccessConnectorTabRow = AccessConnectorRow & {
|
||||
templateUrl: "./access-connectors-tab.component.html",
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
imports: [
|
||||
TimestampPipe,
|
||||
ReactiveFormsModule,
|
||||
AsyncActionsModule,
|
||||
BadgeModule,
|
||||
ButtonModule,
|
||||
ChipActionComponent,
|
||||
FilterMenuModule,
|
||||
IconButtonModule,
|
||||
IconModule,
|
||||
LinkModule,
|
||||
MenuModule,
|
||||
PopoverModule,
|
||||
SearchModule,
|
||||
SkeletonComponent,
|
||||
SkeletonTextComponent,
|
||||
StatusLockupComponent,
|
||||
SvgComponent,
|
||||
BitTableToolbarComponent,
|
||||
BitTableV2Component,
|
||||
BitColumnComponent,
|
||||
BitHeaderCellComponent,
|
||||
BitCellComponent,
|
||||
BitCellDefDirective,
|
||||
BitCellLoadingDirective,
|
||||
TooltipDirective,
|
||||
RotationLoadErrorComponent,
|
||||
RotationLoadingAnnouncerComponent,
|
||||
@@ -106,8 +109,6 @@ export type AccessConnectorTabRow = AccessConnectorRow & {
|
||||
],
|
||||
})
|
||||
export class AccessConnectorsTabComponent {
|
||||
protected readonly noItemsIcon = NoResults;
|
||||
|
||||
private readonly destroyRef = inject(DestroyRef);
|
||||
private readonly route = inject(ActivatedRoute);
|
||||
private readonly router = inject(Router);
|
||||
@@ -124,13 +125,6 @@ export class AccessConnectorsTabComponent {
|
||||
initialValue: null,
|
||||
});
|
||||
|
||||
/** Whether the placeholder is drawn, which trails {@link loading} by the skeleton delay. */
|
||||
protected readonly showSkeleton = showSkeletonWhile(this.loading);
|
||||
|
||||
protected readonly loadingVisible = computed(() => this.loading() || this.showSkeleton());
|
||||
|
||||
protected readonly skeletonRows = [0, 1, 2, 3, 4];
|
||||
|
||||
private readonly serviceRows = toSignal(this.accessConnectorsService.rows$, {
|
||||
initialValue: [] as AccessConnectorRow[],
|
||||
});
|
||||
@@ -157,40 +151,68 @@ export class AccessConnectorsTabComponent {
|
||||
private readonly rows = computed<AccessConnectorTabRow[]>(() => {
|
||||
const eligible = this.automaticSystems();
|
||||
const known = this.targetSystemsKnown();
|
||||
// Read once per rows change, so relative labels such as "5m ago" are not live-updating.
|
||||
const now = Date.now();
|
||||
const unavailable = this.targetSystemsUnavailable();
|
||||
return this.serviceRows().map((row) => ({
|
||||
...row,
|
||||
assignTargetsBlockedKey: this.assignTargetsBlockedKey(row, eligible, known),
|
||||
statusBadge: accessConnectorStatusBadge(accessConnectorDisplayStatus(row.accessConnector)),
|
||||
targetSystemsLabel: this.targetSystemsLabel(row.assignmentNames.length),
|
||||
assignTargetsBlockedKey: this.assignTargetsBlockedKey(row, eligible, known, unavailable),
|
||||
lastSeenLabel:
|
||||
row.lastSeenAtMs == null
|
||||
? null
|
||||
: relativeTimeLabel(this.i18nService, lastSeenText(row.lastSeenAtMs, now)),
|
||||
}));
|
||||
});
|
||||
|
||||
protected readonly table = defineTable<AccessConnectorTabRow, "actions">(this.rows);
|
||||
|
||||
/**
|
||||
* Model for the loading placeholder, with no rows, so rows from an earlier load don't show
|
||||
* through before the skeleton's delay.
|
||||
* Urgency first (Disconnected, Inactive, Connected), then most target systems, then name. The
|
||||
* two tie-breaks hold whichever way the column is sorted.
|
||||
*/
|
||||
protected readonly loadingTable = defineTable<AccessConnectorTabRow, "actions">(
|
||||
signal<AccessConnectorTabRow[]>([]),
|
||||
protected readonly sortByStatus = (
|
||||
a: AccessConnectorTabRow,
|
||||
b: AccessConnectorTabRow,
|
||||
direction?: "asc" | "desc",
|
||||
): number => {
|
||||
const flip = direction === "desc" ? -1 : 1;
|
||||
return (
|
||||
a.statusBadge.sortOrder - b.statusBadge.sortOrder ||
|
||||
flip * (b.assignmentNames.length - a.assignmentNames.length) ||
|
||||
flip * a.name.localeCompare(b.name)
|
||||
);
|
||||
};
|
||||
|
||||
protected readonly sortByLastSeen = withNameTieBreak(
|
||||
(a, b) => (a.lastSeenAtMs ?? -Infinity) - (b.lastSeenAtMs ?? -Infinity) || 0,
|
||||
);
|
||||
|
||||
protected readonly sortByAssignments = withNameTieBreak(
|
||||
(a, b) => a.assignmentNames.length - b.assignmentNames.length,
|
||||
);
|
||||
|
||||
protected readonly searchControl = new FormControl("", { nonNullable: true });
|
||||
|
||||
protected readonly statusOptions = computed(() =>
|
||||
filterOptions(
|
||||
this.rows().map(
|
||||
(row) => [row.statusLabelKey, this.i18nService.t(row.statusLabelKey)] as const,
|
||||
),
|
||||
),
|
||||
);
|
||||
private readonly filterMenus = viewChildren(FilterMenuComponent);
|
||||
|
||||
protected readonly connectionOptions = computed(() =>
|
||||
filterOptions(
|
||||
this.rows().map(
|
||||
(row) =>
|
||||
[
|
||||
row.isConnected,
|
||||
this.i18nService.t(accessConnectorConnectionLabelKey(row.isConnected)),
|
||||
] as const,
|
||||
/** The status filter offers every status, in urgency order, named and iconed like its badge. */
|
||||
protected readonly statusBadges = ACCESS_CONNECTOR_STATUS_BADGES.map((badge) => ({
|
||||
...badge,
|
||||
iconTile: { icon: badge.icon, variant: badge.tileVariant },
|
||||
}));
|
||||
|
||||
/** Every target system a connector serves or could be assigned, so an unserved one counts 0. */
|
||||
protected readonly targetSystemOptions = computed(() =>
|
||||
filterOptions<string>([
|
||||
...this.automaticSystems().map((system) => [String(system.id), system.name] as const),
|
||||
...this.rows().flatMap((row) =>
|
||||
row.accessConnector.assignedTargetSystemIds.map(
|
||||
(id, i) => [String(id), row.assignmentNames[i]] as const,
|
||||
),
|
||||
),
|
||||
),
|
||||
]),
|
||||
);
|
||||
|
||||
private readonly organizationId = toSignal(
|
||||
@@ -216,13 +238,43 @@ export class AccessConnectorsTabComponent {
|
||||
|
||||
protected readonly totalRows = computed(() => this.rows().length);
|
||||
|
||||
/** Resets every chip and the search box, for the empty state shown when they match nothing. */
|
||||
protected readonly clearFilters = (): void => {
|
||||
this.filterMenus().forEach((menu) => menu.clear());
|
||||
this.searchControl.setValue("");
|
||||
};
|
||||
|
||||
private targetSystemsLabel(count: number): string {
|
||||
if (count === 0) {
|
||||
return this.i18nService.t("pamAccessConnectorAssignmentsNone");
|
||||
}
|
||||
return this.i18nService.t(
|
||||
count === 1
|
||||
? "pamAccessConnectorTargetSystemCountSingular"
|
||||
: "pamAccessConnectorTargetSystemCount",
|
||||
count,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Why this connector can take no target-system assignment, as the i18n key the menu item's
|
||||
* reason line states, or null when it can.
|
||||
*
|
||||
* A failed read is stated here rather than only on the click, mirroring the target-systems tab's
|
||||
* `assignConnectorsBlockedKey`: the item is live while the read is in flight, so
|
||||
* {@link openAssignDialog}'s toast covers only the click that arrives before the failure does.
|
||||
*/
|
||||
private assignTargetsBlockedKey(
|
||||
row: AccessConnectorRow,
|
||||
eligible: readonly TargetSystemView[],
|
||||
targetSystemsKnown: boolean,
|
||||
targetSystemsUnavailable: boolean,
|
||||
): string | null {
|
||||
if (!row.canAssign) {
|
||||
return "pamAccessConnectorAssignTargetDisabled";
|
||||
return "pamAccessConnectorAssignTargetSystemsDisabled";
|
||||
}
|
||||
if (targetSystemsUnavailable) {
|
||||
return "pamAccessConnectorTargetSystemsLoadError";
|
||||
}
|
||||
if (!targetSystemsKnown) {
|
||||
return null;
|
||||
@@ -254,7 +306,7 @@ export class AccessConnectorsTabComponent {
|
||||
protected readonly openDetail = (row: AccessConnectorRow): Promise<boolean> =>
|
||||
this.router.navigate(["..", "access-connectors", row.id], { relativeTo: this.route });
|
||||
|
||||
/** Bound to the empty state and the table toolbar. */
|
||||
/** Bound to the empty state's register button. */
|
||||
protected readonly registerAccessConnector = async (): Promise<void> => {
|
||||
const orgId = this.organizationId();
|
||||
const ref = AccessConnectorRegisterDialogComponent.open(this.dialogService, {
|
||||
@@ -263,10 +315,6 @@ export class AccessConnectorsTabComponent {
|
||||
const result = await ref.closed.toPromise();
|
||||
if (result) {
|
||||
await this.accessConnectorsService.registerCompleted(orgId);
|
||||
this.toastService.showToast({
|
||||
variant: "success",
|
||||
message: this.i18nService.t("pamAccessConnectorRegistered"),
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
@@ -327,37 +375,10 @@ export class AccessConnectorsTabComponent {
|
||||
}
|
||||
});
|
||||
|
||||
protected readonly unassign = (
|
||||
row: AccessConnectorRow,
|
||||
targetSystemId: TargetSystemId,
|
||||
targetName: string,
|
||||
): Promise<void> =>
|
||||
this.busyRows.run(row.id, async () => {
|
||||
const confirmed = await this.dialogService.openSimpleDialog({
|
||||
title: { key: "pamAccessConnectorUnassignConfirmTitle" },
|
||||
content: { key: "pamAccessConnectorUnassignConfirmContent", placeholders: [targetName] },
|
||||
acceptButtonText: { key: "remove" },
|
||||
cancelButtonText: { key: "cancel" },
|
||||
type: "warning",
|
||||
});
|
||||
if (!confirmed) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
await this.accessConnectorsService.unassign(row.accessConnector, targetSystemId);
|
||||
this.toastService.showToast({
|
||||
variant: "success",
|
||||
message: this.i18nService.t("pamAccessConnectorUnassigned"),
|
||||
});
|
||||
} catch (e) {
|
||||
this.showError(e);
|
||||
}
|
||||
});
|
||||
|
||||
protected readonly disable = (row: AccessConnectorRow): Promise<void> =>
|
||||
this.busyRows.run(row.id, async () => {
|
||||
const confirmed = await this.dialogService.openSimpleDialog(
|
||||
accessConnectorDeactivateConfirmOptions(row.name),
|
||||
accessConnectorDeactivateConfirmOptions(),
|
||||
);
|
||||
if (!confirmed) {
|
||||
return;
|
||||
@@ -369,7 +390,7 @@ export class AccessConnectorsTabComponent {
|
||||
message: this.i18nService.t("pamAccessConnectorDeactivated"),
|
||||
});
|
||||
} catch (e) {
|
||||
this.showError(e);
|
||||
this.showActionError(e, "pamAccessConnectorDeactivateFailed");
|
||||
}
|
||||
});
|
||||
|
||||
@@ -389,7 +410,7 @@ export class AccessConnectorsTabComponent {
|
||||
protected readonly confirmDelete = (row: AccessConnectorRow): Promise<void> =>
|
||||
this.busyRows.run(row.id, async () => {
|
||||
const confirmed = await this.dialogService.openSimpleDialog(
|
||||
accessConnectorDeleteConfirmOptions(row.name),
|
||||
accessConnectorDeleteConfirmOptions(),
|
||||
);
|
||||
if (!confirmed) {
|
||||
return;
|
||||
@@ -401,7 +422,7 @@ export class AccessConnectorsTabComponent {
|
||||
message: this.i18nService.t("pamAccessConnectorDeleted"),
|
||||
});
|
||||
} catch (e) {
|
||||
this.showError(e);
|
||||
this.showActionError(e, "pamAccessConnectorDeleteFailed");
|
||||
}
|
||||
});
|
||||
|
||||
@@ -412,40 +433,64 @@ export class AccessConnectorsTabComponent {
|
||||
this.i18nService.t("unexpectedError");
|
||||
this.toastService.showToast({ variant: "error", message });
|
||||
}
|
||||
|
||||
/** The server's reason for refusing a row action, else that action's own failure copy. */
|
||||
private showActionError(e: unknown, fallbackKey: string): void {
|
||||
const message = rotationActionErrorMessage(e) ?? this.i18nService.t(fallbackKey);
|
||||
this.toastService.showToast({ variant: "error", message });
|
||||
}
|
||||
}
|
||||
|
||||
/** The toolbar's raw values by filter key, untyped because each chip reports its own shape. */
|
||||
type AccessConnectorFilterValues = {
|
||||
search?: string;
|
||||
status?: unknown;
|
||||
connection?: unknown;
|
||||
targetSystem?: unknown;
|
||||
};
|
||||
|
||||
type AccessConnectorFilter = {
|
||||
text: string;
|
||||
statusLabelKey: string | null;
|
||||
isConnected: boolean | null;
|
||||
statuses: AccessConnectorDisplayStatus[];
|
||||
targetSystemIds: string[];
|
||||
};
|
||||
|
||||
/** Uses `??` because the connection chip's `false` (disconnected) is a chosen filter. */
|
||||
/** A multi-select chip reports an array and a single-select one a scalar or `null`. */
|
||||
function toArray<T>(value: unknown): T[] {
|
||||
if (value == null) {
|
||||
return [];
|
||||
}
|
||||
return Array.isArray(value) ? (value as T[]) : [value as T];
|
||||
}
|
||||
|
||||
function toAccessConnectorFilter(values: AccessConnectorFilterValues): AccessConnectorFilter {
|
||||
return {
|
||||
text: (values.search ?? "").trim().toLowerCase(),
|
||||
statusLabelKey: (values.status ?? null) as string | null,
|
||||
isConnected: (values.connection ?? null) as boolean | null,
|
||||
statuses: toArray<AccessConnectorDisplayStatus>(values.status),
|
||||
targetSystemIds: toArray<string>(values.targetSystem),
|
||||
};
|
||||
}
|
||||
|
||||
function matchesFilter(row: AccessConnectorTabRow, filter: AccessConnectorFilter): boolean {
|
||||
const { text, statusLabelKey, isConnected } = filter;
|
||||
const { text, statuses, targetSystemIds } = filter;
|
||||
if (text !== "" && !row.name.toLowerCase().includes(text)) {
|
||||
return false;
|
||||
}
|
||||
if (statusLabelKey != null && row.statusLabelKey !== statusLabelKey) {
|
||||
if (statuses.length > 0 && !statuses.includes(row.statusBadge.status)) {
|
||||
return false;
|
||||
}
|
||||
if (isConnected != null && row.isConnected !== isConnected) {
|
||||
if (
|
||||
targetSystemIds.length > 0 &&
|
||||
!row.accessConnector.assignedTargetSystemIds.some((id) => targetSystemIds.includes(String(id)))
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
type RowComparator = (a: AccessConnectorTabRow, b: AccessConnectorTabRow) => number;
|
||||
|
||||
/** Ties sort A to Z by name, flipped for descending so they stay A to Z either way. */
|
||||
function withNameTieBreak(compare: RowComparator) {
|
||||
return (a: AccessConnectorTabRow, b: AccessConnectorTabRow, direction?: "asc" | "desc"): number =>
|
||||
compare(a, b) || a.name.localeCompare(b.name) * (direction === "desc" ? -1 : 1);
|
||||
}
|
||||
|
||||
@@ -168,6 +168,24 @@ describe("AccessConnectorsService", () => {
|
||||
expect(rows[0].assignmentNames).toEqual([String(sysId("unknown-id"))]);
|
||||
});
|
||||
|
||||
it("parses the last heartbeat into epoch milliseconds", async () => {
|
||||
rotationSdk.listConnectors.mockResolvedValue([
|
||||
makeAccessConnector({ lastHeartbeatAt: "2026-01-01T00:00:00Z" }),
|
||||
]);
|
||||
await service.load(orgId);
|
||||
const rows = await firstValue(service.rows$);
|
||||
expect(rows[0].lastSeenAtMs).toBe(Date.parse("2026-01-01T00:00:00Z"));
|
||||
});
|
||||
|
||||
it("leaves last seen null for a connector that has never checked in", async () => {
|
||||
rotationSdk.listConnectors.mockResolvedValue([
|
||||
makeAccessConnector({ lastHeartbeatAt: undefined }),
|
||||
]);
|
||||
await service.load(orgId);
|
||||
const rows = await firstValue(service.rows$);
|
||||
expect(rows[0].lastSeenAtMs).toBeNull();
|
||||
});
|
||||
|
||||
it("sets enabled and canAssign true for enabled accessConnectors", async () => {
|
||||
rotationSdk.listConnectors.mockResolvedValue([
|
||||
makeAccessConnector({ status: AccessConnectorStatus.Enabled }),
|
||||
@@ -297,7 +315,7 @@ describe("AccessConnectorsService", () => {
|
||||
expect(rows[0].accessConnector).toBe(untouched);
|
||||
});
|
||||
|
||||
it("does not reach the server — the delete already took the assignments", async () => {
|
||||
it("does not reach the server, the delete already took the assignments", async () => {
|
||||
rotationSdk.listConnectors.mockResolvedValue([
|
||||
makeAccessConnector({ assignedTargetSystemIds: [sysId("ts-1")] }),
|
||||
]);
|
||||
|
||||
@@ -20,6 +20,8 @@ export type AccessConnectorRow = {
|
||||
name: string;
|
||||
statusLabelKey: "active" | "inactive";
|
||||
isConnected: boolean;
|
||||
/** When the access connector last checked in, in epoch milliseconds; null if it never has. */
|
||||
lastSeenAtMs: number | null;
|
||||
/** Target system names for the assignment badges, falling back to the raw ID when unresolved. */
|
||||
assignmentNames: string[];
|
||||
enabled: boolean;
|
||||
@@ -210,6 +212,7 @@ export class AccessConnectorsService {
|
||||
name: accessConnector.name,
|
||||
statusLabelKey: accessConnectorStatusLabelKey(accessConnector.status),
|
||||
isConnected: accessConnector.isConnected,
|
||||
lastSeenAtMs: parseTimestamp(accessConnector.lastHeartbeatAt),
|
||||
assignmentNames: accessConnector.assignedTargetSystemIds.map(
|
||||
(id) => systemById.get(id)?.name ?? String(id),
|
||||
),
|
||||
@@ -219,3 +222,11 @@ export class AccessConnectorsService {
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
function parseTimestamp(value: string | null | undefined): number | null {
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
const ms = Date.parse(value);
|
||||
return Number.isNaN(ms) ? null : ms;
|
||||
}
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
import { inject, NgZone, Signal } from "@angular/core";
|
||||
import { toObservable, toSignal } from "@angular/core/rxjs-interop";
|
||||
import { distinctUntilChanged, Observable } from "rxjs";
|
||||
|
||||
import { skeletonLoadingDelay } from "@bitwarden/common/vault/utils/skeleton-loading.operator";
|
||||
|
||||
/** {@link skeletonLoadingDelay}, with its timers kept out of the Angular zone. */
|
||||
function delayOutsideAngular(zone: NgZone) {
|
||||
return (source: Observable<boolean>): Observable<boolean> =>
|
||||
new Observable<boolean>((subscriber) => {
|
||||
const outside = new Observable<boolean>((inner) =>
|
||||
source.subscribe({
|
||||
next: (value) => zone.runOutsideAngular(() => inner.next(value)),
|
||||
error: (error: unknown) => inner.error(error),
|
||||
complete: () => inner.complete(),
|
||||
}),
|
||||
);
|
||||
|
||||
return outside.pipe(skeletonLoadingDelay()).subscribe({
|
||||
next: (value) => zone.run(() => subscriber.next(value)),
|
||||
error: (error: unknown) => subscriber.error(error),
|
||||
complete: () => subscriber.complete(),
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/** Whether a loading flag has been raised long enough to be worth a placeholder. */
|
||||
export function showSkeletonWhile(loading: Signal<boolean>): Signal<boolean> {
|
||||
const zone = inject(NgZone);
|
||||
return toSignal(toObservable(loading).pipe(distinctUntilChanged(), delayOutsideAngular(zone)), {
|
||||
initialValue: false,
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user