Project format updates
This commit is contained in:
@@ -27,19 +27,19 @@ await client.close();
|
||||
|
||||
The shared UI provides a searchable project overview, recent activity, project creation, an active-project header, file/media browsing, transfer actions and a Tauri-compatible HTML confirmation for dirty project switches. English and Dutch labels are included. It inherits ISA extension theme tokens; detailed application workflows and planning remain in the extension. Components consume a captured client instance: remount with a new client when the launch context changes.
|
||||
|
||||
`client.activate(reference)` opens a listed or recent reference after verifying its manifest. In shared group mode it also refreshes folder identity and access from the launch group's catalog. `client.create(name, operationId?)` creates an ordinary folder and publishes its manifest after the standard subdirectories exist. It retains the same operation ID and folder through uncertain retries in the current client. Callers with durable recovery journals should provide their persisted operation ID. Recent references are private, launch-scoped host preferences rather than canonical project state. Preference failures are observable on `session.preferenceError` and do not invalidate an already committed creation/switch.
|
||||
`client.activate(reference)` opens a listed or recent reference after verifying its manifest. In shared group mode it opens the single selected folder through the host and revalidates its identity and access in the launch group. `client.create(name, operationId?)` creates an ordinary folder and publishes its manifest after the standard subdirectories exist. It retains the same operation ID and folder through uncertain retries in the current client. Callers with durable recovery journals should provide their persisted operation ID. Recent references are private, launch-scoped host preferences rather than canonical project state. Preference failures are observable on `session.preferenceError` and do not invalidate an already committed creation/switch.
|
||||
|
||||
Sessions capture their project path and abort signal. `readJson` returns an authoritative CAS base; `writeJson(relative, value, base, {operationId?})` requires that same file’s base and sends its revision/hash. `ensureDirectory(relative)` creates real parent directories in order; `openKv` does this for its parent before opening a store. A requested synchronized store uses offline storage when the granted parent is synchronized. Otherwise, new stores use the ordinary online filesystem contract. `openKv`, `applyKv` and `subscribeKv` use the captured project destination. Use `extensionPath` for extension-owned paths, `publishStatus` for summaries and `readStatuses` for the overview. Subscriptions and registered cleanup callbacks close on switching; late results cannot use a retired session. Mark unsaved work with `session.markDirty()`. Without explicit confirmation, dirty sessions block switching. Mounting the shared UI supplies a confirmation; applications can provide `beforeSwitch` to integrate an existing save/discard workflow.
|
||||
|
||||
## Project start screen
|
||||
|
||||
Use `sharedProjectsFolder: true` with `filesystem: appInfo.filesystem` for the shared group overview. Declare `group_projects_read` and `filesystem_read` in the extension manifest. The host advertises `supportsSharedGroupProjects` and `filesystem_list_group_projects` when the launch group supports automatic project access. The catalog lists projects created for the launch group through `filesystem_create_group_project`. Each has a direct `/shared/*.isap` path and a manifest that the client verifies. Members can open these projects on their first visit. Earlier projects retain their existing folder access. A writable extension with `filesystem_write` uses `filesystem_create_group_project` to create or import into the same group. Opening a writable project provisions the extension's namespace, where it can initialize its own data. Older hosts display an update instruction.
|
||||
Use `sharedProjectsFolder: true` with `filesystem: appInfo.filesystem` for the shared group overview. Declare `group_projects_read` and `filesystem_read` in the extension manifest. On a host advertising `filesystem_list_group_projects` and `filesystem_open_group_project`, the overview reads the active group's existing file inventory. It lists the active group’s `.isap` folders with valid manifests, including projects created in other extensions. Each row reports whether the extension already has its own instance in the project (`hasInstance`). Listing projects gives the extension no file grants. Selecting a project asks the host for access to that folder using the member's current rights and the extension's declared filesystem permissions. A writable session can create the extension's instance inside the selected project. `filesystem_create_group_project` reserves an ordinary folder for a new project or import. The client creates the standard subdirectories and publishes `project.json` last. The dashboard creates these folders in the originating group’s project directory. Workspace admins retain administrative access. A creator who leaves the group has no ownership exception.
|
||||
|
||||
### Other client configurations
|
||||
|
||||
The default client uses the user's selected folders for listing and creation, including on hosts that advertise the group project catalog.
|
||||
|
||||
Use `client.withListedProject(row, action)` for project-specific background initialization. The callback receives a temporary session and leaves the active project and recent activity intact. ISA Projects initializes its first planning board with a stable ID when a writable shared project opens.
|
||||
Use `client.withListedProject(row, action)` for an explicitly selected project that requires a temporary session. The callback receives a temporary session and leaves the active project and recent activity intact. ISA Projects initializes its first planning board with a stable ID when a writable shared project opens.
|
||||
|
||||
Pass `groupFolder: true` to `createProjectClient` to use the extension’s folder for the current launch group as its default project location. This mode requires the host command `filesystem_ensure_group_folder`. The client lists projects from that folder and any additional folders the user has selected. New projects and project imports use the group folder.
|
||||
|
||||
|
||||
+20
-11
@@ -14,6 +14,7 @@ function reference(value) {
|
||||
validateArchivePath(path.slice(1));
|
||||
return { id, folderId: id, path, name: String(value.name ?? ''),
|
||||
archived: Boolean(value.archived), updatedAt: value.updatedAt, canWrite: value.canWrite,
|
||||
...(typeof value.hasInstance === 'boolean' && { hasInstance: value.hasInstance }),
|
||||
projectIdentity: String(value.projectIdentity ?? id), manifestPath: `${path}/project.json`, formatVersion: 1 };
|
||||
}
|
||||
|
||||
@@ -25,7 +26,8 @@ export function createProjectClient({ bridge, extensionId, scope, filesystem, fi
|
||||
const supportsFilesystem = command => !filesystemCommands || filesystemCommands.includes(command);
|
||||
if (groupFolder && sharedProjectsFolder) throw new TypeError('Choose one project storage location');
|
||||
const supportsSharedGroupProjects = sharedProjectsFolder && filesystem?.supportsSharedGroupProjects === true
|
||||
&& filesystemCommands?.includes('filesystem_list_group_projects') === true;
|
||||
&& filesystemCommands?.includes('filesystem_list_group_projects') === true
|
||||
&& filesystemCommands.includes('filesystem_open_group_project');
|
||||
const canCreateSharedProject = supportsSharedGroupProjects && filesystemCommands.includes('filesystem_create_group_project');
|
||||
const canWrite = supportsFilesystem('filesystem_upload_files');
|
||||
let active = null, recents = [], generation = 0, closed = false;
|
||||
@@ -81,6 +83,12 @@ export function createProjectClient({ bridge, extensionId, scope, filesystem, fi
|
||||
return { project: { ...project, name: manifest.name, updatedAt: manifest.updatedAt,
|
||||
archived: manifest.archived ?? project.archived, canWrite: canWrite && project.canWrite }, manifest, snapshot };
|
||||
}
|
||||
async function loadListedProject(value, check) {
|
||||
check();
|
||||
const project = await projectFiles.openReference(reference(value));
|
||||
check();
|
||||
return loadProject(project, check);
|
||||
}
|
||||
function checkTransition(ticket) {
|
||||
guard();
|
||||
if (ticket !== generation) throw abortError();
|
||||
@@ -285,6 +293,12 @@ export function createProjectClient({ bridge, extensionId, scope, filesystem, fi
|
||||
pendingCreations.set(name, creation);
|
||||
return creation;
|
||||
}
|
||||
async function leave() {
|
||||
guard(); const ticket=beginTransition(); const previous=active;
|
||||
await approveSwitch(previous);
|
||||
if(ticket!==generation)throw abortError();
|
||||
active=null; notify(); await previous?.close();
|
||||
}
|
||||
return {
|
||||
scope: captured, extensionId, groupFolder, sharedProjectsFolder,
|
||||
supports(action) {
|
||||
@@ -348,25 +362,20 @@ export function createProjectClient({ bridge, extensionId, scope, filesystem, fi
|
||||
return current;
|
||||
} finally { await session.close(); }
|
||||
},
|
||||
openListed(project) { return switchTo(check => loadProject(project, check)); },
|
||||
openListed(project) { return switchTo(check => loadListedProject(project, check)); },
|
||||
async withListedProject(value, action) {
|
||||
const { project, manifest, snapshot } = await loadProject(value, guard);
|
||||
const { project, manifest, snapshot } = await loadListedProject(value, guard);
|
||||
guard();
|
||||
const session = makeSession(project, manifest, snapshot);
|
||||
try { return await action(session); } finally { await session.close(); }
|
||||
},
|
||||
activate(project) { return switchTo(async check => loadProject(await projectFiles.refreshReference(reference(project)), check)); },
|
||||
activate(project) { return switchTo(check => loadListedProject(project, check)); },
|
||||
async setArchived(project, archived) {
|
||||
if (typeof archived !== 'boolean') throw new TypeError('Archive state must be a boolean');
|
||||
const loaded = await loadProject(project, guard);
|
||||
const loaded = await loadListedProject(project, guard);
|
||||
await projectFiles.setArchived(loaded.project, loaded.snapshot, loaded.manifest, archived);
|
||||
},
|
||||
async leave() {
|
||||
guard(); const ticket=beginTransition(); const previous=active;
|
||||
await approveSwitch(previous);
|
||||
if(ticket!==generation)throw abortError();
|
||||
active=null; notify(); await previous?.close();
|
||||
},
|
||||
leave,
|
||||
async close() {
|
||||
if (closed) return; closed = true; generation++;
|
||||
active = null; await Promise.allSettled([...sessions].map(session=>session.close())); notify(); listeners.clear(); confirmationHandlers.length=0;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script>
|
||||
import ProjectWorkspace from './ProjectWorkspace.svelte';
|
||||
let {client,bridge,extensionName,locale='en',beforeExport}=$props();
|
||||
let {client,bridge,extensionName,locale='en',onImport,onExport,onOverview,beforeExport}=$props();
|
||||
</script>
|
||||
<ProjectWorkspace {client} {bridge} {extensionName} {locale} {beforeExport} mode="header" />
|
||||
<ProjectWorkspace {client} {bridge} {extensionName} {locale} {beforeExport} {onImport} {onExport} {onOverview} mode="header" />
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script>
|
||||
import ProjectWorkspace from './ProjectWorkspace.svelte';
|
||||
let {client,bridge,extensionName,locale='en',onOverview}=$props();
|
||||
let {client,bridge,extensionName,locale='en',onImport,onExport,onOverview}=$props();
|
||||
</script>
|
||||
<ProjectWorkspace {client} {bridge} {extensionName} {locale} {onOverview} mode="picker" />
|
||||
<ProjectWorkspace {client} {bridge} {extensionName} {locale} {onImport} {onExport} {onOverview} mode="picker" />
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<script>
|
||||
import { onMount } from 'svelte';
|
||||
import { mountProjectWorkspace } from '../dom.js';
|
||||
let {client,bridge,extensionName,locale='en',onOverview,beforeExport,mode='workspace'}=$props();
|
||||
let {client,bridge,extensionName,locale='en',onImport,onExport,onOverview,beforeExport,mode='workspace'}=$props();
|
||||
let target;
|
||||
onMount(()=>{const view=mountProjectWorkspace(target,{client,bridge,extensionName,locale,mode,beforeExport,onOverview});return()=>view.destroy();});
|
||||
onMount(()=>{const view=mountProjectWorkspace(target,{client,bridge,extensionName,locale,mode,beforeExport,onImport,onExport,onOverview});return()=>view.destroy();});
|
||||
</script>
|
||||
<div bind:this={target}></div>
|
||||
|
||||
Vendored
+2
@@ -2,6 +2,8 @@ import type { ProjectClient, ProjectBridge, ProjectSession } from './index.js';
|
||||
export interface ProjectMountOptions {
|
||||
extensionName?: string; client: ProjectClient; bridge?: ProjectBridge; locale?: 'en' | 'nl';
|
||||
onOverview?: (actions: {refresh(): Promise<void>} | null) => void;
|
||||
onImport?: () => Promise<unknown>;
|
||||
onExport?: (session: ProjectSession) => Promise<unknown>;
|
||||
beforeExport?: (session: ProjectSession) => void | Promise<void>;
|
||||
mode?: 'workspace' | 'picker' | 'header';
|
||||
}
|
||||
|
||||
+9
-9
@@ -3,7 +3,7 @@ import { labels } from './labels.js';
|
||||
import { exportProjectToDialog, importProjectFromDialog } from './transfer.js';
|
||||
import { styles } from './styles.js';
|
||||
|
||||
export function mountProjectWorkspace(target, {client,bridge,locale='en',extensionName,mode='workspace',beforeExport,onOverview} = {}) {
|
||||
export function mountProjectWorkspace(target, {client,bridge,locale='en',extensionName,mode='workspace',beforeExport,onOverview,onImport,onExport} = {}) {
|
||||
if (!target?.ownerDocument || !client) throw new TypeError('Mount target and project client required');
|
||||
const document = target.ownerDocument;
|
||||
const text = labels[locale] ?? labels.en;
|
||||
@@ -22,7 +22,7 @@ export function mountProjectWorkspace(target, {client,bridge,locale='en',extensi
|
||||
return element;
|
||||
};
|
||||
function button(label,action) {
|
||||
const element=make('button',label,'isa-extension-button');element.type='button';element.disabled=busy;
|
||||
const element=make('button',label,'isa-extension-button isa-extension-button--secondary');element.type='button';element.disabled=busy;
|
||||
element.addEventListener('click',()=>perform(action));return element;
|
||||
}
|
||||
async function perform(action) {
|
||||
@@ -37,8 +37,8 @@ export function mountProjectWorkspace(target, {client,bridge,locale='en',extensi
|
||||
const question=make('p',text.dirty);question.id=`isa-project-confirm-${crypto.randomUUID()}`;
|
||||
dialog.setAttribute('aria-labelledby',question.id);
|
||||
const actions=make('div',null,'isa-project-toolbar');
|
||||
const cancel=make('button',text.cancel);cancel.type='button';cancel.onclick=()=>dialog.close('cancel');
|
||||
const discard=make('button',text.discard);discard.type='button';discard.onclick=()=>dialog.close('discard');
|
||||
const cancel=make('button',text.cancel,'isa-extension-button isa-extension-button--secondary');cancel.type='button';cancel.onclick=()=>dialog.close('cancel');
|
||||
const discard=make('button',text.discard,'isa-extension-button isa-extension-button--danger');discard.type='button';discard.onclick=()=>dialog.close('discard');
|
||||
actions.append(cancel,discard);dialog.append(question,actions);shell.append(dialog);dialogs.add(dialog);
|
||||
dialog.addEventListener('close',()=>{dialogs.delete(dialog);dialog.remove();resolve(dialog.returnValue==='discard');},{once:true});
|
||||
dialog.showModal();cancel.focus();
|
||||
@@ -87,19 +87,19 @@ export function mountProjectWorkspace(target, {client,bridge,locale='en',extensi
|
||||
if (!removeOverview) {
|
||||
content.replaceChildren();
|
||||
removeOverview = mountOverview(content,{client,extensionName,text,locale,onOverview,
|
||||
onImport:bridge && (() => importProjectFromDialog(client,{bridge}))});
|
||||
onImport:onImport ?? (bridge && (() => importProjectFromDialog(client,{bridge})))});
|
||||
}
|
||||
return;
|
||||
}
|
||||
removeOverview?.(); removeOverview = null;
|
||||
content.replaceChildren();shell.setAttribute('aria-busy',String(busy));
|
||||
const toolbar=make('div',null,'isa-project-toolbar');
|
||||
if(session) toolbar.append(make('h2',session.manifest.name,'isa-project-title'));
|
||||
if(bridge && client.supports('create'))toolbar.append(button(text.import,()=>importProjectFromDialog(client,{bridge})));
|
||||
if(bridge&&session)toolbar.append(button(text.export,()=>exportProjectToDialog(session,{bridge,beforeExport})));
|
||||
if(session) toolbar.append(make('h2',session.manifest.name,'isa-extension-heading isa-extension-heading--section isa-project-title'));
|
||||
if(bridge && client.supports('create'))toolbar.append(button(text.import,onImport ?? (()=>importProjectFromDialog(client,{bridge}))));
|
||||
if(bridge&&session)toolbar.append(button(text.export,()=>onExport ? onExport(session) : exportProjectToDialog(session,{bridge,beforeExport})));
|
||||
if(session) toolbar.append(button(text.close,()=>client.leave()));
|
||||
content.append(toolbar);
|
||||
if(error){const notice=make('p',error);notice.setAttribute('role','alert');content.append(notice);}
|
||||
if(error){const notice=make('p',error,'isa-extension-notice isa-extension-notice--error');notice.setAttribute('role','alert');content.append(notice);}
|
||||
if(session&&mode==='workspace') {
|
||||
const navigation=make('div',null,'isa-project-toolbar');navigation.append(button(text.files,()=>loadFiles(session)));
|
||||
if(directory)navigation.append(button(text.back,()=>loadFiles(session,directory.split('/').slice(0,-1).join('/'))));
|
||||
|
||||
Vendored
+1
-1
@@ -17,7 +17,7 @@ export function extensionDataPath(extensionId: string, relativePath: string): st
|
||||
|
||||
export interface ProjectReference {
|
||||
id: string; folderId: string; path: string; name: string;
|
||||
archived?: boolean; updatedAt?: string; canWrite?: boolean;
|
||||
archived?: boolean; updatedAt?: string; canWrite?: boolean; hasInstance?: boolean;
|
||||
projectIdentity: string; manifestPath: string; formatVersion: 1;
|
||||
}
|
||||
export interface ProjectScope { workspaceId: string; groupId: string; }
|
||||
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
export const labels = {
|
||||
en: {createTitle:'Create new project',updateHost:'Update ISA Warden and the dashboard to use shared group projects.',projects:'Projects',search:'Search projects',updated:'Last modified',sort:'Sort projects',activity:'Recent activity',noActivity:'No projects opened yet.',noProjects:'No projects yet.',noMatches:'No matching projects.',refresh:'Refresh',pickFolder:'Add project folder',create:'Create project',name:'Project name',recent:'Recent projects',files:'Files',back:'Back',close:'Close project',empty:'No files',loading:'Loading…',cancel:'Cancel',discard:'Discard changes',dirty:'Discard unsaved project changes?',retry:'Retry',export:'Export project',import:'Import project'},
|
||||
nl: {createTitle:'Nieuw project aanmaken',updateHost:'Werk ISA Warden en het dashboard bij om gedeelde groepsprojecten te gebruiken.',projects:'Projecten',search:'Zoek op projectnaam',updated:'Laatst gewijzigd',sort:'Projecten sorteren',activity:'Recente activiteit',noActivity:'Nog geen projecten geopend.',noProjects:'Nog geen projecten.',noMatches:'Geen overeenkomende projecten.',refresh:'Vernieuwen',pickFolder:'Projectmap toevoegen',create:'Project maken',name:'Projectnaam',recent:'Recente projecten',files:'Bestanden',back:'Terug',close:'Project sluiten',empty:'Geen bestanden',loading:'Laden…',cancel:'Annuleren',discard:'Wijzigingen weggooien',dirty:'Niet-opgeslagen projectwijzigingen weggooien?',retry:'Opnieuw proberen',export:'Project exporteren',import:'Project importeren'}
|
||||
en: {createInstance:'Create instance',creating:'Creating project…',newProject:'New project',createTitle:'Create new project',saveProject:'Save project',projects:'Projects',search:'Search projects',updated:'Last modified',sort:'Sort projects',activity:'Recent activity',noActivity:'No projects opened yet.',noProjects:'No projects yet.',noMatches:'No matching projects.',refresh:'Refresh',pickFolder:'Add project folder',updateHost:'Update ISA Warden to use shared group projects.',create:'Create project',name:'Project name',recent:'Recent projects',files:'Files',back:'Back',close:'Close project',empty:'No files',loading:'Loading…',cancel:'Cancel',discard:'Discard changes',dirty:'Discard unsaved project changes?',retry:'Retry',export:'Export project',import:'Import project'},
|
||||
nl: {createInstance:'Instance aanmaken',creating:'Project wordt aangemaakt…',newProject:'Nieuw project',createTitle:'Nieuw project aanmaken',saveProject:'Bewaar project',projects:'Projecten',search:'Zoek op projectnaam',updated:'Laatst gewijzigd',sort:'Projecten sorteren',activity:'Recente activiteit',noActivity:'Nog geen projecten geopend.',noProjects:'Nog geen projecten.',noMatches:'Geen overeenkomende projecten.',refresh:'Vernieuwen',pickFolder:'Projectmap toevoegen',updateHost:'Werk ISA Warden bij om gedeelde groepsprojecten te gebruiken.',create:'Project maken',name:'Projectnaam',recent:'Recente projecten',files:'Bestanden',back:'Terug',close:'Project sluiten',empty:'Geen bestanden',loading:'Laden…',cancel:'Annuleren',discard:'Wijzigingen weggooien',dirty:'Niet-opgeslagen projectwijzigingen weggooien?',retry:'Opnieuw proberen',export:'Project exporteren',import:'Project importeren'}
|
||||
};
|
||||
|
||||
+31
-12
@@ -19,12 +19,15 @@ export function mountOverview(target, {client, extensionName, text, locale, onIm
|
||||
header.append(element('h1', extensionName || text.projects));
|
||||
const actions = element('div', '', 'isa-project-toolbar');
|
||||
const refreshButton = button(text.refresh, refresh);
|
||||
refreshButton.className = 'isa-extension-button isa-extension-button--secondary';
|
||||
actions.append(refreshButton);
|
||||
const pickFolder = button(text.pickFolder, () => run(async () => {
|
||||
if (await client.pickFolder()) await refresh();
|
||||
}));
|
||||
pickFolder.className = 'isa-extension-button isa-extension-button--secondary';
|
||||
if (client.supports('pickFolder')) actions.append(pickFolder);
|
||||
const importButton = button(text.import, () => run(onImport));
|
||||
importButton.className = 'isa-extension-button isa-extension-button--secondary';
|
||||
if (onImport && client.supports('create')) actions.append(importButton);
|
||||
header.append(actions);
|
||||
const grid = element('div', '', 'isa-group-grid');
|
||||
@@ -33,8 +36,8 @@ export function mountOverview(target, {client, extensionName, text, locale, onIm
|
||||
activity.append(element('h2', text.activity), recent);
|
||||
const panel = element('section', '', 'isa-group-projects');
|
||||
const heading = element('header');
|
||||
const create = button('+ ' + text.create, () => { name.value = ''; formError.textContent = ''; dialog.showModal(); name.focus(); });
|
||||
create.className = 'isa-group-create';
|
||||
const create = button('+ ' + (client.groupFolder ? text.newProject : text.create), () => { name.value = ''; formError.textContent = ''; dialog.showModal(); name.focus(); });
|
||||
create.className = 'isa-extension-button isa-extension-button--primary';
|
||||
const panelTitle = element('h2', text.projects);
|
||||
panelTitle.id = 'isa-projects-' + crypto.randomUUID();
|
||||
panel.setAttribute('aria-labelledby',panelTitle.id);
|
||||
@@ -58,20 +61,26 @@ export function mountOverview(target, {client, extensionName, text, locale, onIm
|
||||
status.setAttribute('role','status');
|
||||
panel.append(heading,controls,alert,status,list);
|
||||
grid.append(activity,panel);
|
||||
const dialog = element('dialog');
|
||||
const dialog = element('dialog', '', 'isa-project-create-dialog');
|
||||
const title = element('h2', text.createTitle);
|
||||
title.id = 'project-create-' + crypto.randomUUID();
|
||||
dialog.setAttribute('aria-labelledby',title.id);
|
||||
const form = element('form');
|
||||
const label = element('label', text.name);
|
||||
const name = element('input');
|
||||
name.required = true; name.maxLength = 160; label.append(name);
|
||||
const name = element('input', '', 'isa-extension-input');
|
||||
name.required = true;
|
||||
name.maxLength = 160;
|
||||
name.placeholder = text.name;
|
||||
name.setAttribute('aria-label', text.name);
|
||||
const formError = element('p'); formError.setAttribute('role','alert');
|
||||
const cancel = button(text.cancel, () => dialog.close());
|
||||
const submit = element('button',text.create); submit.type = 'submit';
|
||||
const submit = element('button',client.groupFolder ? text.saveProject : text.create); submit.type = 'submit';
|
||||
cancel.className = 'isa-extension-button isa-extension-button--secondary';
|
||||
submit.className = 'isa-extension-button isa-extension-button--primary';
|
||||
const progress = element('p', '', 'isa-project-create-progress');
|
||||
progress.setAttribute('role','status');
|
||||
const footer = element('div', '', 'isa-project-toolbar'); footer.append(cancel,submit);
|
||||
form.append(label,formError,footer);
|
||||
dialog.append(title,form);
|
||||
form.append(name,formError,footer);
|
||||
dialog.append(title,form,progress);
|
||||
if (!onOverview) root.append(header);
|
||||
else root.classList.add('isa-group-home-embedded');
|
||||
root.append(grid,dialog);
|
||||
@@ -97,11 +106,12 @@ export function mountOverview(target, {client, extensionName, text, locale, onIm
|
||||
existing.delete(project.id);
|
||||
row.onclick = () => run(() => client.openListed(project));
|
||||
row.disabled = busy;
|
||||
const firstUse = project.hasInstance === false && project.canWrite && !project.archived;
|
||||
if (detailed) {
|
||||
row.querySelector('strong').textContent = project.name;
|
||||
row.querySelector('small').textContent = project.path;
|
||||
row.querySelector('small').textContent = firstUse ? text.createInstance : project.path;
|
||||
row.querySelector('time').textContent = Number.isFinite(Date.parse(project.updatedAt)) ? date.format(new Date(project.updatedAt)) : '';
|
||||
} else row.textContent = project.name;
|
||||
} else row.textContent = firstUse ? `${project.name} · ${text.createInstance}` : project.name;
|
||||
if (container.children[index] !== row) container.insertBefore(row, container.children[index] ?? null);
|
||||
});
|
||||
for (const obsolete of existing.values()) obsolete.remove();
|
||||
@@ -141,7 +151,16 @@ export function mountOverview(target, {client, extensionName, text, locale, onIm
|
||||
dialog.oncancel = event => { if (busy) event.preventDefault(); };
|
||||
form.onsubmit = event => {
|
||||
event.preventDefault();
|
||||
if (name.value.trim()) void run(() => client.create(name.value.trim()), formError);
|
||||
const projectName = name.value.trim();
|
||||
if (!projectName || busy) return;
|
||||
progress.textContent = text.creating;
|
||||
submit.disabled = cancel.disabled = true;
|
||||
void run(() => client.create(projectName), formError).finally(() => {
|
||||
if (!alive) return;
|
||||
progress.textContent = '';
|
||||
submit.disabled = cancel.disabled = false;
|
||||
name.focus();
|
||||
});
|
||||
};
|
||||
search.oninput = sort.onchange = draw;
|
||||
const unsubscribe = client.subscribe(state => { recents = state.recents; draw(); });
|
||||
|
||||
+40
-28
@@ -4,7 +4,7 @@ import { ProjectUnavailableError } from './shared-read.js';
|
||||
|
||||
const ROOTS_KEY = 'isa-project-format.folders.v1';
|
||||
const folderKey = id => String(id).replace(/^workspace_file:/, '');
|
||||
const isSharedProject = path => typeof path === 'string' && /^\/shared\/[^/]+\.isap$/.test(path);
|
||||
const isSharedProject = path => typeof path === 'string' && /^\/groups\/_group_ids\/[a-f0-9]{64}\/projects\/[^/]+\.isap$/.test(path);
|
||||
|
||||
function unavailableGrant(error) {
|
||||
const message = String(error?.message ?? error).toLowerCase();
|
||||
@@ -13,12 +13,13 @@ function unavailableGrant(error) {
|
||||
}
|
||||
|
||||
function folderReference(value) {
|
||||
const { path, fileId = value.id, access, canWrite, archivedAt } = value;
|
||||
const { path, fileId = value.id, access, canWrite, archivedAt, hasInstance } = value;
|
||||
if (typeof fileId !== 'string' || !fileId || typeof path !== 'string' || !path.startsWith('/')) {
|
||||
throw new ProjectUnavailableError('Invalid project folder reference');
|
||||
}
|
||||
validateArchivePath(path.slice(1));
|
||||
return { path, fileId, canWrite: access ? access === 'read_write' : canWrite === true, archivedAt };
|
||||
return { path, fileId, canWrite: access ? access === 'read_write' : canWrite === true, archivedAt,
|
||||
...(typeof hasInstance === 'boolean' && { hasInstance }) };
|
||||
}
|
||||
|
||||
export function manifestFromSnapshot(snapshot) {
|
||||
@@ -105,14 +106,14 @@ export function createProjectFilesystem({ invoke, invokePrivateStorage, read, ca
|
||||
return {
|
||||
id: folder.fileId, folderId: folder.fileId, path: folder.path,
|
||||
name: manifest.name, projectIdentity: manifest.id,
|
||||
canWrite: canWrite && folder.canWrite, updatedAt: manifest.updatedAt,
|
||||
canWrite: canWrite && folder.canWrite, updatedAt: manifest.updatedAt, hasInstance: folder.hasInstance,
|
||||
archived: manifest.archived ?? Boolean(folder.archivedAt)
|
||||
};
|
||||
}
|
||||
|
||||
function requireSharedCatalog() {
|
||||
if (supportsSharedGroupProjects) return;
|
||||
const error = new ProjectUnavailableError('Update ISA Warden and the dashboard to use shared group projects.');
|
||||
const error = new ProjectUnavailableError('Update ISA Warden to use shared group projects.');
|
||||
error.code = 'SHARED_GROUP_PROJECTS_UNAVAILABLE';
|
||||
throw error;
|
||||
}
|
||||
@@ -130,8 +131,9 @@ export function createProjectFilesystem({ invoke, invokePrivateStorage, read, ca
|
||||
if (result?.authoritative !== true || result.error || !Array.isArray(result.folders)) {
|
||||
throw new ProjectUnavailableError('Group project inventory unavailable');
|
||||
}
|
||||
return result.folders.filter(row => isSharedProject(row?.path)).map(row =>
|
||||
folderReference({ fileId: row.fileId ?? row.id, path: row.path, canWrite: row.canWrite, archivedAt: row.archivedAt }));
|
||||
return result.folders.filter(row => isSharedProject(row?.path)).map(row => ({
|
||||
...folderReference(row), manifest: row.manifest
|
||||
}));
|
||||
}
|
||||
const folders = new Map();
|
||||
for (const root of await roots()) {
|
||||
@@ -157,12 +159,16 @@ export function createProjectFilesystem({ invoke, invokePrivateStorage, read, ca
|
||||
return [...folders.values()];
|
||||
}
|
||||
|
||||
async function refreshReference(project) {
|
||||
async function openReference(project) {
|
||||
if (!sharedProjectsFolder) return project;
|
||||
const folders = await projectFolders();
|
||||
const current = folders.find(folder => folder.path === project.path && folderKey(folder.fileId) === folderKey(project.folderId));
|
||||
if (!current) throw new ProjectUnavailableError('Project is no longer available in this group');
|
||||
return { ...project, id: current.fileId, folderId: current.fileId, canWrite: current.canWrite, archived: Boolean(current.archivedAt) };
|
||||
requireProjectPath(project.path);
|
||||
const row = await invoke('filesystem_open_group_project', { folderId: project.folderId });
|
||||
const current = folderReference(row);
|
||||
if (current.path !== project.path || folderKey(current.fileId) !== folderKey(project.folderId)) {
|
||||
throw new ProjectUnavailableError('Project folder identity changed');
|
||||
}
|
||||
return { ...project, id: current.fileId, folderId: current.fileId,
|
||||
canWrite: current.canWrite, archived: Boolean(current.archivedAt), hasInstance: current.hasInstance };
|
||||
}
|
||||
|
||||
async function list(includeArchived) {
|
||||
@@ -172,15 +178,17 @@ export function createProjectFilesystem({ invoke, invokePrivateStorage, read, ca
|
||||
for (let start = 0; start < candidates.length; start += 12) {
|
||||
const batch = await Promise.all(candidates.slice(start, start + 12).map(async folder => {
|
||||
let snapshot;
|
||||
try {
|
||||
snapshot = await read(folder.path + '/project.json');
|
||||
} catch (error) {
|
||||
if (unavailableGrant(error)) return null;
|
||||
throw error;
|
||||
if (!sharedProjectsFolder) {
|
||||
try {
|
||||
snapshot = await read(folder.path + '/project.json');
|
||||
} catch (error) {
|
||||
if (unavailableGrant(error)) return null;
|
||||
throw error;
|
||||
}
|
||||
if (snapshot.status === 'absent') return null;
|
||||
}
|
||||
if (snapshot.status === 'absent') return null;
|
||||
try {
|
||||
const manifest = manifestFromSnapshot(snapshot);
|
||||
const manifest = sharedProjectsFolder ? parseProjectManifest(folder.manifest) : manifestFromSnapshot(snapshot);
|
||||
return manifest.importPending === true ? null : projectFrom(folder, manifest);
|
||||
} catch {
|
||||
// A folder with the suffix can contain an unrelated or unsupported manifest.
|
||||
@@ -208,20 +216,17 @@ export function createProjectFilesystem({ invoke, invokePrivateStorage, read, ca
|
||||
}
|
||||
}
|
||||
|
||||
async function create(name, creation, check, importing = false) {
|
||||
if (!canWrite) throw new ProjectUnavailableError('Project folder is read-only');
|
||||
const manifest = createProjectManifest({ id: creation.id, name });
|
||||
if (importing) manifest.importPending = true;
|
||||
async function creationFolder(name, creation, check) {
|
||||
if (sharedProjectsFolder) {
|
||||
requireSharedCatalog();
|
||||
if (!canCreateSharedProject) throw new ProjectUnavailableError('Group project creation is unavailable');
|
||||
const row = await invoke('filesystem_create_group_project', {
|
||||
projectId: manifest.id, name: manifest.name, importPending: importing
|
||||
projectId: creation.id, name
|
||||
});
|
||||
if (!isSharedProject(row?.path) || row.canWrite !== true) {
|
||||
throw new ProjectUnavailableError('Group project creation was not confirmed');
|
||||
}
|
||||
return projectFrom(folderReference(row), manifest);
|
||||
return folderReference(row);
|
||||
}
|
||||
if (!creation.root) {
|
||||
const available = groupFolder ? [await groupRoot()] : await selectedRoots();
|
||||
@@ -247,9 +252,16 @@ export function createProjectFilesystem({ invoke, invokePrivateStorage, read, ca
|
||||
throw new ProjectUnavailableError('Choose an editable folder to store projects');
|
||||
}
|
||||
const prefix = name.toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-|-$/g, '').slice(0, 70);
|
||||
const path = `${creation.root.path}/${prefix || 'project'}-${manifest.id}.isap`;
|
||||
const folder = await ensureFolder(path);
|
||||
return ensureFolder(`${creation.root.path}/${prefix || 'project'}-${creation.id}.isap`);
|
||||
}
|
||||
|
||||
async function create(name, creation, check, importing = false) {
|
||||
if (!canWrite) throw new ProjectUnavailableError('Project folder is read-only');
|
||||
const manifest = createProjectManifest({ id: creation.id, name });
|
||||
if (importing) manifest.importPending = true;
|
||||
const folder = await creationFolder(name, creation, check);
|
||||
check();
|
||||
const path = folder.path;
|
||||
const manifestPath = path + '/project.json';
|
||||
const existing = await read(manifestPath, check);
|
||||
if (existing.status === 'found') {
|
||||
@@ -287,5 +299,5 @@ export function createProjectFilesystem({ invoke, invokePrivateStorage, read, ca
|
||||
}] }), project.manifestPath);
|
||||
}
|
||||
|
||||
return { list, pickFolder, create, setArchived, requireProjectPath, refreshReference };
|
||||
return { list, pickFolder, create, setArchived, requireProjectPath, openReference };
|
||||
}
|
||||
|
||||
+17
-10
@@ -1,20 +1,20 @@
|
||||
export const styles = `
|
||||
.isa-project-ui {color:var(--isa-extension-panel-text,CanvasText);font-family:var(--isa-extension-font-family,system-ui);display:flex;flex-direction:column;gap:var(--isa-extension-space-3,.75rem)}
|
||||
.isa-project-ui .isa-project-toolbar,.isa-project-ui form {display:flex;align-items:center;gap:var(--isa-extension-space-2,.5rem);flex-wrap:wrap}
|
||||
.isa-project-ui .isa-project-title {margin:0 auto 0 0;font-size:1.125rem;font-weight:600;overflow-wrap:anywhere}
|
||||
.isa-project-ui .isa-project-title {margin:0 auto 0 0;font-size:var(--isa-extension-font-size-lg,1.125rem);overflow-wrap:anywhere}
|
||||
.isa-project-ui .isa-project-list {display:flex;flex-direction:column;gap:var(--isa-extension-space-1,.25rem);margin-block:var(--isa-extension-space-2,.5rem)}
|
||||
.isa-project-ui button,.isa-project-ui input {font:inherit;min-height:36px;box-sizing:border-box;border:1px solid var(--isa-extension-border,ButtonBorder);border-radius:var(--isa-extension-radius-sm,.375rem);padding:.375rem .75rem;color:inherit;background:var(--isa-extension-control-bg,Canvas)}
|
||||
:where(.isa-project-ui button),.isa-project-ui input {font:inherit;min-height:var(--isa-extension-control-height,2.25rem);box-sizing:border-box;border:1px solid var(--isa-extension-border,ButtonBorder);border-radius:var(--isa-extension-radius-control,.75rem);padding:.375rem .75rem;color:inherit;background:var(--isa-extension-control-bg,Canvas)}
|
||||
.isa-project-ui input {flex:1;min-width:8rem}
|
||||
.isa-project-ui button {cursor:pointer;text-align:start}
|
||||
.isa-project-ui button:hover:not(:disabled) {background:var(--isa-extension-card-hover-bg,ButtonFace)}
|
||||
.isa-project-ui button:focus-visible,.isa-project-ui input:focus-visible {outline:2px solid var(--isa-extension-focus-ring,Highlight);outline-offset:2px}
|
||||
.isa-project-ui button:disabled {opacity:.55;cursor:default}
|
||||
.isa-project-ui [role=alert] {color:var(--isa-extension-danger-text,CanvasText);overflow-wrap:anywhere}
|
||||
:where(.isa-project-ui button) {cursor:pointer;text-align:start}
|
||||
:where(.isa-project-ui button:hover:not(:disabled)) {background:var(--isa-extension-card-hover-bg,ButtonFace)}
|
||||
:where(.isa-project-ui button:focus-visible),.isa-project-ui input:focus-visible {outline:2px solid var(--isa-extension-focus-outline,Highlight);outline-offset:2px}
|
||||
:where(.isa-project-ui button:disabled) {opacity:.55;cursor:default}
|
||||
:where(.isa-project-ui [role=alert]) {color:var(--isa-extension-danger,CanvasText);overflow-wrap:anywhere}
|
||||
.isa-project-ui .isa-project-heading {font-size:1rem;font-weight:600;margin:.75rem 0 .375rem}
|
||||
.isa-project-ui .isa-project-preview audio,.isa-project-ui .isa-project-preview video,.isa-project-ui .isa-project-preview img {display:block;max-width:100%}
|
||||
.isa-project-ui .isa-project-preview pre {white-space:pre-wrap;overflow-wrap:anywhere}
|
||||
.isa-project-ui dialog {color:inherit;background:var(--isa-extension-panel-bg,Canvas);border:1px solid var(--isa-extension-border,ButtonBorder);border-radius:var(--isa-extension-radius-sm,.375rem);max-width:28rem;padding:1rem}
|
||||
.isa-project-ui dialog::backdrop {background:rgb(0 0 0/.4)}
|
||||
.isa-project-ui dialog {color:inherit;background:var(--isa-extension-panel-bg,Canvas);border:1px solid var(--isa-extension-border,ButtonBorder);border-radius:var(--isa-extension-radius-panel,1rem);max-width:28rem;padding:var(--isa-extension-space-4,1rem);box-shadow:var(--isa-extension-modal-shadow,none)}
|
||||
.isa-project-ui dialog::backdrop {background:var(--isa-extension-modal-backdrop,rgb(0 0 0/.4))}
|
||||
|
||||
.isa-group-home {display:grid;gap:9px;padding:10px;min-height:75vh;grid-template-rows:auto 1fr;background:var(--isa-extension-app-bg,var(--isa-extension-panel-bg,Canvas))}
|
||||
.isa-group-home > header,.isa-group-projects {background:var(--isa-extension-card-bg,Canvas);border:1px solid var(--isa-extension-border-subtle,GrayText);border-radius:14px;padding:14px 18px}
|
||||
@@ -29,7 +29,6 @@ export const styles = `
|
||||
.isa-group-projects {display:flex;flex-direction:column;gap:14px;min-width:0}
|
||||
.isa-group-projects h2 {text-transform:uppercase;letter-spacing:.08em}
|
||||
.isa-group-projects select {font:inherit;color:inherit;background:var(--isa-extension-control-bg,Canvas);border:1px solid var(--isa-extension-border-subtle,GrayText);border-radius:.5rem;padding:.5rem;max-width:100%}
|
||||
.isa-project-ui .isa-group-create {background:var(--isa-extension-primary,Highlight);color:var(--isa-extension-primary-text,HighlightText);border-color:transparent;font-weight:600}
|
||||
.isa-group-home.isa-group-home-embedded {min-height:0;grid-template-rows:auto;padding:0;background:transparent}
|
||||
.isa-group-home-embedded .isa-group-projects,.isa-group-home-embedded aside {border:1px solid var(--isa-extension-border-subtle,GrayText);border-radius:var(--isa-extension-radius-md,.625rem);background:var(--isa-extension-card-bg,Canvas)}
|
||||
.isa-group-rows {display:grid;gap:8px}
|
||||
@@ -39,5 +38,13 @@ export const styles = `
|
||||
.isa-group-home p:empty {display:none}
|
||||
.isa-group-home dialog form,.isa-group-home dialog label {display:grid;gap:10px}
|
||||
.isa-group-home dialog h2 {margin-bottom:14px}
|
||||
.isa-project-ui dialog.isa-project-create-dialog {box-sizing:border-box;width:min(28rem,calc(100% - 2rem));padding:1.5rem;border-radius:var(--modal-shell-radius,1rem);background:var(--modal-shell-bg,var(--isa-extension-panel-bg,Canvas));box-shadow:0 12px 48px rgb(0 0 0/.18)}
|
||||
.isa-project-create-dialog h2 {font-size:1.2rem}
|
||||
.isa-project-create-dialog .isa-project-toolbar {justify-content:flex-end;margin-top:.5rem}
|
||||
.isa-project-create-dialog input {box-sizing:border-box;width:100%}
|
||||
.isa-project-create-progress:not(:empty) {display:flex;align-items:center;gap:.6rem;margin-top:1rem}
|
||||
.isa-project-create-progress:not(:empty)::before {content:'';width:.85rem;height:.85rem;border:2px solid currentColor;border-inline-end-color:transparent;border-radius:50%;animation:isa-project-spin .8s linear infinite}
|
||||
@keyframes isa-project-spin {to {transform:rotate(360deg)}}
|
||||
@media(prefers-reduced-motion:reduce){.isa-project-create-progress::before {animation:none!important}}
|
||||
@media(max-width:640px){.isa-group-grid {grid-template-columns:minmax(0,1fr)}.isa-group-projects {grid-row:1}.isa-group-home {min-height:0}.isa-group-home header {gap:8px}}
|
||||
`;
|
||||
|
||||
+39
-14
@@ -5,7 +5,7 @@ import { importProject } from '../src/transfer.js';
|
||||
import { strToU8, zipSync } from 'fflate';
|
||||
|
||||
const project = id => ({id,folderId:id,name:id,path:`/projects/${id}.isap`,projectIdentity:id,formatVersion:1});
|
||||
const sharedCommands = ['filesystem_list_group_projects', 'filesystem_create_group_project'];
|
||||
const sharedCommands = ['filesystem_list_group_projects', 'filesystem_open_group_project', 'filesystem_create_group_project'];
|
||||
const ordinaryCommands = ['open_workspace_folder', 'filesystem_create_folder', 'filesystem_upload_files', 'filesystem_list_dir', 'filesystem_get_files'];
|
||||
function fixture(options = {}) {
|
||||
const writes = [];
|
||||
@@ -49,27 +49,40 @@ function fixture(options = {}) {
|
||||
return {client,writes,bridge,files};
|
||||
}
|
||||
|
||||
const groupProjectsPath = '/groups/_group_ids/' + 'a'.repeat(64) + '/projects';
|
||||
|
||||
test('the shared group catalog excludes picker history and preserves the archived state', async () => {
|
||||
let available = true;
|
||||
const calls = [];
|
||||
const {client,files} = fixture({
|
||||
sharedProjectsFolder: true,
|
||||
filesystem: {supportsSharedGroupProjects:true, commands:['filesystem_list_group_projects', 'filesystem_get_files']},
|
||||
filesystem: {supportsSharedGroupProjects:true, commands:['filesystem_list_group_projects', 'filesystem_open_group_project', 'filesystem_get_files']},
|
||||
invoke(command, args) {
|
||||
calls.push(command);
|
||||
if (command === 'filesystem_list_group_projects') {
|
||||
assert.deepEqual(args, {workspaceId: 'workspace', groupId: 'group'});
|
||||
if (!available) throw new Error('Dashboard unavailable');
|
||||
return {authoritative: true, folders: [
|
||||
{fileId:'one', path:'/shared/one.isap', canWrite:false},
|
||||
{fileId:'two', path:'/shared/two.isap', canWrite:false, archivedAt:'2026-11-03T12:00:00Z'}
|
||||
{fileId:'one', path:groupProjectsPath + '/one.isap', canWrite:false, hasInstance:false, manifest:files.get(groupProjectsPath + '/one.isap/project.json')},
|
||||
{fileId:'two', path:groupProjectsPath + '/two.isap', canWrite:false, hasInstance:true, archivedAt:'2026-11-03T12:00:00Z', manifest:files.get(groupProjectsPath + '/two.isap/project.json')},
|
||||
{fileId:'incomplete', path:groupProjectsPath + '/incomplete.isap', canWrite:true, manifest:null}
|
||||
]};
|
||||
}
|
||||
if (command === 'filesystem_open_group_project') {
|
||||
assert.deepEqual(args, {workspaceId:'workspace',groupId:'group',folderId:'one'});
|
||||
return {fileId:'one', path:groupProjectsPath + '/one.isap', canWrite:false};
|
||||
}
|
||||
if (command === 'localstorage_get' || command === 'open_workspace_folder') assert.fail(command);
|
||||
}
|
||||
});
|
||||
for (const id of ['one','two']) files.set(`/shared/${id}.isap/project.json`, files.get(project(id).path + '/project.json'));
|
||||
for (const id of ['one','two']) files.set(`${groupProjectsPath}/${id}.isap/project.json`, files.get(project(id).path + '/project.json'));
|
||||
assert.deepEqual((await client.list()).map(row => row.id), ['one']);
|
||||
const all = await client.list(true);
|
||||
assert.deepEqual(calls, ['filesystem_list_group_projects', 'filesystem_list_group_projects']);
|
||||
assert.equal(all.find(row => row.id === 'one').hasInstance, false);
|
||||
assert.equal(all.find(row => row.id === 'two').hasInstance, true);
|
||||
assert.equal(all.find(row => row.id === 'two').archived, true);
|
||||
await assert.rejects(client.openListed({...all[0], path:groupProjectsPath + '/another.isap'}), /identity changed/);
|
||||
await client.withListedProject(all[0], async session => assert.equal(session.project.canWrite, false));
|
||||
assert.equal(client.active, null);
|
||||
assert.deepEqual(client.state.recents, []);
|
||||
@@ -335,14 +348,15 @@ test('group creation uses the launch group and opening a listed project creates
|
||||
});
|
||||
|
||||
test('group members open the same writable projects independently of picker history', async () => {
|
||||
const commands = ['filesystem_list_group_projects', 'filesystem_create_group_project', 'filesystem_upload_files', 'filesystem_create_folder'];
|
||||
const commands = [...sharedCommands, 'filesystem_upload_files', 'filesystem_create_folder'];
|
||||
const {bridge: storage, files} = fixture();
|
||||
const catalog = new Map();
|
||||
let loseAcknowledgement = true;
|
||||
function launch(extensionId, groupId = 'demo', writable = true) {
|
||||
const opened = new Set();
|
||||
return createProjectClient({
|
||||
extensionId, scope: {workspaceId: 'w', groupId}, sharedProjectsFolder: true,
|
||||
filesystem: { supportsSharedGroupProjects: true, commands: writable ? commands : ['filesystem_list_group_projects'] },
|
||||
filesystem: { supportsSharedGroupProjects: true, commands: writable ? commands : ['filesystem_list_group_projects', 'filesystem_open_group_project'] },
|
||||
bridge: {async invoke(command, args) {
|
||||
if (command.startsWith('localstorage_')) {
|
||||
assert.equal(args.key, 'isa-project-format.recents.v1', 'A previous read-only picker grant must not participate');
|
||||
@@ -351,24 +365,34 @@ test('group members open the same writable projects independently of picker hist
|
||||
assert.equal(args.workspaceId, 'w');
|
||||
assert.equal(args.groupId, groupId);
|
||||
if (command === 'filesystem_list_group_projects') return {authoritative:true, folders:[
|
||||
...[...catalog.values()].filter(row => row.groupId === groupId),
|
||||
...[...catalog.values()].filter(row => row.groupId === groupId).map(row => ({
|
||||
...row, canWrite:writable, manifest:files.get(row.path + '/project.json')
|
||||
})),
|
||||
{fileId:'private', path:'/groups/demo/extensions/quote/private.isap', canWrite:true},
|
||||
{fileId:'nested', path:'/shared/elsewhere/nested.isap', canWrite:true}
|
||||
{fileId:'nested', path:groupProjectsPath + '/elsewhere/nested.isap', canWrite:true}
|
||||
]};
|
||||
if (command === 'filesystem_open_group_project') {
|
||||
const row = catalog.get(args.folderId);
|
||||
if (!row || row.groupId !== groupId) throw new Error('Project unavailable in this group');
|
||||
opened.add(row.path);
|
||||
return {...row, canWrite:writable};
|
||||
}
|
||||
if (command === 'filesystem_create_group_project') {
|
||||
assert.ok(writable);
|
||||
const path = '/shared/' + args.projectId + '.isap';
|
||||
const path = groupProjectsPath + '/' + args.projectId + '.isap';
|
||||
const row = {fileId:'folder-' + args.projectId, path, groupId, canWrite:true};
|
||||
if (!catalog.has(row.fileId)) {
|
||||
catalog.set(row.fileId, row);
|
||||
files.set(path + '/project.json', { ...files.get('/projects/one.isap/project.json'), id:args.projectId, name:args.name, importPending:args.importPending });
|
||||
for (const dir of [path, path + '/extensions', path + '/assets']) await storage.invoke('filesystem_create_folder',{path:dir});
|
||||
await storage.invoke('filesystem_create_folder',{path});
|
||||
}
|
||||
if (loseAcknowledgement) { loseAcknowledgement = false; throw new Error('Acknowledgement lost'); }
|
||||
opened.add(row.path);
|
||||
return row;
|
||||
}
|
||||
const path = args.path ?? args.files?.[0]?.path;
|
||||
assert.ok([...opened].some(root => path === root || path?.startsWith(root + '/')), 'Filesystem request requires opening that project');
|
||||
assert.ok(!['open_workspace_folder','filesystem_ensure_group_folder'].includes(command), command);
|
||||
if (command === 'filesystem_get_files') assert.match(args.files[0].path, /^\/shared\/[^/]+\.isap\//);
|
||||
if (command === 'filesystem_get_files') assert.match(args.files[0].path, /^\/groups\/_group_ids\/[a-f0-9]{64}\/projects\/[^/]+\.isap\//);
|
||||
return storage.invoke(command, args);
|
||||
}}
|
||||
});
|
||||
@@ -391,6 +415,7 @@ test('group members open the same writable projects independently of picker hist
|
||||
await reopened.ensureExtensionJson('data.json', () => assert.fail('Duplicated board'));
|
||||
const otherGroup = launch('isa-projects', 'another-group');
|
||||
assert.deepEqual(await otherGroup.list(), []);
|
||||
await assert.rejects(otherGroup.activate(row), /unavailable in this group/);
|
||||
const reader = launch('read-only', 'demo', false);
|
||||
assert.equal(reader.supports('create'), false);
|
||||
assert.equal((await reader.openListed((await reader.list())[0])).project.canWrite, false);
|
||||
@@ -408,7 +433,7 @@ test('group members open the same writable projects independently of picker hist
|
||||
});
|
||||
|
||||
test('older shared-project hosts report the required update without opening a picker', async () => {
|
||||
const filesystem = {commands:['filesystem_list_group_projects','filesystem_create_folder','filesystem_upload_files','open_workspace_folder']};
|
||||
const filesystem = {supportsSharedGroupProjects:true, commands:['filesystem_list_group_projects','filesystem_create_group_project','filesystem_create_folder','filesystem_upload_files','open_workspace_folder']};
|
||||
const client = createProjectClient({bridge:{invoke:() => assert.fail('Unexpected host operation')}, filesystem,
|
||||
sharedProjectsFolder:true, extensionId:'reader', scope:{workspaceId:'w',groupId:'g'}});
|
||||
for (const action of ['pickFolder','create','archive']) assert.equal(client.supports(action), false);
|
||||
|
||||
Reference in New Issue
Block a user