@ekanos/harness 0.27.0 → 0.28.0
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 +6 -4
- package/dist/internal/components/approvals-tray.d.ts +44 -6
- package/dist/internal/components/approvals-tray.js +252 -30
- package/dist/internal/components/connect-controls.js +4 -2
- package/dist/internal/components/connect-dialog.d.ts +8 -1
- package/dist/internal/components/connect-dialog.js +23 -10
- package/dist/internal/components/connect-panel.d.ts +3 -2
- package/dist/internal/components/connect-panel.js +680 -340
- package/dist/internal/components/connect-steps.d.ts +72 -0
- package/dist/internal/components/connect-steps.js +341 -0
- package/dist/internal/components/console-not-found.d.ts +14 -0
- package/dist/internal/components/console-not-found.js +57 -0
- package/dist/internal/components/dashboard-grid.d.ts +10 -5
- package/dist/internal/components/dashboard-grid.js +8 -9
- package/dist/internal/components/dev-toolbar.d.ts +27 -5
- package/dist/internal/components/dev-toolbar.js +214 -176
- package/dist/internal/components/ekanos-logo.d.ts +18 -0
- package/dist/internal/components/ekanos-logo.js +74 -0
- package/dist/internal/components/events-panel.d.ts +13 -4
- package/dist/internal/components/events-panel.js +478 -81
- package/dist/internal/components/harness-widget-provider.d.ts +6 -8
- package/dist/internal/components/harness-widget-provider.js +5 -19
- package/dist/internal/components/health-panel.d.ts +8 -1
- package/dist/internal/components/health-panel.js +328 -31
- package/dist/internal/components/integration-badge.js +4 -2
- package/dist/internal/components/integration-tab-skeletons.d.ts +8 -0
- package/dist/internal/components/integration-tab-skeletons.js +76 -0
- package/dist/internal/components/not-found-state.d.ts +39 -0
- package/dist/internal/components/not-found-state.js +127 -0
- package/dist/internal/components/operation-runner-panel.d.ts +1 -1
- package/dist/internal/components/operation-runner-panel.js +624 -189
- package/dist/internal/components/operation-scope.d.ts +13 -0
- package/dist/internal/components/operation-scope.js +79 -0
- package/dist/internal/components/page-skeletons.d.ts +11 -0
- package/dist/internal/components/page-skeletons.js +61 -0
- package/dist/internal/components/provenance-banner.d.ts +13 -4
- package/dist/internal/components/provenance-banner.js +35 -10
- package/dist/internal/components/run-log-copy.d.ts +17 -0
- package/dist/internal/components/run-log-copy.js +67 -0
- package/dist/internal/components/run-log-detail.d.ts +22 -0
- package/dist/internal/components/run-log-detail.js +295 -0
- package/dist/internal/components/run-log-empty.d.ts +13 -0
- package/dist/internal/components/run-log-empty.js +46 -0
- package/dist/internal/components/run-log.d.ts +23 -3
- package/dist/internal/components/run-log.js +384 -130
- package/dist/internal/components/runtime-strip.d.ts +5 -1
- package/dist/internal/components/runtime-strip.js +82 -5
- package/dist/internal/components/schema-form.d.ts +2 -1
- package/dist/internal/components/schema-form.js +212 -79
- package/dist/internal/components/scrollable-nav.js +14 -2
- package/dist/internal/components/segmented-control.d.ts +19 -0
- package/dist/internal/components/segmented-control.js +46 -0
- package/dist/internal/components/shell-header.d.ts +25 -0
- package/dist/internal/components/shell-header.js +126 -0
- package/dist/internal/components/surface-nav.d.ts +12 -4
- package/dist/internal/components/surface-nav.js +77 -77
- package/dist/internal/components/widget-surface.d.ts +5 -1
- package/dist/internal/components/widget-surface.js +86 -14
- package/dist/internal/components/workflow-runner.d.ts +23 -10
- package/dist/internal/components/workflow-runner.js +451 -69
- package/dist/internal/lib/connect-model.d.ts +134 -0
- package/dist/internal/lib/connect-model.js +282 -0
- package/dist/internal/lib/connection-facts.js +2 -1
- package/dist/internal/lib/console-client.js +5 -2
- package/dist/internal/lib/console-hooks.d.ts +4 -1
- package/dist/internal/lib/console-hooks.js +3 -2
- package/dist/internal/lib/console-types.d.ts +6 -0
- package/dist/internal/lib/docs-links.d.ts +28 -0
- package/dist/internal/lib/docs-links.js +57 -1
- package/dist/internal/lib/event-delivery.d.ts +33 -0
- package/dist/internal/lib/event-delivery.js +66 -0
- package/dist/internal/lib/font-files/OFL-BricolageGrotesque.txt +93 -0
- package/dist/internal/lib/font-files/OFL-Figtree.txt +93 -0
- package/dist/internal/lib/font-files/bricolage-grotesque-latin-variable.woff2 +0 -0
- package/dist/internal/lib/font-files/figtree-latin-variable.woff2 +0 -0
- package/dist/internal/lib/fonts.js +13 -12
- package/dist/internal/lib/health-model.d.ts +58 -0
- package/dist/internal/lib/health-model.js +140 -0
- package/dist/internal/lib/integration-console-href.d.ts +5 -0
- package/dist/internal/lib/integration-console-href.js +7 -1
- package/dist/internal/lib/oauth-setup-guide.d.ts +28 -0
- package/dist/internal/lib/oauth-setup-guide.js +35 -1
- package/dist/internal/lib/operation-catalog.d.ts +70 -0
- package/dist/internal/lib/operation-catalog.js +261 -0
- package/dist/internal/lib/overview-model.d.ts +34 -0
- package/dist/internal/lib/overview-model.js +91 -0
- package/dist/internal/lib/registry-entry.d.ts +8 -0
- package/dist/internal/lib/registry-entry.js +11 -0
- package/dist/internal/lib/repo-name.d.ts +9 -0
- package/dist/internal/lib/repo-name.js +21 -0
- package/dist/internal/lib/run-log-view.d.ts +66 -1
- package/dist/internal/lib/run-log-view.js +183 -4
- package/dist/internal/lib/runner-view.d.ts +15 -0
- package/dist/internal/lib/runner-view.js +18 -0
- package/dist/internal/lib/schema-form-model.d.ts +17 -0
- package/dist/internal/lib/schema-form-model.js +50 -0
- package/dist/internal/lib/setup-checklist.d.ts +34 -0
- package/dist/internal/lib/setup-checklist.js +79 -0
- package/dist/internal/lib/toolbar-context.d.ts +0 -1
- package/dist/internal/lib/toolbar-context.js +0 -2
- package/dist/internal/lib/toolbar-visibility.d.ts +9 -2
- package/dist/internal/lib/toolbar-visibility.js +5 -0
- package/dist/internal/lib/use-operation-effects.d.ts +7 -0
- package/dist/internal/lib/use-operation-effects.js +28 -0
- package/dist/internal/lib/use-run-log-query.d.ts +9 -0
- package/dist/internal/lib/use-run-log-query.js +35 -0
- package/dist/internal/lib/widget-grid-gaps.d.ts +18 -0
- package/dist/internal/lib/widget-grid-gaps.js +41 -0
- package/dist/internal/lib/workflow-summary.d.ts +54 -0
- package/dist/internal/lib/workflow-summary.js +147 -0
- package/dist/internal/routes/console-home-page.js +2 -1
- package/dist/internal/routes/experience-connect-page.js +46 -17
- package/dist/internal/routes/experience-layout-page.js +75 -26
- package/dist/internal/routes/experience-page-host.js +63 -5
- package/dist/internal/routes/experience-review-queue-page.d.ts +4 -1
- package/dist/internal/routes/experience-review-queue-page.js +108 -12
- package/dist/internal/routes/experience-runs-page.js +57 -4
- package/dist/internal/routes/experience-summary-page.d.ts +19 -0
- package/dist/internal/routes/experience-summary-page.js +212 -52
- package/dist/internal/routes/experience-widget-page.js +58 -7
- package/dist/internal/routes/experience-widgets-page.d.ts +2 -3
- package/dist/internal/routes/experience-widgets-page.js +29 -4
- package/dist/internal/routes/experience-workflow-page.js +81 -9
- package/dist/internal/routes/experience-workflows-page.js +85 -21
- package/dist/internal/routes/integration-layout.js +28 -3
- package/dist/internal/routes/integrations-connect-page.js +16 -6
- package/dist/internal/routes/integrations-events-page.js +22 -1
- package/dist/internal/routes/integrations-health-page.js +16 -1
- package/dist/internal/routes/integrations-layout.js +28 -4
- package/dist/internal/routes/integrations-list-page.d.ts +0 -1
- package/dist/internal/routes/integrations-list-page.js +11 -9
- package/dist/internal/routes/integrations-operation-page.js +53 -17
- package/dist/internal/routes/integrations-operations-page.js +539 -49
- package/dist/internal/routes/integrations-overview-page.js +332 -69
- package/dist/internal/routes/integrations-runs-page.js +53 -3
- package/dist/internal/routes/integrations-scope.d.ts +15 -2
- package/dist/internal/routes/integrations-scope.js +66 -18
- package/dist/internal/routes/preview-index-page.js +2 -2
- package/dist/internal/routes/repo-home-page.d.ts +2 -2
- package/dist/internal/routes/repo-home-page.js +428 -236
- package/dist/internal/routes/repo-layout.d.ts +12 -0
- package/dist/internal/routes/repo-layout.js +50 -38
- package/dist/internal/routes/repo-package-layouts.js +22 -8
- package/dist/internal/routes/single-widget-page.d.ts +1 -1
- package/dist/internal/routes/single-widget-page.js +28 -5
- package/dist/internal/routes/tile-page.d.ts +1 -1
- package/dist/internal/routes/tile-page.js +1 -2
- package/dist/internal/routes/widgets-page.d.ts +1 -1
- package/dist/internal/routes/widgets-page.js +5 -3
- package/dist/registry.d.ts +4 -5
- package/dist/registry.js +0 -1
- package/dist/routes.d.ts +5 -0
- package/dist/routes.js +2 -0
- package/package.json +8 -8
|
@@ -6,14 +6,24 @@ import {
|
|
|
6
6
|
} from "@ekanos/sdk/hooks";
|
|
7
7
|
import { Alert, AlertDescription, AlertTitle } from "@ekanos/ui/alert";
|
|
8
8
|
import { Button } from "@ekanos/ui/button";
|
|
9
|
+
import { Card } from "@ekanos/ui/card";
|
|
9
10
|
import { ConfirmDialog } from "@ekanos/ui/confirm-dialog";
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
11
|
+
import { Icon } from "@ekanos/ui/icon";
|
|
12
|
+
import { Skeleton } from "@ekanos/ui/skeleton";
|
|
12
13
|
import { StatusBadge } from "@ekanos/ui/status-badge";
|
|
13
|
-
import {
|
|
14
|
+
import { cn } from "@ekanos/ui/utils";
|
|
15
|
+
import { useQuery, useQueryClient } from "@tanstack/react-query";
|
|
14
16
|
import { NextIntlClientProvider } from "next-intl";
|
|
15
17
|
import { TeamAccountWorkspaceContextProvider } from "../../mocks/team-account-workspace.js";
|
|
16
18
|
import { HARNESS_ACCOUNT_ID } from "../../registry.js";
|
|
19
|
+
import {
|
|
20
|
+
activationRows,
|
|
21
|
+
authorizeBlocker,
|
|
22
|
+
connectSteps,
|
|
23
|
+
credentialHints,
|
|
24
|
+
formatWhen,
|
|
25
|
+
groupKeys
|
|
26
|
+
} from "../lib/connect-model.js";
|
|
17
27
|
import { useConsoleClient } from "../lib/console-context.js";
|
|
18
28
|
import {
|
|
19
29
|
consoleKeys,
|
|
@@ -21,6 +31,18 @@ import {
|
|
|
21
31
|
useConsoleMutation
|
|
22
32
|
} from "../lib/console-hooks.js";
|
|
23
33
|
import { oauthConnectHref } from "../lib/oauth-connect-href.js";
|
|
34
|
+
import { buildConnectionSetupGuide } from "../lib/oauth-setup-guide.js";
|
|
35
|
+
import { resolveOriginalFetch } from "../lib/original-fetch.js";
|
|
36
|
+
import { registryEntryFor } from "../lib/registry-entry.js";
|
|
37
|
+
import { fetchLocalSetup } from "../lib/trigger-runner.js";
|
|
38
|
+
import { useOptionalHarnessRegistry } from "../registry-context.js";
|
|
39
|
+
import {
|
|
40
|
+
ConnectStepItem,
|
|
41
|
+
ConnectStepList,
|
|
42
|
+
CredentialGroup,
|
|
43
|
+
CredentialRow,
|
|
44
|
+
SetupGuide
|
|
45
|
+
} from "./connect-steps.js";
|
|
24
46
|
import { ConnectionChip } from "./connection-chip.js";
|
|
25
47
|
const LEVEL_LABEL = {
|
|
26
48
|
source: "For the Source",
|
|
@@ -88,21 +110,37 @@ function ConnectAsSwitch({
|
|
|
88
110
|
const change = useConsoleMutation(
|
|
89
111
|
(c, as) => c.setSwitches(integration, { connectAs: { credential, as } })
|
|
90
112
|
);
|
|
91
|
-
return /* @__PURE__ */
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
113
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1", children: [
|
|
114
|
+
/* @__PURE__ */ jsx(
|
|
115
|
+
TierSwitch,
|
|
116
|
+
{
|
|
117
|
+
label: "Connect as",
|
|
118
|
+
value,
|
|
119
|
+
options: CONNECT_AS_OPTIONS,
|
|
120
|
+
testId,
|
|
121
|
+
disabled: change.isPending,
|
|
122
|
+
onChange: (as) => change.mutate(as, {
|
|
123
|
+
onSuccess: () => queryClient.invalidateQueries({
|
|
124
|
+
queryKey: consoleKeys.connection(integration)
|
|
125
|
+
})
|
|
102
126
|
})
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
|
|
127
|
+
}
|
|
128
|
+
),
|
|
129
|
+
/* @__PURE__ */ jsxs(
|
|
130
|
+
"p",
|
|
131
|
+
{
|
|
132
|
+
className: "text-muted-foreground text-xs",
|
|
133
|
+
"data-test": `${testId}-explain`,
|
|
134
|
+
children: [
|
|
135
|
+
"Me: only your own calls get it, in ",
|
|
136
|
+
/* @__PURE__ */ jsx("code", { children: "ctx.identity" }),
|
|
137
|
+
". The team: every call gets it, in ",
|
|
138
|
+
/* @__PURE__ */ jsx("code", { children: "ctx.secrets" }),
|
|
139
|
+
"."
|
|
140
|
+
]
|
|
141
|
+
}
|
|
142
|
+
)
|
|
143
|
+
] });
|
|
106
144
|
}
|
|
107
145
|
function RunAsSwitch({
|
|
108
146
|
integration,
|
|
@@ -112,7 +150,8 @@ function RunAsSwitch({
|
|
|
112
150
|
const change = useConsoleMutation(
|
|
113
151
|
(c, runAs) => c.setSwitches(integration, { runAs })
|
|
114
152
|
);
|
|
115
|
-
return /* @__PURE__ */ jsxs("
|
|
153
|
+
return /* @__PURE__ */ jsxs("section", { className: "flex flex-col gap-2 border-t pt-6", "data-test": "run-as", children: [
|
|
154
|
+
/* @__PURE__ */ jsx("h3", { className: "font-heading font-heading-title text-base", children: "How calls run" }),
|
|
116
155
|
/* @__PURE__ */ jsx(
|
|
117
156
|
TierSwitch,
|
|
118
157
|
{
|
|
@@ -132,9 +171,43 @@ function RunAsSwitch({
|
|
|
132
171
|
value === "me" ? "Calls act as you, with ctx.identity holding only what you connected as yourself." : "Calls act as a machine: no person, and never a ctx.identity.",
|
|
133
172
|
" ",
|
|
134
173
|
"ctx.secrets stays the team's either way."
|
|
135
|
-
] })
|
|
174
|
+
] }),
|
|
175
|
+
change.isError ? /* @__PURE__ */ jsx("p", { className: "text-destructive text-xs", role: "alert", children: change.error.message }) : null
|
|
136
176
|
] });
|
|
137
177
|
}
|
|
178
|
+
function ConnectSkeleton() {
|
|
179
|
+
return /* @__PURE__ */ jsxs(
|
|
180
|
+
"div",
|
|
181
|
+
{
|
|
182
|
+
className: "flex w-full flex-col gap-6",
|
|
183
|
+
"data-test": "connect-loading",
|
|
184
|
+
"aria-busy": "true",
|
|
185
|
+
"aria-label": "Loading the connection",
|
|
186
|
+
children: [
|
|
187
|
+
/* @__PURE__ */ jsx(Skeleton, { className: "h-16 w-full rounded-lg" }),
|
|
188
|
+
[0, 1].map((step) => /* @__PURE__ */ jsxs("div", { className: "flex gap-4", children: [
|
|
189
|
+
/* @__PURE__ */ jsx(Skeleton, { className: "size-7 rounded-full" }),
|
|
190
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-1 flex-col gap-3", children: [
|
|
191
|
+
/* @__PURE__ */ jsx(Skeleton, { className: "h-5 w-48" }),
|
|
192
|
+
/* @__PURE__ */ jsx(Skeleton, { className: "h-28 w-full rounded-lg" })
|
|
193
|
+
] })
|
|
194
|
+
] }, step))
|
|
195
|
+
]
|
|
196
|
+
}
|
|
197
|
+
);
|
|
198
|
+
}
|
|
199
|
+
function summaryLine(state, oauth) {
|
|
200
|
+
switch (state.facts.state) {
|
|
201
|
+
case "connected":
|
|
202
|
+
return state.facts.answers === "live" ? "Operations that name no mode run live with these credentials." : "Connected. Calls answer from fixtures while this integration is pinned to them.";
|
|
203
|
+
case "no_connection_needed":
|
|
204
|
+
return "This integration works without credentials.";
|
|
205
|
+
case "unreadable":
|
|
206
|
+
return state.facts.detail ?? "The harness could not read the stored credentials.";
|
|
207
|
+
default:
|
|
208
|
+
return oauth ? "Add your app keys, then authorize. Until then, calls answer from fixtures." : "Add your keys to run live. Until then, calls answer from fixtures.";
|
|
209
|
+
}
|
|
210
|
+
}
|
|
138
211
|
function ConnectPanel({
|
|
139
212
|
integration,
|
|
140
213
|
oauth = false,
|
|
@@ -143,24 +216,35 @@ function ConnectPanel({
|
|
|
143
216
|
returnPath,
|
|
144
217
|
surface = "page"
|
|
145
218
|
}) {
|
|
146
|
-
const
|
|
219
|
+
const slug = integration.integration;
|
|
220
|
+
const connection = useConnection(slug);
|
|
147
221
|
const queryClient = useQueryClient();
|
|
148
|
-
const
|
|
149
|
-
const
|
|
150
|
-
|
|
151
|
-
);
|
|
222
|
+
const registry = useOptionalHarnessRegistry();
|
|
223
|
+
const entry = registryEntryFor(registry, slug);
|
|
224
|
+
const hints = credentialHints(entry?.definition);
|
|
152
225
|
const disconnect = useConsoleMutation(
|
|
153
|
-
(c, clearKeys) => c.disconnect(
|
|
226
|
+
(c, clearKeys) => c.disconnect(slug, clearKeys)
|
|
154
227
|
);
|
|
155
228
|
if (connection.isError) {
|
|
156
|
-
return /* @__PURE__ */
|
|
157
|
-
"Could not load the connection
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
229
|
+
return /* @__PURE__ */ jsxs(Alert, { variant: "destructive", "data-test": "connect-error", children: [
|
|
230
|
+
/* @__PURE__ */ jsx(AlertTitle, { children: "Could not load the connection" }),
|
|
231
|
+
/* @__PURE__ */ jsxs(AlertDescription, { children: [
|
|
232
|
+
/* @__PURE__ */ jsx("p", { children: connection.error.message }),
|
|
233
|
+
/* @__PURE__ */ jsx(
|
|
234
|
+
Button,
|
|
235
|
+
{
|
|
236
|
+
variant: "outline",
|
|
237
|
+
size: "sm",
|
|
238
|
+
className: "mt-2",
|
|
239
|
+
onClick: () => void connection.refetch(),
|
|
240
|
+
"data-test": "connect-retry",
|
|
241
|
+
children: "Try again"
|
|
242
|
+
}
|
|
243
|
+
)
|
|
244
|
+
] })
|
|
245
|
+
] });
|
|
163
246
|
}
|
|
247
|
+
if (!connection.data) return /* @__PURE__ */ jsx(ConnectSkeleton, {});
|
|
164
248
|
const state = connection.data;
|
|
165
249
|
if (state.managed) {
|
|
166
250
|
return /* @__PURE__ */ jsxs(Alert, { variant: "info", "data-test": "connect-managed", children: [
|
|
@@ -170,164 +254,352 @@ function ConnectPanel({
|
|
|
170
254
|
}
|
|
171
255
|
const noConnectionNeeded = state.facts.state === "no_connection_needed";
|
|
172
256
|
const inDialog = surface === "dialog";
|
|
173
|
-
const dirty = Object.values(drafts).some((value) => value !== "");
|
|
174
257
|
const showActivationForm = state.fields.length === 0 && activationForm;
|
|
258
|
+
const activationCredentials = state.activationCredentials ?? [];
|
|
259
|
+
const keyNames = new Set(state.fields.map((field) => field.key));
|
|
260
|
+
const extraCredentials = activationCredentials.map((credential) => ({
|
|
261
|
+
...credential,
|
|
262
|
+
fields: credential.fields.filter((field) => !keyNames.has(field.name))
|
|
263
|
+
})).filter((credential) => credential.fields.length > 0);
|
|
264
|
+
const steps = connectSteps(state, oauth, hints);
|
|
265
|
+
const activationNames = new Set(
|
|
266
|
+
activationCredentials.flatMap(
|
|
267
|
+
(credential) => credential.fields.map((field) => field.name)
|
|
268
|
+
)
|
|
269
|
+
);
|
|
270
|
+
const refresh = () => queryClient.invalidateQueries({ queryKey: consoleKeys.connection(slug) });
|
|
271
|
+
const keysForm = state.fields.length > 0 ? /* @__PURE__ */ jsx(
|
|
272
|
+
KeysForm,
|
|
273
|
+
{
|
|
274
|
+
slug,
|
|
275
|
+
state,
|
|
276
|
+
hints,
|
|
277
|
+
entry,
|
|
278
|
+
oauth,
|
|
279
|
+
saveLabel: noConnectionNeeded ? "Save settings" : "Save keys",
|
|
280
|
+
required: !noConnectionNeeded,
|
|
281
|
+
activationNames,
|
|
282
|
+
onSaved: async () => {
|
|
283
|
+
onChanged?.();
|
|
284
|
+
await refresh();
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
) : null;
|
|
288
|
+
const oauthStep = oauth ? /* @__PURE__ */ jsx(
|
|
289
|
+
OAuthConnections,
|
|
290
|
+
{
|
|
291
|
+
integration: slug,
|
|
292
|
+
connections: state.oauthConnections ?? [],
|
|
293
|
+
hints,
|
|
294
|
+
disconnectable: !inDialog,
|
|
295
|
+
...returnPath ? { returnPath } : {},
|
|
296
|
+
...onChanged ? { onChanged } : {}
|
|
297
|
+
}
|
|
298
|
+
) : null;
|
|
175
299
|
return /* @__PURE__ */ jsxs(
|
|
176
300
|
"div",
|
|
177
301
|
{
|
|
178
|
-
className: "flex w-full max-w-full min-w-0 flex-col gap-
|
|
302
|
+
className: "flex w-full max-w-full min-w-0 flex-col gap-8",
|
|
179
303
|
"data-test": "connect-panel",
|
|
180
304
|
children: [
|
|
181
|
-
inDialog ? null : /* @__PURE__ */ jsx("p", { className: "text-muted-foreground text-xs", children: "Credentials are stored on this machine, in the integration repo. They never reach the browser, so a saved key shows as set, not its value." }),
|
|
182
305
|
/* @__PURE__ */ jsxs(
|
|
183
|
-
|
|
306
|
+
Card,
|
|
184
307
|
{
|
|
185
|
-
|
|
186
|
-
|
|
308
|
+
layout: "bleed",
|
|
309
|
+
render: /* @__PURE__ */ jsx("section", {}),
|
|
310
|
+
className: "flex min-w-0 flex-col gap-2 p-4",
|
|
311
|
+
"data-test": "connect-summary",
|
|
187
312
|
children: [
|
|
188
|
-
/* @__PURE__ */
|
|
189
|
-
|
|
190
|
-
"span",
|
|
313
|
+
/* @__PURE__ */ jsxs(
|
|
314
|
+
"div",
|
|
191
315
|
{
|
|
192
|
-
className: "
|
|
193
|
-
"data-test": "connect-
|
|
194
|
-
children:
|
|
316
|
+
className: "flex min-w-0 flex-wrap items-center gap-x-3 gap-y-2",
|
|
317
|
+
"data-test": "connect-target",
|
|
318
|
+
children: [
|
|
319
|
+
/* @__PURE__ */ jsx(ConnectionChip, { facts: state.facts }),
|
|
320
|
+
noConnectionNeeded ? /* @__PURE__ */ jsx(
|
|
321
|
+
"span",
|
|
322
|
+
{
|
|
323
|
+
className: "text-muted-foreground text-xs",
|
|
324
|
+
"data-test": "connect-optional",
|
|
325
|
+
children: "Settings below are optional."
|
|
326
|
+
}
|
|
327
|
+
) : null,
|
|
328
|
+
state.hasStored && !inDialog ? /* @__PURE__ */ jsx("span", { className: "ml-auto", children: /* @__PURE__ */ jsx(
|
|
329
|
+
ConfirmDialog,
|
|
330
|
+
{
|
|
331
|
+
trigger: /* @__PURE__ */ jsx(
|
|
332
|
+
Button,
|
|
333
|
+
{
|
|
334
|
+
variant: "destructive-ghost",
|
|
335
|
+
size: "sm",
|
|
336
|
+
disabled: disconnect.isPending,
|
|
337
|
+
"data-test": "disconnect",
|
|
338
|
+
children: "Disconnect"
|
|
339
|
+
}
|
|
340
|
+
),
|
|
341
|
+
title: `Disconnect ${slug}?`,
|
|
342
|
+
description: oauth ? "This removes the stored connection data for this integration from this machine. The OAuth app keys stay; you can authorize again afterwards." : "This removes the stored keys for this integration from this machine, in its own folder only. You can enter new values afterwards.",
|
|
343
|
+
confirmLabel: "Disconnect",
|
|
344
|
+
confirmTestId: "confirm-disconnect",
|
|
345
|
+
onConfirm: async () => {
|
|
346
|
+
try {
|
|
347
|
+
await disconnect.mutateAsync(!oauth);
|
|
348
|
+
await refresh();
|
|
349
|
+
onChanged?.();
|
|
350
|
+
return true;
|
|
351
|
+
} catch (error) {
|
|
352
|
+
console.error("[harness] disconnect failed", error);
|
|
353
|
+
return false;
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
) }) : null
|
|
358
|
+
]
|
|
195
359
|
}
|
|
196
|
-
)
|
|
197
|
-
state.
|
|
198
|
-
|
|
360
|
+
),
|
|
361
|
+
state.facts.state === "not_connected" && !inDialog ? null : /* @__PURE__ */ jsx("p", { className: "text-sm", "data-test": "connect-summary-line", children: summaryLine(state, oauth) }),
|
|
362
|
+
inDialog ? null : /* @__PURE__ */ jsxs(
|
|
363
|
+
"p",
|
|
199
364
|
{
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
"
|
|
207
|
-
children:
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
try {
|
|
215
|
-
await disconnect.mutateAsync(!oauth);
|
|
216
|
-
setDrafts({});
|
|
217
|
-
await queryClient.invalidateQueries({
|
|
218
|
-
queryKey: consoleKeys.connection(integration.integration)
|
|
219
|
-
});
|
|
220
|
-
onChanged?.();
|
|
221
|
-
return true;
|
|
222
|
-
} catch (error) {
|
|
223
|
-
console.error("[harness] disconnect failed", error);
|
|
224
|
-
return false;
|
|
225
|
-
}
|
|
226
|
-
}
|
|
365
|
+
className: "text-muted-foreground flex gap-2 text-xs",
|
|
366
|
+
"data-test": "store-root",
|
|
367
|
+
children: [
|
|
368
|
+
/* @__PURE__ */ jsx(Icon, { name: "lock-simple", className: "mt-0.5 size-3.5 shrink-0" }),
|
|
369
|
+
/* @__PURE__ */ jsxs("span", { children: [
|
|
370
|
+
"Saved on this machine in",
|
|
371
|
+
" ",
|
|
372
|
+
/* @__PURE__ */ jsxs("code", { title: state.root, children: [
|
|
373
|
+
state.displayRoot ?? state.root ?? "the integration folder",
|
|
374
|
+
"/.ekanos/local-secrets.json"
|
|
375
|
+
] }),
|
|
376
|
+
", outside git. Values never reach the browser: a saved key shows as Set, never its value."
|
|
377
|
+
] })
|
|
378
|
+
]
|
|
227
379
|
}
|
|
228
|
-
)
|
|
380
|
+
),
|
|
381
|
+
disconnect.isError ? /* @__PURE__ */ jsx(Alert, { variant: "destructive", children: /* @__PURE__ */ jsxs(AlertDescription, { children: [
|
|
382
|
+
"Disconnect failed: ",
|
|
383
|
+
disconnect.error.message
|
|
384
|
+
] }) }) : null
|
|
229
385
|
]
|
|
230
386
|
}
|
|
231
387
|
),
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
RunAsSwitch,
|
|
235
|
-
{
|
|
236
|
-
integration: integration.integration,
|
|
237
|
-
value: state.runAs
|
|
238
|
-
}
|
|
239
|
-
) : null,
|
|
240
|
-
/* @__PURE__ */ jsxs(
|
|
241
|
-
"form",
|
|
388
|
+
steps.length > 0 ? /* @__PURE__ */ jsx(ConnectStepList, { children: steps.map((step, index) => /* @__PURE__ */ jsx(
|
|
389
|
+
ConnectStepItem,
|
|
242
390
|
{
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
});
|
|
258
|
-
},
|
|
259
|
-
children: [
|
|
260
|
-
state.root ? /* @__PURE__ */ jsxs("p", { className: "text-muted-foreground text-xs", "data-test": "store-root", children: [
|
|
261
|
-
"Store:",
|
|
262
|
-
" ",
|
|
263
|
-
/* @__PURE__ */ jsx("code", { title: state.root, children: state.displayRoot ?? state.root })
|
|
264
|
-
] }) : null,
|
|
265
|
-
state.fields.length === 0 && !activationForm && (state.activationCredentials ?? []).length === 0 ? /* @__PURE__ */ jsx("p", { className: "text-muted-foreground text-sm", children: "This integration declares no keys." }) : null,
|
|
266
|
-
state.fields.map((field) => /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1.5", children: [
|
|
267
|
-
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
268
|
-
/* @__PURE__ */ jsx(
|
|
269
|
-
Label,
|
|
270
|
-
{
|
|
271
|
-
htmlFor: `connect-${field.key}`,
|
|
272
|
-
className: "text-sm font-medium",
|
|
273
|
-
children: field.label
|
|
274
|
-
}
|
|
275
|
-
),
|
|
276
|
-
/* @__PURE__ */ jsx(StatusBadge, { tone: field.set ? "success" : "neutral", children: field.set ? "set" : "not set" })
|
|
277
|
-
] }),
|
|
278
|
-
/* @__PURE__ */ jsx(
|
|
279
|
-
Input,
|
|
280
|
-
{
|
|
281
|
-
id: `connect-${field.key}`,
|
|
282
|
-
type: field.secret ? "password" : "text",
|
|
283
|
-
autoComplete: "off",
|
|
284
|
-
placeholder: field.set ? "Set" : "",
|
|
285
|
-
value: drafts[field.key] ?? "",
|
|
286
|
-
onChange: (event) => setDrafts({ ...drafts, [field.key]: event.target.value })
|
|
287
|
-
}
|
|
288
|
-
)
|
|
289
|
-
] }, field.key)),
|
|
290
|
-
save.isError ? /* @__PURE__ */ jsx(Alert, { variant: "destructive", children: /* @__PURE__ */ jsx(AlertDescription, { children: save.error.message }) }) : null,
|
|
291
|
-
state.fields.length > 0 ? /* @__PURE__ */ jsx(
|
|
292
|
-
Button,
|
|
293
|
-
{
|
|
294
|
-
type: "submit",
|
|
295
|
-
className: "self-start",
|
|
296
|
-
disabled: !dirty || save.isPending,
|
|
297
|
-
"data-test": "save-secrets",
|
|
298
|
-
children: save.isPending ? "Saving\u2026" : noConnectionNeeded ? "Save settings" : "Save keys"
|
|
299
|
-
}
|
|
300
|
-
) : null
|
|
301
|
-
]
|
|
302
|
-
}
|
|
303
|
-
),
|
|
391
|
+
number: index + 1,
|
|
392
|
+
title: step.title,
|
|
393
|
+
status: step.status,
|
|
394
|
+
summary: step.summary,
|
|
395
|
+
last: index === steps.length - 1,
|
|
396
|
+
testId: `connect-step-${step.id}`,
|
|
397
|
+
children: step.id === "keys" ? keysForm : oauthStep
|
|
398
|
+
},
|
|
399
|
+
step.id
|
|
400
|
+
)) }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
401
|
+
keysForm,
|
|
402
|
+
oauthStep
|
|
403
|
+
] }),
|
|
404
|
+
state.fields.length === 0 && !activationForm && activationCredentials.length === 0 ? /* @__PURE__ */ jsx("p", { className: "text-muted-foreground text-sm", children: "This integration declares no keys." }) : null,
|
|
304
405
|
showActivationForm ? /* @__PURE__ */ jsx(
|
|
305
406
|
ActivationConnect,
|
|
306
407
|
{
|
|
307
|
-
integration:
|
|
408
|
+
integration: slug,
|
|
308
409
|
Form: showActivationForm,
|
|
309
410
|
saveLabel: noConnectionNeeded,
|
|
310
411
|
...onChanged ? { onChanged } : {}
|
|
311
412
|
}
|
|
312
413
|
) : null,
|
|
313
|
-
!showActivationForm &&
|
|
414
|
+
!showActivationForm && extraCredentials.length > 0 ? /* @__PURE__ */ jsx(
|
|
314
415
|
ActivationCredentials,
|
|
315
416
|
{
|
|
316
|
-
integration:
|
|
317
|
-
credentials:
|
|
417
|
+
integration: slug,
|
|
418
|
+
credentials: extraCredentials,
|
|
419
|
+
hints,
|
|
318
420
|
...onChanged ? { onChanged } : {}
|
|
319
421
|
}
|
|
320
422
|
) : null,
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
423
|
+
state.runAs ? /* @__PURE__ */ jsx(RunAsSwitch, { integration: slug, value: state.runAs }) : null
|
|
424
|
+
]
|
|
425
|
+
}
|
|
426
|
+
);
|
|
427
|
+
}
|
|
428
|
+
function KeysForm({
|
|
429
|
+
slug,
|
|
430
|
+
state,
|
|
431
|
+
hints,
|
|
432
|
+
entry,
|
|
433
|
+
oauth,
|
|
434
|
+
saveLabel,
|
|
435
|
+
required,
|
|
436
|
+
activationNames,
|
|
437
|
+
onSaved
|
|
438
|
+
}) {
|
|
439
|
+
const [form, setForm] = useState({ drafts: {}, saved: null });
|
|
440
|
+
const save = useConsoleMutation(
|
|
441
|
+
(c, values) => c.saveSecrets(slug, values)
|
|
442
|
+
);
|
|
443
|
+
const remove = useConsoleMutation(
|
|
444
|
+
(c, key) => c.saveSecrets(slug, { [key]: "" })
|
|
445
|
+
);
|
|
446
|
+
const definition = entry?.definition;
|
|
447
|
+
const setup = useQuery({
|
|
448
|
+
queryKey: ["ekanos-harness", "local-setup", slug],
|
|
449
|
+
queryFn: () => fetchLocalSetup(
|
|
450
|
+
slug,
|
|
451
|
+
(input, init) => resolveOriginalFetch()(input, init)
|
|
452
|
+
),
|
|
453
|
+
enabled: oauth && definition?.oauth !== void 0,
|
|
454
|
+
retry: false,
|
|
455
|
+
staleTime: Infinity
|
|
456
|
+
});
|
|
457
|
+
const redirectUri = setup.data?.redirectUri ?? null;
|
|
458
|
+
const groups = groupKeys(state, { slug, hints, required });
|
|
459
|
+
const typed = Object.fromEntries(
|
|
460
|
+
Object.entries(form.drafts).filter(([, value]) => value.trim() !== "")
|
|
461
|
+
);
|
|
462
|
+
const typedCount = Object.keys(typed).length;
|
|
463
|
+
return /* @__PURE__ */ jsxs(
|
|
464
|
+
"form",
|
|
465
|
+
{
|
|
466
|
+
className: "flex w-full min-w-0 flex-col gap-4",
|
|
467
|
+
"data-test": "keys-form",
|
|
468
|
+
autoComplete: "off",
|
|
469
|
+
onSubmit: (event) => {
|
|
470
|
+
event.preventDefault();
|
|
471
|
+
save.mutate(typed, {
|
|
472
|
+
onSuccess: async () => {
|
|
473
|
+
setForm({ drafts: {}, saved: typedCount });
|
|
474
|
+
await onSaved();
|
|
329
475
|
}
|
|
330
|
-
)
|
|
476
|
+
});
|
|
477
|
+
},
|
|
478
|
+
children: [
|
|
479
|
+
groups.map((group) => {
|
|
480
|
+
const guide = group.connectionId && definition ? buildConnectionSetupGuide({
|
|
481
|
+
definition,
|
|
482
|
+
...entry ? { entry } : {},
|
|
483
|
+
connectionId: group.connectionId,
|
|
484
|
+
redirectUri
|
|
485
|
+
}) : null;
|
|
486
|
+
return /* @__PURE__ */ jsx(
|
|
487
|
+
CredentialGroup,
|
|
488
|
+
{
|
|
489
|
+
title: group.title,
|
|
490
|
+
...group.description ? { description: group.description } : {},
|
|
491
|
+
testId: `key-group-${group.id}`,
|
|
492
|
+
...guide ? {
|
|
493
|
+
guide: /* @__PURE__ */ jsx(
|
|
494
|
+
SetupGuide,
|
|
495
|
+
{
|
|
496
|
+
guide,
|
|
497
|
+
testId: `setup-guide-${group.connectionId}`
|
|
498
|
+
}
|
|
499
|
+
)
|
|
500
|
+
} : {},
|
|
501
|
+
children: group.rows.map((row) => /* @__PURE__ */ jsx(
|
|
502
|
+
CredentialRow,
|
|
503
|
+
{
|
|
504
|
+
id: `connect-${row.name}`,
|
|
505
|
+
name: row.name,
|
|
506
|
+
label: row.label,
|
|
507
|
+
...row.description ? { description: row.description } : {},
|
|
508
|
+
...activationNames.has(row.name) ? {
|
|
509
|
+
note: "The activation form takes this too; when both hold a value, code reads this one."
|
|
510
|
+
} : {},
|
|
511
|
+
requirement: row.purpose.label,
|
|
512
|
+
primary: row.purpose.primary,
|
|
513
|
+
secret: row.secret,
|
|
514
|
+
set: row.set,
|
|
515
|
+
value: form.drafts[row.name] ?? "",
|
|
516
|
+
disabled: save.isPending,
|
|
517
|
+
testId: `key-${row.name}`,
|
|
518
|
+
onChange: (value) => setForm({
|
|
519
|
+
drafts: { ...form.drafts, [row.name]: value },
|
|
520
|
+
saved: null
|
|
521
|
+
}),
|
|
522
|
+
action: row.set ? /* @__PURE__ */ jsx(
|
|
523
|
+
ConfirmDialog,
|
|
524
|
+
{
|
|
525
|
+
trigger: /* @__PURE__ */ jsx(
|
|
526
|
+
Button,
|
|
527
|
+
{
|
|
528
|
+
type: "button",
|
|
529
|
+
variant: "ghost",
|
|
530
|
+
size: "xs",
|
|
531
|
+
disabled: remove.isPending,
|
|
532
|
+
"data-test": `remove-key-${row.name}`,
|
|
533
|
+
children: "Remove"
|
|
534
|
+
}
|
|
535
|
+
),
|
|
536
|
+
title: `Remove ${row.label}?`,
|
|
537
|
+
description: `This clears ${row.name} from this machine. You can paste a new value afterwards.`,
|
|
538
|
+
confirmLabel: "Remove",
|
|
539
|
+
confirmTestId: `confirm-remove-key-${row.name}`,
|
|
540
|
+
onConfirm: async () => {
|
|
541
|
+
try {
|
|
542
|
+
await remove.mutateAsync(row.name);
|
|
543
|
+
await onSaved();
|
|
544
|
+
return true;
|
|
545
|
+
} catch (error) {
|
|
546
|
+
console.error(
|
|
547
|
+
"[harness] removing a key failed",
|
|
548
|
+
error
|
|
549
|
+
);
|
|
550
|
+
return false;
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
) : void 0
|
|
555
|
+
},
|
|
556
|
+
row.name
|
|
557
|
+
))
|
|
558
|
+
},
|
|
559
|
+
group.id
|
|
560
|
+
);
|
|
561
|
+
}),
|
|
562
|
+
remove.isError ? /* @__PURE__ */ jsx(Alert, { variant: "destructive", children: /* @__PURE__ */ jsxs(AlertDescription, { children: [
|
|
563
|
+
"Could not remove the key: ",
|
|
564
|
+
remove.error.message
|
|
565
|
+
] }) }) : null,
|
|
566
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-3", children: [
|
|
567
|
+
/* @__PURE__ */ jsx(
|
|
568
|
+
Button,
|
|
569
|
+
{
|
|
570
|
+
type: "submit",
|
|
571
|
+
disabled: typedCount === 0 || save.isPending,
|
|
572
|
+
"data-test": "save-secrets",
|
|
573
|
+
children: save.isPending ? "Saving\u2026" : saveLabel
|
|
574
|
+
}
|
|
575
|
+
),
|
|
576
|
+
save.isError ? /* @__PURE__ */ jsxs(
|
|
577
|
+
"span",
|
|
578
|
+
{
|
|
579
|
+
className: "text-destructive text-sm",
|
|
580
|
+
role: "alert",
|
|
581
|
+
"data-test": "save-secrets-error",
|
|
582
|
+
children: [
|
|
583
|
+
"Not saved: ",
|
|
584
|
+
save.error.message
|
|
585
|
+
]
|
|
586
|
+
}
|
|
587
|
+
) : form.saved !== null ? /* @__PURE__ */ jsxs(
|
|
588
|
+
"span",
|
|
589
|
+
{
|
|
590
|
+
className: "text-muted-foreground text-sm",
|
|
591
|
+
role: "status",
|
|
592
|
+
"data-test": "save-secrets-done",
|
|
593
|
+
children: [
|
|
594
|
+
"Saved ",
|
|
595
|
+
form.saved,
|
|
596
|
+
" ",
|
|
597
|
+
form.saved === 1 ? "key" : "keys",
|
|
598
|
+
"."
|
|
599
|
+
]
|
|
600
|
+
}
|
|
601
|
+
) : /* @__PURE__ */ jsx("span", { className: "text-muted-foreground text-xs", children: typedCount === 0 ? "Type a value to save it. Blank fields keep what is saved." : `${typedCount} ${typedCount === 1 ? "key" : "keys"} to save. Blank fields keep what is saved.` })
|
|
602
|
+
] })
|
|
331
603
|
]
|
|
332
604
|
}
|
|
333
605
|
);
|
|
@@ -335,6 +607,7 @@ function ConnectPanel({
|
|
|
335
607
|
function OAuthConnections({
|
|
336
608
|
integration,
|
|
337
609
|
connections,
|
|
610
|
+
hints,
|
|
338
611
|
disconnectable,
|
|
339
612
|
returnPath,
|
|
340
613
|
onChanged
|
|
@@ -354,136 +627,189 @@ function OAuthConnections({
|
|
|
354
627
|
}
|
|
355
628
|
];
|
|
356
629
|
const single = connections.length === 0;
|
|
357
|
-
return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-3", "data-test": "oauth-block", children: [
|
|
358
|
-
/* @__PURE__ */ jsx("h3", { className: "text-sm font-medium", children: "OAuth" }),
|
|
630
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex min-w-0 flex-col gap-3", "data-test": "oauth-block", children: [
|
|
359
631
|
/* @__PURE__ */ jsxs("p", { className: "text-muted-foreground text-xs", children: [
|
|
360
|
-
"
|
|
632
|
+
"Authorize runs the real sign-in and callback loop on localhost with your app keys, then comes back here.",
|
|
361
633
|
rows.length > 1 ? " Each connection has its own app, consent and tokens." : ""
|
|
362
634
|
] }),
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
}
|
|
389
|
-
)
|
|
390
|
-
] }),
|
|
391
|
-
connection.description ? /* @__PURE__ */ jsx("p", { className: "text-muted-foreground text-xs", children: connection.description }) : null,
|
|
392
|
-
connection.teamApp ? /* @__PURE__ */ jsxs("p", { className: "text-muted-foreground text-xs", children: [
|
|
393
|
-
"The team brings its own app for this connection. Here, its fields are the keys above:",
|
|
394
|
-
" ",
|
|
395
|
-
connection.keys.map((key) => key.label).join(", "),
|
|
396
|
-
"."
|
|
397
|
-
] }) : null,
|
|
398
|
-
params.length > 0 ? /* @__PURE__ */ jsxs("p", { className: "text-muted-foreground text-xs", children: [
|
|
399
|
-
"Sends",
|
|
400
|
-
" ",
|
|
401
|
-
params.map(([key, value]) => /* @__PURE__ */ jsxs("code", { className: "mr-1", children: [
|
|
402
|
-
key,
|
|
403
|
-
"=",
|
|
404
|
-
value
|
|
405
|
-
] }, key)),
|
|
406
|
-
"to the provider."
|
|
407
|
-
] }) : null,
|
|
408
|
-
connection.connectAs ? /* @__PURE__ */ jsx(
|
|
409
|
-
ConnectAsSwitch,
|
|
410
|
-
{
|
|
411
|
-
integration,
|
|
412
|
-
credential: `oauth:${connection.id}`,
|
|
413
|
-
value: connection.connectAs,
|
|
414
|
-
testId: `oauth-connect-as-${connection.id}`
|
|
415
|
-
}
|
|
416
|
-
) : null,
|
|
417
|
-
missing.length > 0 ? /* @__PURE__ */ jsxs(
|
|
418
|
-
"p",
|
|
419
|
-
{
|
|
420
|
-
className: "text-muted-foreground text-xs",
|
|
421
|
-
"data-test": `oauth-connection-missing-${connection.id}`,
|
|
422
|
-
children: [
|
|
423
|
-
"Save ",
|
|
424
|
-
missing.map((key) => key.label).join(", "),
|
|
425
|
-
" first."
|
|
426
|
-
]
|
|
427
|
-
}
|
|
428
|
-
) : null,
|
|
429
|
-
/* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [
|
|
430
|
-
/* @__PURE__ */ jsx(
|
|
431
|
-
Button,
|
|
432
|
-
{
|
|
433
|
-
variant: "outline",
|
|
434
|
-
className: "self-start",
|
|
435
|
-
"data-test": connection.id === "default" ? "start-oauth" : `start-oauth-${connection.id}`,
|
|
436
|
-
nativeButton: false,
|
|
437
|
-
render: /* @__PURE__ */ jsx(
|
|
438
|
-
"a",
|
|
635
|
+
/* @__PURE__ */ jsx(
|
|
636
|
+
"div",
|
|
637
|
+
{
|
|
638
|
+
className: cn(
|
|
639
|
+
"grid min-w-0 gap-3",
|
|
640
|
+
rows.length > 1 && "lg:grid-cols-2"
|
|
641
|
+
),
|
|
642
|
+
children: rows.map((connection) => {
|
|
643
|
+
const blocker = authorizeBlocker(connection, hints, integration);
|
|
644
|
+
const params = Object.entries(connection.authorizationParams ?? {});
|
|
645
|
+
const name = connection.id === "default" ? connection.label.toLowerCase() : connection.label;
|
|
646
|
+
const label = single ? "Authorize with OAuth" : connection.connected ? `Reauthorize ${name}` : `Authorize ${name}`;
|
|
647
|
+
const testId = connection.id === "default" ? "start-oauth" : `start-oauth-${connection.id}`;
|
|
648
|
+
const failed = disconnect.isError && disconnect.variables?.connection === connection.id;
|
|
649
|
+
return /* @__PURE__ */ jsxs(
|
|
650
|
+
Card,
|
|
651
|
+
{
|
|
652
|
+
layout: "bleed",
|
|
653
|
+
className: "flex min-w-0 flex-col gap-3 p-4",
|
|
654
|
+
"data-test": `oauth-connection-${connection.id}`,
|
|
655
|
+
children: [
|
|
656
|
+
single ? null : /* @__PURE__ */ jsxs("div", { className: "flex min-w-0 items-baseline justify-between gap-2", children: [
|
|
657
|
+
/* @__PURE__ */ jsx("span", { className: "text-sm font-semibold", children: connection.label }),
|
|
658
|
+
/* @__PURE__ */ jsx(
|
|
659
|
+
"code",
|
|
439
660
|
{
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
661
|
+
className: "text-muted-foreground truncate font-mono text-xs",
|
|
662
|
+
title: "Connection id",
|
|
663
|
+
children: connection.id
|
|
664
|
+
}
|
|
665
|
+
)
|
|
666
|
+
] }),
|
|
667
|
+
/* @__PURE__ */ jsxs("div", { className: "flex min-w-0 flex-wrap items-center gap-2", children: [
|
|
668
|
+
/* @__PURE__ */ jsx(
|
|
669
|
+
StatusBadge,
|
|
670
|
+
{
|
|
671
|
+
tone: connection.connected ? "success" : "neutral",
|
|
672
|
+
"data-test": `oauth-connection-status-${connection.id}`,
|
|
673
|
+
children: connection.connected ? "Authorized" : "Not authorized"
|
|
446
674
|
}
|
|
447
675
|
),
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
),
|
|
451
|
-
disconnectable && connection.connected ? /* @__PURE__ */ jsx(
|
|
452
|
-
Button,
|
|
453
|
-
{
|
|
454
|
-
variant: "ghost",
|
|
455
|
-
size: "sm",
|
|
456
|
-
disabled: disconnect.isPending,
|
|
457
|
-
"data-test": `disconnect-oauth-${connection.id}`,
|
|
458
|
-
onClick: () => disconnect.mutate(
|
|
459
|
-
{ connection: connection.id, as: connection.connectAs },
|
|
676
|
+
single ? null : /* @__PURE__ */ jsx(
|
|
677
|
+
LevelBadge,
|
|
460
678
|
{
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
679
|
+
level: connection.level ?? "team",
|
|
680
|
+
testId: `oauth-connection-level-${connection.id}`
|
|
681
|
+
}
|
|
682
|
+
)
|
|
683
|
+
] }),
|
|
684
|
+
connection.description ? /* @__PURE__ */ jsx("p", { className: "text-muted-foreground text-xs", children: connection.description }) : null,
|
|
685
|
+
connection.connected && connection.obtainedAt ? /* @__PURE__ */ jsxs(
|
|
686
|
+
"p",
|
|
687
|
+
{
|
|
688
|
+
className: "text-sm",
|
|
689
|
+
"data-test": `oauth-connection-since-${connection.id}`,
|
|
690
|
+
children: [
|
|
691
|
+
"Authorized ",
|
|
692
|
+
formatWhen(connection.obtainedAt),
|
|
693
|
+
". Tokens live in the dev server's memory; a restart means authorizing again."
|
|
694
|
+
]
|
|
695
|
+
}
|
|
696
|
+
) : null,
|
|
697
|
+
params.length > 0 ? /* @__PURE__ */ jsxs("p", { className: "text-muted-foreground text-xs", children: [
|
|
698
|
+
"Sends",
|
|
699
|
+
" ",
|
|
700
|
+
params.map(([key, value]) => /* @__PURE__ */ jsxs("code", { className: "mr-1 font-mono", children: [
|
|
701
|
+
key,
|
|
702
|
+
"=",
|
|
703
|
+
value
|
|
704
|
+
] }, key)),
|
|
705
|
+
"to the provider."
|
|
706
|
+
] }) : null,
|
|
707
|
+
connection.connectAs ? /* @__PURE__ */ jsx(
|
|
708
|
+
ConnectAsSwitch,
|
|
709
|
+
{
|
|
710
|
+
integration,
|
|
711
|
+
credential: `oauth:${connection.id}`,
|
|
712
|
+
value: connection.connectAs,
|
|
713
|
+
testId: `oauth-connect-as-${connection.id}`
|
|
714
|
+
}
|
|
715
|
+
) : null,
|
|
716
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [
|
|
717
|
+
blocker ? /* @__PURE__ */ jsx(
|
|
718
|
+
Button,
|
|
719
|
+
{
|
|
720
|
+
type: "button",
|
|
721
|
+
variant: connection.connected ? "outline" : "default",
|
|
722
|
+
disabled: true,
|
|
723
|
+
"aria-describedby": `oauth-connection-missing-${connection.id}`,
|
|
724
|
+
"data-test": testId,
|
|
725
|
+
children: label
|
|
726
|
+
}
|
|
727
|
+
) : /* @__PURE__ */ jsx(
|
|
728
|
+
Button,
|
|
729
|
+
{
|
|
730
|
+
variant: connection.connected ? "outline" : "default",
|
|
731
|
+
"data-test": testId,
|
|
732
|
+
nativeButton: false,
|
|
733
|
+
render: /* @__PURE__ */ jsx(
|
|
734
|
+
"a",
|
|
735
|
+
{
|
|
736
|
+
href: oauthConnectHref(
|
|
737
|
+
integration,
|
|
738
|
+
connection.id,
|
|
739
|
+
returnPath,
|
|
740
|
+
connection.connectAs
|
|
741
|
+
)
|
|
742
|
+
}
|
|
743
|
+
),
|
|
744
|
+
children: label
|
|
467
745
|
}
|
|
468
746
|
),
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
747
|
+
disconnectable && connection.connected ? /* @__PURE__ */ jsx(
|
|
748
|
+
ConfirmDialog,
|
|
749
|
+
{
|
|
750
|
+
trigger: /* @__PURE__ */ jsx(
|
|
751
|
+
Button,
|
|
752
|
+
{
|
|
753
|
+
variant: "destructive-ghost",
|
|
754
|
+
size: "sm",
|
|
755
|
+
disabled: disconnect.isPending,
|
|
756
|
+
"data-test": `disconnect-oauth-${connection.id}`,
|
|
757
|
+
children: "Disconnect"
|
|
758
|
+
}
|
|
759
|
+
),
|
|
760
|
+
title: `Disconnect ${connection.label}?`,
|
|
761
|
+
description: "This forgets this connection's tokens on this machine. Its app keys and the other connections stay.",
|
|
762
|
+
confirmLabel: "Disconnect",
|
|
763
|
+
confirmTestId: `confirm-disconnect-oauth-${connection.id}`,
|
|
764
|
+
onConfirm: async () => {
|
|
765
|
+
try {
|
|
766
|
+
await disconnect.mutateAsync({
|
|
767
|
+
connection: connection.id,
|
|
768
|
+
as: connection.connectAs
|
|
769
|
+
});
|
|
770
|
+
await queryClient.invalidateQueries({
|
|
771
|
+
queryKey: consoleKeys.connection(integration)
|
|
772
|
+
});
|
|
773
|
+
onChanged?.();
|
|
774
|
+
return true;
|
|
775
|
+
} catch (error) {
|
|
776
|
+
console.error("[harness] disconnect failed", error);
|
|
777
|
+
return false;
|
|
778
|
+
}
|
|
779
|
+
}
|
|
780
|
+
}
|
|
781
|
+
) : null
|
|
782
|
+
] }),
|
|
783
|
+
blocker ? /* @__PURE__ */ jsx(
|
|
784
|
+
"p",
|
|
785
|
+
{
|
|
786
|
+
id: `oauth-connection-missing-${connection.id}`,
|
|
787
|
+
className: "text-muted-foreground text-xs",
|
|
788
|
+
"data-test": `oauth-connection-missing-${connection.id}`,
|
|
789
|
+
children: blocker
|
|
790
|
+
}
|
|
791
|
+
) : null,
|
|
792
|
+
failed ? /* @__PURE__ */ jsxs("p", { className: "text-destructive text-xs", role: "alert", children: [
|
|
793
|
+
"Disconnect failed: ",
|
|
794
|
+
disconnect.error.message
|
|
795
|
+
] }) : null
|
|
796
|
+
]
|
|
797
|
+
},
|
|
798
|
+
connection.id
|
|
799
|
+
);
|
|
800
|
+
})
|
|
801
|
+
}
|
|
802
|
+
)
|
|
478
803
|
] });
|
|
479
804
|
}
|
|
480
805
|
function ActivationCredentials({
|
|
481
806
|
integration,
|
|
482
807
|
credentials,
|
|
808
|
+
hints,
|
|
483
809
|
onChanged
|
|
484
810
|
}) {
|
|
485
811
|
const queryClient = useQueryClient();
|
|
486
|
-
const [
|
|
812
|
+
const [form, setForm] = useState({ drafts: {}, saved: null });
|
|
487
813
|
const save = useConsoleMutation(
|
|
488
814
|
async (c, groups) => {
|
|
489
815
|
for (const [as, values] of groups) {
|
|
@@ -494,20 +820,25 @@ function ActivationCredentials({
|
|
|
494
820
|
}
|
|
495
821
|
}
|
|
496
822
|
);
|
|
497
|
-
const
|
|
823
|
+
const typed = Object.fromEntries(
|
|
824
|
+
Object.entries(form.drafts).filter(([, value]) => value !== "")
|
|
825
|
+
);
|
|
826
|
+
const typedCount = Object.keys(typed).length;
|
|
498
827
|
const perPerson = credentials.some(
|
|
499
828
|
(credential) => credential.level === "user" && !credential.connectAs
|
|
500
829
|
);
|
|
830
|
+
const allOptional = credentials.every(
|
|
831
|
+
(credential) => credential.fields.every((field) => !field.required)
|
|
832
|
+
);
|
|
833
|
+
const single = credentials.length === 1;
|
|
501
834
|
return /* @__PURE__ */ jsxs(
|
|
502
835
|
"form",
|
|
503
836
|
{
|
|
504
|
-
className: "flex w-full
|
|
837
|
+
className: "flex w-full min-w-0 flex-col gap-4 border-t pt-6",
|
|
505
838
|
"data-test": "activation-credentials",
|
|
839
|
+
autoComplete: "off",
|
|
506
840
|
onSubmit: (event) => {
|
|
507
841
|
event.preventDefault();
|
|
508
|
-
const typed = Object.fromEntries(
|
|
509
|
-
Object.entries(drafts).filter(([, value]) => value !== "")
|
|
510
|
-
);
|
|
511
842
|
const groups = /* @__PURE__ */ new Map();
|
|
512
843
|
for (const credential of credentials) {
|
|
513
844
|
for (const field of credential.fields) {
|
|
@@ -521,7 +852,7 @@ function ActivationCredentials({
|
|
|
521
852
|
}
|
|
522
853
|
save.mutate([...groups], {
|
|
523
854
|
onSuccess: () => {
|
|
524
|
-
|
|
855
|
+
setForm({ drafts: {}, saved: typedCount });
|
|
525
856
|
onChanged?.();
|
|
526
857
|
return queryClient.invalidateQueries({
|
|
527
858
|
queryKey: consoleKeys.connection(integration)
|
|
@@ -530,24 +861,32 @@ function ActivationCredentials({
|
|
|
530
861
|
});
|
|
531
862
|
},
|
|
532
863
|
children: [
|
|
533
|
-
/* @__PURE__ */
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
864
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1", children: [
|
|
865
|
+
/* @__PURE__ */ jsx("h3", { className: "font-heading font-heading-title text-base", children: allOptional ? "Optional credentials" : "More credentials" }),
|
|
866
|
+
/* @__PURE__ */ jsxs("p", { className: "text-muted-foreground text-xs", children: [
|
|
867
|
+
"The integration's own fields, read with",
|
|
868
|
+
" ",
|
|
869
|
+
/* @__PURE__ */ jsx("code", { className: "font-mono", children: "ctx.secrets.get(name)" }),
|
|
870
|
+
".",
|
|
871
|
+
" ",
|
|
872
|
+
allOptional ? "Connecting does not need them; add the ones your code uses." : "Stored beside the keys above.",
|
|
873
|
+
" ",
|
|
874
|
+
perPerson ? "The harness keeps one local store, so a credential for you is stored beside the team\u2019s and every call can read it." : null
|
|
875
|
+
] })
|
|
876
|
+
] }),
|
|
877
|
+
credentials.map((credential) => /* @__PURE__ */ jsx(
|
|
878
|
+
CredentialGroup,
|
|
537
879
|
{
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
children: [
|
|
541
|
-
/* @__PURE__ */
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
{
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
}
|
|
549
|
-
)
|
|
550
|
-
] }),
|
|
880
|
+
title: single && credential.id === "activation" ? "" : credential.label,
|
|
881
|
+
testId: `activation-credential-${credential.id}`,
|
|
882
|
+
aside: /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-start gap-2 pt-1", children: [
|
|
883
|
+
/* @__PURE__ */ jsx(
|
|
884
|
+
LevelBadge,
|
|
885
|
+
{
|
|
886
|
+
level: credential.level,
|
|
887
|
+
testId: `activation-credential-level-${credential.id}`
|
|
888
|
+
}
|
|
889
|
+
),
|
|
551
890
|
credential.connectAs ? /* @__PURE__ */ jsx(
|
|
552
891
|
ConnectAsSwitch,
|
|
553
892
|
{
|
|
@@ -556,52 +895,53 @@ function ActivationCredentials({
|
|
|
556
895
|
value: credential.connectAs,
|
|
557
896
|
testId: `activation-connect-as-${credential.id}`
|
|
558
897
|
}
|
|
559
|
-
) : null
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
id: `activation-${field.name}`,
|
|
582
|
-
type: "password",
|
|
583
|
-
autoComplete: "off",
|
|
584
|
-
placeholder: field.set ? "Set" : "",
|
|
585
|
-
value: drafts[field.name] ?? "",
|
|
586
|
-
onChange: (event) => setDrafts({ ...drafts, [field.name]: event.target.value })
|
|
587
|
-
}
|
|
588
|
-
)
|
|
589
|
-
] }, field.name))
|
|
590
|
-
]
|
|
898
|
+
) : null
|
|
899
|
+
] }),
|
|
900
|
+
children: activationRows(credential, { hints }).map((row) => /* @__PURE__ */ jsx(
|
|
901
|
+
CredentialRow,
|
|
902
|
+
{
|
|
903
|
+
id: `activation-${row.name}`,
|
|
904
|
+
name: row.name,
|
|
905
|
+
label: row.label,
|
|
906
|
+
...row.description ? { description: row.description } : {},
|
|
907
|
+
requirement: row.required ? "Required" : "Optional",
|
|
908
|
+
secret: true,
|
|
909
|
+
set: row.set,
|
|
910
|
+
value: form.drafts[row.name] ?? "",
|
|
911
|
+
disabled: save.isPending,
|
|
912
|
+
testId: `activation-field-${row.name}`,
|
|
913
|
+
onChange: (value) => setForm({
|
|
914
|
+
drafts: { ...form.drafts, [row.name]: value },
|
|
915
|
+
saved: null
|
|
916
|
+
})
|
|
917
|
+
},
|
|
918
|
+
row.name
|
|
919
|
+
))
|
|
591
920
|
},
|
|
592
921
|
credential.id
|
|
593
922
|
)),
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
923
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-3", children: [
|
|
924
|
+
/* @__PURE__ */ jsx(
|
|
925
|
+
Button,
|
|
926
|
+
{
|
|
927
|
+
type: "submit",
|
|
928
|
+
variant: "outline",
|
|
929
|
+
disabled: typedCount === 0 || save.isPending,
|
|
930
|
+
"data-test": "save-activation-credentials",
|
|
931
|
+
children: save.isPending ? "Saving\u2026" : "Save credentials"
|
|
932
|
+
}
|
|
933
|
+
),
|
|
934
|
+
save.isError ? /* @__PURE__ */ jsxs("span", { className: "text-destructive text-sm", role: "alert", children: [
|
|
935
|
+
"Not saved: ",
|
|
936
|
+
save.error.message
|
|
937
|
+
] }) : form.saved !== null ? /* @__PURE__ */ jsxs("span", { className: "text-muted-foreground text-sm", role: "status", children: [
|
|
938
|
+
"Saved ",
|
|
939
|
+
form.saved,
|
|
940
|
+
" ",
|
|
941
|
+
form.saved === 1 ? "credential" : "credentials",
|
|
942
|
+
"."
|
|
943
|
+
] }) : /* @__PURE__ */ jsx("span", { className: "text-muted-foreground text-xs", children: typedCount === 0 ? "Type a value to save it. Blank fields keep what is saved." : `${typedCount} to save.` })
|
|
944
|
+
] })
|
|
605
945
|
]
|
|
606
946
|
}
|
|
607
947
|
);
|
|
@@ -642,11 +982,11 @@ function ActivationConnect({
|
|
|
642
982
|
return /* @__PURE__ */ jsxs(
|
|
643
983
|
"div",
|
|
644
984
|
{
|
|
645
|
-
className: "flex w-full max-w-
|
|
985
|
+
className: "flex w-full max-w-3xl min-w-0 flex-col gap-3 [&_*]:min-w-0 [&_.grid]:grid-cols-[minmax(0,1fr)] [&_fieldset]:min-w-0 [&_form]:min-w-0 [&_input]:max-w-full [&_label]:[overflow-wrap:anywhere] [&_p]:[overflow-wrap:anywhere] [&_textarea]:max-w-full",
|
|
646
986
|
"data-test": "connect-activation",
|
|
647
987
|
children: [
|
|
648
988
|
/* @__PURE__ */ jsx("p", { className: "text-muted-foreground text-xs", children: "This is the integration's own connect form. What you enter is stored on this machine as its local credentials, and live operations read it from there." }),
|
|
649
|
-
/* @__PURE__ */ jsx(IntegrationActivationProvider, { actions, children: /* @__PURE__ */ jsx(TeamAccountWorkspaceContextProvider, { children: /* @__PURE__ */ jsx(Suspense, { fallback:
|
|
989
|
+
/* @__PURE__ */ jsx(IntegrationActivationProvider, { actions, children: /* @__PURE__ */ jsx(TeamAccountWorkspaceContextProvider, { children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx(Skeleton, { className: "h-40 w-full rounded-lg" }), children: /* @__PURE__ */ jsx(SettingsLabels, { enabled: saveLabel, children: /* @__PURE__ */ jsx(
|
|
650
990
|
Form,
|
|
651
991
|
{
|
|
652
992
|
accountId: HARNESS_ACCOUNT_ID,
|