@1agh/maude 2.1.0 → 2.1.2
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/apps/studio/access/request.ts +1 -0
- package/apps/studio/actions/agents.ts +45 -42
- package/apps/studio/actions/defs/app.ts +28 -1
- package/apps/studio/actions/defs/sync.ts +4 -0
- package/apps/studio/actions/verbs.ts +49 -0
- package/apps/studio/actions.manifest.json +162 -20
- package/apps/studio/actions.parity.json +13 -1
- package/apps/studio/ai/create-claim.ts +1 -1
- package/apps/studio/bin/_asset-file.mjs +117 -0
- package/apps/studio/bin/_canvas-file.mjs +146 -0
- package/apps/studio/bin/_curl-local.mjs +7 -4
- package/apps/studio/bin/_footage.mjs +123 -0
- package/apps/studio/bin/_pdf-playwright.mjs +14 -0
- package/apps/studio/bin/_png-playwright.mjs +15 -1
- package/apps/studio/bin/_pw-launch.mjs +98 -0
- package/apps/studio/bin/_retry-save.mjs +49 -0
- package/apps/studio/bin/_sync.mjs +145 -2
- package/apps/studio/bin/asset-rename.sh +12 -0
- package/apps/studio/bin/asset-trash.sh +12 -0
- package/apps/studio/bin/canvas-move.sh +12 -0
- package/apps/studio/bin/canvas-new.sh +12 -0
- package/apps/studio/bin/footage.sh +12 -0
- package/apps/studio/bin/generate.sh +7 -0
- package/apps/studio/bin/retry-save.sh +13 -0
- package/apps/studio/bridge/canvas-mode-store.ts +11 -2
- package/apps/studio/bridge/dgn-protocol.ts +8 -3
- package/apps/studio/bridge/occlusion.ts +45 -0
- package/apps/studio/canvas-theme-pill.tsx +169 -26
- package/apps/studio/client/app.jsx +16 -4
- package/apps/studio/client/export-center.jsx +32 -3
- package/apps/studio/client/home/HomeAccountBanner.jsx +61 -0
- package/apps/studio/client/home/HomeAccountsChip.jsx +404 -0
- package/apps/studio/client/home/HomeConnection.jsx +112 -0
- package/apps/studio/client/home/ProjectRows.jsx +514 -0
- package/apps/studio/client/home/home-accounts-model.js +234 -76
- package/apps/studio/client/home/home-api.js +10 -2
- package/apps/studio/client/home/home-app.jsx +151 -394
- package/apps/studio/client/home/home-icons.jsx +8 -0
- package/apps/studio/client/home/home-model.js +149 -1
- package/apps/studio/client/home/home-where-model.js +105 -0
- package/apps/studio/client/home/home.css +621 -53
- package/apps/studio/client/home/use-account-fix.js +123 -0
- package/apps/studio/client/hooks/use-palette-and-panels.jsx +3 -1
- package/apps/studio/client/hooks/use-tabs.jsx +11 -4
- package/apps/studio/client/panels/TeamProjects.jsx +137 -134
- package/apps/studio/client/share-link.js +12 -0
- package/apps/studio/client/styles/_index.css +4 -0
- package/apps/studio/client/v2/assets/generate-ask.jsx +3 -1
- package/apps/studio/client/v2/diagnostics/diagnostics-host.jsx +1 -0
- package/apps/studio/client/v2/diagnostics/diagnostics-model.js +32 -2
- package/apps/studio/client/v2/diagnostics/diagnostics-sheet.jsx +35 -8
- package/apps/studio/client/v2/diagnostics/diagnostics.css +34 -0
- package/apps/studio/client/v2/diagnostics/sync-details/sync-details-model.js +94 -3
- package/apps/studio/client/v2/diagnostics/sync-details/sync-details.jsx +187 -4
- package/apps/studio/client/v2/export/done-toast.jsx +2 -5
- package/apps/studio/client/v2/export/export-sheet.jsx +9 -2
- package/apps/studio/client/v2/export/export.css +9 -0
- package/apps/studio/client/v2/export/exports-model.js +16 -3
- package/apps/studio/client/v2/export/file-rows.jsx +81 -5
- package/apps/studio/client/v2/export/native-save.js +33 -0
- package/apps/studio/client/v2/export/sections/print-copy.js +3 -0
- package/apps/studio/client/v2/export/sections/print.jsx +37 -20
- package/apps/studio/client/v2/link-server/LinkServerDialog.jsx +492 -0
- package/apps/studio/client/v2/link-server/LinkServerHost.jsx +42 -0
- package/apps/studio/client/v2/link-server/link-server-api.js +142 -0
- package/apps/studio/client/v2/link-server/link-server-model.js +438 -0
- package/apps/studio/client/v2/link-server/link-server.css +109 -0
- package/apps/studio/client/v2/onboarding/AdvancedSheets.jsx +31 -86
- package/apps/studio/client/v2/onboarding/onboarding-model.js +1 -18
- package/apps/studio/client/v2/search/search-keywords.js +3 -2
- package/apps/studio/client/v2/settings/account.jsx +4 -2
- package/apps/studio/client/v2/settings/advanced-section.jsx +245 -148
- package/apps/studio/client/v2/settings/connection-row.jsx +3 -59
- package/apps/studio/client/v2/settings/connections-section.jsx +118 -425
- package/apps/studio/client/v2/settings/general-section.jsx +138 -43
- package/apps/studio/client/v2/settings/project-sync-settings.jsx +4 -3
- package/apps/studio/client/v2/settings/reset-section.jsx +14 -3
- package/apps/studio/client/v2/settings/settings-card.jsx +142 -0
- package/apps/studio/client/v2/settings/settings-cards.js +220 -0
- package/apps/studio/client/v2/settings/settings-handlers.js +7 -6
- package/apps/studio/client/v2/settings/settings-model.js +91 -31
- package/apps/studio/client/v2/settings/settings-sheet.jsx +25 -6
- package/apps/studio/client/v2/settings/settings.css +374 -64
- package/apps/studio/client/v2/settings/this-project-card.jsx +730 -0
- package/apps/studio/client/v2/settings/this-project-model.js +172 -0
- package/apps/studio/client/v2/settings/use-connections.js +3 -2
- package/apps/studio/client/v2/settings/use-open-card.js +37 -0
- package/apps/studio/client/v2/shell/connection-state.js +197 -0
- package/apps/studio/client/v2/shell/menu-runner.js +7 -2
- package/apps/studio/client/v2/shell/occlusion-insets.js +37 -9
- package/apps/studio/client/v2/shell/project-account-bus.js +36 -0
- package/apps/studio/client/v2/shell/project-account-card.jsx +357 -148
- package/apps/studio/client/v2/shell/project-account-model.js +272 -149
- package/apps/studio/client/v2/shell/project-account-toast.js +66 -0
- package/apps/studio/client/v2/shell/project-account.css +237 -0
- package/apps/studio/client/v2/shell/share-cluster-host.jsx +166 -83
- package/apps/studio/client/v2/shell/shell-parity.js +3 -2
- package/apps/studio/client/v2/shell/shell-parity.json +40 -26
- package/apps/studio/client/v2/shell/use-account.js +2 -0
- package/apps/studio/client/v2/shell/use-occluded-insets.js +13 -3
- package/apps/studio/client/v2/signin/use-signin.js +1 -1
- package/apps/studio/cloud/endpoints.ts +29 -4
- package/apps/studio/collab/room.ts +21 -7
- package/apps/studio/dist/client.bundle.js +886 -886
- package/apps/studio/dist/comment-mount.js +2 -2
- package/apps/studio/dist/styles.css +1 -1
- package/apps/studio/exporters/ghostscript.ts +78 -1
- package/apps/studio/exporters/pdf-fonts.ts +31 -4
- package/apps/studio/generation/jobs.ts +6 -0
- package/apps/studio/home/accounts.ts +30 -11
- package/apps/studio/home/cloud.ts +6 -1
- package/apps/studio/home/hub-health.ts +76 -0
- package/apps/studio/home/routes.ts +9 -3
- package/apps/studio/http.ts +14 -2
- package/apps/studio/migrate/hub.ts +8 -1
- package/apps/studio/routes/agent.ts +6 -2
- package/apps/studio/routes/hub-link-folder.ts +334 -0
- package/apps/studio/routes/hub-signin.ts +78 -1
- package/apps/studio/routes/index.ts +4 -0
- package/apps/studio/routes/project-undo.ts +10 -0
- package/apps/studio/routes/sync.ts +22 -4
- package/apps/studio/server.ts +25 -0
- package/apps/studio/shell/api-key.ts +11 -0
- package/apps/studio/shell/cli-yield.ts +48 -11
- package/apps/studio/sync/accepted-cold-start.ts +144 -8
- package/apps/studio/sync/action-stage.ts +18 -1
- package/apps/studio/sync/ctl-heal.ts +58 -0
- package/apps/studio/sync/file-ledger.ts +38 -4
- package/apps/studio/sync/file-plane.ts +226 -19
- package/apps/studio/sync/held-deletes.ts +86 -5
- package/apps/studio/sync/hub-link.ts +8 -0
- package/apps/studio/sync/index.ts +68 -4
- package/apps/studio/sync/link-consent.ts +22 -75
- package/apps/studio/sync/link-survey.ts +252 -0
- package/apps/studio/sync/local-kernel.ts +16 -1
- package/apps/studio/sync/seed-progress.ts +12 -0
- package/apps/studio/sync/source-recovery.ts +18 -2
- package/apps/studio/sync/status.ts +11 -1
- package/apps/studio/sync/writer-registry.ts +5 -0
- package/apps/studio/whats-new.json +36 -0
- package/cli/commands/design.mjs +74 -16
- package/cli/lib/bash-guard.mjs +23 -4
- package/cli/lib/confine-read.mjs +2 -0
- package/cli/lib/design-help.gen.mjs +15 -2
- package/cli/lib/design-hook.mjs +1 -1
- package/cli/lib/desktop-locate.mjs +36 -8
- package/cli/lib/studio-locate.mjs +8 -2
- package/cli/lib/sub-verbs.mjs +13 -1
- package/package.json +9 -8
- package/apps/studio/client/home/HomeAccounts.jsx +0 -262
- package/apps/studio/client/v2/onboarding/HubSheet.jsx +0 -212
- package/apps/studio/client/v2/shell/account-card-model.js +0 -114
- package/apps/studio/client/v2/shell/account-card.jsx +0 -189
|
@@ -0,0 +1,514 @@
|
|
|
1
|
+
// client/home/ProjectRows.jsx — 2.1.2 Home declutter (canvas 17, artboards 15/16/19): the Projects list as
|
|
2
|
+
// one flat list of slim rows. A row is a name, where the project lives (one word or an icon), a state only
|
|
3
|
+
// when it isn't fine, and a quiet last-opened time; the folder, the copy on this Mac, the worktrees and the
|
|
4
|
+
// account moved into the row's "…" menu. A folder that moved is one quiet row with two ways out: Find the
|
|
5
|
+
// folder… or Remove from list. Remove from list takes the project off Home only — nothing on disk changes —
|
|
6
|
+
// and waits for the person's yes in a small confirm. The rows come from `home-model.js` `projects`.
|
|
7
|
+
|
|
8
|
+
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
9
|
+
import { reasonProps } from '../v2/access/disabled-reason.js';
|
|
10
|
+
import { useDismissOutside } from '../v2/shell/use-dismiss-outside.js';
|
|
11
|
+
import { thumbObjectUrl } from './home-api.js';
|
|
12
|
+
import { AcctFace, KeptGlyph, StateWord } from './HomeConnection.jsx';
|
|
13
|
+
import { HIcon, HSpark } from './home-icons.jsx';
|
|
14
|
+
import { relativeTime } from './home-model.js';
|
|
15
|
+
import { tildePath } from './home-where-model.js';
|
|
16
|
+
|
|
17
|
+
/** A Home picture: fetched with the Home header (home-api `thumbObjectUrl`), shown as a blob URL. */
|
|
18
|
+
export function Thumb({ src, className }) {
|
|
19
|
+
const [url, setUrl] = useState(null);
|
|
20
|
+
const [broken, setBroken] = useState(false);
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
let alive = true;
|
|
23
|
+
setUrl(null);
|
|
24
|
+
setBroken(false);
|
|
25
|
+
if (src)
|
|
26
|
+
thumbObjectUrl(src).then((u) => {
|
|
27
|
+
if (alive) setUrl(u);
|
|
28
|
+
});
|
|
29
|
+
return () => {
|
|
30
|
+
alive = false;
|
|
31
|
+
};
|
|
32
|
+
}, [src]);
|
|
33
|
+
if (!url || broken) return <span className={`home-thumb home-thumb--empty ${className}`} />;
|
|
34
|
+
return (
|
|
35
|
+
<span className={`home-thumb ${className}`}>
|
|
36
|
+
<img src={url} alt="" decoding="async" onError={() => setBroken(true)} />
|
|
37
|
+
</span>
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function MoreGlyph() {
|
|
42
|
+
return (
|
|
43
|
+
<svg width="14" height="14" viewBox="0 0 16 16" aria-hidden="true" fill="currentColor">
|
|
44
|
+
<circle cx="3.5" cy="8" r="1.25" />
|
|
45
|
+
<circle cx="8" cy="8" r="1.25" />
|
|
46
|
+
<circle cx="12.5" cy="8" r="1.25" />
|
|
47
|
+
</svg>
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** Where a row lives, in one word: the account face (two Maude Cloud accounts only) or an icon + the word. */
|
|
52
|
+
function Lives({ lives, testid }) {
|
|
53
|
+
if (!lives) return <span className="home-prow-lives" />;
|
|
54
|
+
return (
|
|
55
|
+
<span className="home-prow-lives" data-kind={lives.kind} data-testid={testid}>
|
|
56
|
+
{lives.face ? (
|
|
57
|
+
<AcctFace face={{ kind: 'cloud', ...lives.face }} size="sm" />
|
|
58
|
+
) : lives.kind === 'kept' ? (
|
|
59
|
+
<KeptGlyph size={12} />
|
|
60
|
+
) : (
|
|
61
|
+
<HIcon name={lives.kind === 'server' ? 'server' : lives.kind} size={12} />
|
|
62
|
+
)}
|
|
63
|
+
<span className="home-prow-lives-w">{lives.word}</span>
|
|
64
|
+
</span>
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/** A row's state, only when it isn't fine (artboard 19). */
|
|
69
|
+
function Flag({ row, id }) {
|
|
70
|
+
const f = row.flag;
|
|
71
|
+
return (
|
|
72
|
+
<span
|
|
73
|
+
className="home-prow-flag"
|
|
74
|
+
data-testid={`home-project-conn-${id}`}
|
|
75
|
+
data-kind={row.connection?.kind ?? undefined}
|
|
76
|
+
data-state={row.conn?.state ?? undefined}
|
|
77
|
+
>
|
|
78
|
+
{f?.kind === 'ai' ? (
|
|
79
|
+
<span
|
|
80
|
+
className="chip chip--spark home-prow-ai"
|
|
81
|
+
data-testid={`home-project-ai-${id}`}
|
|
82
|
+
data-ai="running"
|
|
83
|
+
>
|
|
84
|
+
<HSpark size={9} />
|
|
85
|
+
AI working
|
|
86
|
+
</span>
|
|
87
|
+
) : f?.kind === 'needs' ? (
|
|
88
|
+
<span
|
|
89
|
+
className="chip chip--accent home-prow-ai"
|
|
90
|
+
data-testid={`home-project-ai-${id}`}
|
|
91
|
+
data-ai="awaiting"
|
|
92
|
+
>
|
|
93
|
+
Needs you
|
|
94
|
+
</span>
|
|
95
|
+
) : f?.kind === 'signin' ? (
|
|
96
|
+
<StateWord tone="bad" testid={`home-project-state-${id}`}>
|
|
97
|
+
{f.word}
|
|
98
|
+
</StateWord>
|
|
99
|
+
) : f?.kind === 'away' ? (
|
|
100
|
+
<span className="home-prow-quiet">
|
|
101
|
+
<HIcon name="cloud" size={12} />
|
|
102
|
+
{f.word}
|
|
103
|
+
</span>
|
|
104
|
+
) : null}
|
|
105
|
+
</span>
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* The menu rows of a project's "…" (artboard 19): Open, then the project's group — its account, Show in
|
|
111
|
+
* Finder (its folder), the copy on this Mac and its worktrees — then Remove from list. Pure, so a test reads it.
|
|
112
|
+
* Each item: `{ id, label, note?, act?, testid, info? }`; `info` rows say something and do nothing.
|
|
113
|
+
*/
|
|
114
|
+
export function projectMenuItems(row) {
|
|
115
|
+
const items = [{ id: 'open', label: 'Open', testid: 'home-project-menu-open', act: 'open' }];
|
|
116
|
+
const group = [];
|
|
117
|
+
const c = row.connection;
|
|
118
|
+
if (c?.kind === 'cloud' || c?.kind === 'team')
|
|
119
|
+
group.push({
|
|
120
|
+
id: 'account',
|
|
121
|
+
label: c.kind === 'cloud' ? 'Maude Cloud' : c.host || 'Your server',
|
|
122
|
+
note: c.account || null,
|
|
123
|
+
testid: 'home-project-menu-account',
|
|
124
|
+
info: true,
|
|
125
|
+
});
|
|
126
|
+
const kept = row.lives?.kind === 'kept';
|
|
127
|
+
if (kept)
|
|
128
|
+
group.push({
|
|
129
|
+
id: 'kept',
|
|
130
|
+
label: 'Kept by Maude',
|
|
131
|
+
note: 'this Mac’s copy',
|
|
132
|
+
testid: 'home-project-menu-kept',
|
|
133
|
+
info: true,
|
|
134
|
+
});
|
|
135
|
+
else if (row.root)
|
|
136
|
+
group.push({
|
|
137
|
+
id: 'reveal',
|
|
138
|
+
label: 'Show in Finder',
|
|
139
|
+
note: tildePath(row.root),
|
|
140
|
+
testid: 'home-project-menu-reveal',
|
|
141
|
+
act: 'reveal',
|
|
142
|
+
});
|
|
143
|
+
for (const cp of row.copies ?? [])
|
|
144
|
+
group.push({
|
|
145
|
+
id: `copy-${cp.pid}`,
|
|
146
|
+
label: cp.kind === 'folder' ? 'Also in a folder' : 'Kept by Maude',
|
|
147
|
+
note: cp.kind === 'folder' ? tildePath(cp.root) : 'this Mac’s copy',
|
|
148
|
+
testid: `home-project-copy-${cp.pid}`,
|
|
149
|
+
aria: cp.kind === 'folder' ? `Open ${cp.label}` : `Open the ${cp.label} of ${row.name}`,
|
|
150
|
+
act: 'open-copy',
|
|
151
|
+
pid: cp.pid,
|
|
152
|
+
});
|
|
153
|
+
for (const w of row.worktrees ?? [])
|
|
154
|
+
group.push({
|
|
155
|
+
id: `wt-${w.pid}`,
|
|
156
|
+
label: w.branch,
|
|
157
|
+
note: 'worktree',
|
|
158
|
+
testid: `home-worktree-${w.pid}`,
|
|
159
|
+
aria: `Open the ${w.branch} worktree of ${row.name}`,
|
|
160
|
+
act: 'open-worktree',
|
|
161
|
+
pid: w.pid,
|
|
162
|
+
});
|
|
163
|
+
if (group.length) items.push({ sep: true, id: 'sep-1', head: row.name }, ...group);
|
|
164
|
+
items.push(
|
|
165
|
+
{ sep: true, id: 'sep-2' },
|
|
166
|
+
{ id: 'forget', label: 'Remove from list', testid: 'home-project-menu-forget', act: 'forget' }
|
|
167
|
+
);
|
|
168
|
+
return items;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
function RowMenu({ row, canOpen, onAct, onClose, anchorRef }) {
|
|
172
|
+
const ref = useRef(null);
|
|
173
|
+
const items = projectMenuItems(row);
|
|
174
|
+
const close = useCallback(
|
|
175
|
+
(back = true) => {
|
|
176
|
+
onClose();
|
|
177
|
+
if (back) anchorRef.current?.focus();
|
|
178
|
+
},
|
|
179
|
+
[onClose, anchorRef]
|
|
180
|
+
);
|
|
181
|
+
useEffect(() => {
|
|
182
|
+
ref.current?.querySelector('button[role="menuitem"]:not([disabled])')?.focus();
|
|
183
|
+
}, []);
|
|
184
|
+
useDismissOutside(true, ref, () => close(false));
|
|
185
|
+
const onKey = (e) => {
|
|
186
|
+
if (e.key === 'Escape') {
|
|
187
|
+
e.preventDefault();
|
|
188
|
+
e.stopPropagation();
|
|
189
|
+
close();
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
if (e.key === 'Tab') {
|
|
193
|
+
close(false);
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
if (e.key !== 'ArrowDown' && e.key !== 'ArrowUp' && e.key !== 'Home' && e.key !== 'End') return;
|
|
197
|
+
e.preventDefault();
|
|
198
|
+
const btns = Array.from(
|
|
199
|
+
ref.current?.querySelectorAll('button[role="menuitem"]:not([disabled])') ?? []
|
|
200
|
+
);
|
|
201
|
+
if (!btns.length) return;
|
|
202
|
+
const i = btns.indexOf(document.activeElement);
|
|
203
|
+
const n =
|
|
204
|
+
e.key === 'Home'
|
|
205
|
+
? 0
|
|
206
|
+
: e.key === 'End'
|
|
207
|
+
? btns.length - 1
|
|
208
|
+
: e.key === 'ArrowDown'
|
|
209
|
+
? (i + 1) % btns.length
|
|
210
|
+
: (i - 1 + btns.length) % btns.length;
|
|
211
|
+
btns[n]?.focus();
|
|
212
|
+
};
|
|
213
|
+
return (
|
|
214
|
+
<div
|
|
215
|
+
ref={ref}
|
|
216
|
+
role="menu"
|
|
217
|
+
aria-label={`More for ${row.name}`}
|
|
218
|
+
className="sh-pm home-prow-menu"
|
|
219
|
+
data-testid="home-project-menu"
|
|
220
|
+
onKeyDown={onKey}
|
|
221
|
+
>
|
|
222
|
+
{items.map((it) => {
|
|
223
|
+
if (it.sep)
|
|
224
|
+
return (
|
|
225
|
+
<div key={it.id} role="none">
|
|
226
|
+
<hr className="sh-pm-sep" />
|
|
227
|
+
{it.head ? <p className="home-prow-menu-h">{it.head}</p> : null}
|
|
228
|
+
</div>
|
|
229
|
+
);
|
|
230
|
+
if (it.info)
|
|
231
|
+
return (
|
|
232
|
+
<div key={it.id} role="none" className="home-prow-menu-info" data-testid={it.testid}>
|
|
233
|
+
<span className="sh-pm-lab">{it.label}</span>
|
|
234
|
+
{it.note ? <span className="home-prow-menu-note">{it.note}</span> : null}
|
|
235
|
+
</div>
|
|
236
|
+
);
|
|
237
|
+
const off = !canOpen && it.act !== 'forget';
|
|
238
|
+
return (
|
|
239
|
+
<div key={it.id} role="none" className="sh-pm-li">
|
|
240
|
+
<button
|
|
241
|
+
type="button"
|
|
242
|
+
role="menuitem"
|
|
243
|
+
className="sh-pm-row"
|
|
244
|
+
data-testid={it.testid}
|
|
245
|
+
aria-label={it.aria}
|
|
246
|
+
disabled={off}
|
|
247
|
+
{...reasonProps(off, 'homeBrowser')}
|
|
248
|
+
onClick={() => {
|
|
249
|
+
close(it.act === 'forget');
|
|
250
|
+
onAct(it);
|
|
251
|
+
}}
|
|
252
|
+
>
|
|
253
|
+
<span className="sh-pm-lab">{it.label}</span>
|
|
254
|
+
{it.note ? (
|
|
255
|
+
<span className="home-prow-menu-note" title={it.note}>
|
|
256
|
+
{it.note}
|
|
257
|
+
</span>
|
|
258
|
+
) : null}
|
|
259
|
+
</button>
|
|
260
|
+
</div>
|
|
261
|
+
);
|
|
262
|
+
})}
|
|
263
|
+
</div>
|
|
264
|
+
);
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
function LocalRow({ row, canOpen, onOpen, onAct }) {
|
|
268
|
+
const [open, setOpen] = useState(false);
|
|
269
|
+
const more = useRef(null);
|
|
270
|
+
const when = relativeTime(row.lastOpenedAt ?? undefined);
|
|
271
|
+
return (
|
|
272
|
+
<li className="home-prow-li" data-menu={open ? 'open' : undefined}>
|
|
273
|
+
<div className="row-item home-prow home-prow--slim">
|
|
274
|
+
<button
|
|
275
|
+
type="button"
|
|
276
|
+
className="home-prow-main"
|
|
277
|
+
data-testid={`home-project-row-${row.pid}`}
|
|
278
|
+
data-place={row.place}
|
|
279
|
+
onClick={() => onOpen(row.pid)}
|
|
280
|
+
disabled={!canOpen}
|
|
281
|
+
{...reasonProps(!canOpen, 'homeBrowser')}
|
|
282
|
+
>
|
|
283
|
+
<Thumb src={row.cover} className="home-prow-thumb" />
|
|
284
|
+
<span className="home-prow-name">
|
|
285
|
+
<strong>{row.name}</strong>
|
|
286
|
+
</span>
|
|
287
|
+
<Lives lives={row.lives} testid={`home-project-where-${row.pid}`} />
|
|
288
|
+
<Flag row={row} id={row.pid} />
|
|
289
|
+
<span className="home-prow-when" data-testid={`home-project-when-${row.pid}`}>
|
|
290
|
+
{when}
|
|
291
|
+
</span>
|
|
292
|
+
</button>
|
|
293
|
+
<button
|
|
294
|
+
type="button"
|
|
295
|
+
ref={more}
|
|
296
|
+
className="icon-btn home-prow-more"
|
|
297
|
+
data-testid={`home-project-more-${row.pid}`}
|
|
298
|
+
aria-haspopup="menu"
|
|
299
|
+
aria-expanded={open}
|
|
300
|
+
aria-label={`More for ${row.name}`}
|
|
301
|
+
onClick={() => setOpen((v) => !v)}
|
|
302
|
+
onKeyDown={(e) => {
|
|
303
|
+
if (e.key === 'ArrowDown' && !open) {
|
|
304
|
+
e.preventDefault();
|
|
305
|
+
setOpen(true);
|
|
306
|
+
}
|
|
307
|
+
}}
|
|
308
|
+
>
|
|
309
|
+
<MoreGlyph />
|
|
310
|
+
</button>
|
|
311
|
+
</div>
|
|
312
|
+
{open ? (
|
|
313
|
+
<RowMenu
|
|
314
|
+
row={row}
|
|
315
|
+
canOpen={canOpen}
|
|
316
|
+
anchorRef={more}
|
|
317
|
+
onClose={() => setOpen(false)}
|
|
318
|
+
onAct={(it) => onAct(row, it)}
|
|
319
|
+
/>
|
|
320
|
+
) : null}
|
|
321
|
+
</li>
|
|
322
|
+
);
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
function CloudRow({ row, canOpen, onOpenCloud }) {
|
|
326
|
+
return (
|
|
327
|
+
<li className="home-prow-li">
|
|
328
|
+
<div className="row-item home-prow home-prow--slim home-prow--cloud">
|
|
329
|
+
<button
|
|
330
|
+
type="button"
|
|
331
|
+
className="home-prow-main"
|
|
332
|
+
data-testid={`home-cloud-open-${row.projectId}`}
|
|
333
|
+
onClick={() => onOpenCloud(row)}
|
|
334
|
+
disabled={!canOpen}
|
|
335
|
+
{...reasonProps(!canOpen, 'homeBrowser')}
|
|
336
|
+
aria-label={`Open ${row.name}`}
|
|
337
|
+
>
|
|
338
|
+
<span className="home-thumb home-thumb--empty home-prow-thumb" />
|
|
339
|
+
<span className="home-prow-name" data-testid={`home-cloud-row-${row.projectId}`}>
|
|
340
|
+
<strong>{row.name}</strong>
|
|
341
|
+
</span>
|
|
342
|
+
<Lives lives={row.lives} testid={`home-project-where-${row.projectId}`} />
|
|
343
|
+
<Flag row={row} id={row.projectId} />
|
|
344
|
+
<span className="home-prow-when" />
|
|
345
|
+
</button>
|
|
346
|
+
<span className="home-prow-more-gap" />
|
|
347
|
+
</div>
|
|
348
|
+
</li>
|
|
349
|
+
);
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
function OrphanRow({ row, canOpen, onRelink, onForget }) {
|
|
353
|
+
return (
|
|
354
|
+
<li className="home-prow-li">
|
|
355
|
+
<div
|
|
356
|
+
className="row-item home-prow home-prow--slim home-prow--gone"
|
|
357
|
+
data-testid={`home-project-row-${row.pid}`}
|
|
358
|
+
>
|
|
359
|
+
<span className="home-prow-gone" aria-hidden="true">
|
|
360
|
+
<HIcon name="folder" size={14} />
|
|
361
|
+
</span>
|
|
362
|
+
<span className="home-prow-name home-prow-name--two">
|
|
363
|
+
<strong>{row.name}</strong>
|
|
364
|
+
<span>The folder isn’t where it was.</span>
|
|
365
|
+
</span>
|
|
366
|
+
<span className="home-prow-acts">
|
|
367
|
+
<button
|
|
368
|
+
type="button"
|
|
369
|
+
className="btn btn--ghost btn--sm"
|
|
370
|
+
data-testid={`home-relink-${row.pid}`}
|
|
371
|
+
onClick={() => onRelink(row.pid)}
|
|
372
|
+
disabled={!canOpen}
|
|
373
|
+
{...reasonProps(!canOpen, 'homeBrowser')}
|
|
374
|
+
>
|
|
375
|
+
Find the folder…
|
|
376
|
+
</button>
|
|
377
|
+
<button
|
|
378
|
+
type="button"
|
|
379
|
+
className="btn btn--ghost btn--sm"
|
|
380
|
+
data-testid={`home-project-forget-${row.pid}`}
|
|
381
|
+
onClick={() => onForget(row)}
|
|
382
|
+
disabled={!canOpen}
|
|
383
|
+
{...reasonProps(!canOpen, 'homeBrowser')}
|
|
384
|
+
>
|
|
385
|
+
Remove from list
|
|
386
|
+
</button>
|
|
387
|
+
</span>
|
|
388
|
+
</div>
|
|
389
|
+
</li>
|
|
390
|
+
);
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
/** "Remove <name> from this list?" — the person's yes before anything changes. */
|
|
394
|
+
export function ForgetConfirm({ row, busy, onConfirm, onCancel }) {
|
|
395
|
+
const cancel = useRef(null);
|
|
396
|
+
useEffect(() => {
|
|
397
|
+
cancel.current?.focus();
|
|
398
|
+
const onKey = (e) => {
|
|
399
|
+
if (e.key === 'Escape') onCancel();
|
|
400
|
+
};
|
|
401
|
+
document.addEventListener('keydown', onKey);
|
|
402
|
+
return () => document.removeEventListener('keydown', onKey);
|
|
403
|
+
}, [onCancel]);
|
|
404
|
+
return (
|
|
405
|
+
<div
|
|
406
|
+
className="home-link-modal"
|
|
407
|
+
role="dialog"
|
|
408
|
+
aria-modal="true"
|
|
409
|
+
aria-labelledby="home-forget-t"
|
|
410
|
+
data-testid="home-forget-dialog"
|
|
411
|
+
>
|
|
412
|
+
<div className="home-link-scrim" aria-hidden="true" onClick={onCancel} />
|
|
413
|
+
<div className="island home-link-dialog">
|
|
414
|
+
<h2 id="home-forget-t">Remove {row.name} from this list?</h2>
|
|
415
|
+
<p>The folder and its files stay where they are.</p>
|
|
416
|
+
<div className="home-link-foot">
|
|
417
|
+
<button
|
|
418
|
+
type="button"
|
|
419
|
+
ref={cancel}
|
|
420
|
+
className="btn"
|
|
421
|
+
data-testid="home-forget-cancel"
|
|
422
|
+
onClick={onCancel}
|
|
423
|
+
>
|
|
424
|
+
Cancel
|
|
425
|
+
</button>
|
|
426
|
+
<button
|
|
427
|
+
type="button"
|
|
428
|
+
className="btn btn--primary"
|
|
429
|
+
data-testid="home-forget-confirm"
|
|
430
|
+
disabled={busy}
|
|
431
|
+
onClick={onConfirm}
|
|
432
|
+
>
|
|
433
|
+
Remove from list
|
|
434
|
+
</button>
|
|
435
|
+
</div>
|
|
436
|
+
</div>
|
|
437
|
+
</div>
|
|
438
|
+
);
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
/**
|
|
442
|
+
* The list. `onForget(pids)` resolves `{ ok }` once Rust took them off; `onReveal(pid)` shows the folder.
|
|
443
|
+
* @param {{ rows: object[], canOpen: boolean, onOpen: (pid: string) => void,
|
|
444
|
+
* onOpenWorktree: (pid: string) => void, onRelink: (pid: string) => void,
|
|
445
|
+
* onOpenCloud: (row: object) => void, onReveal: (pid: string) => void,
|
|
446
|
+
* onForget: (pids: string[]) => Promise<unknown> }} props
|
|
447
|
+
*/
|
|
448
|
+
export function ProjectList({
|
|
449
|
+
rows,
|
|
450
|
+
canOpen,
|
|
451
|
+
onOpen,
|
|
452
|
+
onOpenWorktree,
|
|
453
|
+
onRelink,
|
|
454
|
+
onOpenCloud,
|
|
455
|
+
onReveal,
|
|
456
|
+
onForget,
|
|
457
|
+
}) {
|
|
458
|
+
const [asking, setAsking] = useState(null);
|
|
459
|
+
const [busy, setBusy] = useState(false);
|
|
460
|
+
const act = useCallback(
|
|
461
|
+
(row, it) => {
|
|
462
|
+
if (it.act === 'open') onOpen(row.pid);
|
|
463
|
+
else if (it.act === 'reveal') onReveal(row.pid);
|
|
464
|
+
else if (it.act === 'open-copy') onOpen(it.pid);
|
|
465
|
+
else if (it.act === 'open-worktree') onOpenWorktree(it.pid);
|
|
466
|
+
else if (it.act === 'forget') setAsking(row);
|
|
467
|
+
},
|
|
468
|
+
[onOpen, onReveal, onOpenWorktree]
|
|
469
|
+
);
|
|
470
|
+
const confirm = useCallback(async () => {
|
|
471
|
+
if (!asking) return;
|
|
472
|
+
setBusy(true);
|
|
473
|
+
try {
|
|
474
|
+
await onForget(asking.pids?.length ? asking.pids : [asking.pid]);
|
|
475
|
+
} finally {
|
|
476
|
+
setBusy(false);
|
|
477
|
+
setAsking(null);
|
|
478
|
+
}
|
|
479
|
+
}, [asking, onForget]);
|
|
480
|
+
return (
|
|
481
|
+
<>
|
|
482
|
+
<ul className="home-prows home-prows--slim" data-testid="home-project-list">
|
|
483
|
+
{rows.map((r) =>
|
|
484
|
+
r.kind === 'cloud' ? (
|
|
485
|
+
<CloudRow
|
|
486
|
+
key={`c:${r.profile}:${r.projectId}`}
|
|
487
|
+
row={r}
|
|
488
|
+
canOpen={canOpen}
|
|
489
|
+
onOpenCloud={onOpenCloud}
|
|
490
|
+
/>
|
|
491
|
+
) : r.status === 'gone' ? (
|
|
492
|
+
<OrphanRow
|
|
493
|
+
key={r.pid}
|
|
494
|
+
row={r}
|
|
495
|
+
canOpen={canOpen}
|
|
496
|
+
onRelink={onRelink}
|
|
497
|
+
onForget={setAsking}
|
|
498
|
+
/>
|
|
499
|
+
) : (
|
|
500
|
+
<LocalRow key={r.pid} row={r} canOpen={canOpen} onOpen={onOpen} onAct={act} />
|
|
501
|
+
)
|
|
502
|
+
)}
|
|
503
|
+
</ul>
|
|
504
|
+
{asking ? (
|
|
505
|
+
<ForgetConfirm
|
|
506
|
+
row={asking}
|
|
507
|
+
busy={busy}
|
|
508
|
+
onConfirm={confirm}
|
|
509
|
+
onCancel={() => setAsking(null)}
|
|
510
|
+
/>
|
|
511
|
+
) : null}
|
|
512
|
+
</>
|
|
513
|
+
);
|
|
514
|
+
}
|