@startsimpli/integrations 0.2.134 → 0.2.135

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 (31) hide show
  1. package/package.json +2 -2
  2. package/src/__tests__/corpus-planning.test.tsx +13 -3
  3. package/src/__tests__/corpus-tracker.test.tsx +53 -69
  4. package/src/__tests__/focus-standings.test.tsx +3 -1
  5. package/src/__tests__/home-brief.test.tsx +84 -0
  6. package/src/__tests__/project-surfaces.test.tsx +1 -1
  7. package/src/__tests__/work-groups.test.ts +181 -0
  8. package/src/components/index.ts +1 -0
  9. package/src/components/pages/ConnectionsPage.tsx +7 -1402
  10. package/src/components/pages/PlanningPage.tsx +129 -67
  11. package/src/components/pages/TrackerPage.tsx +174 -149
  12. package/src/components/pages/connections/CapabilityPicker.tsx +75 -0
  13. package/src/components/pages/connections/CatalogCard.tsx +300 -0
  14. package/src/components/pages/connections/ConnectionCard.tsx +489 -0
  15. package/src/components/pages/connections/ConnectionForms.tsx +215 -0
  16. package/src/components/pages/connections/MemberPolicyToggle.tsx +106 -0
  17. package/src/components/pages/connections/bound-api.ts +175 -0
  18. package/src/components/pages/connections/copy.ts +74 -0
  19. package/src/components/pages/home/BriefCard.tsx +84 -0
  20. package/src/components/pages/home/CompactItemRow.tsx +61 -0
  21. package/src/components/pages/home/DueAcrossProjects.tsx +74 -0
  22. package/src/components/pages/home/HomeBriefPage.tsx +112 -0
  23. package/src/components/pages/home/RecentNotes.tsx +69 -0
  24. package/src/components/pages/home/index.ts +10 -0
  25. package/src/components/pages/home/useProjectNames.ts +23 -0
  26. package/src/components/pages/work-items.tsx +15 -9
  27. package/src/corpus/due-groups.ts +81 -0
  28. package/src/corpus/focus-overview.ts +54 -0
  29. package/src/corpus/index.ts +10 -0
  30. package/src/corpus/note-actions.ts +44 -0
  31. package/src/corpus/tracker-groups.ts +84 -0
@@ -34,12 +34,14 @@ import * as React from 'react';
34
34
  import { displayProgress, focusStatusLabel, standingLabel } from '../../corpus/planning';
35
35
  import { FocusDocuments } from '../FocusDocuments';
36
36
  import {
37
- UnfilteredNotice,
38
37
  WorkItemRow,
39
38
  compareForScreen,
40
39
  failureMessage,
41
40
  isOverdue,
41
+ unfilteredMessage,
42
42
  } from './work-items';
43
+ import { dueLabel } from './home/CompactItemRow';
44
+ import { summarizeFocuses } from '../../corpus/focus-overview';
43
45
  import type {
44
46
  AuthoredItem,
45
47
  Commitment,
@@ -78,6 +80,9 @@ const DEFAULTS: Record<PlanningSlot, string> = {
78
80
  /** Which filters this screen asks for, and therefore owes a confession about. */
79
81
  const PLANNING_FILTER_KEYS = ['status', 'owner', 'dueBefore', 'focus'] as const;
80
82
 
83
+ /** Focuses listed before "Show all". */
84
+ const OVERVIEW_ROWS = 8;
85
+
81
86
  const FOCUS_STATUS_OPTIONS: FocusStatus[] = [
82
87
  'draft', 'active', 'on_track', 'at_risk', 'off_track', 'completed', 'cancelled',
83
88
  ];
@@ -114,11 +119,13 @@ export interface PlanningPageProps {
114
119
  * effect, which sets state, which renders.
115
120
  */
116
121
  now?: number;
122
+ /** The reader's IANA zone, for "overdue" and "next due". Default UTC. */
123
+ timeZone?: string;
117
124
  classNames?: Partial<Record<PlanningSlot, string>>;
118
125
  }
119
126
 
120
127
  export function PlanningPage({
121
- api, scope, onOpenDocument, now, classNames = {},
128
+ api, scope, onOpenDocument, now, timeZone, classNames = {},
122
129
  }: PlanningPageProps) {
123
130
  const cn = { ...DEFAULTS, ...classNames };
124
131
 
@@ -246,51 +253,126 @@ export function PlanningPage({
246
253
  const selectedFocus = focuses.find((focus) => focus.id === selected) ?? null;
247
254
  const overdueCount = visible.filter((item) => isOverdue(item, clock)).length;
248
255
 
249
- return (
250
- <div className={cn.root}>
251
- <section className={cn.section}>
252
- <div className="flex flex-wrap items-center gap-2">
253
- <h2 className={cn.heading}>Focuses</h2>
254
- {canAuthor ? (
255
- <NewFocusForm
256
- classNames={cn}
257
- onCreate={async (draft) => {
258
- await apiRef.current.createFocus!(draft);
259
- refresh();
260
- }}
261
- onError={setError}
262
- />
256
+ // The overview: one row per ACTIVE focus, most urgent first. Over the open
257
+ // items already read (one server page), never a second walk.
258
+ const overview = React.useMemo(
259
+ () => summarizeFocuses(focuses, showDone ? [] : items, { now: clock, timeZone }),
260
+ [focuses, items, showDone, clock, timeZone],
261
+ );
262
+ const [showAll, setShowAll] = React.useState(false);
263
+ const [warningsOpen, setWarningsOpen] = React.useState(false);
264
+ const shown = showAll ? overview : overview.slice(0, OVERVIEW_ROWS);
265
+ const unfiled = React.useMemo(
266
+ () => items.filter((item) => !item.focusId && (item.status === 'open' || item.status === 'in_progress' || item.status === 'blocked')).length,
267
+ [items],
268
+ );
269
+ const warning = unfilteredMessage(PLANNING_FILTER_KEYS, applied, itemQuery);
270
+
271
+ const warningChip = warning ? (
272
+ <button
273
+ type="button"
274
+ className="ml-auto inline-flex items-center gap-1 rounded-full border border-amber-300 bg-amber-50 px-2.5 py-0.5 text-xs font-medium text-amber-900"
275
+ onClick={() => setWarningsOpen(true)}
276
+ >
277
+ 1 warning
278
+ </button>
279
+ ) : null;
280
+ const drawer = warning && warningsOpen ? (
281
+ <aside role="dialog" aria-label="Warnings" className="fixed inset-y-0 right-0 z-40 w-full max-w-sm overflow-y-auto border-l border-gray-200 bg-white p-4 shadow-xl">
282
+ <div className="flex items-center gap-2">
283
+ <h2 className={cn.heading}>Warnings</h2>
284
+ <button type="button" className={`ml-auto ${cn.secondaryButton}`} onClick={() => setWarningsOpen(false)}>Close</button>
285
+ </div>
286
+ <p className={`mt-3 ${cn.warning}`}>{warning}</p>
287
+ </aside>
288
+ ) : null;
289
+
290
+ if (!selectedFocus) {
291
+ return (
292
+ <div className={cn.root}>
293
+ <section className={cn.section} aria-label="Focuses">
294
+ <div className="flex flex-wrap items-center gap-2">
295
+ <h2 className={cn.heading}>
296
+ {loadingFocuses ? 'Loading…' : `${overview.length} active focus${overview.length === 1 ? '' : 'es'}`}
297
+ </h2>
298
+ {canAuthor ? (
299
+ <NewFocusForm
300
+ classNames={cn}
301
+ onCreate={async (draft) => {
302
+ await apiRef.current.createFocus!(draft);
303
+ refresh();
304
+ }}
305
+ onError={setError}
306
+ />
307
+ ) : null}
308
+ {warningChip}
309
+ </div>
310
+
311
+ {error ? <p className={cn.error} role="alert">{error}</p> : null}
312
+
313
+ {!loadingFocuses && focuses.length === 0 ? (
314
+ <p className={cn.muted}>
315
+ No focuses yet. A focus is something you are trying to achieve — a
316
+ launch, a quarter’s revenue, a client matter — and items get filed
317
+ under it.
318
+ </p>
263
319
  ) : null}
264
- </div>
265
320
 
266
- {error ? <p className={cn.error} role="alert">{error}</p> : null}
321
+ <ul className="divide-y divide-gray-100 rounded-lg border border-gray-200 bg-white">
322
+ {shown.map(({ focus, open, overdue, next, nextDue, nextDays }) => (
323
+ <li key={focus.id}>
324
+ <button
325
+ type="button"
326
+ className="flex w-full items-center gap-3 px-4 py-3 text-left hover:bg-gray-50"
327
+ onClick={() => setSelected(focus.id)}
328
+ >
329
+ <span className="min-w-0 flex-1">
330
+ <span className="block truncate text-sm font-medium text-gray-900">{focus.title}</span>
331
+ <span className="block truncate text-xs text-gray-500">
332
+ {next && nextDue
333
+ ? `Next: ${next.title} · ${dueLabel(nextDays, nextDue)}`
334
+ : open ? 'Nothing dated' : 'Nothing open'}
335
+ </span>
336
+ </span>
337
+ <span className={cn.badge}>{focusStatusLabel(focus.status)}</span>
338
+ <span className="w-16 shrink-0 text-right text-xs text-gray-600">{open} open</span>
339
+ <span className={`w-20 shrink-0 text-right text-xs ${overdue ? 'font-semibold text-red-700' : 'text-gray-400'}`}>
340
+ {overdue ? `${overdue} overdue` : 'on time'}
341
+ </span>
342
+ </button>
343
+ </li>
344
+ ))}
345
+ </ul>
267
346
 
268
- {loadingFocuses ? <p className={cn.muted}>Loading…</p> : null}
269
-
270
- {!loadingFocuses && focuses.length === 0 ? (
271
- <p className={cn.muted}>
272
- {/* Advice, and only when it is true. A workspace with no focuses is
273
- a workspace nobody has set one up in — distinct from a filtered
274
- view that came back empty, which is the distinction the tracker
275
- had to learn the hard way. */}
276
- No focuses yet. A focus is something you are trying to achieve — a
277
- launch, a quarter’s revenue, a client matter — and items get filed
278
- under it.
279
- </p>
280
- ) : null}
347
+ {overview.length > OVERVIEW_ROWS ? (
348
+ <button type="button" className="text-sm text-blue-700 underline" onClick={() => setShowAll((on) => !on)}>
349
+ {showAll ? 'Show fewer' : `Show all ${overview.length}`}
350
+ </button>
351
+ ) : null}
352
+ {unfiled ? <p className={cn.muted}>{unfiled} open item{unfiled === 1 ? ' is' : 's are'} not filed under a focus. Open the Tracker to see them.</p> : null}
353
+ </section>
354
+ {drawer}
355
+ </div>
356
+ );
357
+ }
281
358
 
282
- <div className="grid gap-3 sm:grid-cols-2 lg:grid-cols-3">
283
- {focuses.map((focus) => (
284
- <FocusCard
285
- key={focus.id}
286
- focus={focus}
287
- standing={standings[focus.id] ?? null}
288
- selected={focus.id === selected}
289
- classNames={cn}
290
- onSelect={() => setSelected(focus.id === selected ? null : focus.id)}
291
- />
292
- ))}
359
+ return (
360
+ <div className={cn.root}>
361
+ <section className={cn.section} aria-label="Focus">
362
+ <div className="flex flex-wrap items-center gap-2">
363
+ <button type="button" className={cn.secondaryButton} onClick={() => setSelected(null)}>
364
+ ← All focuses
365
+ </button>
366
+ {warningChip}
293
367
  </div>
368
+ <FocusCard
369
+ focus={selectedFocus}
370
+ standing={standings[selectedFocus.id] ?? null}
371
+ selected
372
+ classNames={cn}
373
+ onSelect={() => setSelected(null)}
374
+ />
375
+ {error ? <p className={cn.error} role="alert">{error}</p> : null}
294
376
  </section>
295
377
 
296
378
  <section className={cn.section} aria-label="Items">
@@ -298,17 +380,8 @@ export function PlanningPage({
298
380
  <h2 className={cn.heading}>
299
381
  {loadingItems
300
382
  ? 'Loading…'
301
- : `${visible.length} item${visible.length === 1 ? '' : 's'}` +
302
- (selectedFocus ? ` in ${selectedFocus.title}` : ' across every focus') +
303
- (overdueCount ? ` · ${overdueCount} overdue` : '')}
383
+ : `${visible.length} item${visible.length === 1 ? '' : 's'}${overdueCount ? ` · ${overdueCount} overdue` : ''}`}
304
384
  </h2>
305
-
306
- {selected ? (
307
- <button type="button" className={cn.secondaryButton} onClick={() => setSelected(null)}>
308
- Show everything
309
- </button>
310
- ) : null}
311
-
312
385
  <label className="ml-auto flex items-center gap-2">
313
386
  <span className="sr-only">Filter by owner</span>
314
387
  <input
@@ -318,7 +391,6 @@ export function PlanningPage({
318
391
  onChange={(event) => setOwner(event.target.value)}
319
392
  />
320
393
  </label>
321
-
322
394
  <button
323
395
  type="button"
324
396
  className={showDone ? cn.button : cn.secondaryButton}
@@ -329,19 +401,12 @@ export function PlanningPage({
329
401
  </button>
330
402
  </div>
331
403
 
332
- <UnfilteredNotice
333
- requested={PLANNING_FILTER_KEYS}
334
- applied={applied}
335
- query={itemQuery}
336
- className={cn.warning}
337
- />
338
-
339
404
  {canAuthor ? (
340
405
  <NewItemForm
341
406
  classNames={cn}
342
407
  members={members}
343
408
  focusId={selected}
344
- focusTitle={selectedFocus?.title ?? null}
409
+ focusTitle={selectedFocus.title}
345
410
  onCreate={async (draft) => {
346
411
  await apiRef.current.createCommitment!(draft);
347
412
  refresh();
@@ -351,11 +416,7 @@ export function PlanningPage({
351
416
  ) : null}
352
417
 
353
418
  {!loadingItems && visible.length === 0 ? (
354
- <p className={cn.muted}>
355
- {selectedFocus
356
- ? 'Nothing is filed under this focus yet.'
357
- : 'Nothing matches this view.'}
358
- </p>
419
+ <p className={cn.muted}>Nothing is filed under this focus yet.</p>
359
420
  ) : null}
360
421
 
361
422
  {visible.map((item) => (
@@ -383,7 +444,7 @@ export function PlanningPage({
383
444
  ))}
384
445
  </section>
385
446
 
386
- {selectedFocus && api.listDocuments ? (
447
+ {api.listDocuments ? (
387
448
  <FocusDocuments
388
449
  listDocuments={(query) => apiRef.current.listDocuments!(query)}
389
450
  focusId={selectedFocus.id}
@@ -393,6 +454,7 @@ export function PlanningPage({
393
454
  classNames={cn}
394
455
  />
395
456
  ) : null}
457
+ {drawer}
396
458
  </div>
397
459
  );
398
460
  }