@kelpie/ui 0.21.0 → 0.23.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/dist/api/resource.d.ts +12 -0
- package/dist/api/resource.d.ts.map +1 -1
- package/dist/api/resource.js +11 -0
- package/dist/api/resource.js.map +1 -1
- package/dist/api/resources/decisions.d.ts +31 -0
- package/dist/api/resources/decisions.d.ts.map +1 -1
- package/dist/api/resources/decisions.js +51 -1
- package/dist/api/resources/decisions.js.map +1 -1
- package/dist/api/resources/forms.d.ts +21 -7
- package/dist/api/resources/forms.d.ts.map +1 -1
- package/dist/api/resources/forms.js +39 -1
- package/dist/api/resources/forms.js.map +1 -1
- package/dist/api/resources/oauth.d.ts +2 -0
- package/dist/api/resources/oauth.d.ts.map +1 -1
- package/dist/api/resources/oauth.js +13 -1
- package/dist/api/resources/oauth.js.map +1 -1
- package/dist/api/resources/personIntake.d.ts +15 -3
- package/dist/api/resources/personIntake.d.ts.map +1 -1
- package/dist/api/resources/personIntake.js +38 -9
- package/dist/api/resources/personIntake.js.map +1 -1
- package/dist/api/resources/session.d.ts.map +1 -1
- package/dist/api/resources/session.js +4 -0
- package/dist/api/resources/session.js.map +1 -1
- package/dist/api/resources/tags.d.ts +20 -0
- package/dist/api/resources/tags.d.ts.map +1 -0
- package/dist/api/resources/tags.js +52 -0
- package/dist/api/resources/tags.js.map +1 -0
- package/dist/app/KelpieApp.d.ts.map +1 -1
- package/dist/app/KelpieApp.js +2 -1
- package/dist/app/KelpieApp.js.map +1 -1
- package/dist/components/AddRecordPanel.d.ts +35 -0
- package/dist/components/AddRecordPanel.d.ts.map +1 -0
- package/dist/components/AddRecordPanel.js +35 -0
- package/dist/components/AddRecordPanel.js.map +1 -0
- package/dist/components/AiDrawer.d.ts.map +1 -1
- package/dist/components/AiDrawer.js +29 -6
- package/dist/components/AiDrawer.js.map +1 -1
- package/dist/components/ApiKeysPanel.d.ts.map +1 -1
- package/dist/components/ApiKeysPanel.js +101 -44
- package/dist/components/ApiKeysPanel.js.map +1 -1
- package/dist/components/Chip.d.ts +5 -1
- package/dist/components/Chip.d.ts.map +1 -1
- package/dist/components/Chip.js +8 -2
- package/dist/components/Chip.js.map +1 -1
- package/dist/components/CustomFieldsPanel.d.ts.map +1 -1
- package/dist/components/CustomFieldsPanel.js +5 -2
- package/dist/components/CustomFieldsPanel.js.map +1 -1
- package/dist/components/DecisionProvenance.d.ts +27 -0
- package/dist/components/DecisionProvenance.d.ts.map +1 -0
- package/dist/components/DecisionProvenance.js +53 -0
- package/dist/components/DecisionProvenance.js.map +1 -0
- package/dist/components/DecisionsPanel.d.ts +3 -0
- package/dist/components/DecisionsPanel.d.ts.map +1 -1
- package/dist/components/DecisionsPanel.js +9 -5
- package/dist/components/DecisionsPanel.js.map +1 -1
- package/dist/components/MarkdownView.d.ts.map +1 -1
- package/dist/components/MarkdownView.js +18 -2
- package/dist/components/MarkdownView.js.map +1 -1
- package/dist/components/NotesPanel.d.ts.map +1 -1
- package/dist/components/NotesPanel.js +7 -3
- package/dist/components/NotesPanel.js.map +1 -1
- package/dist/components/OriginLabel.d.ts +5 -0
- package/dist/components/OriginLabel.d.ts.map +1 -0
- package/dist/components/OriginLabel.js +22 -0
- package/dist/components/OriginLabel.js.map +1 -0
- package/dist/components/Shell.d.ts.map +1 -1
- package/dist/components/Shell.js +17 -5
- package/dist/components/Shell.js.map +1 -1
- package/dist/components/TagInput.d.ts +29 -0
- package/dist/components/TagInput.d.ts.map +1 -0
- package/dist/components/TagInput.js +139 -0
- package/dist/components/TagInput.js.map +1 -0
- package/dist/components/aiDrawerState.d.ts +12 -0
- package/dist/components/aiDrawerState.d.ts.map +1 -1
- package/dist/components/aiDrawerState.js.map +1 -1
- package/dist/components/personIntakeTask.d.ts +15 -0
- package/dist/components/personIntakeTask.d.ts.map +1 -1
- package/dist/components/personIntakeTask.js +42 -0
- package/dist/components/personIntakeTask.js.map +1 -1
- package/dist/lib/personIntakeRunStorage.d.ts +15 -0
- package/dist/lib/personIntakeRunStorage.d.ts.map +1 -0
- package/dist/lib/personIntakeRunStorage.js +88 -0
- package/dist/lib/personIntakeRunStorage.js.map +1 -0
- package/dist/modules/PersonIntakeWizard.d.ts +1 -1
- package/dist/modules/PersonIntakeWizard.d.ts.map +1 -1
- package/dist/modules/PersonIntakeWizard.js +243 -29
- package/dist/modules/PersonIntakeWizard.js.map +1 -1
- package/dist/modules/ai.d.ts +1 -1
- package/dist/modules/ai.js +1 -1
- package/dist/pages/CompaniesPage.d.ts.map +1 -1
- package/dist/pages/CompaniesPage.js +13 -6
- package/dist/pages/CompaniesPage.js.map +1 -1
- package/dist/pages/CompanyDetail.d.ts.map +1 -1
- package/dist/pages/CompanyDetail.js +4 -3
- package/dist/pages/CompanyDetail.js.map +1 -1
- package/dist/pages/DealDetail.d.ts.map +1 -1
- package/dist/pages/DealDetail.js +4 -3
- package/dist/pages/DealDetail.js.map +1 -1
- package/dist/pages/DealsPage.d.ts.map +1 -1
- package/dist/pages/DealsPage.js +16 -8
- package/dist/pages/DealsPage.js.map +1 -1
- package/dist/pages/DecisionsPage.d.ts.map +1 -1
- package/dist/pages/DecisionsPage.js +7 -3
- package/dist/pages/DecisionsPage.js.map +1 -1
- package/dist/pages/EnquiriesPage.d.ts.map +1 -1
- package/dist/pages/EnquiriesPage.js +14 -6
- package/dist/pages/EnquiriesPage.js.map +1 -1
- package/dist/pages/EnquiryDetail.js +4 -4
- package/dist/pages/EnquiryDetail.js.map +1 -1
- package/dist/pages/EventDetail.js +4 -4
- package/dist/pages/EventDetail.js.map +1 -1
- package/dist/pages/FundraisingPage.d.ts.map +1 -1
- package/dist/pages/FundraisingPage.js +16 -11
- package/dist/pages/FundraisingPage.js.map +1 -1
- package/dist/pages/OpportunitiesPage.d.ts.map +1 -1
- package/dist/pages/OpportunitiesPage.js +14 -6
- package/dist/pages/OpportunitiesPage.js.map +1 -1
- package/dist/pages/OpportunityDetail.js +4 -4
- package/dist/pages/OpportunityDetail.js.map +1 -1
- package/dist/pages/PartnershipDetail.js +4 -4
- package/dist/pages/PartnershipDetail.js.map +1 -1
- package/dist/pages/PartnershipsPage.d.ts.map +1 -1
- package/dist/pages/PartnershipsPage.js +16 -11
- package/dist/pages/PartnershipsPage.js.map +1 -1
- package/dist/pages/PeoplePage.d.ts.map +1 -1
- package/dist/pages/PeoplePage.js +13 -8
- package/dist/pages/PeoplePage.js.map +1 -1
- package/dist/pages/PersonDetail.js +7 -7
- package/dist/pages/PersonDetail.js.map +1 -1
- package/dist/pages/RaiseDetail.js +4 -4
- package/dist/pages/RaiseDetail.js.map +1 -1
- package/dist/pages/SearchPage.d.ts.map +1 -1
- package/dist/pages/SearchPage.js +2 -1
- package/dist/pages/SearchPage.js.map +1 -1
- package/dist/pages/account/ConnectedAppsPage.d.ts +0 -5
- package/dist/pages/account/ConnectedAppsPage.d.ts.map +1 -1
- package/dist/pages/account/ConnectedAppsPage.js +38 -6
- package/dist/pages/account/ConnectedAppsPage.js.map +1 -1
- package/dist/pages/admin/AgentsPanel.d.ts +10 -0
- package/dist/pages/admin/AgentsPanel.d.ts.map +1 -0
- package/dist/pages/admin/AgentsPanel.js +81 -0
- package/dist/pages/admin/AgentsPanel.js.map +1 -0
- package/dist/pages/admin/AiAdminPage.d.ts.map +1 -1
- package/dist/pages/admin/AiAdminPage.js +9 -6
- package/dist/pages/admin/AiAdminPage.js.map +1 -1
- package/dist/pages/admin/AiPage.js +1 -1
- package/dist/pages/admin/TeamPage.d.ts.map +1 -1
- package/dist/pages/admin/TeamPage.js +16 -3
- package/dist/pages/admin/TeamPage.js.map +1 -1
- package/dist/pages/ai/AiAccessPage.d.ts +11 -0
- package/dist/pages/ai/AiAccessPage.d.ts.map +1 -0
- package/dist/pages/ai/AiAccessPage.js +16 -0
- package/dist/pages/ai/AiAccessPage.js.map +1 -0
- package/dist/pages/ai/McpPanel.d.ts +7 -0
- package/dist/pages/ai/McpPanel.d.ts.map +1 -0
- package/dist/pages/ai/McpPanel.js +86 -0
- package/dist/pages/ai/McpPanel.js.map +1 -0
- package/dist/pages/auth/nextPath.d.ts +6 -0
- package/dist/pages/auth/nextPath.d.ts.map +1 -1
- package/dist/pages/auth/nextPath.js +16 -1
- package/dist/pages/auth/nextPath.js.map +1 -1
- package/dist/pages/dashboard/sections.d.ts.map +1 -1
- package/dist/pages/dashboard/sections.js +4 -2
- package/dist/pages/dashboard/sections.js.map +1 -1
- package/dist/pages/forms/EmbedPanel.js +1 -1
- package/dist/pages/forms/EmbedPanel.js.map +1 -1
- package/dist/pages/forms/FieldsEditor.d.ts.map +1 -1
- package/dist/pages/forms/FieldsEditor.js +6 -7
- package/dist/pages/forms/FieldsEditor.js.map +1 -1
- package/dist/pages/forms/FormActions.d.ts.map +1 -1
- package/dist/pages/forms/FormActions.js +4 -11
- package/dist/pages/forms/FormActions.js.map +1 -1
- package/dist/pages/forms/FormEmails.d.ts.map +1 -1
- package/dist/pages/forms/FormEmails.js +6 -1
- package/dist/pages/forms/FormEmails.js.map +1 -1
- package/dist/pages/forms/FormSettings.d.ts.map +1 -1
- package/dist/pages/forms/FormSettings.js +6 -2
- package/dist/pages/forms/FormSettings.js.map +1 -1
- package/dist/pages/forms/SubmissionDetail.d.ts.map +1 -1
- package/dist/pages/forms/SubmissionDetail.js +26 -6
- package/dist/pages/forms/SubmissionDetail.js.map +1 -1
- package/dist/pages/forms/SubmissionsTable.d.ts.map +1 -1
- package/dist/pages/forms/SubmissionsTable.js +81 -6
- package/dist/pages/forms/SubmissionsTable.js.map +1 -1
- package/dist/pages/forms/fieldList.d.ts +13 -5
- package/dist/pages/forms/fieldList.d.ts.map +1 -1
- package/dist/pages/forms/fieldList.js +12 -4
- package/dist/pages/forms/fieldList.js.map +1 -1
- package/dist/pages/oauth/ConsentPage.d.ts.map +1 -1
- package/dist/pages/oauth/ConsentPage.js +132 -15
- package/dist/pages/oauth/ConsentPage.js.map +1 -1
- package/dist/registry/contributions.d.ts +1 -1
- package/package.json +3 -3
- package/src/api/resource.ts +16 -0
- package/src/api/resources/decisions.ts +81 -1
- package/src/api/resources/forms.ts +68 -7
- package/src/api/resources/oauth.ts +15 -1
- package/src/api/resources/personIntake.ts +54 -13
- package/src/api/resources/session.ts +4 -0
- package/src/api/resources/tags.ts +71 -0
- package/src/app/KelpieApp.tsx +4 -2
- package/src/components/AddRecordPanel.tsx +143 -0
- package/src/components/AiDrawer.tsx +34 -7
- package/src/components/ApiKeysPanel.tsx +193 -75
- package/src/components/Chip.tsx +32 -1
- package/src/components/CustomFieldsPanel.tsx +15 -5
- package/src/components/DecisionProvenance.tsx +95 -0
- package/src/components/DecisionsPanel.tsx +30 -2
- package/src/components/MarkdownView.tsx +45 -11
- package/src/components/NotesPanel.tsx +15 -6
- package/src/components/OriginLabel.tsx +26 -0
- package/src/components/Shell.tsx +30 -6
- package/src/components/TagInput.tsx +285 -0
- package/src/components/aiDrawerState.ts +12 -0
- package/src/components/personIntakeTask.tsx +48 -0
- package/src/lib/personIntakeRunStorage.ts +97 -0
- package/src/modules/PersonIntakeWizard.tsx +391 -30
- package/src/modules/ai.tsx +1 -1
- package/src/pages/CompaniesPage.tsx +22 -5
- package/src/pages/CompanyDetail.tsx +6 -17
- package/src/pages/DealDetail.tsx +6 -17
- package/src/pages/DealsPage.tsx +25 -8
- package/src/pages/DecisionsPage.tsx +28 -1
- package/src/pages/EnquiriesPage.tsx +23 -5
- package/src/pages/EnquiryDetail.tsx +6 -18
- package/src/pages/EventDetail.tsx +6 -18
- package/src/pages/FundraisingPage.tsx +25 -11
- package/src/pages/OpportunitiesPage.tsx +23 -5
- package/src/pages/OpportunityDetail.tsx +6 -18
- package/src/pages/PartnershipDetail.tsx +6 -18
- package/src/pages/PartnershipsPage.tsx +25 -11
- package/src/pages/PeoplePage.tsx +22 -7
- package/src/pages/PersonDetail.tsx +11 -21
- package/src/pages/RaiseDetail.tsx +6 -18
- package/src/pages/SearchPage.tsx +3 -0
- package/src/pages/account/ConnectedAppsPage.tsx +97 -14
- package/src/pages/admin/{McpPanel.tsx → AgentsPanel.tsx} +11 -168
- package/src/pages/admin/AiAdminPage.tsx +16 -11
- package/src/pages/admin/AiPage.tsx +1 -1
- package/src/pages/admin/TeamPage.tsx +33 -0
- package/src/pages/ai/AiAccessPage.tsx +23 -0
- package/src/pages/ai/McpPanel.tsx +261 -0
- package/src/pages/auth/nextPath.ts +18 -1
- package/src/pages/dashboard/sections.tsx +4 -0
- package/src/pages/forms/EmbedPanel.tsx +3 -2
- package/src/pages/forms/FieldsEditor.tsx +6 -7
- package/src/pages/forms/FormActions.tsx +18 -20
- package/src/pages/forms/FormEmails.tsx +11 -2
- package/src/pages/forms/FormSettings.tsx +5 -0
- package/src/pages/forms/SubmissionDetail.tsx +47 -9
- package/src/pages/forms/SubmissionsTable.tsx +180 -5
- package/src/pages/forms/fieldList.ts +21 -7
- package/src/pages/oauth/ConsentPage.tsx +271 -33
- package/src/registry/contributions.ts +1 -1
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
API_KEY_SCOPE_LABELS,
|
|
3
|
+
apiKeyScopeRisk,
|
|
4
|
+
expandApiKeyScopes,
|
|
5
|
+
isApiKeyPresetScope,
|
|
6
|
+
isApiKeyRiskScope,
|
|
7
|
+
} from '@kelpie/schemas'
|
|
2
8
|
import type { ApiKeyScope, OAuthRequest } from '@kelpie/schemas'
|
|
3
9
|
import { useState } from 'react'
|
|
4
10
|
import { Link, Navigate, useParams } from 'react-router'
|
|
@@ -22,7 +28,7 @@ import { AuthLayout } from '../auth/AuthLayout.tsx'
|
|
|
22
28
|
*/
|
|
23
29
|
export function ConsentPage(): React.JSX.Element {
|
|
24
30
|
const { requestId = '' } = useParams()
|
|
25
|
-
const { isLoading: sessionLoading, isSignedOut, error: sessionError } = useSession()
|
|
31
|
+
const { session, isLoading: sessionLoading, isSignedOut, error: sessionError } = useSession()
|
|
26
32
|
|
|
27
33
|
if (isSignedOut) {
|
|
28
34
|
return <Navigate to={`/login?next=${encodeURIComponent(`/consent/${requestId}`)}`} replace />
|
|
@@ -42,10 +48,16 @@ export function ConsentPage(): React.JSX.Element {
|
|
|
42
48
|
return <LoadingPanel />
|
|
43
49
|
}
|
|
44
50
|
|
|
45
|
-
return <ConsentForRequest requestId={requestId} />
|
|
51
|
+
return <ConsentForRequest requestId={requestId} activeWorkspaceId={session?.workspaceId ?? null} />
|
|
46
52
|
}
|
|
47
53
|
|
|
48
|
-
|
|
54
|
+
interface ConsentForRequestProps {
|
|
55
|
+
readonly requestId: string
|
|
56
|
+
/** The workspace the session is in, which is the one ticked at the start. */
|
|
57
|
+
readonly activeWorkspaceId: string | null
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function ConsentForRequest({ requestId, activeWorkspaceId }: ConsentForRequestProps): React.JSX.Element {
|
|
49
61
|
const { request, isLoading, error } = useOAuthRequest(requestId)
|
|
50
62
|
|
|
51
63
|
if (error !== null) {
|
|
@@ -65,14 +77,140 @@ function ConsentForRequest({ requestId }: { readonly requestId: string }): React
|
|
|
65
77
|
return <LoadingPanel label="Loading the request…" />
|
|
66
78
|
}
|
|
67
79
|
|
|
68
|
-
return <ConsentForm request={request} />
|
|
80
|
+
return <ConsentForm request={request} activeWorkspaceId={activeWorkspaceId} />
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
interface ConsentFormProps {
|
|
84
|
+
readonly request: OAuthRequest
|
|
85
|
+
readonly activeWorkspaceId: string | null
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* The workspaces ticked when the page opens.
|
|
90
|
+
*
|
|
91
|
+
* When the app is connected already, they are the workspaces it is connected
|
|
92
|
+
* to, whichever workspace the session is in. The app is then asking for more
|
|
93
|
+
* access, and an approval that named another workspace would make a new
|
|
94
|
+
* connection there and end the one that asked.
|
|
95
|
+
*
|
|
96
|
+
* For an app that is new to this person: the workspace the session is in, or
|
|
97
|
+
* the first when the session has none the person can connect. One, never all:
|
|
98
|
+
* a person who only clicks Allow gives the app the workspace they are working in.
|
|
99
|
+
*/
|
|
100
|
+
function initialWorkspaceIds(request: OAuthRequest, activeWorkspaceId: string | null): readonly string[] {
|
|
101
|
+
const connected = request.workspaces.filter((workspace) => workspace.connected)
|
|
102
|
+
|
|
103
|
+
if (connected.length > 0) {
|
|
104
|
+
return connected.map((workspace) => workspace.id)
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const active = request.workspaces.find((workspace) => workspace.id === activeWorkspaceId)
|
|
108
|
+
const first = active ?? request.workspaces[0]
|
|
109
|
+
|
|
110
|
+
return first === undefined ? [] : [first.id]
|
|
69
111
|
}
|
|
70
112
|
|
|
71
|
-
|
|
113
|
+
/**
|
|
114
|
+
* The scopes the page offers: each preset the app asked for, then each
|
|
115
|
+
* per-resource scope that none of those presets includes.
|
|
116
|
+
*
|
|
117
|
+
* A per-resource scope inside a requested preset is not listed. The preset
|
|
118
|
+
* grants it, so a separate tick box for it would change nothing. Only the
|
|
119
|
+
* listed scopes are approved: clearing a preset also drops what it included.
|
|
120
|
+
*
|
|
121
|
+
* A scope that gives a sensitive power is not listed here, also when the app
|
|
122
|
+
* asked for it. The server names those in `extraScopes`; they are in their
|
|
123
|
+
* own section and start clear.
|
|
124
|
+
*/
|
|
125
|
+
function offeredScopes(request: OAuthRequest): readonly ApiKeyScope[] {
|
|
126
|
+
const requested = request.scopes.filter((scope) => !request.extraScopes.includes(scope))
|
|
127
|
+
const presets = requested.filter(isApiKeyPresetScope)
|
|
128
|
+
const included: ReadonlySet<ApiKeyScope> = expandApiKeyScopes(presets)
|
|
129
|
+
|
|
130
|
+
return [...presets, ...requested.filter((scope) => !isApiKeyPresetScope(scope) && !included.has(scope))]
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function ConsentForm({ request, activeWorkspaceId }: ConsentFormProps): React.JSX.Element {
|
|
72
134
|
const approve = useApproveOAuthRequest()
|
|
73
135
|
const deny = useDenyOAuthRequest()
|
|
74
|
-
const [
|
|
75
|
-
|
|
136
|
+
const [workspaceIds, setWorkspaceIds] = useState<readonly string[]>(() =>
|
|
137
|
+
initialWorkspaceIds(request, activeWorkspaceId),
|
|
138
|
+
)
|
|
139
|
+
const [onlyWorkspace] = request.workspaces
|
|
140
|
+
const offered = offeredScopes(request)
|
|
141
|
+
const [scopes, setScopes] = useState<readonly ApiKeyScope[]>(offered)
|
|
142
|
+
// Only what the person changed by hand. An extra they did not touch is
|
|
143
|
+
// ticked when the app has it already in every selected workspace, and
|
|
144
|
+
// clear otherwise, so it follows the workspaces as they are ticked.
|
|
145
|
+
const [extraChoices, setExtraChoices] = useState<ReadonlyMap<ApiKeyScope, boolean>>(new Map())
|
|
146
|
+
const selectedWorkspaces = request.workspaces.filter((workspace) => workspaceIds.includes(workspace.id))
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* True when an approval with this extra ticked gives nothing new: each
|
|
150
|
+
* selected workspace has it from an earlier approval. The server says what
|
|
151
|
+
* each workspace holds. One workspace that lacks it makes this false, so a
|
|
152
|
+
* tick that nobody made never gives a new power anywhere.
|
|
153
|
+
*/
|
|
154
|
+
function alreadyAllowed(scope: ApiKeyScope): boolean {
|
|
155
|
+
return (
|
|
156
|
+
selectedWorkspaces.length > 0 && selectedWorkspaces.every((workspace) => workspace.heldScopes.includes(scope))
|
|
157
|
+
)
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
function extraTicked(scope: ApiKeyScope): boolean {
|
|
161
|
+
return extraChoices.get(scope) ?? alreadyAllowed(scope)
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* The selected workspaces that have this extra now, when some have it and
|
|
166
|
+
* some do not. The row then starts clear, and an approval takes the extra
|
|
167
|
+
* away where the app had it. The row has to say so.
|
|
168
|
+
*/
|
|
169
|
+
function allowedOnlyIn(scope: ApiKeyScope): readonly string[] {
|
|
170
|
+
const holders = selectedWorkspaces.filter((workspace) => workspace.heldScopes.includes(scope))
|
|
171
|
+
|
|
172
|
+
return holders.length === selectedWorkspaces.length ? [] : holders.map((workspace) => workspace.name)
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* For an app on this computer: every workspace where it has this extra
|
|
177
|
+
* now, ticked on this page or not. Read from the display fields and shown
|
|
178
|
+
* as words. No tick on this page is ever taken from them.
|
|
179
|
+
*/
|
|
180
|
+
function shownAsAllowedIn(scope: ApiKeyScope): readonly string[] {
|
|
181
|
+
if (!request.localClient) {
|
|
182
|
+
return []
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
return request.workspaces
|
|
186
|
+
.filter((workspace) => workspace.displayHeldScopes.includes(scope))
|
|
187
|
+
.map((workspace) => workspace.name)
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
function connectedNow(workspace: OAuthRequest['workspaces'][number]): boolean {
|
|
191
|
+
return request.localClient && workspace.displayConnected
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* The ticked extra that gives everything this one gives and more, if there
|
|
196
|
+
* is one: "Delete objects" for `people:delete`, "Write all" for "Handbook
|
|
197
|
+
* (write)". The narrower row is then shown ticked and locked. Clear, it
|
|
198
|
+
* would say the app does not get a power that the wider row gives it.
|
|
199
|
+
*/
|
|
200
|
+
function widerTickedExtra(scope: ApiKeyScope): ApiKeyScope | undefined {
|
|
201
|
+
const needed = [...expandApiKeyScopes([scope])]
|
|
202
|
+
|
|
203
|
+
return request.extraScopes.find((other) => {
|
|
204
|
+
const given = expandApiKeyScopes([other])
|
|
205
|
+
|
|
206
|
+
return other !== scope && extraTicked(other) && given.size > needed.length && needed.every((entry) => given.has(entry))
|
|
207
|
+
})
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
// Only the rows the person ticked, or left ticked. A row that is shown
|
|
211
|
+
// ticked because a wider one covers it is not sent: the wider one gives it.
|
|
212
|
+
const extras = request.extraScopes.filter(extraTicked)
|
|
213
|
+
const nothingTicked = scopes.length + extras.length === 0
|
|
76
214
|
const [leaving, setLeaving] = useState(false)
|
|
77
215
|
const busy = approve.isPending || deny.isPending || leaving
|
|
78
216
|
|
|
@@ -87,11 +225,19 @@ function ConsentForm({ request }: { readonly request: OAuthRequest }): React.JSX
|
|
|
87
225
|
setScopes((current) => (current.includes(scope) ? current.filter((entry) => entry !== scope) : [...current, scope]))
|
|
88
226
|
}
|
|
89
227
|
|
|
228
|
+
function toggleExtra(scope: ApiKeyScope): void {
|
|
229
|
+
setExtraChoices((current) => new Map(current).set(scope, !extraTicked(scope)))
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
function toggleWorkspace(id: string): void {
|
|
233
|
+
setWorkspaceIds((current) => (current.includes(id) ? current.filter((entry) => entry !== id) : [...current, id]))
|
|
234
|
+
}
|
|
235
|
+
|
|
90
236
|
if (request.workspaces.length === 0) {
|
|
91
237
|
return (
|
|
92
238
|
<AuthLayout
|
|
93
239
|
title={`Connect ${request.clientName}`}
|
|
94
|
-
description="A connection is made to
|
|
240
|
+
description="A connection is made to a workspace, and this account is not a member of any."
|
|
95
241
|
>
|
|
96
242
|
<p className="mt-4 text-[13px] text-ink-muted">
|
|
97
243
|
<Link to="/onboarding/workspace" className="text-accent hover:underline">
|
|
@@ -137,30 +283,59 @@ function ConsentForm({ request }: { readonly request: OAuthRequest }): React.JSX
|
|
|
137
283
|
)}
|
|
138
284
|
</div>
|
|
139
285
|
|
|
140
|
-
|
|
141
|
-
<
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
286
|
+
{request.localClient && (
|
|
287
|
+
<p className="rounded-md border border-border bg-surface px-3 py-2.5 text-[12px] text-ink-muted">
|
|
288
|
+
This app runs on your computer, so Kelpie does not use what you allowed it before. Tick each
|
|
289
|
+
workspace and each extra permission that it needs. What it has now is marked. After you select
|
|
290
|
+
Allow, the app uses only the workspaces that you tick here. Tick a connected workspace again to
|
|
291
|
+
keep it.
|
|
292
|
+
</p>
|
|
293
|
+
)}
|
|
294
|
+
|
|
295
|
+
{request.workspaces.length === 1 && onlyWorkspace !== undefined ? (
|
|
296
|
+
<div>
|
|
297
|
+
<p className="mb-1.5 text-[12px] font-medium text-ink">Workspace</p>
|
|
298
|
+
<p className="text-[13px] text-ink">
|
|
299
|
+
{onlyWorkspace.name}{' '}
|
|
300
|
+
<span className="text-ink-muted capitalize">({onlyWorkspace.role})</span>
|
|
301
|
+
{connectedNow(onlyWorkspace) && <span className="text-[11px] text-ink-muted"> · connected now</span>}
|
|
302
|
+
</p>
|
|
303
|
+
<p className="mt-1 text-[11px] text-ink-faint">The app sees this workspace only.</p>
|
|
304
|
+
</div>
|
|
305
|
+
) : (
|
|
306
|
+
<fieldset>
|
|
307
|
+
<legend className="mb-1.5 text-[12px] font-medium text-ink">Workspaces</legend>
|
|
308
|
+
<div className="space-y-1.5">
|
|
309
|
+
{request.workspaces.map((workspace) => (
|
|
310
|
+
<label key={workspace.id} className="flex items-center gap-2 text-[13px] text-ink">
|
|
311
|
+
<input
|
|
312
|
+
type="checkbox"
|
|
313
|
+
checked={workspaceIds.includes(workspace.id)}
|
|
314
|
+
onChange={() => {
|
|
315
|
+
toggleWorkspace(workspace.id)
|
|
316
|
+
}}
|
|
317
|
+
/>
|
|
318
|
+
<span className="min-w-0 flex-1 truncate">
|
|
319
|
+
{workspace.name}
|
|
320
|
+
{connectedNow(workspace) && <span className="text-[11px] text-ink-muted"> · connected now</span>}
|
|
321
|
+
</span>
|
|
322
|
+
<span className="shrink-0 text-[11px] text-ink-muted capitalize">{workspace.role}</span>
|
|
323
|
+
</label>
|
|
324
|
+
))}
|
|
325
|
+
</div>
|
|
326
|
+
<p className="mt-1.5 text-[11px] text-ink-faint">
|
|
327
|
+
{workspaceIds.length > 1
|
|
328
|
+
? 'The app can read and write in each of these workspaces.'
|
|
329
|
+
: 'The app sees only the workspaces you select.'}
|
|
330
|
+
</p>
|
|
331
|
+
</fieldset>
|
|
332
|
+
)}
|
|
159
333
|
|
|
160
|
-
|
|
334
|
+
{/* A request for sensitive scopes only has nothing to list here. */}
|
|
335
|
+
<fieldset hidden={offered.length === 0}>
|
|
161
336
|
<legend className="mb-1.5 text-[12px] font-medium text-ink">Access</legend>
|
|
162
337
|
<div className="space-y-1.5">
|
|
163
|
-
{
|
|
338
|
+
{offered.map((scope) => (
|
|
164
339
|
<label key={scope} className="flex items-center gap-2 text-[13px] text-ink">
|
|
165
340
|
<input
|
|
166
341
|
type="checkbox"
|
|
@@ -174,10 +349,73 @@ function ConsentForm({ request }: { readonly request: OAuthRequest }): React.JSX
|
|
|
174
349
|
))}
|
|
175
350
|
</div>
|
|
176
351
|
<p className="mt-1.5 text-[11px] text-ink-faint">
|
|
177
|
-
The app can do no more than your own role allows. Clear an item to give less access.
|
|
352
|
+
The app can do no more than your own role allows. Clear an item to give less access. A wider item,
|
|
353
|
+
such as Read all, includes the narrower ones.
|
|
178
354
|
</p>
|
|
179
355
|
</fieldset>
|
|
180
356
|
|
|
357
|
+
{request.extraScopes.length > 0 && (
|
|
358
|
+
<fieldset className="rounded-md border border-border px-3 py-2.5">
|
|
359
|
+
<legend className="px-1 text-[12px] font-medium text-ink">Extra permissions</legend>
|
|
360
|
+
<p className="mb-2 text-[11px] text-ink-muted">
|
|
361
|
+
Not part of the access above. Tick one only if you want this app to have it.
|
|
362
|
+
</p>
|
|
363
|
+
<div className="space-y-2">
|
|
364
|
+
{request.extraScopes.map((scope) => {
|
|
365
|
+
const wider = widerTickedExtra(scope)
|
|
366
|
+
const partly = allowedOnlyIn(scope)
|
|
367
|
+
const shown = shownAsAllowedIn(scope)
|
|
368
|
+
|
|
369
|
+
return (
|
|
370
|
+
<label key={scope} className="flex items-start gap-2 text-[13px] text-ink">
|
|
371
|
+
<input
|
|
372
|
+
type="checkbox"
|
|
373
|
+
className="mt-0.5"
|
|
374
|
+
checked={wider !== undefined || extraTicked(scope)}
|
|
375
|
+
disabled={wider !== undefined}
|
|
376
|
+
onChange={() => {
|
|
377
|
+
toggleExtra(scope)
|
|
378
|
+
}}
|
|
379
|
+
/>
|
|
380
|
+
<span>
|
|
381
|
+
{API_KEY_SCOPE_LABELS[scope]}
|
|
382
|
+
{request.scopes.includes(scope) && (
|
|
383
|
+
<span className="text-[11px] text-ink-muted"> · this app asks for it</span>
|
|
384
|
+
)}
|
|
385
|
+
{alreadyAllowed(scope) && (
|
|
386
|
+
<span className="text-[11px] text-ink-muted"> · already allowed</span>
|
|
387
|
+
)}
|
|
388
|
+
{wider !== undefined && (
|
|
389
|
+
<span className="text-[11px] text-ink-muted"> · included in {API_KEY_SCOPE_LABELS[wider]}</span>
|
|
390
|
+
)}
|
|
391
|
+
{isApiKeyRiskScope(scope) && (
|
|
392
|
+
<span className="block text-[11px] text-ink-muted">{apiKeyScopeRisk(scope)}</span>
|
|
393
|
+
)}
|
|
394
|
+
{shown.length > 0 && (
|
|
395
|
+
<span className="block text-[11px] text-warning">
|
|
396
|
+
Allowed now in {shown.join(', ')}. Tick it to allow it in the workspaces you select.
|
|
397
|
+
</span>
|
|
398
|
+
)}
|
|
399
|
+
{partly.length > 0 && (
|
|
400
|
+
<span className="block text-[11px] text-warning">
|
|
401
|
+
Allowed now in {partly.join(', ')}.{' '}
|
|
402
|
+
{extraTicked(scope) || wider !== undefined
|
|
403
|
+
? 'Ticked, it is allowed in every selected workspace.'
|
|
404
|
+
: 'If you leave it clear, it is removed there.'}
|
|
405
|
+
</span>
|
|
406
|
+
)}
|
|
407
|
+
</span>
|
|
408
|
+
</label>
|
|
409
|
+
)
|
|
410
|
+
})}
|
|
411
|
+
</div>
|
|
412
|
+
<p className="mt-2 text-[11px] text-ink-faint">
|
|
413
|
+
What you allow here replaces what this app had. Clear an item that is already allowed to take
|
|
414
|
+
it away.
|
|
415
|
+
</p>
|
|
416
|
+
</fieldset>
|
|
417
|
+
)}
|
|
418
|
+
|
|
181
419
|
{approve.error !== null && <ErrorPanel error={approve.error} />}
|
|
182
420
|
{deny.error !== null && <ErrorPanel error={deny.error} />}
|
|
183
421
|
|
|
@@ -199,10 +437,10 @@ function ConsentForm({ request }: { readonly request: OAuthRequest }): React.JSX
|
|
|
199
437
|
</button>
|
|
200
438
|
<button
|
|
201
439
|
type="button"
|
|
202
|
-
disabled={busy ||
|
|
440
|
+
disabled={busy || nothingTicked || workspaceIds.length === 0}
|
|
203
441
|
onClick={() => {
|
|
204
442
|
approve
|
|
205
|
-
.runAsync({ requestId: request.id,
|
|
443
|
+
.runAsync({ requestId: request.id, workspaceIds, scopes: [...scopes, ...extras] })
|
|
206
444
|
.then((decision) => {
|
|
207
445
|
leaveTo(decision.redirectUrl)
|
|
208
446
|
})
|
|
@@ -84,7 +84,7 @@ export interface RecordTab {
|
|
|
84
84
|
|
|
85
85
|
/**
|
|
86
86
|
* An admin page whose tabs modules may add to. `ai` is Admin → AI: core owns
|
|
87
|
-
* the page and its
|
|
87
|
+
* the page and its Agents tab, and the optional `ai` module adds Kelpie AI's
|
|
88
88
|
* settings and run log.
|
|
89
89
|
*/
|
|
90
90
|
export type ExtensibleAdminPage = 'ai'
|