@codemation/next-host 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +25 -0
- package/app/(shell)/credentials/page.tsx +5 -0
- package/app/(shell)/dashboard/page.tsx +14 -0
- package/app/(shell)/layout.tsx +11 -0
- package/app/(shell)/page.tsx +5 -0
- package/app/(shell)/users/page.tsx +5 -0
- package/app/(shell)/workflows/[workflowId]/page.tsx +19 -0
- package/app/(shell)/workflows/page.tsx +5 -0
- package/app/api/[[...path]]/route.ts +40 -0
- package/app/api/auth/[...nextauth]/route.ts +3 -0
- package/app/globals.css +997 -0
- package/app/invite/[token]/page.tsx +10 -0
- package/app/layout.tsx +65 -0
- package/app/login/layout.tsx +25 -0
- package/app/login/page.tsx +22 -0
- package/components.json +21 -0
- package/docs/FORMS.md +46 -0
- package/docs/TAILWIND_SHADCN_MIGRATION.md +89 -0
- package/eslint.config.mjs +56 -0
- package/middleware.ts +29 -0
- package/next-env.d.ts +6 -0
- package/next.config.ts +34 -0
- package/package.json +76 -0
- package/postcss.config.mjs +7 -0
- package/public/canvas-icons/builtin/openai.svg +5 -0
- package/src/api/CodemationApiClient.ts +107 -0
- package/src/api/CodemationApiHttpError.ts +17 -0
- package/src/auth/CodemationNextAuthConfigResolver.ts +14 -0
- package/src/auth/CodemationNextAuthOAuthProviderDescriptorMapper.ts +30 -0
- package/src/auth/CodemationNextAuthOAuthProviderSnapshotResolver.ts +17 -0
- package/src/auth/CodemationNextAuthProviderCatalog.ts +107 -0
- package/src/auth/codemationEdgeAuth.ts +25 -0
- package/src/auth/codemationNextAuth.ts +32 -0
- package/src/components/Codemation.tsx +6 -0
- package/src/components/CodemationDataTable.tsx +37 -0
- package/src/components/CodemationDialog.tsx +137 -0
- package/src/components/CodemationFormattedDateTime.tsx +46 -0
- package/src/components/GoogleColorGIcon.tsx +39 -0
- package/src/components/OauthProviderIcon.tsx +33 -0
- package/src/components/PasswordStrengthMeter.tsx +59 -0
- package/src/components/forms/index.ts +28 -0
- package/src/components/json/JsonMonacoEditor.tsx +75 -0
- package/src/components/oauthProviderIconData.ts +17 -0
- package/src/components/ui/alert.tsx +56 -0
- package/src/components/ui/badge.tsx +40 -0
- package/src/components/ui/button.tsx +64 -0
- package/src/components/ui/card.tsx +70 -0
- package/src/components/ui/collapsible.tsx +26 -0
- package/src/components/ui/dialog.tsx +137 -0
- package/src/components/ui/dropdown-menu.tsx +238 -0
- package/src/components/ui/form.tsx +147 -0
- package/src/components/ui/input.tsx +19 -0
- package/src/components/ui/label.tsx +26 -0
- package/src/components/ui/scroll-area.tsx +47 -0
- package/src/components/ui/select.tsx +169 -0
- package/src/components/ui/separator.tsx +28 -0
- package/src/components/ui/switch.tsx +28 -0
- package/src/components/ui/table.tsx +72 -0
- package/src/components/ui/tabs.tsx +76 -0
- package/src/components/ui/textarea.tsx +18 -0
- package/src/components/ui/toggle.tsx +41 -0
- package/src/features/credentials/components/CredentialConfirmDialog.tsx +58 -0
- package/src/features/credentials/components/CredentialDialog.tsx +252 -0
- package/src/features/credentials/components/CredentialDialogFeedback.tsx +36 -0
- package/src/features/credentials/components/CredentialDialogFieldRows.tsx +257 -0
- package/src/features/credentials/components/CredentialDialogFormSections.tsx +230 -0
- package/src/features/credentials/components/CredentialEnvFieldStatusRow.tsx +64 -0
- package/src/features/credentials/components/CredentialFieldCopyButton.tsx +48 -0
- package/src/features/credentials/components/CredentialsScreenHealthBadge.tsx +21 -0
- package/src/features/credentials/components/CredentialsScreenInstancesTable.tsx +108 -0
- package/src/features/credentials/components/CredentialsScreenTestFailureAlert.tsx +33 -0
- package/src/features/credentials/hooks/useCredentialCreateDialog.ts +33 -0
- package/src/features/credentials/hooks/useCredentialDialogSession.ts +616 -0
- package/src/features/credentials/hooks/useCredentialsScreen.ts +213 -0
- package/src/features/credentials/lib/credentialFieldHelpers.ts +35 -0
- package/src/features/credentials/lib/credentialFormTypes.ts +1 -0
- package/src/features/credentials/lib/credentialInstanceTestPayloadParser.ts +10 -0
- package/src/features/credentials/screens/CredentialsScreen.tsx +187 -0
- package/src/features/invite/screens/InviteAcceptScreen.tsx +190 -0
- package/src/features/users/components/UsersInviteDialog.tsx +121 -0
- package/src/features/users/components/UsersRegenerateDialog.tsx +81 -0
- package/src/features/users/components/UsersScreenUserStatusBadge.tsx +19 -0
- package/src/features/users/schemas/usersInviteFormSchema.ts +7 -0
- package/src/features/users/screens/UsersScreen.tsx +240 -0
- package/src/features/workflows/components/WorkflowListFolderSection.tsx +91 -0
- package/src/features/workflows/components/WorkflowListItemCard.tsx +67 -0
- package/src/features/workflows/components/WorkflowListRoot.tsx +39 -0
- package/src/features/workflows/components/WorkflowsListTree.tsx +28 -0
- package/src/features/workflows/components/canvas/CanvasNodeChromeTooltip.tsx +96 -0
- package/src/features/workflows/components/canvas/CanvasNodeIconSlot.tsx +25 -0
- package/src/features/workflows/components/canvas/VisibleNodeStatusResolver.tsx +84 -0
- package/src/features/workflows/components/canvas/WorkflowCanvas.tsx +248 -0
- package/src/features/workflows/components/canvas/WorkflowCanvasCodemationNode.tsx +182 -0
- package/src/features/workflows/components/canvas/WorkflowCanvasCodemationNodeAccents.tsx +73 -0
- package/src/features/workflows/components/canvas/WorkflowCanvasCodemationNodeAgentBottomSourceHandles.tsx +43 -0
- package/src/features/workflows/components/canvas/WorkflowCanvasCodemationNodeAgentLabels.tsx +47 -0
- package/src/features/workflows/components/canvas/WorkflowCanvasCodemationNodeCard.tsx +202 -0
- package/src/features/workflows/components/canvas/WorkflowCanvasCodemationNodeHandles.tsx +77 -0
- package/src/features/workflows/components/canvas/WorkflowCanvasCodemationNodeLabelBelow.tsx +51 -0
- package/src/features/workflows/components/canvas/WorkflowCanvasCodemationNodeMainGlyph.tsx +64 -0
- package/src/features/workflows/components/canvas/WorkflowCanvasCodemationNodeToolbar.tsx +95 -0
- package/src/features/workflows/components/canvas/WorkflowCanvasLoadingPlaceholder.tsx +69 -0
- package/src/features/workflows/components/canvas/WorkflowCanvasNodeIcon.tsx +102 -0
- package/src/features/workflows/components/canvas/WorkflowCanvasSimpleIconGlyph.tsx +21 -0
- package/src/features/workflows/components/canvas/WorkflowCanvasStraightCountEdge.tsx +33 -0
- package/src/features/workflows/components/canvas/WorkflowCanvasStructureSignature.tsx +7 -0
- package/src/features/workflows/components/canvas/WorkflowCanvasSymmetricForkEdge.tsx +32 -0
- package/src/features/workflows/components/canvas/WorkflowCanvasToolbarIconButton.tsx +95 -0
- package/src/features/workflows/components/canvas/lib/WorkflowCanvasBuiltinIconRegistry.ts +26 -0
- package/src/features/workflows/components/canvas/lib/WorkflowCanvasEdgeCountResolver.ts +51 -0
- package/src/features/workflows/components/canvas/lib/WorkflowCanvasEdgeStyleResolver.ts +35 -0
- package/src/features/workflows/components/canvas/lib/WorkflowCanvasLabelLayoutEstimator.ts +42 -0
- package/src/features/workflows/components/canvas/lib/WorkflowCanvasOverlapResolver.ts +78 -0
- package/src/features/workflows/components/canvas/lib/WorkflowCanvasPortOrderResolver.ts +25 -0
- package/src/features/workflows/components/canvas/lib/WorkflowCanvasRoundedOrthogonalPathPlanner.ts +56 -0
- package/src/features/workflows/components/canvas/lib/WorkflowCanvasSiIconRegistry.ts +18 -0
- package/src/features/workflows/components/canvas/lib/WorkflowCanvasSymmetricForkPathPlanner.ts +43 -0
- package/src/features/workflows/components/canvas/lib/layoutWorkflow.ts +315 -0
- package/src/features/workflows/components/canvas/lib/workflowCanvasEdgeGeometry.ts +3 -0
- package/src/features/workflows/components/canvas/lib/workflowCanvasEmbeddedStyles.ts +62 -0
- package/src/features/workflows/components/canvas/lib/workflowCanvasFlowTypes.ts +10 -0
- package/src/features/workflows/components/canvas/lib/workflowCanvasNodeData.ts +41 -0
- package/src/features/workflows/components/canvas/lib/workflowCanvasNodeGeometry.ts +99 -0
- package/src/features/workflows/components/canvas/workflowCanvasNodeChrome.tsx +46 -0
- package/src/features/workflows/components/realtime/RealtimeContext.tsx +14 -0
- package/src/features/workflows/components/realtime/WorkflowRealtimeProvider.tsx +15 -0
- package/src/features/workflows/components/workflowDetail/NodeCredentialBindingRow.tsx +209 -0
- package/src/features/workflows/components/workflowDetail/NodeCredentialBindingsSection.tsx +227 -0
- package/src/features/workflows/components/workflowDetail/NodePropertiesConfigSection.tsx +51 -0
- package/src/features/workflows/components/workflowDetail/NodePropertiesPanelHeader.tsx +50 -0
- package/src/features/workflows/components/workflowDetail/NodePropertiesSlidePanel.tsx +134 -0
- package/src/features/workflows/components/workflowDetail/WorkflowActivationErrorDialog.tsx +71 -0
- package/src/features/workflows/components/workflowDetail/WorkflowActivationHeaderControl.tsx +64 -0
- package/src/features/workflows/components/workflowDetail/WorkflowDetailIcons.tsx +52 -0
- package/src/features/workflows/components/workflowDetail/WorkflowExecutionInspector.tsx +110 -0
- package/src/features/workflows/components/workflowDetail/WorkflowExecutionInspectorDetailBody.tsx +213 -0
- package/src/features/workflows/components/workflowDetail/WorkflowExecutionInspectorPanes.tsx +239 -0
- package/src/features/workflows/components/workflowDetail/WorkflowExecutionInspectorSidebarResizer.tsx +31 -0
- package/src/features/workflows/components/workflowDetail/WorkflowExecutionInspectorTreePanel.tsx +133 -0
- package/src/features/workflows/components/workflowDetail/WorkflowInspectorAttachmentGroupingPresenter.tsx +31 -0
- package/src/features/workflows/components/workflowDetail/WorkflowInspectorAttachmentList.tsx +118 -0
- package/src/features/workflows/components/workflowDetail/WorkflowInspectorBinaryView.tsx +15 -0
- package/src/features/workflows/components/workflowDetail/WorkflowInspectorErrorView.tsx +107 -0
- package/src/features/workflows/components/workflowDetail/WorkflowInspectorJsonView.tsx +114 -0
- package/src/features/workflows/components/workflowDetail/WorkflowInspectorPrettyTreePresenter.tsx +132 -0
- package/src/features/workflows/components/workflowDetail/WorkflowInspectorPrettyTreeViewRenderer.tsx +147 -0
- package/src/features/workflows/components/workflowDetail/WorkflowInspectorPrettyView.tsx +65 -0
- package/src/features/workflows/components/workflowDetail/WorkflowInspectorViews.tsx +5 -0
- package/src/features/workflows/components/workflowDetail/WorkflowJsonEditorBinaryAttachmentRow.tsx +74 -0
- package/src/features/workflows/components/workflowDetail/WorkflowJsonEditorBinaryUploadRow.tsx +69 -0
- package/src/features/workflows/components/workflowDetail/WorkflowJsonEditorDialog.tsx +254 -0
- package/src/features/workflows/components/workflowDetail/WorkflowRunsList.tsx +89 -0
- package/src/features/workflows/components/workflowDetail/WorkflowRunsSidebar.tsx +50 -0
- package/src/features/workflows/hooks/canvas/useWorkflowCanvasVisibleNodeStatuses.ts +14 -0
- package/src/features/workflows/hooks/realtime/realtime.tsx +271 -0
- package/src/features/workflows/hooks/realtime/runQueryPolling.ts +34 -0
- package/src/features/workflows/hooks/realtime/useWorkflowRealtimeInfrastructure.ts +541 -0
- package/src/features/workflows/hooks/realtime/useWorkflowRealtimeShowDisconnectedBadge.ts +9 -0
- package/src/features/workflows/hooks/workflowDetail/useWorkflowDetailController.tsx +1300 -0
- package/src/features/workflows/lib/realtime/realtimeApi.ts +78 -0
- package/src/features/workflows/lib/realtime/realtimeClientBridge.ts +52 -0
- package/src/features/workflows/lib/realtime/realtimeDomainTypes.ts +191 -0
- package/src/features/workflows/lib/realtime/realtimeQueryKeys.ts +15 -0
- package/src/features/workflows/lib/realtime/realtimeRunMutations.ts +167 -0
- package/src/features/workflows/lib/realtime/workflowTypes.ts +5 -0
- package/src/features/workflows/lib/workflowDetail/PersistedWorkflowSnapshotMapper.ts +205 -0
- package/src/features/workflows/lib/workflowDetail/WorkflowActivationHttpErrorFormat.ts +32 -0
- package/src/features/workflows/lib/workflowDetail/WorkflowDetailPresenter.ts +1017 -0
- package/src/features/workflows/lib/workflowDetail/WorkflowDetailUrlCodec.ts +70 -0
- package/src/features/workflows/lib/workflowDetail/workflowDetailTypes.ts +152 -0
- package/src/features/workflows/lib/workflowDetailTreeStyles.ts +65 -0
- package/src/features/workflows/screens/WorkflowDetailScreen.tsx +236 -0
- package/src/features/workflows/screens/WorkflowDetailScreenInspectorPanel.tsx +55 -0
- package/src/features/workflows/screens/WorkflowsList.tsx +35 -0
- package/src/features/workflows/screens/WorkflowsScreen.tsx +31 -0
- package/src/index.ts +1 -0
- package/src/lib/utils.ts +6 -0
- package/src/middleware/CodemationNextHostMiddlewarePathRules.ts +31 -0
- package/src/providers/CodemationSessionProvider.tsx +23 -0
- package/src/providers/Providers.tsx +36 -0
- package/src/providers/RealtimeBoundary.tsx +17 -0
- package/src/providers/WhitelabelProvider.tsx +22 -0
- package/src/server/CodemationAuthPrismaClient.ts +21 -0
- package/src/server/CodemationNextHost.ts +379 -0
- package/src/shell/AppLayout.tsx +141 -0
- package/src/shell/AppLayoutNavItems.tsx +129 -0
- package/src/shell/AppLayoutPageHeader.tsx +79 -0
- package/src/shell/AppLayoutSidebarBrand.tsx +33 -0
- package/src/shell/AppMainContent.tsx +17 -0
- package/src/shell/AppShellHeaderActions.tsx +12 -0
- package/src/shell/AppShellHeaderActionsAuthenticated.tsx +51 -0
- package/src/shell/CodemationNextClientShell.tsx +17 -0
- package/src/shell/CredentialsSignInRedirectResolver.ts +21 -0
- package/src/shell/LoginPageClient.tsx +231 -0
- package/src/shell/WorkflowDetailChromeContext.tsx +42 -0
- package/src/shell/WorkflowFolderTreeBuilder.ts +62 -0
- package/src/shell/WorkflowFolderUi.ts +42 -0
- package/src/shell/WorkflowSidebarNavFolder.tsx +112 -0
- package/src/shell/WorkflowSidebarNavTree.tsx +68 -0
- package/src/shell/appLayoutPageTitle.ts +16 -0
- package/src/shell/appLayoutSidebarIcons.tsx +108 -0
- package/src/whitelabel/CodemationWhitelabelSnapshot.ts +4 -0
- package/src/whitelabel/CodemationWhitelabelSnapshotFactory.ts +18 -0
- package/tsconfig.json +40 -0
- package/tsconfig.tsbuildinfo +1 -0
- package/vitest.config.ts +34 -0
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
import { useCallback, useState } from "react";
|
|
2
|
+
|
|
3
|
+
import { ApiPaths } from "@codemation/host-src/presentation/http/ApiPaths";
|
|
4
|
+
|
|
5
|
+
import { codemationApiClient } from "../../../api/CodemationApiClient";
|
|
6
|
+
import { CodemationApiHttpError } from "../../../api/CodemationApiHttpError";
|
|
7
|
+
import type { CredentialInstanceDto } from "../../workflows/hooks/realtime/realtime";
|
|
8
|
+
import { parseCredentialInstanceTestPayload } from "../lib/credentialInstanceTestPayloadParser";
|
|
9
|
+
import { useCredentialDialogSession } from "./useCredentialDialogSession";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Credentials page: list/table actions plus dialog orchestration via {@link useCredentialDialogSession}.
|
|
13
|
+
*/
|
|
14
|
+
export function useCredentialsScreen() {
|
|
15
|
+
const {
|
|
16
|
+
credentialInstances,
|
|
17
|
+
credentialTypesAll,
|
|
18
|
+
credentialFieldEnvStatus,
|
|
19
|
+
credentialTypesQuery,
|
|
20
|
+
credentialWithSecretsQuery,
|
|
21
|
+
editingInstance,
|
|
22
|
+
dialogMode,
|
|
23
|
+
editingInstanceId,
|
|
24
|
+
selectedTypeId,
|
|
25
|
+
setSelectedTypeId,
|
|
26
|
+
displayName,
|
|
27
|
+
setDisplayName,
|
|
28
|
+
editDisplayName,
|
|
29
|
+
setEditDisplayName,
|
|
30
|
+
sourceKind,
|
|
31
|
+
setSourceKind,
|
|
32
|
+
publicFieldValues,
|
|
33
|
+
setPublicFieldValues,
|
|
34
|
+
secretFieldValues,
|
|
35
|
+
setSecretFieldValues,
|
|
36
|
+
envRefValues,
|
|
37
|
+
setEnvRefValues,
|
|
38
|
+
editPublicFieldValues,
|
|
39
|
+
setEditPublicFieldValues,
|
|
40
|
+
editSecretFieldValues,
|
|
41
|
+
setEditSecretFieldValues,
|
|
42
|
+
editEnvRefValues,
|
|
43
|
+
setEditEnvRefValues,
|
|
44
|
+
showSecrets,
|
|
45
|
+
setShowSecrets,
|
|
46
|
+
oauth2RedirectUri,
|
|
47
|
+
isLoadingOauth2RedirectUri,
|
|
48
|
+
errorMessage,
|
|
49
|
+
setErrorMessage,
|
|
50
|
+
dialogTestResult,
|
|
51
|
+
isSubmitting,
|
|
52
|
+
isEditSubmitting,
|
|
53
|
+
isDialogTesting,
|
|
54
|
+
createCredentialInstance,
|
|
55
|
+
updateCredentialInstance,
|
|
56
|
+
testCredentialFromDialog,
|
|
57
|
+
connectOAuth2Credential,
|
|
58
|
+
closeDialog,
|
|
59
|
+
openCreateDialog: openCreateDialogSession,
|
|
60
|
+
openEditDialog,
|
|
61
|
+
refreshQueries,
|
|
62
|
+
oauthDisconnectConfirmOpen,
|
|
63
|
+
setOauthDisconnectConfirmOpen,
|
|
64
|
+
executeOAuthDisconnect,
|
|
65
|
+
} = useCredentialDialogSession({
|
|
66
|
+
closeAfterCreatePolicy: "always",
|
|
67
|
+
oauthConnectedPolicy: "refresh_only",
|
|
68
|
+
buildDialogProps: false,
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
const [activeTestInstanceId, setActiveTestInstanceId] = useState<string | null>(null);
|
|
72
|
+
const [testResult, setTestResult] = useState<{ instanceId: string; status: string; message?: string } | null>(null);
|
|
73
|
+
const [deleteConfirmTarget, setDeleteConfirmTarget] = useState<CredentialInstanceDto | null>(null);
|
|
74
|
+
|
|
75
|
+
const openCreateDialog = useCallback(() => {
|
|
76
|
+
openCreateDialogSession();
|
|
77
|
+
}, [openCreateDialogSession]);
|
|
78
|
+
|
|
79
|
+
const testCredentialInstance = useCallback(
|
|
80
|
+
async (instance: CredentialInstanceDto): Promise<void> => {
|
|
81
|
+
try {
|
|
82
|
+
setActiveTestInstanceId(instance.instanceId);
|
|
83
|
+
setTestResult(null);
|
|
84
|
+
setErrorMessage(null);
|
|
85
|
+
const data = await codemationApiClient.postJson<{ status?: string; message?: string }>(
|
|
86
|
+
ApiPaths.credentialInstanceTest(instance.instanceId),
|
|
87
|
+
);
|
|
88
|
+
setTestResult({
|
|
89
|
+
instanceId: instance.instanceId,
|
|
90
|
+
status: data?.status ?? "healthy",
|
|
91
|
+
message: data?.message,
|
|
92
|
+
});
|
|
93
|
+
await refreshQueries();
|
|
94
|
+
} catch (error) {
|
|
95
|
+
if (error instanceof CodemationApiHttpError) {
|
|
96
|
+
const parsed = parseCredentialInstanceTestPayload(error.bodyText);
|
|
97
|
+
setTestResult({
|
|
98
|
+
instanceId: instance.instanceId,
|
|
99
|
+
status: "failing",
|
|
100
|
+
message: parsed.message ?? "Test failed",
|
|
101
|
+
});
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
setTestResult({
|
|
105
|
+
instanceId: instance.instanceId,
|
|
106
|
+
status: "failing",
|
|
107
|
+
message: error instanceof Error ? error.message : String(error),
|
|
108
|
+
});
|
|
109
|
+
} finally {
|
|
110
|
+
setActiveTestInstanceId(null);
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
[refreshQueries, setErrorMessage],
|
|
114
|
+
);
|
|
115
|
+
|
|
116
|
+
const openDeleteCredentialConfirm = (instance: CredentialInstanceDto): void => {
|
|
117
|
+
setDeleteConfirmTarget(instance);
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
const closeDeleteCredentialConfirm = (): void => {
|
|
121
|
+
setDeleteConfirmTarget(null);
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
const executeConfirmedDeleteCredential = async (): Promise<void> => {
|
|
125
|
+
if (!deleteConfirmTarget) {
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
const instanceId = deleteConfirmTarget.instanceId;
|
|
129
|
+
try {
|
|
130
|
+
setErrorMessage(null);
|
|
131
|
+
await codemationApiClient.delete(ApiPaths.credentialInstance(instanceId));
|
|
132
|
+
closeDeleteCredentialConfirm();
|
|
133
|
+
if (editingInstanceId === instanceId) closeDialog();
|
|
134
|
+
await refreshQueries();
|
|
135
|
+
} catch (error) {
|
|
136
|
+
setErrorMessage(error instanceof Error ? error.message : String(error));
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
const openOAuthDisconnectConfirm = (): void => {
|
|
141
|
+
setOauthDisconnectConfirmOpen(true);
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
const typesLoading = credentialTypesQuery.isLoading;
|
|
145
|
+
const typesError = credentialTypesQuery.isError;
|
|
146
|
+
const typesEmpty = credentialTypesAll.length === 0;
|
|
147
|
+
|
|
148
|
+
const isDialogOpen = dialogMode !== null;
|
|
149
|
+
const showTestFailureAlert = testResult?.status === "failing";
|
|
150
|
+
|
|
151
|
+
return {
|
|
152
|
+
credentialInstances,
|
|
153
|
+
credentialTypes: credentialTypesAll,
|
|
154
|
+
credentialFieldEnvStatus,
|
|
155
|
+
typesLoading,
|
|
156
|
+
typesError,
|
|
157
|
+
typesEmpty,
|
|
158
|
+
showTestFailureAlert,
|
|
159
|
+
testResult,
|
|
160
|
+
activeTestInstanceId,
|
|
161
|
+
openCreateDialog,
|
|
162
|
+
openEditDialog,
|
|
163
|
+
testCredentialInstance,
|
|
164
|
+
deleteConfirmTarget,
|
|
165
|
+
closeDeleteCredentialConfirm,
|
|
166
|
+
executeConfirmedDeleteCredential,
|
|
167
|
+
oauthDisconnectConfirmOpen,
|
|
168
|
+
setOauthDisconnectConfirmOpen,
|
|
169
|
+
executeOAuthDisconnect,
|
|
170
|
+
isDialogOpen,
|
|
171
|
+
dialogMode,
|
|
172
|
+
editingInstanceId,
|
|
173
|
+
selectedTypeId,
|
|
174
|
+
setSelectedTypeId,
|
|
175
|
+
displayName,
|
|
176
|
+
setDisplayName,
|
|
177
|
+
editDisplayName,
|
|
178
|
+
setEditDisplayName,
|
|
179
|
+
sourceKind,
|
|
180
|
+
setSourceKind,
|
|
181
|
+
publicFieldValues,
|
|
182
|
+
setPublicFieldValues,
|
|
183
|
+
secretFieldValues,
|
|
184
|
+
setSecretFieldValues,
|
|
185
|
+
envRefValues,
|
|
186
|
+
setEnvRefValues,
|
|
187
|
+
editPublicFieldValues,
|
|
188
|
+
setEditPublicFieldValues,
|
|
189
|
+
editSecretFieldValues,
|
|
190
|
+
setEditSecretFieldValues,
|
|
191
|
+
editEnvRefValues,
|
|
192
|
+
setEditEnvRefValues,
|
|
193
|
+
showSecrets,
|
|
194
|
+
setShowSecrets,
|
|
195
|
+
oauth2RedirectUri,
|
|
196
|
+
isLoadingOauth2RedirectUri,
|
|
197
|
+
credentialWithSecretsQuery,
|
|
198
|
+
editingInstance,
|
|
199
|
+
errorMessage,
|
|
200
|
+
dialogTestResult,
|
|
201
|
+
isSubmitting,
|
|
202
|
+
isEditSubmitting,
|
|
203
|
+
isDialogTesting,
|
|
204
|
+
createCredentialInstance,
|
|
205
|
+
updateCredentialInstance,
|
|
206
|
+
testCredentialFromDialog,
|
|
207
|
+
connectOAuth2Credential,
|
|
208
|
+
openOAuthDisconnectConfirm,
|
|
209
|
+
closeDialog,
|
|
210
|
+
setTestResult,
|
|
211
|
+
openDeleteCredentialConfirm,
|
|
212
|
+
};
|
|
213
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { CredentialFieldSchema } from "@codemation/core/browser";
|
|
2
|
+
|
|
3
|
+
export function maskedDisplayValue(): string {
|
|
4
|
+
return "••••••••••••";
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export function buildEmptySecretFieldValues(fields: ReadonlyArray<CredentialFieldSchema>): Record<string, string> {
|
|
8
|
+
const out: Record<string, string> = {};
|
|
9
|
+
for (const f of fields) {
|
|
10
|
+
out[f.key] = "";
|
|
11
|
+
}
|
|
12
|
+
return out;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function buildFieldStringValues(
|
|
16
|
+
fields: ReadonlyArray<CredentialFieldSchema>,
|
|
17
|
+
source?: Readonly<Record<string, unknown>>,
|
|
18
|
+
): Record<string, string> {
|
|
19
|
+
const out: Record<string, string> = {};
|
|
20
|
+
for (const field of fields) {
|
|
21
|
+
out[field.key] = String(source?.[field.key] ?? "");
|
|
22
|
+
}
|
|
23
|
+
return out;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function isCredentialFieldLockedByEnv(
|
|
27
|
+
field: CredentialFieldSchema,
|
|
28
|
+
envStatus: Readonly<Record<string, boolean>>,
|
|
29
|
+
): boolean {
|
|
30
|
+
const name = field.envVarName?.trim();
|
|
31
|
+
if (!name) {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
return envStatus[name] === true;
|
|
35
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type FormSourceKind = "db" | "env";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export function parseCredentialInstanceTestPayload(text: string): { status?: string; message?: string } {
|
|
2
|
+
if (!text.trim()) {
|
|
3
|
+
return {};
|
|
4
|
+
}
|
|
5
|
+
try {
|
|
6
|
+
return JSON.parse(text) as { status?: string; message?: string };
|
|
7
|
+
} catch {
|
|
8
|
+
return { message: text || "Test failed" };
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { Button } from "@/components/ui/button";
|
|
4
|
+
|
|
5
|
+
import { CredentialConfirmDialog } from "../components/CredentialConfirmDialog";
|
|
6
|
+
import { CredentialDialog } from "../components/CredentialDialog";
|
|
7
|
+
import { CredentialsScreenInstancesTable } from "../components/CredentialsScreenInstancesTable";
|
|
8
|
+
import { CredentialsScreenTestFailureAlert } from "../components/CredentialsScreenTestFailureAlert";
|
|
9
|
+
import { useCredentialsScreen } from "../hooks/useCredentialsScreen";
|
|
10
|
+
|
|
11
|
+
export function CredentialsScreen() {
|
|
12
|
+
const {
|
|
13
|
+
credentialInstances,
|
|
14
|
+
credentialTypes,
|
|
15
|
+
credentialFieldEnvStatus,
|
|
16
|
+
typesLoading,
|
|
17
|
+
typesError,
|
|
18
|
+
typesEmpty,
|
|
19
|
+
showTestFailureAlert,
|
|
20
|
+
testResult,
|
|
21
|
+
activeTestInstanceId,
|
|
22
|
+
openCreateDialog,
|
|
23
|
+
openEditDialog,
|
|
24
|
+
testCredentialInstance,
|
|
25
|
+
deleteConfirmTarget,
|
|
26
|
+
closeDeleteCredentialConfirm,
|
|
27
|
+
executeConfirmedDeleteCredential,
|
|
28
|
+
oauthDisconnectConfirmOpen,
|
|
29
|
+
setOauthDisconnectConfirmOpen,
|
|
30
|
+
executeOAuthDisconnect,
|
|
31
|
+
isDialogOpen,
|
|
32
|
+
dialogMode,
|
|
33
|
+
editingInstanceId,
|
|
34
|
+
selectedTypeId,
|
|
35
|
+
setSelectedTypeId,
|
|
36
|
+
displayName,
|
|
37
|
+
setDisplayName,
|
|
38
|
+
editDisplayName,
|
|
39
|
+
setEditDisplayName,
|
|
40
|
+
sourceKind,
|
|
41
|
+
setSourceKind,
|
|
42
|
+
publicFieldValues,
|
|
43
|
+
setPublicFieldValues,
|
|
44
|
+
secretFieldValues,
|
|
45
|
+
setSecretFieldValues,
|
|
46
|
+
envRefValues,
|
|
47
|
+
setEnvRefValues,
|
|
48
|
+
editPublicFieldValues,
|
|
49
|
+
setEditPublicFieldValues,
|
|
50
|
+
editSecretFieldValues,
|
|
51
|
+
setEditSecretFieldValues,
|
|
52
|
+
editEnvRefValues,
|
|
53
|
+
setEditEnvRefValues,
|
|
54
|
+
showSecrets,
|
|
55
|
+
setShowSecrets,
|
|
56
|
+
oauth2RedirectUri,
|
|
57
|
+
isLoadingOauth2RedirectUri,
|
|
58
|
+
credentialWithSecretsQuery,
|
|
59
|
+
editingInstance,
|
|
60
|
+
errorMessage,
|
|
61
|
+
dialogTestResult,
|
|
62
|
+
isSubmitting,
|
|
63
|
+
isEditSubmitting,
|
|
64
|
+
isDialogTesting,
|
|
65
|
+
createCredentialInstance,
|
|
66
|
+
updateCredentialInstance,
|
|
67
|
+
testCredentialFromDialog,
|
|
68
|
+
connectOAuth2Credential,
|
|
69
|
+
openOAuthDisconnectConfirm,
|
|
70
|
+
closeDialog,
|
|
71
|
+
setTestResult,
|
|
72
|
+
openDeleteCredentialConfirm,
|
|
73
|
+
} = useCredentialsScreen();
|
|
74
|
+
|
|
75
|
+
return (
|
|
76
|
+
<div data-testid="credentials-screen" className="flex flex-col gap-6">
|
|
77
|
+
{showTestFailureAlert && (
|
|
78
|
+
<CredentialsScreenTestFailureAlert message={testResult?.message} onDismiss={() => setTestResult(null)} />
|
|
79
|
+
)}
|
|
80
|
+
<div className="flex flex-wrap items-start justify-between gap-4">
|
|
81
|
+
<p className="m-0 max-w-2xl text-sm text-muted-foreground">
|
|
82
|
+
Create credential instances, store secrets safely, and verify health before binding them to workflow slots.
|
|
83
|
+
</p>
|
|
84
|
+
<Button
|
|
85
|
+
type="button"
|
|
86
|
+
onClick={openCreateDialog}
|
|
87
|
+
disabled={typesLoading || typesEmpty}
|
|
88
|
+
data-testid="credential-add-button"
|
|
89
|
+
>
|
|
90
|
+
Add credential
|
|
91
|
+
</Button>
|
|
92
|
+
</div>
|
|
93
|
+
|
|
94
|
+
{credentialInstances.length === 0 ? (
|
|
95
|
+
<div
|
|
96
|
+
className="rounded-lg border border-dashed border-border bg-muted/30 px-4 py-8 text-center text-sm text-muted-foreground"
|
|
97
|
+
data-testid="credentials-empty"
|
|
98
|
+
>
|
|
99
|
+
No credential instances yet. Click "Add credential" to create one.
|
|
100
|
+
</div>
|
|
101
|
+
) : (
|
|
102
|
+
<CredentialsScreenInstancesTable
|
|
103
|
+
credentialInstances={credentialInstances}
|
|
104
|
+
testResult={testResult}
|
|
105
|
+
activeTestInstanceId={activeTestInstanceId}
|
|
106
|
+
onOpenEdit={openEditDialog}
|
|
107
|
+
onTest={testCredentialInstance}
|
|
108
|
+
onOpenDelete={openDeleteCredentialConfirm}
|
|
109
|
+
/>
|
|
110
|
+
)}
|
|
111
|
+
|
|
112
|
+
{deleteConfirmTarget && (
|
|
113
|
+
<CredentialConfirmDialog
|
|
114
|
+
title="Delete credential?"
|
|
115
|
+
testId="credential-delete-confirm-dialog"
|
|
116
|
+
cancelTestId="credential-delete-confirm-cancel"
|
|
117
|
+
confirmTestId="credential-delete-confirm-delete"
|
|
118
|
+
confirmLabel="Delete"
|
|
119
|
+
confirmVariant="danger"
|
|
120
|
+
onCancel={closeDeleteCredentialConfirm}
|
|
121
|
+
onConfirm={() => void executeConfirmedDeleteCredential()}
|
|
122
|
+
>
|
|
123
|
+
<p className="m-0 text-sm text-muted-foreground">
|
|
124
|
+
This will permanently remove <strong>{deleteConfirmTarget.displayName}</strong>. This cannot be undone.
|
|
125
|
+
</p>
|
|
126
|
+
</CredentialConfirmDialog>
|
|
127
|
+
)}
|
|
128
|
+
|
|
129
|
+
{oauthDisconnectConfirmOpen && (
|
|
130
|
+
<CredentialConfirmDialog
|
|
131
|
+
title="Disconnect OAuth2?"
|
|
132
|
+
testId="credential-oauth-disconnect-confirm-dialog"
|
|
133
|
+
cancelTestId="credential-oauth-disconnect-confirm-cancel"
|
|
134
|
+
confirmTestId="credential-oauth-disconnect-confirm-confirm"
|
|
135
|
+
confirmLabel="Disconnect"
|
|
136
|
+
confirmVariant="primary"
|
|
137
|
+
onCancel={() => setOauthDisconnectConfirmOpen(false)}
|
|
138
|
+
onConfirm={() => void executeOAuthDisconnect()}
|
|
139
|
+
>
|
|
140
|
+
<p className="m-0 text-sm text-muted-foreground">
|
|
141
|
+
This will remove the OAuth connection for this credential. You can reconnect later.
|
|
142
|
+
</p>
|
|
143
|
+
</CredentialConfirmDialog>
|
|
144
|
+
)}
|
|
145
|
+
|
|
146
|
+
{isDialogOpen && (
|
|
147
|
+
<CredentialDialog
|
|
148
|
+
key={editingInstanceId ?? "create"}
|
|
149
|
+
mode={dialogMode!}
|
|
150
|
+
credentialTypes={credentialTypes}
|
|
151
|
+
typesLoading={typesLoading}
|
|
152
|
+
typesError={typesError}
|
|
153
|
+
typesEmpty={typesEmpty}
|
|
154
|
+
selectedTypeId={selectedTypeId}
|
|
155
|
+
setSelectedTypeId={setSelectedTypeId}
|
|
156
|
+
displayName={dialogMode === "create" ? displayName : editDisplayName}
|
|
157
|
+
setDisplayName={dialogMode === "create" ? setDisplayName : setEditDisplayName}
|
|
158
|
+
sourceKind={sourceKind}
|
|
159
|
+
setSourceKind={setSourceKind}
|
|
160
|
+
publicFieldValues={dialogMode === "create" ? publicFieldValues : editPublicFieldValues}
|
|
161
|
+
setPublicFieldValues={dialogMode === "create" ? setPublicFieldValues : setEditPublicFieldValues}
|
|
162
|
+
secretFieldValues={dialogMode === "create" ? secretFieldValues : editSecretFieldValues}
|
|
163
|
+
setSecretFieldValues={dialogMode === "create" ? setSecretFieldValues : setEditSecretFieldValues}
|
|
164
|
+
envRefValues={dialogMode === "create" ? envRefValues : editEnvRefValues}
|
|
165
|
+
setEnvRefValues={dialogMode === "create" ? setEnvRefValues : setEditEnvRefValues}
|
|
166
|
+
showSecrets={showSecrets}
|
|
167
|
+
setShowSecrets={setShowSecrets}
|
|
168
|
+
oauth2RedirectUri={oauth2RedirectUri}
|
|
169
|
+
isLoadingOauth2RedirectUri={isLoadingOauth2RedirectUri}
|
|
170
|
+
secretsLoading={credentialWithSecretsQuery.isLoading}
|
|
171
|
+
editingInstance={editingInstance}
|
|
172
|
+
errorMessage={errorMessage}
|
|
173
|
+
dialogTestResult={dialogTestResult}
|
|
174
|
+
isSubmitting={dialogMode === "create" ? isSubmitting : isEditSubmitting}
|
|
175
|
+
isDialogTesting={isDialogTesting}
|
|
176
|
+
onCreate={createCredentialInstance}
|
|
177
|
+
onUpdate={updateCredentialInstance}
|
|
178
|
+
onTest={testCredentialFromDialog}
|
|
179
|
+
onConnectOAuth2={connectOAuth2Credential}
|
|
180
|
+
onDisconnectOAuth2={openOAuthDisconnectConfirm}
|
|
181
|
+
onClose={closeDialog}
|
|
182
|
+
credentialFieldEnvStatus={credentialFieldEnvStatus}
|
|
183
|
+
/>
|
|
184
|
+
)}
|
|
185
|
+
</div>
|
|
186
|
+
);
|
|
187
|
+
}
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import type { VerifyUserInviteResponseDto } from "@codemation/host-src/application/contracts/userDirectoryContracts.types";
|
|
4
|
+
import { ApiPaths } from "@codemation/host-src/presentation/http/ApiPaths";
|
|
5
|
+
import { useEffect, useState, type FormEvent, type ReactNode } from "react";
|
|
6
|
+
|
|
7
|
+
import { Button } from "@/components/ui/button";
|
|
8
|
+
import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from "@/components/ui/card";
|
|
9
|
+
import { Input } from "@/components/ui/input";
|
|
10
|
+
import { Label } from "@/components/ui/label";
|
|
11
|
+
|
|
12
|
+
import { codemationApiClient } from "../../../api/CodemationApiClient";
|
|
13
|
+
import { CodemationApiHttpError } from "../../../api/CodemationApiHttpError";
|
|
14
|
+
import { PasswordStrengthMeter } from "../../../components/PasswordStrengthMeter";
|
|
15
|
+
|
|
16
|
+
export type InviteAcceptScreenProps = Readonly<{
|
|
17
|
+
inviteToken: string;
|
|
18
|
+
/** Where to send the user after activation (Next.js app login). */
|
|
19
|
+
loginHref?: string;
|
|
20
|
+
}>;
|
|
21
|
+
|
|
22
|
+
export function InviteAcceptScreen(props: InviteAcceptScreenProps) {
|
|
23
|
+
const loginHref = props.loginHref ?? "/login";
|
|
24
|
+
const [verifyState, setVerifyState] = useState<"pending" | "invalid" | "valid">("pending");
|
|
25
|
+
const [email, setEmail] = useState<string | null>(null);
|
|
26
|
+
const [password, setPassword] = useState("");
|
|
27
|
+
const [confirmPassword, setConfirmPassword] = useState("");
|
|
28
|
+
const [error, setError] = useState<string | null>(null);
|
|
29
|
+
const [isSubmitting, setIsSubmitting] = useState(false);
|
|
30
|
+
const [done, setDone] = useState(false);
|
|
31
|
+
|
|
32
|
+
useEffect(() => {
|
|
33
|
+
let cancelled = false;
|
|
34
|
+
const run = async (): Promise<void> => {
|
|
35
|
+
const url = `${ApiPaths.userInviteVerify()}?token=${encodeURIComponent(props.inviteToken)}`;
|
|
36
|
+
try {
|
|
37
|
+
const data = await codemationApiClient.getJson<VerifyUserInviteResponseDto>(url);
|
|
38
|
+
if (cancelled) return;
|
|
39
|
+
if (data.valid && data.email) {
|
|
40
|
+
setVerifyState("valid");
|
|
41
|
+
setEmail(data.email);
|
|
42
|
+
} else {
|
|
43
|
+
setVerifyState("invalid");
|
|
44
|
+
}
|
|
45
|
+
} catch {
|
|
46
|
+
if (!cancelled) setVerifyState("invalid");
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
void run();
|
|
50
|
+
return () => {
|
|
51
|
+
cancelled = true;
|
|
52
|
+
};
|
|
53
|
+
}, [props.inviteToken]);
|
|
54
|
+
|
|
55
|
+
const submit = async (): Promise<void> => {
|
|
56
|
+
setError(null);
|
|
57
|
+
if (password.length < 8) {
|
|
58
|
+
setError("Password must be at least 8 characters.");
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
if (password !== confirmPassword) {
|
|
62
|
+
setError("Passwords do not match.");
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
try {
|
|
66
|
+
setIsSubmitting(true);
|
|
67
|
+
await codemationApiClient.postJson(ApiPaths.userInviteAccept(), { token: props.inviteToken, password });
|
|
68
|
+
setDone(true);
|
|
69
|
+
} catch (e) {
|
|
70
|
+
if (e instanceof CodemationApiHttpError) {
|
|
71
|
+
setError(e.bodyText.trim() || e.message);
|
|
72
|
+
} else {
|
|
73
|
+
setError(e instanceof Error ? e.message : String(e));
|
|
74
|
+
}
|
|
75
|
+
} finally {
|
|
76
|
+
setIsSubmitting(false);
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
const onFormSubmit = (e: FormEvent) => {
|
|
81
|
+
e.preventDefault();
|
|
82
|
+
void submit();
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
const shell = (children: ReactNode) => (
|
|
86
|
+
<div className="flex min-h-[60vh] flex-col items-center justify-center p-4">{children}</div>
|
|
87
|
+
);
|
|
88
|
+
|
|
89
|
+
if (verifyState === "pending") {
|
|
90
|
+
return shell(
|
|
91
|
+
<Card className="w-full max-w-md" data-testid="invite-accept-loading">
|
|
92
|
+
<CardContent className="pt-6">
|
|
93
|
+
<p className="text-center text-muted-foreground" data-testid="invite-accept-loading-message">
|
|
94
|
+
Checking your invite…
|
|
95
|
+
</p>
|
|
96
|
+
</CardContent>
|
|
97
|
+
</Card>,
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if (verifyState === "invalid") {
|
|
102
|
+
return shell(
|
|
103
|
+
<Card className="w-full max-w-md" data-testid="invite-accept-invalid">
|
|
104
|
+
<CardHeader>
|
|
105
|
+
<CardTitle data-testid="invite-accept-invalid-title">Invite invalid or expired</CardTitle>
|
|
106
|
+
<CardDescription data-testid="invite-accept-invalid-message">
|
|
107
|
+
Ask your administrator to send a new invite.
|
|
108
|
+
</CardDescription>
|
|
109
|
+
</CardHeader>
|
|
110
|
+
<CardFooter>
|
|
111
|
+
<Button variant="outline" asChild>
|
|
112
|
+
<a href={loginHref} data-testid="invite-accept-back-to-login">
|
|
113
|
+
Log in
|
|
114
|
+
</a>
|
|
115
|
+
</Button>
|
|
116
|
+
</CardFooter>
|
|
117
|
+
</Card>,
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
if (done) {
|
|
122
|
+
return shell(
|
|
123
|
+
<Card className="w-full max-w-md" data-testid="invite-accept-done">
|
|
124
|
+
<CardHeader>
|
|
125
|
+
<CardTitle data-testid="invite-accept-done-title">You're all set</CardTitle>
|
|
126
|
+
<CardDescription data-testid="invite-accept-done-message">
|
|
127
|
+
Your account is active. Sign in with your email and new password.
|
|
128
|
+
</CardDescription>
|
|
129
|
+
</CardHeader>
|
|
130
|
+
<CardFooter>
|
|
131
|
+
<Button asChild>
|
|
132
|
+
<a href={loginHref} data-testid="invite-accept-login">
|
|
133
|
+
Log in
|
|
134
|
+
</a>
|
|
135
|
+
</Button>
|
|
136
|
+
</CardFooter>
|
|
137
|
+
</Card>,
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
return shell(
|
|
142
|
+
<Card className="w-full max-w-lg" data-testid="invite-accept-form">
|
|
143
|
+
<CardHeader>
|
|
144
|
+
<CardTitle data-testid="invite-accept-form-title">Set your password</CardTitle>
|
|
145
|
+
<CardDescription data-testid="invite-accept-email">{email}</CardDescription>
|
|
146
|
+
</CardHeader>
|
|
147
|
+
<CardContent>
|
|
148
|
+
<form className="flex flex-col gap-4" data-testid="invite-accept-password-form" onSubmit={onFormSubmit}>
|
|
149
|
+
<div className="space-y-2">
|
|
150
|
+
<Label htmlFor="invite-password">Password</Label>
|
|
151
|
+
<Input
|
|
152
|
+
id="invite-password"
|
|
153
|
+
type="password"
|
|
154
|
+
value={password}
|
|
155
|
+
onChange={(e) => {
|
|
156
|
+
setPassword(e.target.value);
|
|
157
|
+
setError(null);
|
|
158
|
+
}}
|
|
159
|
+
data-testid="invite-accept-password"
|
|
160
|
+
autoComplete="new-password"
|
|
161
|
+
/>
|
|
162
|
+
<PasswordStrengthMeter password={password} dataTestId="invite-accept-password-strength" />
|
|
163
|
+
</div>
|
|
164
|
+
<div className="space-y-2">
|
|
165
|
+
<Label htmlFor="invite-confirm">Confirm password</Label>
|
|
166
|
+
<Input
|
|
167
|
+
id="invite-confirm"
|
|
168
|
+
type="password"
|
|
169
|
+
value={confirmPassword}
|
|
170
|
+
onChange={(e) => {
|
|
171
|
+
setConfirmPassword(e.target.value);
|
|
172
|
+
setError(null);
|
|
173
|
+
}}
|
|
174
|
+
data-testid="invite-accept-confirm-password"
|
|
175
|
+
autoComplete="new-password"
|
|
176
|
+
/>
|
|
177
|
+
</div>
|
|
178
|
+
{error ? (
|
|
179
|
+
<p className="text-sm text-destructive" data-testid="invite-accept-error" role="alert">
|
|
180
|
+
{error}
|
|
181
|
+
</p>
|
|
182
|
+
) : null}
|
|
183
|
+
<Button type="submit" className="w-full" data-testid="invite-accept-submit" disabled={isSubmitting}>
|
|
184
|
+
{isSubmitting ? "Saving…" : "Activate account"}
|
|
185
|
+
</Button>
|
|
186
|
+
</form>
|
|
187
|
+
</CardContent>
|
|
188
|
+
</Card>,
|
|
189
|
+
);
|
|
190
|
+
}
|