0.1.3: upload a vault to a team from the app, detach first; AGPL-3.0
- The Lune window shows Upload on a vault that isn't on a team, for the team owner and anyone who manages a vault there. The hub now lets those people create vaults too (was owner only); /api/me and the canvas say can_create. - A vault on its own remote (GitHub, GitLab, Gitea…) must be detached first (`lunesync vault detach`, or the Upload sheet's Detach): it shares what's waiting one last time, then lives on this device only. Upload refuses anything else, and a check-in no longer silently moves a same-named vault off its own remote onto the hub. - Upload logic moved from the CLI into core (lune_core::upload). - Canvas: "1 person loses access". - License: AGPL-3.0-only. README and SPEC §8 updated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -117,6 +117,7 @@ export function Canvas({ data, reload, onSignOut }: { data: CanvasData; reload:
|
||||
}, [sel, data]);
|
||||
|
||||
const vaults = data.vaults;
|
||||
const canCreate = data.me.owner || !!data.me.can_create;
|
||||
const people = data.people;
|
||||
const vault = (id: string) => vaults.find((v) => v.id === id)!;
|
||||
const person = (id: string) => people.find((p) => p.id === id)!;
|
||||
@@ -429,8 +430,8 @@ export function Canvas({ data, reload, onSignOut }: { data: CanvasData; reload:
|
||||
{vaults.length === 0 ? (
|
||||
<div className="empty"><div>
|
||||
<h2 className="disp" style={{ margin: 0 }}>No vaults yet</h2>
|
||||
<p className="muted">{data.me.owner ? 'Create one here, or move an existing vault onto the hub with `lunesync vault upload`.' : 'When someone gives you a vault, it shows up here.'}</p>
|
||||
{data.me.owner && <button className="btn btn-primary" onClick={() => setSheet('vault')}>New vault</button>}
|
||||
<p className="muted">{canCreate ? 'Create one here, or upload one that’s already on your Mac from the Lune app.' : 'When someone gives you a vault, it shows up here.'}</p>
|
||||
{canCreate && <button className="btn btn-primary" onClick={() => setSheet('vault')}>New vault</button>}
|
||||
</div></div>
|
||||
) : (
|
||||
<div className="board" style={boardStyle}>
|
||||
@@ -649,7 +650,7 @@ function Overview({ data, members, log, open, close, newVault, signOut }: {
|
||||
<span aria-hidden="true" className="chev">›</span>
|
||||
</button>
|
||||
))}
|
||||
{data.me.owner && <button className="btn btn-small" style={{ alignSelf: 'flex-start', marginTop: 6 }} onClick={newVault}>New vault</button>}
|
||||
{(data.me.owner || data.me.can_create) && <button className="btn btn-small" style={{ alignSelf: 'flex-start', marginTop: 6 }} onClick={newVault}>New vault</button>}
|
||||
</section>
|
||||
<section className="ov-sec" aria-label="People">
|
||||
<div className="ov-head"><h3>People</h3><span className="ov-count">{data.people.length}</span></div>
|
||||
@@ -767,7 +768,7 @@ function DeleteVaultDialog({ v, members, close, confirm }: { v: Vault; members:
|
||||
<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)'}.
|
||||
{plural(people, 'person', 'people')} {people === 1 ? 'loses' : '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">
|
||||
|
||||
@@ -48,7 +48,7 @@ export interface Member {
|
||||
}
|
||||
|
||||
export interface CanvasData {
|
||||
me: { id: string; person: string; owner: boolean };
|
||||
me: { id: string; person: string; owner: boolean; can_create?: boolean };
|
||||
vaults: Vault[];
|
||||
people: Person[];
|
||||
members: Member[];
|
||||
|
||||
@@ -13,6 +13,7 @@ interface VaultStatus {
|
||||
name: string;
|
||||
path: string;
|
||||
team: string | null;
|
||||
elsewhere: string | null;
|
||||
level: Level;
|
||||
headline: string;
|
||||
last_synced: number | null;
|
||||
@@ -146,7 +147,10 @@ function SecretCard({ vault, s, act }: { vault: string; s: VaultStatus['secrets'
|
||||
);
|
||||
}
|
||||
|
||||
function VaultCard({ v, several, act, compare }: { v: VaultStatus; several: boolean; act: (cmd: string, args: Record<string, unknown>, msg: string) => void; compare: (vault: string, copy: string) => void }) {
|
||||
function VaultCard({ v, several, canUpload, upload, act, compare }: {
|
||||
v: VaultStatus; several: boolean; canUpload: boolean; upload: (v: VaultStatus) => void;
|
||||
act: (cmd: string, args: Record<string, unknown>, msg: string) => void; compare: (vault: string, copy: string) => void;
|
||||
}) {
|
||||
return (
|
||||
<article className="vault" data-vault={v.name}>
|
||||
<div className="vault-head">
|
||||
@@ -155,6 +159,7 @@ function VaultCard({ v, several, act, compare }: { v: VaultStatus; several: bool
|
||||
<b>{v.name}{several && v.team && <span className="team-tag">{host(v.team)}</span>}</b>
|
||||
<span className="muted">{v.headline}</span>
|
||||
</div>
|
||||
{canUpload && !v.team && <button className="btn btn-small" onClick={() => upload(v)}>Upload</button>}
|
||||
<button className="btn btn-small btn-ghost" onClick={() => act('open_folder', { vault: v.name }, '')}>Open folder</button>
|
||||
</div>
|
||||
{v.held.map((h) => (
|
||||
@@ -233,6 +238,74 @@ function CompareSheet({ vault, copy, close, done }: { vault: string; copy: strin
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Putting a vault on a team. A vault that still syncs somewhere else is detached from there first, so its notes
|
||||
* don't end up in two places; then it goes up with its history.
|
||||
*/
|
||||
function UploadSheet({ v, teams, close, done }: { v: VaultStatus; teams: string[]; close: () => void; done: (msg: string) => void }) {
|
||||
const [team, setTeam] = useState(teams[0]);
|
||||
const [error, setError] = useState('');
|
||||
const [busy, setBusy] = useState('');
|
||||
const [detached, setDetached] = useState(false);
|
||||
const elsewhere = v.elsewhere && !detached ? v.elsewhere : null;
|
||||
const run = async (what: string, f: () => Promise<string>) => {
|
||||
setBusy(what);
|
||||
setError('');
|
||||
try {
|
||||
return await f();
|
||||
} catch (e) {
|
||||
setError(String(e));
|
||||
} finally {
|
||||
setBusy('');
|
||||
}
|
||||
};
|
||||
const detach = async () => {
|
||||
const said = await run('Detaching…', () => invoke<string>('detach_vault', { vault: v.name }));
|
||||
if (said) setDetached(true);
|
||||
};
|
||||
const upload = async (fresh: boolean) => {
|
||||
const said = await run('Uploading…', () => invoke<string>('upload_vault', { vault: v.name, team, fresh }));
|
||||
if (said) done(said);
|
||||
};
|
||||
const secret = error.includes('fresh start');
|
||||
return (
|
||||
<div className="scrim" onPointerDown={(e) => { if (e.target === e.currentTarget && !busy) close(); }}>
|
||||
<div className="dialog" role="dialog" aria-modal="true" aria-label={`Upload ${v.name}`}>
|
||||
<div><span className="eyebrow">{v.name}</span><h2 className="disp">Upload to a team</h2></div>
|
||||
{elsewhere ? (
|
||||
<>
|
||||
<p className="muted">{v.name} syncs with <b>{elsewhere}</b> now. Detach it from there first, so its notes don't end up in two places. It stays on this Mac with all its history; {elsewhere} keeps its copy as it is.</p>
|
||||
<p className="muted">Other devices that sync it with {elsewhere} won't follow. Once it's on the team, connect them to the team instead.</p>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<p className="muted">{v.name} {detached ? 'is detached and ' : ''}is only on this Mac. Uploading puts it on the team with its history; you can then give people access on the team canvas.</p>
|
||||
{teams.length > 1 && (
|
||||
<>
|
||||
<label htmlFor="up-team">Team</label>
|
||||
<select id="up-team" className="field" value={team} onChange={(e) => setTeam(e.target.value)}>
|
||||
{teams.map((t) => <option key={t} value={t}>{host(t)}</option>)}
|
||||
</select>
|
||||
</>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
{error && <p className="error" role="alert">{error}</p>}
|
||||
<div className="actions">
|
||||
<button className="btn" disabled={!!busy} onClick={close}>{detached ? 'Later' : 'Cancel'}</button>
|
||||
{elsewhere ? (
|
||||
<button className="btn btn-primary" disabled={!!busy} onClick={detach}>{busy || `Detach from ${elsewhere}`}</button>
|
||||
) : secret ? (
|
||||
<button className="btn btn-primary" disabled={!!busy} onClick={() => upload(true)}>{busy || 'Upload current notes only'}</button>
|
||||
) : (
|
||||
<button className="btn btn-primary" disabled={!!busy} onClick={() => upload(false)}>{busy || `Upload to ${host(team)}`}</button>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
/** 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('');
|
||||
@@ -274,6 +347,8 @@ function App() {
|
||||
const [comparing, setComparing] = useState<{ vault: string; copy: string } | null>(null);
|
||||
const [joining, setJoining] = useState(false);
|
||||
const [leaving, setLeaving] = useState<string | null>(null);
|
||||
const [uploading, setUploading] = useState<VaultStatus | null>(null);
|
||||
const [uploadTeams, setUploadTeams] = useState<string[]>([]);
|
||||
|
||||
const load = useCallback(() => invoke<Overview>('overview').then(setO).catch((e) => setError(String(e))), []);
|
||||
useEffect(() => {
|
||||
@@ -281,6 +356,13 @@ function App() {
|
||||
const t = setInterval(load, 2000);
|
||||
return () => clearInterval(t);
|
||||
}, [load]);
|
||||
// Which teams this Mac may upload to is learned at each check-in, so it's asked for now and then, not every refresh.
|
||||
useEffect(() => {
|
||||
const ask = () => invoke<string[]>('upload_teams').then(setUploadTeams).catch(() => setUploadTeams([]));
|
||||
ask();
|
||||
const t = setInterval(ask, 15000);
|
||||
return () => clearInterval(t);
|
||||
}, [o?.teams.join(' ')]);
|
||||
useEffect(() => {
|
||||
if (!toast) return;
|
||||
const t = setTimeout(() => setToast(''), 4000);
|
||||
@@ -319,7 +401,9 @@ function App() {
|
||||
<>
|
||||
<section className="vaults">
|
||||
{o.vaults.length === 0 && <p className="muted center">Your vaults are on their way. They'll appear in {o.folder}.</p>}
|
||||
{o.vaults.map((v) => <VaultCard key={v.path} v={v} several={o.teams.length > 1} act={act} compare={(vault, copy) => setComparing({ vault, copy })} />)}
|
||||
{o.vaults.map((v) => (
|
||||
<VaultCard key={v.path} v={v} several={o.teams.length > 1} canUpload={uploadTeams.length > 0} upload={setUploading} act={act} compare={(vault, copy) => setComparing({ vault, copy })} />
|
||||
))}
|
||||
</section>
|
||||
<footer className="foot">
|
||||
<span className="muted">{o.device} · Lune {o.version}</span>
|
||||
@@ -348,6 +432,7 @@ function App() {
|
||||
</>
|
||||
)}
|
||||
{comparing && <CompareSheet {...comparing} close={() => setComparing(null)} done={(msg) => { setComparing(null); setToast(msg); load(); }} />}
|
||||
{uploading && <UploadSheet v={uploading} teams={uploadTeams} close={() => { setUploading(null); load(); }} done={(msg) => { setUploading(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