@startsimpli/integrations 0.2.140 → 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",
|
|
@@ -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
|
) : (
|