@startsimpli/integrations 0.2.139 → 0.2.141
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@startsimpli/integrations",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.141",
|
|
4
4
|
"description": "Provider-agnostic types, API clients, hooks, and UI primitives for email + calendar integrations across StartSimpli apps, plus foundry customer email (subpath ./comms).",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://startsimpli.com",
|
|
@@ -50,9 +50,9 @@
|
|
|
50
50
|
"react-native": ">=0.74.0",
|
|
51
51
|
"@startsimpli/ui-native": ">=0.1.12",
|
|
52
52
|
"react-native-safe-area-context": ">=4.0.0",
|
|
53
|
-
"@startsimpli/ui": "^0.4.171",
|
|
54
53
|
"@startsimpli/auth": "^0.4.50",
|
|
55
|
-
"@startsimpli/utils": "^0.4.17"
|
|
54
|
+
"@startsimpli/utils": "^0.4.17",
|
|
55
|
+
"@startsimpli/ui": "^0.4.171"
|
|
56
56
|
},
|
|
57
57
|
"peerDependenciesMeta": {
|
|
58
58
|
"react": {
|
|
@@ -627,3 +627,22 @@ describe('TrackerPage — opening a to-do', () => {
|
|
|
627
627
|
expect(onOpenDocument).not.toHaveBeenCalled();
|
|
628
628
|
});
|
|
629
629
|
});
|
|
630
|
+
|
|
631
|
+
describe('TrackerPage — adding a to-do', () => {
|
|
632
|
+
it('adds a to-do from a quick-add box and re-reads the list', async () => {
|
|
633
|
+
const createCommitment = vi.fn(async () => ROWS[0]);
|
|
634
|
+
let calls = 0;
|
|
635
|
+
const api = { ...makeApi({ onQuery: () => { calls += 1; } }), createCommitment } as CommitmentTrackerApi;
|
|
636
|
+
render(<TrackerPage api={api} scope={SCOPE} />);
|
|
637
|
+
await screen.findByText('Chase the inventor for comments on 2148');
|
|
638
|
+
await userEvent.type(screen.getByRole('textbox', { name: /add a to-do/i }), 'Call the notary{Enter}');
|
|
639
|
+
expect(createCommitment).toHaveBeenCalledWith(expect.objectContaining({ title: 'Call the notary' }));
|
|
640
|
+
await vi.waitFor(() => expect(calls).toBeGreaterThan(1));
|
|
641
|
+
});
|
|
642
|
+
|
|
643
|
+
it('offers no quick-add when the api cannot create', async () => {
|
|
644
|
+
render(<TrackerPage api={makeApi()} scope={SCOPE} />);
|
|
645
|
+
await screen.findByText('Chase the inventor for comments on 2148');
|
|
646
|
+
expect(screen.queryByRole('textbox', { name: /add a to-do/i })).toBeNull();
|
|
647
|
+
});
|
|
648
|
+
});
|
|
@@ -66,3 +66,39 @@ describe('TaskDetailPage', () => {
|
|
|
66
66
|
expect(await screen.findByRole('link', { name: 'Open in Linear: ENG-7' })).toBeInTheDocument();
|
|
67
67
|
});
|
|
68
68
|
});
|
|
69
|
+
|
|
70
|
+
describe('TaskDetailPage — editing', () => {
|
|
71
|
+
it('saves a changed title, notes, owner and due date through updateCommitment', async () => {
|
|
72
|
+
const api = apiWith([make('a', { owner_name: 'Megan' })]);
|
|
73
|
+
render(<TaskDetailPage api={api} scope={scope} itemId="commit:a" />);
|
|
74
|
+
fireEvent.click(await screen.findByRole('button', { name: /^edit$/i }));
|
|
75
|
+
fireEvent.change(screen.getByLabelText('Title'), { target: { value: 'Renamed task' } });
|
|
76
|
+
fireEvent.change(screen.getByLabelText('Notes'), { target: { value: 'More detail' } });
|
|
77
|
+
fireEvent.change(screen.getByLabelText('Owner'), { target: { value: 'Rae' } });
|
|
78
|
+
fireEvent.change(screen.getByLabelText('Due date'), { target: { value: '2026-12-01' } });
|
|
79
|
+
fireEvent.click(screen.getByRole('button', { name: /^save$/i }));
|
|
80
|
+
await waitFor(() => expect(api.updateCommitment).toHaveBeenCalledWith(
|
|
81
|
+
expect.objectContaining({ externalId: 'commit:a' }),
|
|
82
|
+
expect.objectContaining({ title: 'Renamed task', detail: 'More detail', ownerName: 'Rae', dueAt: expect.stringMatching(/^2026-12-01/) }),
|
|
83
|
+
));
|
|
84
|
+
expect(await screen.findByRole('heading', { name: 'Renamed task' })).toBeInTheDocument();
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
it('refuses an empty title', async () => {
|
|
88
|
+
const api = apiWith([make('a')]);
|
|
89
|
+
render(<TaskDetailPage api={api} scope={scope} itemId="commit:a" />);
|
|
90
|
+
fireEvent.click(await screen.findByRole('button', { name: /^edit$/i }));
|
|
91
|
+
fireEvent.change(screen.getByLabelText('Title'), { target: { value: ' ' } });
|
|
92
|
+
expect(screen.getByRole('button', { name: /^save$/i })).toBeDisabled();
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
it('cancel discards the edit', async () => {
|
|
96
|
+
const api = apiWith([make('a')]);
|
|
97
|
+
render(<TaskDetailPage api={api} scope={scope} itemId="commit:a" />);
|
|
98
|
+
fireEvent.click(await screen.findByRole('button', { name: /^edit$/i }));
|
|
99
|
+
fireEvent.change(screen.getByLabelText('Title'), { target: { value: 'x' } });
|
|
100
|
+
fireEvent.click(screen.getByRole('button', { name: /cancel/i }));
|
|
101
|
+
expect(screen.getByRole('heading', { name: 'Task a' })).toBeInTheDocument();
|
|
102
|
+
expect(api.updateCommitment).not.toHaveBeenCalled();
|
|
103
|
+
});
|
|
104
|
+
});
|
|
@@ -78,6 +78,8 @@ export function TaskDetailPage({
|
|
|
78
78
|
const [loading, setLoading] = React.useState(true);
|
|
79
79
|
const [error, setError] = React.useState('');
|
|
80
80
|
const [busy, setBusy] = React.useState(false);
|
|
81
|
+
const [editing, setEditing] = React.useState(false);
|
|
82
|
+
const [form, setForm] = React.useState({ title: '', detail: '', owner: '', due: '' });
|
|
81
83
|
|
|
82
84
|
React.useEffect(() => {
|
|
83
85
|
let live = true;
|
|
@@ -107,6 +109,36 @@ export function TaskDetailPage({
|
|
|
107
109
|
}
|
|
108
110
|
};
|
|
109
111
|
|
|
112
|
+
const startEdit = () => {
|
|
113
|
+
if (!item) return;
|
|
114
|
+
setForm({
|
|
115
|
+
title: item.title, detail: item.detail ?? '', owner: item.ownerName ?? '',
|
|
116
|
+
due: item.dueAt ? item.dueAt.slice(0, 10) : '',
|
|
117
|
+
});
|
|
118
|
+
setEditing(true);
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
const save = async () => {
|
|
122
|
+
if (!item || !apiRef.current.updateCommitment || !form.title.trim()) return;
|
|
123
|
+
setBusy(true);
|
|
124
|
+
setError('');
|
|
125
|
+
try {
|
|
126
|
+
const patch = {
|
|
127
|
+
title: form.title.trim(),
|
|
128
|
+
detail: form.detail,
|
|
129
|
+
ownerName: form.owner.trim() || undefined,
|
|
130
|
+
dueAt: form.due ? `${form.due}T00:00:00Z` : null,
|
|
131
|
+
};
|
|
132
|
+
const updated = await apiRef.current.updateCommitment(item, patch);
|
|
133
|
+
setItem({ ...item, ...patch, ...updated });
|
|
134
|
+
setEditing(false);
|
|
135
|
+
} catch (err) {
|
|
136
|
+
setError(failureMessage(err));
|
|
137
|
+
} finally {
|
|
138
|
+
setBusy(false);
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
|
|
110
142
|
const back = onBack ? (
|
|
111
143
|
<button type="button" className="text-sm text-blue-700 underline" onClick={onBack}>← Back to Tracker</button>
|
|
112
144
|
) : null;
|
|
@@ -140,6 +172,28 @@ export function TaskDetailPage({
|
|
|
140
172
|
{project ? <span className={cn.badge}>{project}</span> : null}
|
|
141
173
|
{item.sync ? <ExternalLinkChip sync={item.sync} trackerName={trackerName} className={cn.badge} /> : null}
|
|
142
174
|
</div>
|
|
175
|
+
{editing ? (
|
|
176
|
+
<form className="mt-3 space-y-3" onSubmit={(e) => { e.preventDefault(); void save(); }}>
|
|
177
|
+
<label className="block text-sm">Title
|
|
178
|
+
<input className="mt-1 block w-full rounded-md border border-gray-300 px-3 py-1.5 text-sm" value={form.title} onChange={(e) => setForm({ ...form, title: e.target.value })} />
|
|
179
|
+
</label>
|
|
180
|
+
<label className="block text-sm">Notes
|
|
181
|
+
<textarea className="mt-1 block w-full rounded-md border border-gray-300 px-3 py-1.5 text-sm" rows={3} value={form.detail} onChange={(e) => setForm({ ...form, detail: e.target.value })} />
|
|
182
|
+
</label>
|
|
183
|
+
<div className="flex flex-wrap gap-3">
|
|
184
|
+
<label className="block text-sm">Owner
|
|
185
|
+
<input className="mt-1 block rounded-md border border-gray-300 px-3 py-1.5 text-sm" value={form.owner} onChange={(e) => setForm({ ...form, owner: e.target.value })} />
|
|
186
|
+
</label>
|
|
187
|
+
<label className="block text-sm">Due date
|
|
188
|
+
<input type="date" className="mt-1 block rounded-md border border-gray-300 px-3 py-1.5 text-sm" value={form.due} onChange={(e) => setForm({ ...form, due: e.target.value })} />
|
|
189
|
+
</label>
|
|
190
|
+
</div>
|
|
191
|
+
<div className="flex gap-2">
|
|
192
|
+
<button type="submit" className={cn.button} disabled={busy || !form.title.trim()}>Save</button>
|
|
193
|
+
<button type="button" className={cn.secondaryButton} disabled={busy} onClick={() => setEditing(false)}>Cancel</button>
|
|
194
|
+
</div>
|
|
195
|
+
</form>
|
|
196
|
+
) : (<>
|
|
143
197
|
<h1 className={`mt-2 ${cn.heading}`}>{item.title}</h1>
|
|
144
198
|
|
|
145
199
|
<dl className="mt-3 grid grid-cols-[7rem_1fr] gap-y-1 text-sm">
|
|
@@ -159,8 +213,11 @@ export function TaskDetailPage({
|
|
|
159
213
|
<p className="mt-3 text-sm text-gray-600">{item.status === 'done' ? 'Closed by' : 'Blocked by'}: “{item.statusReason}”</p>
|
|
160
214
|
) : null}
|
|
161
215
|
|
|
162
|
-
|
|
216
|
+
</>)}
|
|
217
|
+
|
|
218
|
+
{canWrite && !editing ? (
|
|
163
219
|
<div className="mt-4 flex flex-wrap gap-2">
|
|
220
|
+
<button type="button" className={cn.secondaryButton} disabled={busy} onClick={startEdit}>Edit</button>
|
|
164
221
|
{closed ? (
|
|
165
222
|
<button type="button" className={cn.secondaryButton} disabled={busy} onClick={() => void setStatus('open')}>Reopen</button>
|
|
166
223
|
) : (
|
|
@@ -335,6 +335,25 @@ export function TrackerPage({
|
|
|
335
335
|
}
|
|
336
336
|
}, [doneOpen, loadDone]);
|
|
337
337
|
const canWrite = Boolean(api.updateCommitment);
|
|
338
|
+
const canAdd = Boolean(api.createCommitment);
|
|
339
|
+
const [draftTitle, setDraftTitle] = React.useState('');
|
|
340
|
+
const [adding, setAdding] = React.useState(false);
|
|
341
|
+
/** Quick-add: a title is enough; everything else is edited on the detail page. */
|
|
342
|
+
const addTodo = async () => {
|
|
343
|
+
const title = draftTitle.trim();
|
|
344
|
+
if (!title || adding) return;
|
|
345
|
+
setAdding(true);
|
|
346
|
+
setError('');
|
|
347
|
+
try {
|
|
348
|
+
await apiRef.current.createCommitment!({ title });
|
|
349
|
+
setDraftTitle('');
|
|
350
|
+
await loadRef.current();
|
|
351
|
+
} catch (err) {
|
|
352
|
+
setError(failureMessage(err));
|
|
353
|
+
} finally {
|
|
354
|
+
setAdding(false);
|
|
355
|
+
}
|
|
356
|
+
};
|
|
338
357
|
const open = (item: Commitment) => {
|
|
339
358
|
if (onOpenItem) { onOpenItem(item); return; }
|
|
340
359
|
const doc = item.mentions[0]?.documentId;
|
|
@@ -372,6 +391,16 @@ export function TrackerPage({
|
|
|
372
391
|
|
|
373
392
|
return (
|
|
374
393
|
<div className={cn.root}>
|
|
394
|
+
{canAdd ? (
|
|
395
|
+
<form className="flex gap-2" onSubmit={(e) => { e.preventDefault(); void addTodo(); }}>
|
|
396
|
+
<input
|
|
397
|
+
className={`${cn.input} flex-1`} value={draftTitle} disabled={adding}
|
|
398
|
+
onChange={(e) => setDraftTitle(e.target.value)}
|
|
399
|
+
placeholder="Add a to-do…" aria-label="Add a to-do"
|
|
400
|
+
/>
|
|
401
|
+
<button type="submit" className={cn.secondaryButton} disabled={adding || !draftTitle.trim()}>Add</button>
|
|
402
|
+
</form>
|
|
403
|
+
) : null}
|
|
375
404
|
<div className="flex flex-wrap items-center gap-3">
|
|
376
405
|
<p className={cn.muted} data-testid="tracker-summary">
|
|
377
406
|
{loading ? 'Loading…' : `${owed} owed · ${c.today} today · ${c.inProgress} in progress`}
|