@kelpie/ui 0.26.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.
Files changed (224) hide show
  1. package/dist/api/resources/account.d.ts +7 -1
  2. package/dist/api/resources/account.d.ts.map +1 -1
  3. package/dist/api/resources/account.js +17 -1
  4. package/dist/api/resources/account.js.map +1 -1
  5. package/dist/api/resources/bulkActions.d.ts +50 -0
  6. package/dist/api/resources/bulkActions.d.ts.map +1 -0
  7. package/dist/api/resources/bulkActions.js +192 -0
  8. package/dist/api/resources/bulkActions.js.map +1 -0
  9. package/dist/api/resources/forms.d.ts +26 -1
  10. package/dist/api/resources/forms.d.ts.map +1 -1
  11. package/dist/api/resources/forms.js +98 -1
  12. package/dist/api/resources/forms.js.map +1 -1
  13. package/dist/app/KelpieApp.d.ts.map +1 -1
  14. package/dist/app/KelpieApp.js +3 -1
  15. package/dist/app/KelpieApp.js.map +1 -1
  16. package/dist/components/ActivitiesPanel.d.ts.map +1 -1
  17. package/dist/components/ActivitiesPanel.js +3 -12
  18. package/dist/components/ActivitiesPanel.js.map +1 -1
  19. package/dist/components/BulkActions.d.ts +61 -0
  20. package/dist/components/BulkActions.d.ts.map +1 -0
  21. package/dist/components/BulkActions.js +351 -0
  22. package/dist/components/BulkActions.js.map +1 -0
  23. package/dist/components/BulkParamFields.d.ts +13 -0
  24. package/dist/components/BulkParamFields.d.ts.map +1 -0
  25. package/dist/components/BulkParamFields.js +177 -0
  26. package/dist/components/BulkParamFields.js.map +1 -0
  27. package/dist/components/CellLinks.d.ts +38 -0
  28. package/dist/components/CellLinks.d.ts.map +1 -0
  29. package/dist/components/CellLinks.js +58 -0
  30. package/dist/components/CellLinks.js.map +1 -0
  31. package/dist/components/CustomFieldsPanel.d.ts +12 -1
  32. package/dist/components/CustomFieldsPanel.d.ts.map +1 -1
  33. package/dist/components/CustomFieldsPanel.js +5 -1
  34. package/dist/components/CustomFieldsPanel.js.map +1 -1
  35. package/dist/components/DataTable.d.ts +42 -1
  36. package/dist/components/DataTable.d.ts.map +1 -1
  37. package/dist/components/DataTable.js +51 -16
  38. package/dist/components/DataTable.js.map +1 -1
  39. package/dist/components/NotesPanel.d.ts.map +1 -1
  40. package/dist/components/NotesPanel.js +2 -15
  41. package/dist/components/NotesPanel.js.map +1 -1
  42. package/dist/components/PhonesField.d.ts.map +1 -1
  43. package/dist/components/PhonesField.js +1 -3
  44. package/dist/components/PhonesField.js.map +1 -1
  45. package/dist/components/Shell.d.ts.map +1 -1
  46. package/dist/components/Shell.js +16 -6
  47. package/dist/components/Shell.js.map +1 -1
  48. package/dist/components/TagInput.d.ts.map +1 -1
  49. package/dist/components/TagInput.js +5 -0
  50. package/dist/components/TagInput.js.map +1 -1
  51. package/dist/components/bulkActionParams.d.ts +71 -0
  52. package/dist/components/bulkActionParams.d.ts.map +1 -0
  53. package/dist/components/bulkActionParams.js +241 -0
  54. package/dist/components/bulkActionParams.js.map +1 -0
  55. package/dist/components/bulkActionSummary.d.ts +22 -0
  56. package/dist/components/bulkActionSummary.d.ts.map +1 -0
  57. package/dist/components/bulkActionSummary.js +68 -0
  58. package/dist/components/bulkActionSummary.js.map +1 -0
  59. package/dist/components/bulkJobStatus.d.ts +4 -0
  60. package/dist/components/bulkJobStatus.d.ts.map +1 -0
  61. package/dist/components/bulkJobStatus.js +10 -0
  62. package/dist/components/bulkJobStatus.js.map +1 -0
  63. package/dist/index.d.ts +2 -2
  64. package/dist/index.d.ts.map +1 -1
  65. package/dist/index.js +1 -1
  66. package/dist/index.js.map +1 -1
  67. package/dist/lib/attribution.d.ts +31 -0
  68. package/dist/lib/attribution.d.ts.map +1 -0
  69. package/dist/lib/attribution.js +48 -0
  70. package/dist/lib/attribution.js.map +1 -0
  71. package/dist/lib/bulkSelection.d.ts +43 -0
  72. package/dist/lib/bulkSelection.d.ts.map +1 -0
  73. package/dist/lib/bulkSelection.js +70 -0
  74. package/dist/lib/bulkSelection.js.map +1 -0
  75. package/dist/lib/contactLinks.d.ts +15 -0
  76. package/dist/lib/contactLinks.d.ts.map +1 -0
  77. package/dist/lib/contactLinks.js +22 -0
  78. package/dist/lib/contactLinks.js.map +1 -0
  79. package/dist/pages/BulkJobsPage.d.ts +3 -0
  80. package/dist/pages/BulkJobsPage.d.ts.map +1 -0
  81. package/dist/pages/BulkJobsPage.js +92 -0
  82. package/dist/pages/BulkJobsPage.js.map +1 -0
  83. package/dist/pages/CompaniesPage.d.ts.map +1 -1
  84. package/dist/pages/CompaniesPage.js +9 -5
  85. package/dist/pages/CompaniesPage.js.map +1 -1
  86. package/dist/pages/CompanyDetail.d.ts.map +1 -1
  87. package/dist/pages/CompanyDetail.js +4 -3
  88. package/dist/pages/CompanyDetail.js.map +1 -1
  89. package/dist/pages/DealsPage.d.ts.map +1 -1
  90. package/dist/pages/DealsPage.js +15 -4
  91. package/dist/pages/DealsPage.js.map +1 -1
  92. package/dist/pages/DecisionsPage.d.ts.map +1 -1
  93. package/dist/pages/DecisionsPage.js +11 -1
  94. package/dist/pages/DecisionsPage.js.map +1 -1
  95. package/dist/pages/EnquiriesPage.d.ts.map +1 -1
  96. package/dist/pages/EnquiriesPage.js +15 -6
  97. package/dist/pages/EnquiriesPage.js.map +1 -1
  98. package/dist/pages/EventDetail.d.ts.map +1 -1
  99. package/dist/pages/EventDetail.js +14 -6
  100. package/dist/pages/EventDetail.js.map +1 -1
  101. package/dist/pages/EventsPage.d.ts.map +1 -1
  102. package/dist/pages/EventsPage.js +22 -5
  103. package/dist/pages/EventsPage.js.map +1 -1
  104. package/dist/pages/FormsPage.d.ts.map +1 -1
  105. package/dist/pages/FormsPage.js +2 -2
  106. package/dist/pages/FormsPage.js.map +1 -1
  107. package/dist/pages/FundraisingPage.d.ts.map +1 -1
  108. package/dist/pages/FundraisingPage.js +15 -4
  109. package/dist/pages/FundraisingPage.js.map +1 -1
  110. package/dist/pages/HiringPage.d.ts.map +1 -1
  111. package/dist/pages/HiringPage.js +2 -1
  112. package/dist/pages/HiringPage.js.map +1 -1
  113. package/dist/pages/ListDetail.d.ts.map +1 -1
  114. package/dist/pages/ListDetail.js +39 -7
  115. package/dist/pages/ListDetail.js.map +1 -1
  116. package/dist/pages/ListsPage.d.ts.map +1 -1
  117. package/dist/pages/ListsPage.js +2 -1
  118. package/dist/pages/ListsPage.js.map +1 -1
  119. package/dist/pages/OpportunitiesPage.d.ts.map +1 -1
  120. package/dist/pages/OpportunitiesPage.js +15 -6
  121. package/dist/pages/OpportunitiesPage.js.map +1 -1
  122. package/dist/pages/PartnershipsPage.d.ts.map +1 -1
  123. package/dist/pages/PartnershipsPage.js +15 -4
  124. package/dist/pages/PartnershipsPage.js.map +1 -1
  125. package/dist/pages/PeoplePage.d.ts.map +1 -1
  126. package/dist/pages/PeoplePage.js +10 -9
  127. package/dist/pages/PeoplePage.js.map +1 -1
  128. package/dist/pages/PlanningPage.d.ts.map +1 -1
  129. package/dist/pages/PlanningPage.js +15 -4
  130. package/dist/pages/PlanningPage.js.map +1 -1
  131. package/dist/pages/RoleDetail.d.ts.map +1 -1
  132. package/dist/pages/RoleDetail.js +12 -4
  133. package/dist/pages/RoleDetail.js.map +1 -1
  134. package/dist/pages/dashboard/sections.d.ts.map +1 -1
  135. package/dist/pages/dashboard/sections.js +8 -10
  136. package/dist/pages/dashboard/sections.js.map +1 -1
  137. package/dist/pages/forms/BlockedSendersPage.d.ts +10 -0
  138. package/dist/pages/forms/BlockedSendersPage.d.ts.map +1 -0
  139. package/dist/pages/forms/BlockedSendersPage.js +65 -0
  140. package/dist/pages/forms/BlockedSendersPage.js.map +1 -0
  141. package/dist/pages/forms/MarkSpamPanel.d.ts +19 -0
  142. package/dist/pages/forms/MarkSpamPanel.d.ts.map +1 -0
  143. package/dist/pages/forms/MarkSpamPanel.js +62 -0
  144. package/dist/pages/forms/MarkSpamPanel.js.map +1 -0
  145. package/dist/pages/forms/SubmissionDetail.d.ts.map +1 -1
  146. package/dist/pages/forms/SubmissionDetail.js +41 -11
  147. package/dist/pages/forms/SubmissionDetail.js.map +1 -1
  148. package/dist/pages/forms/SubmissionsTable.d.ts +1 -1
  149. package/dist/pages/forms/SubmissionsTable.d.ts.map +1 -1
  150. package/dist/pages/forms/SubmissionsTable.js +6 -4
  151. package/dist/pages/forms/SubmissionsTable.js.map +1 -1
  152. package/dist/pages/forms/markSpamChoices.d.ts +51 -0
  153. package/dist/pages/forms/markSpamChoices.d.ts.map +1 -0
  154. package/dist/pages/forms/markSpamChoices.js +96 -0
  155. package/dist/pages/forms/markSpamChoices.js.map +1 -0
  156. package/dist/pages/positionDirectory.d.ts +5 -0
  157. package/dist/pages/positionDirectory.d.ts.map +1 -1
  158. package/dist/pages/positionDirectory.js +11 -3
  159. package/dist/pages/positionDirectory.js.map +1 -1
  160. package/dist/registry/context.d.ts +3 -1
  161. package/dist/registry/context.d.ts.map +1 -1
  162. package/dist/registry/context.js +4 -0
  163. package/dist/registry/context.js.map +1 -1
  164. package/dist/registry/contributions.d.ts +23 -0
  165. package/dist/registry/contributions.d.ts.map +1 -1
  166. package/dist/registry/contributions.js.map +1 -1
  167. package/dist/registry/registry.d.ts +4 -1
  168. package/dist/registry/registry.d.ts.map +1 -1
  169. package/dist/registry/registry.js +6 -0
  170. package/dist/registry/registry.js.map +1 -1
  171. package/dist/registry/visibleNav.d.ts.map +1 -1
  172. package/dist/registry/visibleNav.js +1 -0
  173. package/dist/registry/visibleNav.js.map +1 -1
  174. package/package.json +3 -3
  175. package/src/api/resources/account.ts +20 -0
  176. package/src/api/resources/bulkActions.ts +267 -0
  177. package/src/api/resources/forms.ts +135 -0
  178. package/src/app/KelpieApp.tsx +5 -0
  179. package/src/components/ActivitiesPanel.tsx +3 -14
  180. package/src/components/BulkActions.tsx +961 -0
  181. package/src/components/BulkParamFields.tsx +524 -0
  182. package/src/components/CellLinks.tsx +138 -0
  183. package/src/components/CustomFieldsPanel.tsx +6 -2
  184. package/src/components/DataTable.tsx +142 -2
  185. package/src/components/NotesPanel.tsx +2 -17
  186. package/src/components/PhonesField.tsx +2 -4
  187. package/src/components/Shell.tsx +23 -6
  188. package/src/components/TagInput.tsx +5 -0
  189. package/src/components/bulkActionParams.ts +405 -0
  190. package/src/components/bulkActionSummary.ts +104 -0
  191. package/src/components/bulkJobStatus.ts +11 -0
  192. package/src/index.ts +3 -0
  193. package/src/lib/attribution.ts +59 -0
  194. package/src/lib/bulkSelection.ts +128 -0
  195. package/src/lib/contactLinks.ts +25 -0
  196. package/src/pages/BulkJobsPage.tsx +206 -0
  197. package/src/pages/CompaniesPage.tsx +21 -6
  198. package/src/pages/CompanyDetail.tsx +4 -3
  199. package/src/pages/DealsPage.tsx +30 -2
  200. package/src/pages/DecisionsPage.tsx +21 -1
  201. package/src/pages/EnquiriesPage.tsx +33 -5
  202. package/src/pages/EventDetail.tsx +43 -16
  203. package/src/pages/EventsPage.tsx +35 -4
  204. package/src/pages/FormsPage.tsx +7 -1
  205. package/src/pages/FundraisingPage.tsx +30 -2
  206. package/src/pages/HiringPage.tsx +6 -1
  207. package/src/pages/ListDetail.tsx +69 -5
  208. package/src/pages/ListsPage.tsx +6 -1
  209. package/src/pages/OpportunitiesPage.tsx +33 -5
  210. package/src/pages/PartnershipsPage.tsx +30 -2
  211. package/src/pages/PeoplePage.tsx +26 -21
  212. package/src/pages/PlanningPage.tsx +65 -24
  213. package/src/pages/RoleDetail.tsx +35 -7
  214. package/src/pages/dashboard/sections.tsx +13 -14
  215. package/src/pages/forms/BlockedSendersPage.tsx +155 -0
  216. package/src/pages/forms/MarkSpamPanel.tsx +193 -0
  217. package/src/pages/forms/SubmissionDetail.tsx +73 -18
  218. package/src/pages/forms/SubmissionsTable.tsx +7 -5
  219. package/src/pages/forms/markSpamChoices.ts +141 -0
  220. package/src/pages/positionDirectory.ts +16 -4
  221. package/src/registry/context.ts +6 -0
  222. package/src/registry/contributions.ts +25 -0
  223. package/src/registry/registry.ts +12 -0
  224. package/src/registry/visibleNav.ts +1 -0
@@ -0,0 +1,128 @@
1
+ import type { BulkSelection } from '@kelpie/schemas'
2
+ import { useState } from 'react'
3
+
4
+ /**
5
+ * Which rows of a list page a bulk action applies to.
6
+ *
7
+ * Two modes, matching the two selections the API takes. `ids` is rows ticked
8
+ * one by one, on this page or others. `filter` is every record matching the
9
+ * page's filter, less the rows unticked since.
10
+ *
11
+ * Changing the filter, the sort or the view clears the selection: the rows
12
+ * the reader ticked may no longer be the rows on screen. Paging does not, so
13
+ * a reader can tick rows on several pages.
14
+ */
15
+
16
+ /** The page's filter, with the keys its list `GET` takes. */
17
+ export type BulkFilter = Readonly<Record<string, string | boolean | readonly string[]>>
18
+
19
+ export type BulkSelectionState =
20
+ | { readonly mode: 'ids'; readonly ids: ReadonlySet<string> }
21
+ | { readonly mode: 'filter'; readonly exceptIds: ReadonlySet<string> }
22
+
23
+ const EMPTY: BulkSelectionState = { mode: 'ids', ids: new Set() }
24
+
25
+ export interface BulkSelectionController {
26
+ readonly state: BulkSelectionState
27
+ /** The filter a filter selection names. The page's current filter. */
28
+ readonly filter: BulkFilter
29
+ readonly hasSelection: boolean
30
+ /** Ticked rows in id mode. Undefined in filter mode, where only a preview knows the count. */
31
+ readonly idCount: number | undefined
32
+ /** The selection as the API takes it, or undefined when nothing is selected. */
33
+ readonly selection: BulkSelection | undefined
34
+ readonly isSelected: (id: string) => boolean
35
+ readonly onToggle: (id: string) => void
36
+ readonly onTogglePage: (ids: readonly string[], selected: boolean) => void
37
+ readonly selectAllMatching: () => void
38
+ readonly clear: () => void
39
+ }
40
+
41
+ export interface BulkSelectionOptions {
42
+ readonly filter: BulkFilter
43
+ /** Other values whose change clears the selection: the sort, the view. */
44
+ readonly resetOn?: readonly unknown[]
45
+ }
46
+
47
+ function toggled(set: ReadonlySet<string>, id: string): ReadonlySet<string> {
48
+ const next = new Set(set)
49
+
50
+ if (next.has(id)) {
51
+ next.delete(id)
52
+ } else {
53
+ next.add(id)
54
+ }
55
+
56
+ return next
57
+ }
58
+
59
+ function withPage(set: ReadonlySet<string>, ids: readonly string[], add: boolean): ReadonlySet<string> {
60
+ const next = new Set(set)
61
+
62
+ for (const id of ids) {
63
+ if (add) {
64
+ next.add(id)
65
+ } else {
66
+ next.delete(id)
67
+ }
68
+ }
69
+
70
+ return next
71
+ }
72
+
73
+ export function useBulkSelection({ filter, resetOn = [] }: BulkSelectionOptions): BulkSelectionController {
74
+ const [state, setState] = useState<BulkSelectionState>(EMPTY)
75
+ const resetKey = JSON.stringify([filter, resetOn])
76
+ const [seenKey, setSeenKey] = useState(resetKey)
77
+
78
+ // Reset during render, not in an effect, so no frame draws the old ticks
79
+ // against the new rows.
80
+ if (seenKey !== resetKey) {
81
+ setSeenKey(resetKey)
82
+ setState(EMPTY)
83
+ }
84
+
85
+ const isSelected = (id: string): boolean =>
86
+ state.mode === 'ids' ? state.ids.has(id) : !state.exceptIds.has(id)
87
+
88
+ const hasSelection = state.mode === 'filter' || state.ids.size > 0
89
+
90
+ const selection: BulkSelection | undefined =
91
+ state.mode === 'filter'
92
+ ? {
93
+ filter,
94
+ ...(state.exceptIds.size > 0 ? { exceptIds: [...state.exceptIds] } : {}),
95
+ }
96
+ : state.ids.size > 0
97
+ ? { ids: [...state.ids] }
98
+ : undefined
99
+
100
+ return {
101
+ state,
102
+ filter,
103
+ hasSelection,
104
+ idCount: state.mode === 'ids' ? state.ids.size : undefined,
105
+ selection,
106
+ isSelected,
107
+ onToggle: (id) => {
108
+ setState((current) =>
109
+ current.mode === 'ids'
110
+ ? { mode: 'ids', ids: toggled(current.ids, id) }
111
+ : { mode: 'filter', exceptIds: toggled(current.exceptIds, id) },
112
+ )
113
+ },
114
+ onTogglePage: (ids, selected) => {
115
+ setState((current) =>
116
+ current.mode === 'ids'
117
+ ? { mode: 'ids', ids: withPage(current.ids, ids, selected) }
118
+ : { mode: 'filter', exceptIds: withPage(current.exceptIds, ids, !selected) },
119
+ )
120
+ },
121
+ selectAllMatching: () => {
122
+ setState({ mode: 'filter', exceptIds: new Set() })
123
+ },
124
+ clear: () => {
125
+ setState(EMPTY)
126
+ },
127
+ }
128
+ }
@@ -0,0 +1,25 @@
1
+ /**
2
+ * `tel:` and `mailto:` and website hrefs for values a record stores as text.
3
+ * Kept in one place so a list cell and a detail field dial the same number.
4
+ */
5
+
6
+ /** Strips everything a dialer cannot use, keeping a leading `+`. */
7
+ export function telHref(phone: string): string {
8
+ return `tel:${phone.replace(/[^\d+]/gu, '')}`
9
+ }
10
+
11
+ export function mailtoHref(email: string): string {
12
+ return `mailto:${email}`
13
+ }
14
+
15
+ /**
16
+ * A company domain is stored bare (`example.com`), but an import can carry a
17
+ * full URL. Only http and https are linked: any other scheme in the stored
18
+ * value is treated as part of a host and gets `https://` in front, so a
19
+ * `javascript:` value can never become a live link.
20
+ */
21
+ export function websiteHref(domain: string): string {
22
+ const trimmed = domain.trim()
23
+
24
+ return /^https?:\/\//iu.test(trimmed) ? trimmed : `https://${trimmed}`
25
+ }
@@ -0,0 +1,206 @@
1
+ import { BULK_JOB_STATUSES, RECORD_TARGET_TYPE_LABELS } from '@kelpie/schemas'
2
+ import type { BulkActionTargetType, BulkJob, BulkJobStatus } from '@kelpie/schemas'
3
+ import { useState } from 'react'
4
+ import { Link, useNavigate, useParams } from 'react-router'
5
+
6
+ import { useTimezone } from '../api/resources/account.ts'
7
+ import {
8
+ isBulkJobFinal,
9
+ useBulkActionCatalog,
10
+ useBulkJob,
11
+ useBulkJobs,
12
+ useCancelBulkJob,
13
+ } from '../api/resources/bulkActions.ts'
14
+ import { BulkError, BulkJobDownload, JobCounts } from '../components/BulkActions.tsx'
15
+ import { STATUS_TEXT } from '../components/bulkJobStatus.ts'
16
+ import { DataTable } from '../components/DataTable.tsx'
17
+ import type { Column } from '../components/DataTable.tsx'
18
+ import { PageHeader } from '../components/PageHeader.tsx'
19
+ import { Paginator } from '../components/Paginator.tsx'
20
+ import { ErrorPanel, LoadingPanel, NotFoundPanel } from '../components/QueryState.tsx'
21
+ import { formatDateTime } from '../lib/dates.ts'
22
+
23
+ /**
24
+ * Bulk jobs: every bulk action the reader may see, newest first, and one job
25
+ * with its counts, its failed records, Cancel while it works, and its file
26
+ * when it made one.
27
+ *
28
+ * Read through `GET /v1/bulk-actions`, the same list an agent reads. The job
29
+ * list does not poll; one job does, until it ends.
30
+ */
31
+
32
+ const TYPE_LABELS: Readonly<Record<BulkActionTargetType, string>> = {
33
+ ...RECORD_TARGET_TYPE_LABELS,
34
+ decision: 'Decision',
35
+ plan_item: 'Plan item',
36
+ }
37
+
38
+ const STATUS_FILTER_LABELS: Readonly<Record<BulkJobStatus, string>> = {
39
+ queued: 'Queued',
40
+ running: 'Running',
41
+ completed: 'Done',
42
+ completed_with_errors: 'Done, with failures',
43
+ failed: 'Stopped',
44
+ cancelled: 'Cancelled',
45
+ }
46
+
47
+ function isStatus(value: string): value is BulkJobStatus {
48
+ return (BULK_JOB_STATUSES as readonly string[]).includes(value)
49
+ }
50
+
51
+ /** The action's label from its type's catalog. The key while that loads, or for an action no longer offered. */
52
+ function ActionLabel({ job }: { readonly job: BulkJob }): React.JSX.Element {
53
+ const catalog = useBulkActionCatalog(job.targetType)
54
+ const entry = catalog.actions.find((action) => action.key === job.action)
55
+
56
+ return <>{entry?.label ?? job.action}</>
57
+ }
58
+
59
+ export function BulkJobsPage(): React.JSX.Element {
60
+ const [status, setStatus] = useState<BulkJobStatus | undefined>(undefined)
61
+ const jobs = useBulkJobs(status)
62
+ const navigate = useNavigate()
63
+ const timezone = useTimezone()
64
+
65
+ const columns: readonly Column<BulkJob>[] = [
66
+ {
67
+ key: 'action',
68
+ header: 'Action',
69
+ render: (job) => (
70
+ <Link to={`/bulk-jobs/${job.id}`} className="font-medium text-ink hover:text-accent">
71
+ <ActionLabel job={job} />
72
+ </Link>
73
+ ),
74
+ },
75
+ { key: 'type', header: 'Records', render: (job) => TYPE_LABELS[job.targetType] },
76
+ { key: 'status', header: 'Status', render: (job) => STATUS_TEXT[job.status] },
77
+ {
78
+ key: 'counts',
79
+ header: 'Counts',
80
+ render: (job) =>
81
+ `${job.processedCount.toLocaleString()} of ${job.totalCount.toLocaleString()} · ${job.succeededCount.toLocaleString()} succeeded · ${job.skippedCount.toLocaleString()} skipped · ${job.failedCount.toLocaleString()} failed`,
82
+ },
83
+ { key: 'created', header: 'Created', render: (job) => formatDateTime(job.createdAt, timezone) },
84
+ ]
85
+
86
+ return (
87
+ <div className="animate-fade-in">
88
+ <PageHeader title="Bulk jobs" description="Actions run on many records at once, newest first." />
89
+
90
+ <label className="mb-3 inline-flex items-center gap-2 text-[12px] font-medium text-ink-muted">
91
+ Status
92
+ <select
93
+ value={status ?? ''}
94
+ onChange={(event) => {
95
+ setStatus(isStatus(event.target.value) ? event.target.value : undefined)
96
+ }}
97
+ className="rounded-md border border-border bg-surface px-2 py-1 text-[13px] text-ink outline-none focus:border-accent"
98
+ >
99
+ <option value="">Any status</option>
100
+ {BULK_JOB_STATUSES.map((value) => (
101
+ <option key={value} value={value}>
102
+ {STATUS_FILTER_LABELS[value]}
103
+ </option>
104
+ ))}
105
+ </select>
106
+ </label>
107
+
108
+ {jobs.error !== null ? (
109
+ <ErrorPanel error={jobs.error} />
110
+ ) : jobs.isLoading ? (
111
+ <LoadingPanel label="Loading bulk jobs…" />
112
+ ) : (
113
+ <>
114
+ <Paginator list={jobs} placement="top" />
115
+ <DataTable
116
+ columns={columns}
117
+ rows={jobs.records}
118
+ getRowId={(job) => job.id}
119
+ onRowClick={(job) => {
120
+ void navigate(`/bulk-jobs/${job.id}`)
121
+ }}
122
+ emptyMessage={status === undefined ? 'No bulk jobs yet' : 'No bulk jobs have this status'}
123
+ emptyDescription={
124
+ status === undefined
125
+ ? 'Select records on a list page and choose an action to start one.'
126
+ : 'Choose another status.'
127
+ }
128
+ />
129
+ <Paginator list={jobs} placement="bottom" />
130
+ </>
131
+ )}
132
+ </div>
133
+ )
134
+ }
135
+
136
+ export function BulkJobDetail(): React.JSX.Element {
137
+ const { id } = useParams()
138
+ const watched = useBulkJob(id)
139
+ const cancel = useCancelBulkJob()
140
+ const timezone = useTimezone()
141
+ const job = watched.record
142
+
143
+ if (watched.isNotFound) {
144
+ return <NotFoundPanel label="Bulk job" backTo="/bulk-jobs" />
145
+ }
146
+
147
+ if (watched.error !== null) {
148
+ return <ErrorPanel error={watched.error} />
149
+ }
150
+
151
+ if (watched.isLoading || job === undefined) {
152
+ return <LoadingPanel label="Loading bulk job…" />
153
+ }
154
+
155
+ const working = !isBulkJobFinal(job.status)
156
+
157
+ return (
158
+ <div className="animate-fade-in mx-auto max-w-3xl">
159
+ <Link
160
+ to="/bulk-jobs"
161
+ className="mb-4 inline-flex text-[12px] font-medium text-ink-muted transition hover:text-accent"
162
+ >
163
+ ← Bulk jobs
164
+ </Link>
165
+
166
+ <div className="mb-4 flex flex-wrap items-start gap-3">
167
+ <div className="min-w-[12rem] flex-1">
168
+ <h1 className="text-[22px] font-semibold tracking-tight text-ink">
169
+ <ActionLabel job={job} />
170
+ </h1>
171
+ <p className="mt-1 text-[12px] text-ink-muted">
172
+ {TYPE_LABELS[job.targetType]} records · created {formatDateTime(job.createdAt, timezone)}
173
+ {job.startedAt !== null && ` · started ${formatDateTime(job.startedAt, timezone)}`}
174
+ </p>
175
+ </div>
176
+ <div className="flex flex-wrap items-center gap-2">
177
+ {job.downloadUrl !== null && <BulkJobDownload job={job} />}
178
+ {working && (
179
+ <button
180
+ type="button"
181
+ disabled={cancel.isPending}
182
+ onClick={() => {
183
+ cancel.run(job.id)
184
+ }}
185
+ className="rounded-md border border-border px-2.5 py-1 text-[12px] font-medium text-ink-muted transition hover:border-danger hover:text-danger disabled:opacity-50"
186
+ >
187
+ {cancel.isPending ? 'Cancelling…' : 'Cancel'}
188
+ </button>
189
+ )}
190
+ </div>
191
+ </div>
192
+
193
+ <section aria-label="Progress" className="rounded-md border border-border bg-surface-raised px-4 py-3">
194
+ <p className="text-[13px] font-semibold text-ink" aria-live="polite">
195
+ {STATUS_TEXT[job.status]}
196
+ </p>
197
+ {cancel.error !== null && (
198
+ <div className="mt-2">
199
+ <BulkError error={cancel.error} />
200
+ </div>
201
+ )}
202
+ <JobCounts job={job} />
203
+ </section>
204
+ </div>
205
+ )
206
+ }
@@ -5,8 +5,10 @@ import { useNavigate } from 'react-router'
5
5
 
6
6
  import { useTimezone } from '../api/resources/account.ts'
7
7
  import { useCompanies, useCreateCompany } from '../api/resources/companies.ts'
8
+ import { RecordLink, WebsiteLink } from '../components/CellLinks.tsx'
8
9
  import { AddRecordPanel } from '../components/AddRecordPanel.tsx'
9
10
  import type { AddRecordValues } from '../components/AddRecordPanel.tsx'
11
+ import { BulkActions } from '../components/BulkActions.tsx'
10
12
  import { Chip } from '../components/Chip.tsx'
11
13
  import type { ChipTone } from '../components/Chip.tsx'
12
14
  import { ColumnPicker } from '../components/ColumnPicker.tsx'
@@ -15,6 +17,7 @@ import type { Column } from '../components/DataTable.tsx'
15
17
  import { FilterBar, PageHeader } from '../components/PageHeader.tsx'
16
18
  import { Paginator } from '../components/Paginator.tsx'
17
19
  import { ErrorPanel, LoadingPanel } from '../components/QueryState.tsx'
20
+ import { useBulkSelection } from '../lib/bulkSelection.ts'
18
21
  import { formatDate } from '../lib/dates.ts'
19
22
  import { useListView } from '../lib/listView.ts'
20
23
  import { serverSortOnly } from '../lib/sort.ts'
@@ -49,6 +52,7 @@ export function CompaniesPage(): React.JSX.Element {
49
52
  term: hasFilter ? term.trim() : undefined,
50
53
  sort: serverSortOnly(sort, SERVER_SORT_KEYS),
51
54
  })
55
+ const bulk = useBulkSelection({ filter: hasFilter ? { q: term.trim() } : {}, resetOn: [sort] })
52
56
  const headcounts = useCompanyHeadcounts(companies.records.map((company) => company.id))
53
57
  const createCompany = useCreateCompany()
54
58
 
@@ -67,15 +71,17 @@ export function CompaniesPage(): React.JSX.Element {
67
71
  key: 'name',
68
72
  header: 'Name',
69
73
  sortKey: 'name',
70
- render: (company) => <span className="font-medium">{company.name}</span>,
74
+ render: (company) => (
75
+ <RecordLink to={`/companies/${company.id}`} className="font-medium">
76
+ {company.name}
77
+ </RecordLink>
78
+ ),
71
79
  },
72
80
  {
73
81
  key: 'domain',
74
82
  header: 'Domain',
75
83
  getSortValue: (company) => company.domain,
76
- render: (company) => (
77
- <span className="font-mono text-[12px] text-ink-muted">{company.domain ?? '—'}</span>
78
- ),
84
+ render: (company) => <WebsiteLink domain={company.domain} />,
79
85
  },
80
86
  {
81
87
  key: 'industry',
@@ -113,7 +119,7 @@ export function CompaniesPage(): React.JSX.Element {
113
119
  key: 'sizeBand',
114
120
  header: 'Size',
115
121
  getSortValue: (company) => company.sizeBand,
116
- render: (company) => company.sizeBand,
122
+ render: (company) => company.sizeBand ?? '—',
117
123
  },
118
124
  {
119
125
  key: 'icp',
@@ -212,7 +218,15 @@ export function CompaniesPage(): React.JSX.Element {
212
218
  />
213
219
  }
214
220
  />
215
- <FilterBar value={term} onChange={setTerm} placeholder="Filter by name, type, tags…" />
221
+ <BulkActions
222
+ targetType="company"
223
+ selection={bulk}
224
+ pageIds={companies.records.map((company) => company.id)}
225
+ hasNextPage={companies.hasNext}
226
+ noun={{ one: 'company', many: 'companies' }}
227
+ >
228
+ <FilterBar value={term} onChange={setTerm} placeholder="Filter by name, type, tags…" />
229
+ </BulkActions>
216
230
 
217
231
  {adding && (
218
232
  <AddRecordPanel
@@ -260,6 +274,7 @@ export function CompaniesPage(): React.JSX.Element {
260
274
  sort={sort}
261
275
  onSortChange={setSort}
262
276
  visibleColumnKeys={listView.visibleKeys}
277
+ selection={{ ...bulk, rowLabel: (company) => company.name }}
263
278
  />
264
279
  {!headcounts.isComplete && !headcounts.isLoading && (
265
280
  <p className="mt-2 text-[11px] text-ink-faint">
@@ -70,7 +70,8 @@ import { toOptions, toTags } from './fields.ts'
70
70
  */
71
71
 
72
72
  const STAGE_OPTIONS = toOptions(COMPANY_STAGES)
73
- const SIZE_OPTIONS = toOptions(SIZE_BANDS)
73
+ /** Leads with an empty choice, so a band set by mistake can be cleared. */
74
+ const SIZE_OPTIONS = [{ value: '', label: 'Not set' }, ...toOptions(SIZE_BANDS)]
74
75
  const ACCOUNT_OPTIONS = toOptions(ACCOUNT_TYPES)
75
76
  const ICP_OPTIONS = toOptions(ICP_FITS)
76
77
 
@@ -333,9 +334,9 @@ function CompanySidebar({
333
334
  </SidebarField>
334
335
  <SidebarField label="Size">
335
336
  <InlineEdit
336
- value={company.sizeBand}
337
+ value={company.sizeBand ?? ''}
337
338
  onChange={(value) => {
338
- patch({ sizeBand: value as SizeBand })
339
+ patch({ sizeBand: value.length > 0 ? (value as SizeBand) : null })
339
340
  }}
340
341
  options={SIZE_OPTIONS}
341
342
  displayClassName="not-italic text-[12px]"
@@ -10,6 +10,8 @@ import { MAX_PAGE_SIZE, usePlanItems } from '../api/resources/planItems.ts'
10
10
  import { useTimezone } from '../api/resources/account.ts'
11
11
  import { AddCompanyRecordPanel } from '../components/AddRecordPanel.tsx'
12
12
  import type { AddRecordValues } from '../components/AddRecordPanel.tsx'
13
+ import { CompanyLink, RecordLink } from '../components/CellLinks.tsx'
14
+ import { BulkActions } from '../components/BulkActions.tsx'
13
15
  import { Chip } from '../components/Chip.tsx'
14
16
  import type { ChipTone } from '../components/Chip.tsx'
15
17
  import { ColumnPicker } from '../components/ColumnPicker.tsx'
@@ -20,6 +22,7 @@ import { PageHeader } from '../components/PageHeader.tsx'
20
22
  import { Paginator } from '../components/Paginator.tsx'
21
23
  import { ErrorPanel, LoadingPanel } from '../components/QueryState.tsx'
22
24
  import { SegmentedControl } from '../components/SegmentedControl.tsx'
25
+ import { useBulkSelection } from '../lib/bulkSelection.ts'
23
26
  import { formatDate, formatDay } from '../lib/dates.ts'
24
27
  import { useListView } from '../lib/listView.ts'
25
28
  import { formatMoney } from '../lib/money.ts'
@@ -115,6 +118,15 @@ export function DealsPage(): React.JSX.Element {
115
118
  const visibleStageIds = new Set(visibleStages.map((stage) => stage.id))
116
119
  const visibleDeals = deals.records.filter((deal) => visibleStageIds.has(deal.stageId))
117
120
 
121
+ // The board has no checkboxes, so a selection lives only in the list, and
122
+ // switching view clears it. The Open scope is a filter on stage, so a
123
+ // filter selection names the open stages the list is showing.
124
+ const openStageIds = visibleStages.map((stage) => stage.id)
125
+ const bulk = useBulkSelection({
126
+ filter: scope === 'open' && openStageIds.length > 0 ? { stage_id: openStageIds } : {},
127
+ resetOn: [sort, view],
128
+ })
129
+
118
130
  // The next-step column asks about the deals on screen by id. `?target_id=`
119
131
  // takes at most one page of them (`docs/agents/api-and-webhooks.md`), so past that ceiling the rest
120
132
  // read as having no plan; the note under the table says so.
@@ -150,13 +162,19 @@ export function DealsPage(): React.JSX.Element {
150
162
  key: 'name',
151
163
  header: 'Deal',
152
164
  sortKey: 'name',
153
- render: (deal) => <span className="font-medium text-ink">{deal.name}</span>,
165
+ render: (deal) => (
166
+ <RecordLink to={`/deals/${deal.id}`} className="font-medium text-ink">
167
+ {deal.name}
168
+ </RecordLink>
169
+ ),
154
170
  },
155
171
  {
156
172
  key: 'company',
157
173
  header: 'Company',
158
174
  getSortValue: (deal) => companyNameById.get(deal.companyId) ?? null,
159
- render: (deal) => companyNameById.get(deal.companyId) ?? '—',
175
+ render: (deal) => (
176
+ <CompanyLink id={deal.companyId} name={companyNameById.get(deal.companyId)} />
177
+ ),
160
178
  },
161
179
  {
162
180
  key: 'stage',
@@ -431,6 +449,15 @@ export function DealsPage(): React.JSX.Element {
431
449
  <LoadingPanel label="Loading deals…" />
432
450
  ) : (
433
451
  <>
452
+ {view === 'list' && (
453
+ <BulkActions
454
+ targetType="deal"
455
+ selection={bulk}
456
+ pageIds={visibleDeals.map((deal) => deal.id)}
457
+ hasNextPage={deals.hasNext}
458
+ noun={{ one: 'deal', many: 'deals' }}
459
+ />
460
+ )}
434
461
  {view === 'list' && <Paginator list={deals} placement="top" />}
435
462
  {view === 'columns' ? (
436
463
  <KanbanBoard
@@ -488,6 +515,7 @@ export function DealsPage(): React.JSX.Element {
488
515
  listView.setSort(next)
489
516
  }}
490
517
  visibleColumnKeys={listView.visibleKeys}
518
+ selection={{ ...bulk, rowLabel: (deal) => deal.name }}
491
519
  />
492
520
  )}
493
521
  {updateDeal.error !== null && (
@@ -12,6 +12,7 @@ import { useOpportunities } from '../api/resources/opportunities.ts'
12
12
  import { usePartnerships } from '../api/resources/partnerships.ts'
13
13
  import { usePeople } from '../api/resources/people.ts'
14
14
  import { useRaises } from '../api/resources/raises.ts'
15
+ import { BulkActions } from '../components/BulkActions.tsx'
15
16
  import { ColumnPicker } from '../components/ColumnPicker.tsx'
16
17
  import { DataTable } from '../components/DataTable.tsx'
17
18
  import type { Column } from '../components/DataTable.tsx'
@@ -23,6 +24,7 @@ import {
23
24
  import { FilterBar, PageHeader } from '../components/PageHeader.tsx'
24
25
  import { Paginator } from '../components/Paginator.tsx'
25
26
  import { ErrorPanel, LoadingPanel } from '../components/QueryState.tsx'
27
+ import { useBulkSelection } from '../lib/bulkSelection.ts'
26
28
  import { formatDate } from '../lib/dates.ts'
27
29
  import { serverSortOnly } from '../lib/sort.ts'
28
30
  import { useListView } from '../lib/listView.ts'
@@ -146,6 +148,10 @@ export function DecisionsPage(): React.JSX.Element {
146
148
  term: term.trim().length > 0 ? term.trim() : undefined,
147
149
  sort: serverSortOnly(sort, SERVER_SORT_KEYS),
148
150
  })
151
+ const bulk = useBulkSelection({
152
+ filter: term.trim().length > 0 ? { q: term.trim() } : {},
153
+ resetOn: [sort],
154
+ })
149
155
  const confirmDecision = useConfirmDecision()
150
156
  const directory = useTargetDirectory()
151
157
  const members = useMembers()
@@ -261,7 +267,15 @@ export function DecisionsPage(): React.JSX.Element {
261
267
  />
262
268
  }
263
269
  />
264
- <FilterBar value={term} onChange={setTerm} placeholder="Filter decisions…" />
270
+ <BulkActions
271
+ targetType="decision"
272
+ selection={bulk}
273
+ pageIds={decisions.records.map((decision) => decision.id)}
274
+ hasNextPage={decisions.hasNext}
275
+ noun={{ one: 'decision', many: 'decisions' }}
276
+ >
277
+ <FilterBar value={term} onChange={setTerm} placeholder="Filter decisions…" />
278
+ </BulkActions>
265
279
 
266
280
  <ConfirmedAnnouncement count={confirmDecision.confirmedCount} />
267
281
  {confirmDecision.error !== null && (
@@ -285,6 +299,7 @@ export function DecisionsPage(): React.JSX.Element {
285
299
  sort={sort}
286
300
  onSortChange={setSort}
287
301
  visibleColumnKeys={listView.visibleKeys}
302
+ selection={{ ...bulk, rowLabel: (decision) => shortLabel(decision.body) }}
288
303
  />
289
304
  <Paginator list={decisions} />
290
305
  </>
@@ -292,3 +307,8 @@ export function DecisionsPage(): React.JSX.Element {
292
307
  </div>
293
308
  )
294
309
  }
310
+
311
+ /** A decision's body is prose, so a checkbox label takes its opening words. */
312
+ function shortLabel(body: string): string {
313
+ return body.length > 60 ? `${body.slice(0, 60)}…` : body
314
+ }