Leave a team, delete a vault; keep tests out of the real settings
- A hub test unset LUNE_HOME for the whole test run, so later tests saved into the real user's config. Tests now always keep their own settings folder. - Leaving a team: `lunesync leave` and the app's Leave hand over and remove this device there; a hub that's gone can be forgotten (folders stay). - Deleting a vault (owner): everyone is removed the usual way, the history is archived on the hub and the name is freed. Canvas asks first. - Connect this Mac says what to do when Lune isn't installed. - Update checks skip http hubs instead of failing for all of them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -62,6 +62,7 @@ type Sheet =
|
||||
| 'vault'
|
||||
| { kind: 'compare'; vault: Vault; copy: string }
|
||||
| { kind: 'team'; p: Person }
|
||||
| { kind: 'delete'; v: Vault }
|
||||
| { kind: 'restored'; p: Person; link: string };
|
||||
|
||||
function store(key: string, value?: string): string | null {
|
||||
@@ -565,6 +566,7 @@ export function Canvas({ data, reload, onSignOut }: { data: CanvasData; reload:
|
||||
<VaultPanel v={vault(sel.id)} data={data} members={members} open={open} close={() => setSel(null)}
|
||||
cycleRole={cycleRole} remove={(m) => revoke(keyOf(m))} grant={grant} run={run}
|
||||
compare={(copy) => setSheet({ kind: 'compare', vault: vault(sel.id), copy })}
|
||||
deleteVault={data.me.owner ? (v) => setSheet({ kind: 'delete', v }) : undefined}
|
||||
toggleDelete={(v) => run(() => api.vaultSetting(v.name, !v.delete_from_devices), v.delete_from_devices ? `Removed people keep a read-only copy of ${v.name}.` : `Removed people's copies of ${v.name} are deleted from their devices.`)} />
|
||||
)}
|
||||
{sel.kind === 'person' && person(sel.id) && (
|
||||
@@ -585,6 +587,10 @@ export function Canvas({ data, reload, onSignOut }: { data: CanvasData; reload:
|
||||
<TeamDialog p={sheet.p} data={data} members={members} close={() => setSheet(null)}
|
||||
confirm={() => { const p = sheet.p; setSheet(null); setSel({ kind: 'person', id: p.id }); run(() => api.teamRemove(p.name), `${p.name} was removed from the team. Their devices send unshared work, then delete every vault copy.`); }} />
|
||||
)}
|
||||
{typeof sheet === 'object' && sheet?.kind === 'delete' && (
|
||||
<DeleteVaultDialog v={sheet.v} members={members} close={() => setSheet(null)}
|
||||
confirm={() => { const v = sheet.v; setSheet(null); setSel(null); run(() => api.deleteVault(v.name), `${v.name} was deleted. Every device sends unshared work, then removes its copy.`); }} />
|
||||
)}
|
||||
{typeof sheet === 'object' && sheet?.kind === 'restored' && (
|
||||
<div className="scrim" onPointerDown={(e) => { if (e.target === e.currentTarget) setSheet(null); }}>
|
||||
<div className="dialog" role="dialog" aria-modal="true" aria-label={`${sheet.p.name} restored`}>
|
||||
@@ -678,8 +684,8 @@ function Overview({ data, members, log, open, close, newVault, signOut }: {
|
||||
);
|
||||
}
|
||||
|
||||
function VaultPanel({ v, data, members, open, close, cycleRole, remove, grant, toggleDelete, run, compare }: {
|
||||
v: Vault; data: CanvasData; members: Member[]; open: (s: Sel) => void; close: () => void;
|
||||
function VaultPanel({ v, data, members, open, close, cycleRole, remove, grant, toggleDelete, run, compare, deleteVault }: {
|
||||
v: Vault; data: CanvasData; members: Member[]; open: (s: Sel) => void; close: () => void; deleteVault?: (v: Vault) => void;
|
||||
cycleRole: (m: Member) => void; remove: (m: Member) => void; grant: (v: string, p: string) => void; toggleDelete: (v: Vault) => void;
|
||||
run: (action: () => Promise<unknown>, ok?: string) => Promise<void>; compare: (copy: string) => void;
|
||||
}) {
|
||||
@@ -744,10 +750,35 @@ function VaultPanel({ v, data, members, open, close, cycleRole, remove, grant, t
|
||||
<p className="muted">Removing someone only affects this vault. Copies made elsewhere can't be recalled.</p>
|
||||
</div>
|
||||
)}
|
||||
{deleteVault && (
|
||||
<div style={{ borderTop: '1px solid #EEEAF6', paddingTop: 16 }}>
|
||||
<button className="btn btn-danger" onClick={() => deleteVault(v)}>Delete vault…</button>
|
||||
</div>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
/** Deleting a vault asks first: it ends everyone's access at once (team owner only). */
|
||||
function DeleteVaultDialog({ v, members, close, confirm }: { v: Vault; members: Member[]; close: () => void; confirm: () => void }) {
|
||||
const people = members.filter((m) => m.vault === v.id).length;
|
||||
return (
|
||||
<div className="scrim" onPointerDown={(e) => { if (e.target === e.currentTarget) close(); }}>
|
||||
<div className="dialog" role="dialog" aria-modal="true" aria-label={`Delete ${v.name}?`}>
|
||||
<h2 className="disp">Delete {v.name}?</h2>
|
||||
<p style={{ margin: 0, lineHeight: 1.5 }}>
|
||||
{plural(people, 'person', 'people')} lose access. Their devices first send anything not yet shared, then remove their copy{v.delete_from_devices ? '' : ' (or keep it read-only, as this vault is set)'}.
|
||||
</p>
|
||||
<p className="muted">The vault's history stays archived on the hub, so nothing is lost; the name {v.name} is free for a new vault. Copies made elsewhere can't be recalled.</p>
|
||||
<div className="actions">
|
||||
<button className="btn" onClick={close}>Cancel</button>
|
||||
<button className="btn btn-primary" style={{ background: '#A52A2F', borderColor: '#A52A2F' }} onClick={confirm}>Delete vault</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function PersonPanel({ p, data, members, open, close, run, removeFromTeam, restore }: {
|
||||
p: Person; data: CanvasData; members: Member[]; open: (s: Sel) => void; close: () => void;
|
||||
run: (action: () => Promise<unknown>, ok?: string) => Promise<void>; removeFromTeam: (p: Person) => void; restore: (p: Person) => void;
|
||||
|
||||
@@ -16,6 +16,7 @@ const FIRST_OPEN = 'This pilot build isn’t signed by Apple yet: the first time
|
||||
/** On an invite page: download, then join from the app with this link. */
|
||||
export function JoinWithApp({ link }: { link: string }) {
|
||||
const r = useRelease();
|
||||
const [tried, setTried] = useState(false);
|
||||
return (
|
||||
<>
|
||||
<ol className="steps">
|
||||
@@ -24,8 +25,9 @@ export function JoinWithApp({ link }: { link: string }) {
|
||||
{r?.mac && <span className="muted">Open the download and drag Lune to Applications, then open it. {FIRST_OPEN}</span>}
|
||||
</li>
|
||||
<li>
|
||||
<a className="btn" href={`lune://join?link=${encodeURIComponent(link)}`}>Open Lune to join</a>
|
||||
<a className="btn" href={`lune://join?link=${encodeURIComponent(link)}`} onClick={() => setTried(true)}>Open Lune to join</a>
|
||||
<span className="muted">Lune asks for a name for this Mac and where shared vaults should go. This link works once.</span>
|
||||
{tried && <span className="muted" role="status">Nothing happened? Install and open Lune first (step 1), then click again.</span>}
|
||||
</li>
|
||||
</ol>
|
||||
</>
|
||||
@@ -36,10 +38,13 @@ export function JoinWithApp({ link }: { link: string }) {
|
||||
export function MacSection() {
|
||||
const r = useRelease();
|
||||
const [error, setError] = useState('');
|
||||
// A lune:// link does nothing visible when Lune isn't installed, so say what to do instead.
|
||||
const [sent, setSent] = useState<string | null>(null);
|
||||
const connect = async () => {
|
||||
setError('');
|
||||
try {
|
||||
const { code } = await api.pair();
|
||||
setSent(code);
|
||||
location.href = `lune://pair?hub=${encodeURIComponent(location.origin)}&code=${encodeURIComponent(code)}`;
|
||||
} catch (e) {
|
||||
setError((e as Error).message);
|
||||
@@ -52,6 +57,13 @@ export function MacSection() {
|
||||
{r?.mac && <a className="btn btn-small" href={r.mac}>Get the Mac app</a>}
|
||||
<button className="btn btn-small" onClick={connect}>Connect this Mac</button>
|
||||
</div>
|
||||
{sent && (
|
||||
<p className="muted" role="status" style={{ padding: '4px 6px 0' }}>
|
||||
Opening Lune… Nothing happened? Lune isn't installed on this Mac yet: {r?.mac ? <a href={r.mac}>download it</a> : 'install it'}, open it, then
|
||||
click Connect this Mac again. Or in Lune choose <b>I have a pairing code instead</b> and enter <b>{location.host}</b> with
|
||||
the code <b>{sent}</b> (works once, for 10 minutes).
|
||||
</p>
|
||||
)}
|
||||
{error && <p className="error" style={{ padding: '0 6px' }}>{error}</p>}
|
||||
</section>
|
||||
);
|
||||
|
||||
@@ -101,6 +101,7 @@ export const api = {
|
||||
undoRemove: (pending: number) => call<object>('POST', '/api/remove/undo', { pending }),
|
||||
invite: (person: string, grants: { vault: string; role: Role }[]) =>
|
||||
call<{ link: string }>('POST', '/api/invites', { person, grants }),
|
||||
deleteVault: (name: string) => call<{ devices: number }>('POST', '/api/vaults/delete', { vault: name }),
|
||||
createVault: (name: string) => call<object>('POST', '/api/vaults', { name }),
|
||||
vaultSetting: (vault: string, deleteFromDevices: boolean) =>
|
||||
call<object>('POST', '/api/vaults/settings', { vault, delete_from_devices: deleteFromDevices }),
|
||||
|
||||
@@ -233,12 +233,47 @@ function CompareSheet({ vault, copy, close, done }: { vault: string; copy: strin
|
||||
);
|
||||
}
|
||||
|
||||
/** Leaving a team on this Mac. A team whose hub is gone can be forgotten here instead. */
|
||||
function LeaveSheet({ team, close, done }: { team: string; close: () => void; done: (msg: string) => void }) {
|
||||
const [error, setError] = useState('');
|
||||
const [busy, setBusy] = useState(false);
|
||||
const leave = async (forget: boolean) => {
|
||||
setBusy(true);
|
||||
setError('');
|
||||
try {
|
||||
done(await invoke<string>('leave_team', { team, forget }));
|
||||
} catch (e) {
|
||||
setError(String(e));
|
||||
} finally {
|
||||
setBusy(false);
|
||||
}
|
||||
};
|
||||
const unreachable = error.includes("can't reach");
|
||||
return (
|
||||
<div className="scrim" onPointerDown={(e) => { if (e.target === e.currentTarget) close(); }}>
|
||||
<div className="dialog" role="dialog" aria-modal="true" aria-label={`Leave ${host(team)}?`}>
|
||||
<h2 className="disp">Leave {host(team)}?</h2>
|
||||
<p className="muted">This Mac hands anything not yet shared to that team, then stops syncing its vaults. The team can add you back later.</p>
|
||||
{error && <p className="error">{error}</p>}
|
||||
{unreachable && <p className="muted">If that team is gone for good, forget it on this Mac only: its folders stay where they are, no longer synced.</p>}
|
||||
<div className="actions">
|
||||
<button className="btn" onClick={close}>Cancel</button>
|
||||
{unreachable
|
||||
? <button className="btn btn-danger" disabled={busy} onClick={() => leave(true)}>Forget it on this Mac</button>
|
||||
: <button className="btn btn-danger" disabled={busy} onClick={() => leave(false)}>{busy ? 'Leaving…' : 'Leave'}</button>}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function App() {
|
||||
const [o, setO] = useState<Overview | null>(null);
|
||||
const [error, setError] = useState('');
|
||||
const [toast, setToast] = useState('');
|
||||
const [comparing, setComparing] = useState<{ vault: string; copy: string } | null>(null);
|
||||
const [joining, setJoining] = useState(false);
|
||||
const [leaving, setLeaving] = useState<string | null>(null);
|
||||
|
||||
const load = useCallback(() => invoke<Overview>('overview').then(setO).catch((e) => setError(String(e))), []);
|
||||
useEffect(() => {
|
||||
@@ -292,7 +327,10 @@ function App() {
|
||||
{o.teams.map((t) => (
|
||||
<li key={t}>
|
||||
<span>{host(t)}</span>
|
||||
<button className="btn btn-small btn-ghost" onClick={() => act('open_canvas', { team: t }, '')}>Open canvas</button>
|
||||
<span>
|
||||
<button className="btn btn-small btn-ghost" onClick={() => act('open_canvas', { team: t }, '')}>Open canvas</button>
|
||||
<button className="btn btn-small btn-ghost" onClick={() => setLeaving(t)}>Leave</button>
|
||||
</span>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
@@ -310,6 +348,7 @@ function App() {
|
||||
</>
|
||||
)}
|
||||
{comparing && <CompareSheet {...comparing} close={() => setComparing(null)} done={(msg) => { setComparing(null); setToast(msg); load(); }} />}
|
||||
{leaving && <LeaveSheet team={leaving} close={() => setLeaving(null)} done={(msg) => { setLeaving(null); setToast(msg); load(); }} />}
|
||||
{toast && <div className="toast-d" role="status">{toast}</div>}
|
||||
</main>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user