@kelpie/ui 0.15.0 → 0.17.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/client.d.ts +6 -5
- package/dist/api/client.d.ts.map +1 -1
- package/dist/api/client.js +2 -2
- package/dist/api/client.js.map +1 -1
- package/dist/api/resource.d.ts +4 -4
- package/dist/api/resource.d.ts.map +1 -1
- package/dist/api/resource.js +4 -5
- package/dist/api/resource.js.map +1 -1
- package/dist/api/resources/ai.d.ts +16 -0
- package/dist/api/resources/ai.d.ts.map +1 -0
- package/dist/api/resources/ai.js +93 -0
- package/dist/api/resources/ai.js.map +1 -0
- package/dist/api/resources/conversions.js +1 -1
- package/dist/api/resources/conversions.js.map +1 -1
- package/dist/api/resources/members.d.ts +2 -2
- package/dist/api/resources/oauth.d.ts +21 -0
- package/dist/api/resources/oauth.d.ts.map +1 -0
- package/dist/api/resources/oauth.js +74 -0
- package/dist/api/resources/oauth.js.map +1 -0
- package/dist/api/resources/planItems.d.ts +1 -1
- package/dist/api/resources/planItems.d.ts.map +1 -1
- package/dist/api/resources/planItems.js +1 -1
- package/dist/api/resources/planItems.js.map +1 -1
- package/dist/api/resources/session.d.ts +1 -1
- package/dist/api/resources/session.d.ts.map +1 -1
- package/dist/api/resources/session.js +4 -2
- package/dist/api/resources/session.js.map +1 -1
- package/dist/api/resources/workspace.d.ts +2 -2
- package/dist/api/resources/workspace.js +2 -2
- package/dist/app/KelpieApp.d.ts.map +1 -1
- package/dist/app/KelpieApp.js +3 -1
- package/dist/app/KelpieApp.js.map +1 -1
- package/dist/components/ActivitiesPanel.d.ts +7 -4
- package/dist/components/ActivitiesPanel.d.ts.map +1 -1
- package/dist/components/ActivitiesPanel.js +12 -2
- package/dist/components/ActivitiesPanel.js.map +1 -1
- package/dist/components/ActivityAction.d.ts +15 -0
- package/dist/components/ActivityAction.d.ts.map +1 -0
- package/dist/components/ActivityAction.js +20 -0
- package/dist/components/ActivityAction.js.map +1 -0
- package/dist/components/AgentTasks.d.ts +5 -0
- package/dist/components/AgentTasks.d.ts.map +1 -1
- package/dist/components/AgentTasks.js +88 -10
- package/dist/components/AgentTasks.js.map +1 -1
- package/dist/components/ApiKeysPanel.d.ts.map +1 -1
- package/dist/components/ApiKeysPanel.js +4 -1
- package/dist/components/ApiKeysPanel.js.map +1 -1
- package/dist/components/DecisionsPanel.d.ts.map +1 -1
- package/dist/components/DecisionsPanel.js +3 -1
- package/dist/components/DecisionsPanel.js.map +1 -1
- package/dist/components/LinkedText.d.ts +12 -0
- package/dist/components/LinkedText.d.ts.map +1 -0
- package/dist/components/LinkedText.js +25 -0
- package/dist/components/LinkedText.js.map +1 -0
- package/dist/components/MarkdownView.d.ts +3 -1
- package/dist/components/MarkdownView.d.ts.map +1 -1
- package/dist/components/MarkdownView.js +17 -3
- package/dist/components/MarkdownView.js.map +1 -1
- package/dist/components/NotesPanel.d.ts +2 -1
- package/dist/components/NotesPanel.d.ts.map +1 -1
- package/dist/components/NotesPanel.js +6 -7
- package/dist/components/NotesPanel.js.map +1 -1
- package/dist/components/Paginator.d.ts +1 -1
- package/dist/components/PlanPanel.d.ts.map +1 -1
- package/dist/components/PlanPanel.js +3 -1
- package/dist/components/PlanPanel.js.map +1 -1
- package/dist/components/RecordLinkTextarea.d.ts +12 -0
- package/dist/components/RecordLinkTextarea.d.ts.map +1 -0
- package/dist/components/RecordLinkTextarea.js +142 -0
- package/dist/components/RecordLinkTextarea.js.map +1 -0
- package/dist/components/Shell.js +1 -1
- package/dist/components/SummaryBlock.d.ts +1 -1
- package/dist/components/SummaryBlock.js +1 -1
- package/dist/components/WorkspaceSwitcher.d.ts +2 -1
- package/dist/components/WorkspaceSwitcher.d.ts.map +1 -1
- package/dist/components/WorkspaceSwitcher.js +7 -2
- package/dist/components/WorkspaceSwitcher.js.map +1 -1
- package/dist/index.d.ts +5 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -1
- package/dist/index.js.map +1 -1
- package/dist/lib/fragmentTarget.d.ts +18 -0
- package/dist/lib/fragmentTarget.d.ts.map +1 -0
- package/dist/lib/fragmentTarget.js +73 -0
- package/dist/lib/fragmentTarget.js.map +1 -0
- package/dist/lib/mcpConfig.d.ts +10 -0
- package/dist/lib/mcpConfig.d.ts.map +1 -0
- package/dist/lib/mcpConfig.js +23 -0
- package/dist/lib/mcpConfig.js.map +1 -0
- package/dist/lib/money.d.ts +2 -2
- package/dist/lib/money.js +2 -2
- package/dist/lib/recordLinks.d.ts +17 -0
- package/dist/lib/recordLinks.d.ts.map +1 -0
- package/dist/lib/recordLinks.js +48 -0
- package/dist/lib/recordLinks.js.map +1 -0
- package/dist/lib/recordReferences.d.ts +41 -0
- package/dist/lib/recordReferences.d.ts.map +1 -0
- package/dist/lib/recordReferences.js +92 -0
- package/dist/lib/recordReferences.js.map +1 -0
- package/dist/modules/ai.d.ts +13 -0
- package/dist/modules/ai.d.ts.map +1 -0
- package/dist/modules/ai.js +22 -0
- package/dist/modules/ai.js.map +1 -0
- package/dist/modules/aiRunner.d.ts +3 -0
- package/dist/modules/aiRunner.d.ts.map +1 -0
- package/dist/modules/aiRunner.js +66 -0
- package/dist/modules/aiRunner.js.map +1 -0
- package/dist/pages/CompanyDetail.d.ts.map +1 -1
- package/dist/pages/CompanyDetail.js +2 -1
- package/dist/pages/CompanyDetail.js.map +1 -1
- package/dist/pages/DealDetail.d.ts.map +1 -1
- package/dist/pages/DealDetail.js +2 -1
- package/dist/pages/DealDetail.js.map +1 -1
- package/dist/pages/DealsPage.js +1 -1
- package/dist/pages/DealsPage.js.map +1 -1
- package/dist/pages/DecisionsPage.d.ts.map +1 -1
- package/dist/pages/DecisionsPage.js +5 -3
- package/dist/pages/DecisionsPage.js.map +1 -1
- package/dist/pages/EnquiryDetail.d.ts.map +1 -1
- package/dist/pages/EnquiryDetail.js +2 -1
- package/dist/pages/EnquiryDetail.js.map +1 -1
- package/dist/pages/EventDetail.d.ts.map +1 -1
- package/dist/pages/EventDetail.js +2 -1
- package/dist/pages/EventDetail.js.map +1 -1
- package/dist/pages/FundraisingPage.js +1 -1
- package/dist/pages/FundraisingPage.js.map +1 -1
- package/dist/pages/OpportunitiesPage.js +1 -1
- package/dist/pages/OpportunitiesPage.js.map +1 -1
- package/dist/pages/OpportunityDetail.d.ts.map +1 -1
- package/dist/pages/OpportunityDetail.js +2 -1
- package/dist/pages/OpportunityDetail.js.map +1 -1
- package/dist/pages/PartnershipDetail.d.ts.map +1 -1
- package/dist/pages/PartnershipDetail.js +2 -1
- package/dist/pages/PartnershipDetail.js.map +1 -1
- package/dist/pages/PartnershipsPage.js +1 -1
- package/dist/pages/PartnershipsPage.js.map +1 -1
- package/dist/pages/PersonDetail.d.ts.map +1 -1
- package/dist/pages/PersonDetail.js +4 -3
- package/dist/pages/PersonDetail.js.map +1 -1
- package/dist/pages/RaiseDetail.d.ts.map +1 -1
- package/dist/pages/RaiseDetail.js +2 -1
- package/dist/pages/RaiseDetail.js.map +1 -1
- package/dist/pages/SearchPage.d.ts.map +1 -1
- package/dist/pages/SearchPage.js +26 -14
- package/dist/pages/SearchPage.js.map +1 -1
- package/dist/pages/account/AccountLayout.d.ts.map +1 -1
- package/dist/pages/account/AccountLayout.js +2 -1
- package/dist/pages/account/AccountLayout.js.map +1 -1
- package/dist/pages/account/ConnectedAppsPage.d.ts +7 -0
- package/dist/pages/account/ConnectedAppsPage.d.ts.map +1 -0
- package/dist/pages/account/ConnectedAppsPage.js +32 -0
- package/dist/pages/account/ConnectedAppsPage.js.map +1 -0
- package/dist/pages/admin/AiPage.d.ts +2 -0
- package/dist/pages/admin/AiPage.d.ts.map +1 -0
- package/dist/pages/admin/AiPage.js +134 -0
- package/dist/pages/admin/AiPage.js.map +1 -0
- package/dist/pages/admin/McpPage.d.ts.map +1 -1
- package/dist/pages/admin/McpPage.js +7 -15
- package/dist/pages/admin/McpPage.js.map +1 -1
- package/dist/pages/admin/ModulesPage.d.ts.map +1 -1
- package/dist/pages/admin/ModulesPage.js +5 -4
- package/dist/pages/admin/ModulesPage.js.map +1 -1
- package/dist/pages/admin/WorkspaceSettingsPage.d.ts +5 -6
- package/dist/pages/admin/WorkspaceSettingsPage.d.ts.map +1 -1
- package/dist/pages/admin/WorkspaceSettingsPage.js +12 -17
- package/dist/pages/admin/WorkspaceSettingsPage.js.map +1 -1
- package/dist/pages/auth/AuthLayout.d.ts +1 -1
- package/dist/pages/auth/AuthLayout.d.ts.map +1 -1
- package/dist/pages/auth/AuthLayout.js +1 -1
- package/dist/pages/auth/AuthLayout.js.map +1 -1
- package/dist/pages/auth/SignUpPage.d.ts +1 -1
- package/dist/pages/auth/SignUpPage.js +1 -1
- package/dist/pages/dashboard/attention.d.ts +0 -5
- package/dist/pages/dashboard/attention.d.ts.map +1 -1
- package/dist/pages/dashboard/attention.js +1 -21
- package/dist/pages/dashboard/attention.js.map +1 -1
- package/dist/pages/dashboard/sections.d.ts.map +1 -1
- package/dist/pages/dashboard/sections.js +6 -3
- package/dist/pages/dashboard/sections.js.map +1 -1
- package/dist/pages/forms/SubmissionDetail.js +1 -1
- 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 +4 -3
- package/dist/pages/forms/SubmissionsTable.js.map +1 -1
- package/dist/pages/handbook/HandbookPage.d.ts.map +1 -1
- package/dist/pages/handbook/HandbookPage.js +2 -3
- package/dist/pages/handbook/HandbookPage.js.map +1 -1
- package/dist/pages/hiringDirectory.js +2 -2
- package/dist/pages/hiringDirectory.js.map +1 -1
- package/dist/pages/oauth/ConsentPage.d.ts +14 -0
- package/dist/pages/oauth/ConsentPage.d.ts.map +1 -0
- package/dist/pages/oauth/ConsentPage.js +87 -0
- package/dist/pages/oauth/ConsentPage.js.map +1 -0
- package/dist/pages/onboarding/WorkspaceStepPage.d.ts.map +1 -1
- package/dist/pages/onboarding/WorkspaceStepPage.js +9 -27
- package/dist/pages/onboarding/WorkspaceStepPage.js.map +1 -1
- package/dist/pages/onboarding/onboardingModules.d.ts +1 -1
- package/dist/pages/onboarding/onboardingRerun.d.ts +10 -1
- package/dist/pages/onboarding/onboardingRerun.d.ts.map +1 -1
- package/dist/pages/onboarding/onboardingRerun.js +12 -1
- package/dist/pages/onboarding/onboardingRerun.js.map +1 -1
- package/dist/pages/positionDirectory.js +2 -2
- package/dist/pages/positionDirectory.js.map +1 -1
- package/dist/registry/context.d.ts +3 -1
- package/dist/registry/context.d.ts.map +1 -1
- package/dist/registry/context.js +4 -0
- package/dist/registry/context.js.map +1 -1
- package/dist/registry/contributions.d.ts +39 -1
- package/dist/registry/contributions.d.ts.map +1 -1
- package/dist/registry/contributions.js +1 -1
- package/dist/registry/overridable.d.ts +1 -1
- package/dist/registry/registry.d.ts +8 -4
- package/dist/registry/registry.d.ts.map +1 -1
- package/dist/registry/registry.js +9 -1
- package/dist/registry/registry.js.map +1 -1
- package/package.json +2 -2
- package/src/api/client.ts +7 -6
- package/src/api/resource.ts +6 -7
- package/src/api/resources/ai.ts +110 -0
- package/src/api/resources/conversions.ts +1 -1
- package/src/api/resources/members.ts +2 -2
- package/src/api/resources/oauth.ts +112 -0
- package/src/api/resources/planItems.ts +1 -1
- package/src/api/resources/session.ts +4 -2
- package/src/api/resources/workspace.ts +4 -4
- package/src/app/KelpieApp.tsx +6 -0
- package/src/components/ActivitiesPanel.tsx +39 -10
- package/src/components/ActivityAction.tsx +33 -0
- package/src/components/AgentTasks.tsx +138 -10
- package/src/components/ApiKeysPanel.tsx +17 -0
- package/src/components/DecisionsPanel.tsx +9 -1
- package/src/components/LinkedText.tsx +51 -0
- package/src/components/MarkdownView.tsx +37 -7
- package/src/components/NotesPanel.tsx +18 -12
- package/src/components/Paginator.tsx +1 -1
- package/src/components/PlanPanel.tsx +9 -1
- package/src/components/RecordLinkTextarea.tsx +257 -0
- package/src/components/Shell.tsx +1 -1
- package/src/components/SummaryBlock.tsx +1 -1
- package/src/components/WorkspaceSwitcher.tsx +15 -1
- package/src/index.ts +10 -0
- package/src/lib/fragmentTarget.ts +96 -0
- package/src/lib/mcpConfig.ts +24 -0
- package/src/lib/money.ts +2 -2
- package/src/lib/recordLinks.ts +57 -0
- package/src/lib/recordReferences.ts +139 -0
- package/src/modules/ai.tsx +23 -0
- package/src/modules/aiRunner.ts +80 -0
- package/src/pages/CompanyDetail.tsx +2 -1
- package/src/pages/DealDetail.tsx +2 -1
- package/src/pages/DealsPage.tsx +1 -1
- package/src/pages/DecisionsPage.tsx +5 -3
- package/src/pages/EnquiryDetail.tsx +2 -1
- package/src/pages/EventDetail.tsx +2 -1
- package/src/pages/FormsPage.tsx +1 -1
- package/src/pages/FundraisingPage.tsx +1 -1
- package/src/pages/OpportunitiesPage.tsx +1 -1
- package/src/pages/OpportunityDetail.tsx +2 -1
- package/src/pages/PartnershipDetail.tsx +2 -1
- package/src/pages/PartnershipsPage.tsx +1 -1
- package/src/pages/PersonDetail.tsx +4 -3
- package/src/pages/RaiseDetail.tsx +2 -1
- package/src/pages/SearchPage.tsx +30 -15
- package/src/pages/account/AccountLayout.tsx +2 -1
- package/src/pages/account/ConnectedAppsPage.tsx +131 -0
- package/src/pages/admin/AiPage.tsx +353 -0
- package/src/pages/admin/McpPage.tsx +48 -27
- package/src/pages/admin/ModulesPage.tsx +5 -4
- package/src/pages/admin/WorkspaceSettingsPage.tsx +13 -28
- package/src/pages/auth/AuthLayout.tsx +1 -1
- package/src/pages/auth/SignUpPage.tsx +1 -1
- package/src/pages/dashboard/attention.ts +1 -24
- package/src/pages/dashboard/sections.tsx +9 -4
- package/src/pages/forms/SubmissionDetail.tsx +1 -1
- package/src/pages/forms/SubmissionsTable.tsx +4 -3
- package/src/pages/handbook/HandbookPage.tsx +5 -6
- package/src/pages/hiringDirectory.ts +2 -2
- package/src/pages/oauth/ConsentPage.tsx +219 -0
- package/src/pages/onboarding/InvitesStepPage.tsx +1 -1
- package/src/pages/onboarding/WorkspaceStepPage.tsx +19 -43
- package/src/pages/onboarding/onboardingModules.ts +1 -1
- package/src/pages/onboarding/onboardingRerun.ts +15 -1
- package/src/pages/positionDirectory.ts +2 -2
- package/src/registry/context.ts +6 -0
- package/src/registry/contributions.ts +31 -1
- package/src/registry/overridable.ts +1 -1
- package/src/registry/registry.ts +21 -3
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { splitRecordLinkTokens } from '@kelpie/schemas'
|
|
2
|
+
import type { RecordLinkToken, RecordReference } from '@kelpie/schemas'
|
|
3
|
+
import type { Link, Parent, PhrasingContent, Root, Text } from 'mdast'
|
|
4
|
+
|
|
5
|
+
import { referenceHref } from './recordLinks.ts'
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Turning the record ids a text cites into something a person can follow.
|
|
9
|
+
*
|
|
10
|
+
* The server already found the ids and named them (`references` on an activity
|
|
11
|
+
* or a note). This side only finds each named id in the text by string match.
|
|
12
|
+
* An id the server did not name stays as it is: it is not a record in this
|
|
13
|
+
* workspace, and a link to it would go nowhere.
|
|
14
|
+
*
|
|
15
|
+
* Text cites a record in two ways, and one pass reads both. A `[[type:id|Label]]`
|
|
16
|
+
* link token is read first, so the id inside it is never matched a second time as
|
|
17
|
+
* a bare id. The text between tokens is then searched for bare ids. A token the
|
|
18
|
+
* server named shows the record's current name; one it did not name shows the
|
|
19
|
+
* token's label as plain text, because the record is gone.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
export type TextSegment =
|
|
23
|
+
| { readonly kind: 'text'; readonly text: string }
|
|
24
|
+
| { readonly kind: 'reference'; readonly reference: RecordReference }
|
|
25
|
+
| { readonly kind: 'unresolved'; readonly token: RecordLinkToken }
|
|
26
|
+
|
|
27
|
+
/** What an unresolved token shows: its label, or its id when it has none. */
|
|
28
|
+
export function unresolvedLabel(token: RecordLinkToken): string {
|
|
29
|
+
return token.label ?? token.targetId
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function escapeForPattern(value: string): string {
|
|
33
|
+
return value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* `text` cut into plain runs and cited records, in order.
|
|
38
|
+
*
|
|
39
|
+
* @returns One text segment holding all of `text` when nothing is cited.
|
|
40
|
+
*/
|
|
41
|
+
export function splitOnReferences(
|
|
42
|
+
text: string,
|
|
43
|
+
references: readonly RecordReference[],
|
|
44
|
+
): readonly TextSegment[] {
|
|
45
|
+
const byTokenId = new Map(references.map((reference) => [reference.targetId, reference]))
|
|
46
|
+
|
|
47
|
+
return splitRecordLinkTokens(text).flatMap((segment): readonly TextSegment[] => {
|
|
48
|
+
if (segment.kind === 'text') {
|
|
49
|
+
return splitOnBareIds(segment.text, references)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const reference = byTokenId.get(segment.token.targetId)
|
|
53
|
+
|
|
54
|
+
return reference === undefined
|
|
55
|
+
? [{ kind: 'unresolved', token: segment.token }]
|
|
56
|
+
: [{ kind: 'reference', reference }]
|
|
57
|
+
})
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** Bare ids only. Every segment it returns is `text` or `reference`. */
|
|
61
|
+
function splitOnBareIds(text: string, references: readonly RecordReference[]): TextSegment[] {
|
|
62
|
+
if (references.length === 0) {
|
|
63
|
+
return text.length === 0 ? [] : [{ kind: 'text', text }]
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const byId = new Map(references.map((reference) => [reference.targetId, reference]))
|
|
67
|
+
// Longest first, so an id can never lose to a shorter one it starts with.
|
|
68
|
+
const ids = [...byId.keys()].sort((left, right) => right.length - left.length)
|
|
69
|
+
const pattern = new RegExp(`(${ids.map(escapeForPattern).join('|')})`)
|
|
70
|
+
const segments: TextSegment[] = []
|
|
71
|
+
|
|
72
|
+
// `split` with one capture group puts each match at an odd index.
|
|
73
|
+
text.split(pattern).forEach((part, index) => {
|
|
74
|
+
const reference = index % 2 === 1 ? byId.get(part) : undefined
|
|
75
|
+
|
|
76
|
+
if (reference !== undefined) {
|
|
77
|
+
segments.push({ kind: 'reference', reference })
|
|
78
|
+
} else if (part.length > 0) {
|
|
79
|
+
segments.push({ kind: 'text', text: part })
|
|
80
|
+
}
|
|
81
|
+
})
|
|
82
|
+
|
|
83
|
+
return segments
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** A cited record as a Markdown node: a link to its page, or its name when it has none. */
|
|
87
|
+
function referenceNode(reference: RecordReference): Link | Text {
|
|
88
|
+
const href = referenceHref(reference)
|
|
89
|
+
const name: Text = { type: 'text', value: reference.name }
|
|
90
|
+
|
|
91
|
+
return href === undefined ? name : { type: 'link', url: href, title: null, children: [name] }
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/** Node types whose text must stay as written: a link cannot hold a link, and code is literal. */
|
|
95
|
+
const LEAVE_ALONE = new Set(['link', 'linkReference', 'code', 'inlineCode'])
|
|
96
|
+
|
|
97
|
+
function isParent(node: { readonly type: string }): node is Parent {
|
|
98
|
+
return 'children' in node && Array.isArray(node.children)
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function rewriteChildren(parent: Parent, references: readonly RecordReference[]): void {
|
|
102
|
+
const rewritten: Parent['children'] = []
|
|
103
|
+
|
|
104
|
+
for (const child of parent.children) {
|
|
105
|
+
if (child.type === 'text') {
|
|
106
|
+
for (const segment of splitOnReferences(child.value, references)) {
|
|
107
|
+
rewritten.push(
|
|
108
|
+
segment.kind === 'text'
|
|
109
|
+
? ({ type: 'text', value: segment.text } satisfies PhrasingContent)
|
|
110
|
+
: segment.kind === 'reference'
|
|
111
|
+
? referenceNode(segment.reference)
|
|
112
|
+
: ({ type: 'text', value: unresolvedLabel(segment.token) } satisfies PhrasingContent),
|
|
113
|
+
)
|
|
114
|
+
}
|
|
115
|
+
} else {
|
|
116
|
+
if (isParent(child) && !LEAVE_ALONE.has(child.type)) {
|
|
117
|
+
rewriteChildren(child, references)
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
rewritten.push(child)
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
parent.children = rewritten
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* A remark plugin: every cited record in the Markdown's text, bare id or link
|
|
129
|
+
* token, becomes a link to the record, labelled with its name. The source string
|
|
130
|
+
* is not touched, so what the author wrote is still what is stored and edited.
|
|
131
|
+
*/
|
|
132
|
+
export function remarkRecordReferences(
|
|
133
|
+
references: readonly RecordReference[],
|
|
134
|
+
): () => (tree: Root) => void {
|
|
135
|
+
// Runs even with no references: a token must still lose its brackets.
|
|
136
|
+
return () => (tree) => {
|
|
137
|
+
rewriteChildren(tree, references)
|
|
138
|
+
}
|
|
139
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { AiPage } from '../pages/admin/AiPage.tsx'
|
|
2
|
+
import type { UiModule } from '../registry/registry.ts'
|
|
3
|
+
import { aiRunner } from './aiRunner.ts'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* The UI half of the optional `ai` module in `@kelpie/server`.
|
|
7
|
+
*
|
|
8
|
+
* Not registered by default. An assembly that lists `createAiModule()` on the
|
|
9
|
+
* server lists `aiUi` in `kelpie.ui.config.ts`, the same pairing any module
|
|
10
|
+
* uses. One Admin nav item, after MCP, and one page. On record pages it is the
|
|
11
|
+
* Agent menu's runner: Run dispatches straight to the "Kelpie AI" agent row, and
|
|
12
|
+
* stays disabled until AI is enabled and has a key. Preview's Run… still lists
|
|
13
|
+
* every registered agent, Kelpie AI included.
|
|
14
|
+
*/
|
|
15
|
+
export const aiUi: UiModule = {
|
|
16
|
+
id: 'ai',
|
|
17
|
+
|
|
18
|
+
register(context) {
|
|
19
|
+
context.nav('admin', { id: 'ai', label: 'AI', to: '/admin/ai', order: 550 })
|
|
20
|
+
context.route({ path: 'admin/ai', element: <AiPage /> })
|
|
21
|
+
context.agentRunner(aiRunner)
|
|
22
|
+
},
|
|
23
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { ApiError } from '../api/client.ts'
|
|
2
|
+
import { useAiRunForAgentRun, useAiSettings } from '../api/resources/ai.ts'
|
|
3
|
+
import { useAgents } from '../api/resources/agentTasks.ts'
|
|
4
|
+
import type { AgentRunner, AgentRunnerAvailability, AgentRunnerProgress } from '../registry/contributions.ts'
|
|
5
|
+
|
|
6
|
+
/** The `managed_by` value the server module writes on its agent row. */
|
|
7
|
+
const AI_MODULE_ID = 'ai'
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Kelpie AI as the Agent menu's runner.
|
|
11
|
+
*
|
|
12
|
+
* Ready only when the workspace can run a task now: the module answers (so it
|
|
13
|
+
* is in the assembly and switched on), AI is enabled, a provider and key are
|
|
14
|
+
* available (the workspace's own, or the deployment's), and the agent row the
|
|
15
|
+
* module manages exists to dispatch to.
|
|
16
|
+
*/
|
|
17
|
+
function useAvailability(options: { readonly enabled: boolean }): AgentRunnerAvailability {
|
|
18
|
+
const settings = useAiSettings({ enabled: options.enabled })
|
|
19
|
+
const agents = useAgents({ enabled: options.enabled })
|
|
20
|
+
|
|
21
|
+
if (settings.isLoading || agents.isLoading || !options.enabled) {
|
|
22
|
+
return { status: 'loading' }
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (settings.error !== null) {
|
|
26
|
+
// The runtime answers 403 or 404 when the module is switched off.
|
|
27
|
+
return settings.error instanceof ApiError && (settings.error.status === 403 || settings.error.status === 404)
|
|
28
|
+
? { status: 'unavailable', reason: 'Kelpie AI is switched off for this workspace.' }
|
|
29
|
+
: { status: 'unavailable', reason: 'Kelpie AI settings could not be read.' }
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const record = settings.record
|
|
33
|
+
|
|
34
|
+
if (record === undefined || !record.enabled) {
|
|
35
|
+
return { status: 'unavailable', reason: 'Kelpie AI is not enabled. An admin can enable it under Admin → AI.' }
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (!record.configured) {
|
|
39
|
+
return {
|
|
40
|
+
status: 'unavailable',
|
|
41
|
+
reason: 'Kelpie AI has no provider key. An admin can add one under Admin → AI.',
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const agent = agents.records.find((candidate) => candidate.managedBy === AI_MODULE_ID)
|
|
46
|
+
|
|
47
|
+
if (agent === undefined) {
|
|
48
|
+
return {
|
|
49
|
+
status: 'unavailable',
|
|
50
|
+
reason: 'The Kelpie AI agent is missing. An admin can save Admin → AI again to restore it.',
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return { status: 'ready', agentId: agent.id }
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function useProgress(agentRunId: string | undefined): AgentRunnerProgress | undefined {
|
|
58
|
+
const run = useAiRunForAgentRun(agentRunId)
|
|
59
|
+
|
|
60
|
+
if (agentRunId === undefined) {
|
|
61
|
+
return undefined
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
switch (run?.status) {
|
|
65
|
+
case 'succeeded':
|
|
66
|
+
return { status: 'succeeded' }
|
|
67
|
+
case 'failed':
|
|
68
|
+
return { status: 'failed', reason: run.failureReason ?? 'no reason recorded' }
|
|
69
|
+
case 'queued':
|
|
70
|
+
case 'running':
|
|
71
|
+
case undefined:
|
|
72
|
+
return { status: 'running' }
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export const aiRunner: AgentRunner = {
|
|
77
|
+
id: AI_MODULE_ID,
|
|
78
|
+
useAvailability,
|
|
79
|
+
useProgress,
|
|
80
|
+
}
|
|
@@ -56,6 +56,7 @@ import { SidebarField } from '../components/SidebarField.tsx'
|
|
|
56
56
|
import { SummaryBlock } from '../components/SummaryBlock.tsx'
|
|
57
57
|
import { useRecordTabs } from '../registry/context.ts'
|
|
58
58
|
import { inSlotOrder } from '../registry/registry.ts'
|
|
59
|
+
import { useRecordTab } from '../lib/fragmentTarget.ts'
|
|
59
60
|
import { toOptions, toTags } from './fields.ts'
|
|
60
61
|
|
|
61
62
|
/**
|
|
@@ -87,7 +88,7 @@ export function CompanyDetail(): React.JSX.Element {
|
|
|
87
88
|
const moduleTabs = inSlotOrder(useRecordTabs('company'))
|
|
88
89
|
const hasCustomFields = useHasCustomFields('company')
|
|
89
90
|
const eventsEnabled = useModuleEnabled('events')
|
|
90
|
-
const [activeTab, setActiveTab] =
|
|
91
|
+
const [activeTab, setActiveTab] = useRecordTab()
|
|
91
92
|
const formSubmissions = useFormSubmissionsForRecord('company', id)
|
|
92
93
|
|
|
93
94
|
if (isNotFound) {
|
package/src/pages/DealDetail.tsx
CHANGED
|
@@ -42,6 +42,7 @@ import { SidebarField } from '../components/SidebarField.tsx'
|
|
|
42
42
|
import { SummaryBlock } from '../components/SummaryBlock.tsx'
|
|
43
43
|
import { formatDay } from '../lib/dates.ts'
|
|
44
44
|
import { formatMoney } from '../lib/money.ts'
|
|
45
|
+
import { useRecordTab } from '../lib/fragmentTarget.ts'
|
|
45
46
|
import { useRecordTabs } from '../registry/context.ts'
|
|
46
47
|
import { inSlotOrder } from '../registry/registry.ts'
|
|
47
48
|
import { toTags } from './fields.ts'
|
|
@@ -68,7 +69,7 @@ export function DealDetail(): React.JSX.Element {
|
|
|
68
69
|
const moduleTabs = inSlotOrder(useRecordTabs('deal'))
|
|
69
70
|
const hasCustomFields = useHasCustomFields('deal')
|
|
70
71
|
const eventsEnabled = useModuleEnabled('events')
|
|
71
|
-
const [activeTab, setActiveTab] =
|
|
72
|
+
const [activeTab, setActiveTab] = useRecordTab()
|
|
72
73
|
const [showConvert, setShowConvert] = useState(false)
|
|
73
74
|
const formSubmissions = useFormSubmissionsForRecord('deal', id)
|
|
74
75
|
|
package/src/pages/DealsPage.tsx
CHANGED
|
@@ -113,7 +113,7 @@ export function DealsPage(): React.JSX.Element {
|
|
|
113
113
|
const visibleDeals = deals.records.filter((deal) => visibleStageIds.has(deal.stageId))
|
|
114
114
|
|
|
115
115
|
// The next-step column asks about the deals on screen by id. `?target_id=`
|
|
116
|
-
// takes at most one page of them (`api.md`), so past that ceiling the rest
|
|
116
|
+
// takes at most one page of them (`docs/agents/api-and-webhooks.md`), so past that ceiling the rest
|
|
117
117
|
// read as having no plan; the note under the table says so.
|
|
118
118
|
const askedDealIds = visibleDeals.slice(0, MAX_PAGE_SIZE).map((deal) => deal.id)
|
|
119
119
|
const planItems = usePlanItems(
|
|
@@ -29,13 +29,15 @@ import { useListView } from '../lib/listView.ts'
|
|
|
29
29
|
* matches target names the loaded page may not even hold.
|
|
30
30
|
*
|
|
31
31
|
* The "Linked to" column joins client-side against one page each of people,
|
|
32
|
-
* companies, deals, opportunities, raises and partnerships, because
|
|
33
|
-
* has no include-expansion
|
|
32
|
+
* companies, deals, opportunities, raises and partnerships, because the API
|
|
33
|
+
* has no include-expansion. The repeatable id filters (`?person_id=`,
|
|
34
|
+
* `?company_id=`, …) match a foreign key; no list filters on its own `?id=`,
|
|
35
|
+
* so there is no way to fetch just the targets by id. A target past
|
|
34
36
|
* those pages, or one whose type has no page yet (candidate), names its record
|
|
35
37
|
* type instead — better than a raw id or a link to a route that does not exist.
|
|
36
38
|
*/
|
|
37
39
|
|
|
38
|
-
/**
|
|
40
|
+
/** `?limit=` maxes out at 200 (`docs/agents/api-and-webhooks.md`). */
|
|
39
41
|
const MAX_PAGE = 200
|
|
40
42
|
|
|
41
43
|
const TARGET_LABELS: Readonly<Record<RecordTargetType, string>> = {
|
|
@@ -46,6 +46,7 @@ import { SidebarField } from '../components/SidebarField.tsx'
|
|
|
46
46
|
import { SummaryBlock } from '../components/SummaryBlock.tsx'
|
|
47
47
|
import { useRecordTabs } from '../registry/context.ts'
|
|
48
48
|
import { inSlotOrder } from '../registry/registry.ts'
|
|
49
|
+
import { useRecordTab } from '../lib/fragmentTarget.ts'
|
|
49
50
|
import { toTags } from './fields.ts'
|
|
50
51
|
|
|
51
52
|
/**
|
|
@@ -71,7 +72,7 @@ export function EnquiryDetail(): React.JSX.Element {
|
|
|
71
72
|
const moduleTabs = inSlotOrder(useRecordTabs('enquiry'))
|
|
72
73
|
const hasCustomFields = useHasCustomFields('enquiry')
|
|
73
74
|
const eventsEnabled = useModuleEnabled('events')
|
|
74
|
-
const [activeTab, setActiveTab] =
|
|
75
|
+
const [activeTab, setActiveTab] = useRecordTab()
|
|
75
76
|
const [showConvert, setShowConvert] = useState(false)
|
|
76
77
|
const formSubmissions = useFormSubmissionsForRecord('enquiry', id)
|
|
77
78
|
|
|
@@ -64,6 +64,7 @@ import { SidebarField } from '../components/SidebarField.tsx'
|
|
|
64
64
|
import { SummaryBlock } from '../components/SummaryBlock.tsx'
|
|
65
65
|
import { TimezoneSearch } from '../components/TimezoneSearch.tsx'
|
|
66
66
|
import { formatDateTime } from '../lib/dates.ts'
|
|
67
|
+
import { useRecordTab } from '../lib/fragmentTarget.ts'
|
|
67
68
|
import { useRecordTabs } from '../registry/context.ts'
|
|
68
69
|
import { inSlotOrder } from '../registry/registry.ts'
|
|
69
70
|
import { toTags } from './fields.ts'
|
|
@@ -106,7 +107,7 @@ export function EventDetail(): React.JSX.Element {
|
|
|
106
107
|
const deleteEvent = useDeleteEvent()
|
|
107
108
|
const moduleTabs = inSlotOrder(useRecordTabs('event'))
|
|
108
109
|
const hasCustomFields = useHasCustomFields('event')
|
|
109
|
-
const [activeTab, setActiveTab] =
|
|
110
|
+
const [activeTab, setActiveTab] = useRecordTab()
|
|
110
111
|
|
|
111
112
|
if (isNotFound) {
|
|
112
113
|
return <NotFoundPanel label="Event" backTo="/events" />
|
package/src/pages/FormsPage.tsx
CHANGED
|
@@ -24,7 +24,7 @@ import { CONTACT_FORM_FIELDS } from './forms/template.ts'
|
|
|
24
24
|
* loaded array, so they match forms this page has not paged to yet.
|
|
25
25
|
*
|
|
26
26
|
* There is no submissions count column. The mockup had one because its seed data
|
|
27
|
-
* was a local array; here it would be one request per row, and
|
|
27
|
+
* was a local array; here it would be one request per row, and the API has no
|
|
28
28
|
* expansion to fold that into the list. The count lives on the detail page,
|
|
29
29
|
* where the submissions are already being fetched.
|
|
30
30
|
*/
|
|
@@ -109,7 +109,7 @@ export function FundraisingPage(): React.JSX.Element {
|
|
|
109
109
|
const visibleRaises = raises.records.filter((raise) => visibleStageIds.has(raise.stageId))
|
|
110
110
|
|
|
111
111
|
// The next-step column asks about the records on screen by id. `?target_id=`
|
|
112
|
-
// takes at most one page of them (`api.md`), so past that ceiling the rest
|
|
112
|
+
// takes at most one page of them (`docs/agents/api-and-webhooks.md`), so past that ceiling the rest
|
|
113
113
|
// read as having no plan; the note under the table says so.
|
|
114
114
|
const askedIds = visibleRaises.slice(0, MAX_PAGE_SIZE).map((raise) => raise.id)
|
|
115
115
|
const planItems = usePlanItems(
|
|
@@ -109,7 +109,7 @@ export function OpportunitiesPage(): React.JSX.Element {
|
|
|
109
109
|
)
|
|
110
110
|
|
|
111
111
|
// The next-step column asks about the records on screen by id. `?target_id=`
|
|
112
|
-
// takes at most one page of them (`api.md`), so past that ceiling the rest
|
|
112
|
+
// takes at most one page of them (`docs/agents/api-and-webhooks.md`), so past that ceiling the rest
|
|
113
113
|
// read as having no plan; the note under the table says so.
|
|
114
114
|
const askedIds = visibleOpportunities.slice(0, MAX_PAGE_SIZE).map((opportunity) => opportunity.id)
|
|
115
115
|
const planItems = usePlanItems(
|
|
@@ -45,6 +45,7 @@ import { SectionHeader } from '../components/SectionHeader.tsx'
|
|
|
45
45
|
import { SidebarField } from '../components/SidebarField.tsx'
|
|
46
46
|
import { SummaryBlock } from '../components/SummaryBlock.tsx'
|
|
47
47
|
import { formatDay } from '../lib/dates.ts'
|
|
48
|
+
import { useRecordTab } from '../lib/fragmentTarget.ts'
|
|
48
49
|
import { useRecordTabs } from '../registry/context.ts'
|
|
49
50
|
import { inSlotOrder } from '../registry/registry.ts'
|
|
50
51
|
import { toTags } from './fields.ts'
|
|
@@ -73,7 +74,7 @@ export function OpportunityDetail(): React.JSX.Element {
|
|
|
73
74
|
const moduleTabs = inSlotOrder(useRecordTabs('opportunity'))
|
|
74
75
|
const hasCustomFields = useHasCustomFields('opportunity')
|
|
75
76
|
const eventsEnabled = useModuleEnabled('events')
|
|
76
|
-
const [activeTab, setActiveTab] =
|
|
77
|
+
const [activeTab, setActiveTab] = useRecordTab()
|
|
77
78
|
const [showConvert, setShowConvert] = useState(false)
|
|
78
79
|
const formSubmissions = useFormSubmissionsForRecord('opportunity', id)
|
|
79
80
|
|
|
@@ -45,6 +45,7 @@ import { SectionHeader } from '../components/SectionHeader.tsx'
|
|
|
45
45
|
import { SidebarField } from '../components/SidebarField.tsx'
|
|
46
46
|
import { SummaryBlock } from '../components/SummaryBlock.tsx'
|
|
47
47
|
import { formatDay } from '../lib/dates.ts'
|
|
48
|
+
import { useRecordTab } from '../lib/fragmentTarget.ts'
|
|
48
49
|
import { useRecordTabs } from '../registry/context.ts'
|
|
49
50
|
import { inSlotOrder } from '../registry/registry.ts'
|
|
50
51
|
import { toTags } from './fields.ts'
|
|
@@ -73,7 +74,7 @@ export function PartnershipDetail(): React.JSX.Element {
|
|
|
73
74
|
const moduleTabs = inSlotOrder(useRecordTabs('partnership'))
|
|
74
75
|
const hasCustomFields = useHasCustomFields('partnership')
|
|
75
76
|
const eventsEnabled = useModuleEnabled('events')
|
|
76
|
-
const [activeTab, setActiveTab] =
|
|
77
|
+
const [activeTab, setActiveTab] = useRecordTab()
|
|
77
78
|
const [showConvert, setShowConvert] = useState(false)
|
|
78
79
|
const formSubmissions = useFormSubmissionsForRecord('partnership', id)
|
|
79
80
|
|
|
@@ -110,7 +110,7 @@ export function PartnershipsPage(): React.JSX.Element {
|
|
|
110
110
|
)
|
|
111
111
|
|
|
112
112
|
// The next-step column asks about the records on screen by id. `?target_id=`
|
|
113
|
-
// takes at most one page of them (`api.md`), so past that ceiling the rest
|
|
113
|
+
// takes at most one page of them (`docs/agents/api-and-webhooks.md`), so past that ceiling the rest
|
|
114
114
|
// read as having no plan; the note under the table says so.
|
|
115
115
|
const askedIds = visiblePartnerships.slice(0, MAX_PAGE_SIZE).map((partnership) => partnership.id)
|
|
116
116
|
const planItems = usePlanItems(
|
|
@@ -55,6 +55,7 @@ import { PhonesField } from '../components/PhonesField.tsx'
|
|
|
55
55
|
import { SummaryBlock } from '../components/SummaryBlock.tsx'
|
|
56
56
|
import { useRecordTabs } from '../registry/context.ts'
|
|
57
57
|
import { inSlotOrder } from '../registry/registry.ts'
|
|
58
|
+
import { useRecordTab } from '../lib/fragmentTarget.ts'
|
|
58
59
|
import {
|
|
59
60
|
CandidateReferrerField,
|
|
60
61
|
CandidateStageField,
|
|
@@ -91,7 +92,7 @@ export function PersonDetail(): React.JSX.Element {
|
|
|
91
92
|
const moduleTabs = inSlotOrder(useRecordTabs('person'))
|
|
92
93
|
const hasCustomFields = useHasCustomFields('person')
|
|
93
94
|
const eventsEnabled = useModuleEnabled('events')
|
|
94
|
-
const [activeTab, setActiveTab] =
|
|
95
|
+
const [activeTab, setActiveTab] = useRecordTab()
|
|
95
96
|
const candidacies = useCandidates({ personIds: id === undefined ? [] : [id] }, {
|
|
96
97
|
enabled: id !== undefined,
|
|
97
98
|
})
|
|
@@ -209,7 +210,7 @@ export function PersonDetail(): React.JSX.Element {
|
|
|
209
210
|
)
|
|
210
211
|
}
|
|
211
212
|
|
|
212
|
-
/** A committed inline edit is one `PATCH` of one field
|
|
213
|
+
/** A committed inline edit is one `PATCH` of one field. */
|
|
213
214
|
function usePersonPatch(person: Person): PatchResult<PersonInput> {
|
|
214
215
|
return usePatch(useUpdatePerson, person)
|
|
215
216
|
}
|
|
@@ -672,7 +673,7 @@ function PersonFields({ person }: { readonly person: Person }): React.JSX.Elemen
|
|
|
672
673
|
* The companies this person holds a title at.
|
|
673
674
|
*
|
|
674
675
|
* Two requests, not one per position: `?person_id=` on both lists is exactly the
|
|
675
|
-
* filter `api.md` documents for this, and it exists so a detail page is not N+1.
|
|
676
|
+
* filter `docs/api-reference.md` documents for this, and it exists so a detail page is not N+1.
|
|
676
677
|
*/
|
|
677
678
|
function PersonPositions({ person }: { readonly person: Person }): React.JSX.Element {
|
|
678
679
|
const positions = usePositions({ personIds: [person.id] })
|
|
@@ -40,6 +40,7 @@ import { SidebarField } from '../components/SidebarField.tsx'
|
|
|
40
40
|
import { SummaryBlock } from '../components/SummaryBlock.tsx'
|
|
41
41
|
import { formatDay } from '../lib/dates.ts'
|
|
42
42
|
import { formatMoney } from '../lib/money.ts'
|
|
43
|
+
import { useRecordTab } from '../lib/fragmentTarget.ts'
|
|
43
44
|
import { useRecordTabs } from '../registry/context.ts'
|
|
44
45
|
import { inSlotOrder } from '../registry/registry.ts'
|
|
45
46
|
import { toTags } from './fields.ts'
|
|
@@ -72,7 +73,7 @@ export function RaiseDetail(): React.JSX.Element {
|
|
|
72
73
|
const moduleTabs = inSlotOrder(useRecordTabs('raise'))
|
|
73
74
|
const hasCustomFields = useHasCustomFields('raise')
|
|
74
75
|
const eventsEnabled = useModuleEnabled('events')
|
|
75
|
-
const [activeTab, setActiveTab] =
|
|
76
|
+
const [activeTab, setActiveTab] = useRecordTab()
|
|
76
77
|
const [showConvert, setShowConvert] = useState(false)
|
|
77
78
|
|
|
78
79
|
if (isNotFound) {
|
package/src/pages/SearchPage.tsx
CHANGED
|
@@ -4,6 +4,7 @@ import { Link, useSearchParams } from 'react-router'
|
|
|
4
4
|
import { useSearch } from '../api/resources/search.ts'
|
|
5
5
|
import { ErrorPanel, LoadingPanel } from '../components/QueryState.tsx'
|
|
6
6
|
import { PageHeader } from '../components/PageHeader.tsx'
|
|
7
|
+
import { attachedHref } from '../lib/recordLinks.ts'
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* `/search?q=`, the destination of the box in the application shell.
|
|
@@ -13,21 +14,35 @@ import { PageHeader } from '../components/PageHeader.tsx'
|
|
|
13
14
|
* renderer, and the only thing it still owns is where a result links to.
|
|
14
15
|
*/
|
|
15
16
|
|
|
17
|
+
/**
|
|
18
|
+
* Where a Decision, Note or Plan item result opens: the page of the record it is
|
|
19
|
+
* on, at the item. With no record to open, the fallback.
|
|
20
|
+
*/
|
|
21
|
+
function onItsRecord(fallback: string): (item: SearchResult) => string {
|
|
22
|
+
return (item) => (item.target === null ? fallback : (attachedHref(item.id, item.target) ?? fallback))
|
|
23
|
+
}
|
|
24
|
+
|
|
16
25
|
/** What each collection is called on screen, and where one of its results lives. */
|
|
17
|
-
const COLLECTIONS: Readonly<
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
26
|
+
const COLLECTIONS: Readonly<
|
|
27
|
+
Record<SearchCollection, { label: string; path: (item: SearchResult) => string }>
|
|
28
|
+
> = {
|
|
29
|
+
handbook_page: { label: 'Handbook', path: (item) => `/handbook/${item.id}` },
|
|
30
|
+
person: { label: 'People', path: (item) => `/people/${item.id}` },
|
|
31
|
+
role: { label: 'Roles', path: (item) => `/hiring/${item.id}` },
|
|
32
|
+
company: { label: 'Companies', path: (item) => `/companies/${item.id}` },
|
|
33
|
+
enquiry: { label: 'Enquiries', path: (item) => `/enquiries/${item.id}` },
|
|
34
|
+
deal: { label: 'Deals', path: (item) => `/deals/${item.id}` },
|
|
35
|
+
opportunity: { label: 'Opportunities', path: (item) => `/opportunities/${item.id}` },
|
|
36
|
+
raise: { label: 'Fundraising', path: (item) => `/fundraising/${item.id}` },
|
|
37
|
+
partnership: { label: 'Partnerships', path: (item) => `/partnerships/${item.id}` },
|
|
38
|
+
event: { label: 'Events', path: (item) => `/events/${item.id}` },
|
|
39
|
+
// Decisions, Notes and Plan items have no page of their own. Each opens on the
|
|
40
|
+
// record it is on; the global list is where a decision with none is read.
|
|
41
|
+
decision: { label: 'Decisions', path: onItsRecord('/decisions') },
|
|
42
|
+
note: { label: 'Notes', path: onItsRecord('/dashboard') },
|
|
43
|
+
plan_item: { label: 'Plan items', path: onItsRecord('/planning') },
|
|
44
|
+
list: { label: 'Lists', path: (item) => `/lists/${item.id}` },
|
|
45
|
+
form: { label: 'Forms', path: (item) => `/forms/${item.id}` },
|
|
31
46
|
}
|
|
32
47
|
|
|
33
48
|
export function SearchPage(): React.JSX.Element {
|
|
@@ -120,7 +135,7 @@ function ResultRow({
|
|
|
120
135
|
}): React.JSX.Element {
|
|
121
136
|
return (
|
|
122
137
|
<Link
|
|
123
|
-
to={COLLECTIONS[collection].path(item
|
|
138
|
+
to={COLLECTIONS[collection].path(item)}
|
|
124
139
|
className="block px-4 py-2.5 transition hover:bg-accent-soft/30"
|
|
125
140
|
>
|
|
126
141
|
<div className="flex items-center justify-between gap-3">
|
|
@@ -7,7 +7,7 @@ import { useVisibleNavItems } from '../../registry/visibleNav.ts'
|
|
|
7
7
|
/**
|
|
8
8
|
* Tabs across the account's own settings, from the mockup's `AccountNav`.
|
|
9
9
|
*
|
|
10
|
-
*
|
|
10
|
+
* Five tabs are core's. The rest come from `nav.account`, which is
|
|
11
11
|
* where a module's own account page announces itself: a module route mounts as
|
|
12
12
|
* a sibling of `/account` rather than a child of it, so without this the page
|
|
13
13
|
* would render with no tab strip and nothing anywhere pointing at it.
|
|
@@ -21,6 +21,7 @@ const CORE_TABS: readonly NavItem[] = [
|
|
|
21
21
|
{ id: 'security', to: '/account/security', label: 'Security', order: 200 },
|
|
22
22
|
{ id: 'preferences', to: '/account/preferences', label: 'Preferences', order: 300 },
|
|
23
23
|
{ id: 'api-keys', to: '/account/api-keys', label: 'API keys', order: 400 },
|
|
24
|
+
{ id: 'connected-apps', to: '/account/connected-apps', label: 'Connected apps', order: 500 },
|
|
24
25
|
]
|
|
25
26
|
|
|
26
27
|
function tabClass({ isActive }: { isActive: boolean }): string {
|