Project format updates

This commit is contained in:
Sander Grootendorst
2026-12-01 14:58:50 +01:00
parent 8d0a531084
commit 9339b7a131
17 changed files with 707 additions and 134 deletions
+19 -12
View File
@@ -57,9 +57,11 @@ export function mountOverview(target, {client, extensionName, text, locale, onIm
const alert = element('p');
alert.setAttribute('role','alert');
const list = element('div', '', 'isa-group-rows');
const columns = element('div', '', 'isa-project-columns');
columns.append(element('span', text.name), element('span', text.owner), element('span', text.creationDate));
const status = element('p');
status.setAttribute('role','status');
panel.append(heading,controls,alert,status,list);
panel.append(heading,controls,alert,status,columns,list);
grid.append(activity,panel);
const dialog = element('dialog', '', 'isa-project-create-dialog');
const title = element('h2', text.createTitle);
@@ -86,7 +88,7 @@ export function mountOverview(target, {client, extensionName, text, locale, onIm
root.append(grid,dialog);
target.append(root);
let projects = [], recents = [], loading = true, failed = false, busy = false, alive = true, generation = 0;
let projects = [], recents = [], loading = true, hasInventory = false, busy = false, alive = true, generation = 0;
const date = new Intl.DateTimeFormat(locale,{dateStyle:'medium'});
// The host focuses an extension iframe on pointer-down. Preserve matching
// buttons through that refresh so the subsequent click reaches the same row.
@@ -98,9 +100,7 @@ export function mountOverview(target, {client, extensionName, text, locale, onIm
row = button();
row.dataset.projectId = project.id;
if (detailed) {
const info = element('span');
info.append(element('strong'), element('small'));
row.append(info, element('time'));
row.append(element('strong'), element('small'), element('time'));
}
}
existing.delete(project.id);
@@ -109,8 +109,9 @@ export function mountOverview(target, {client, extensionName, text, locale, onIm
const firstUse = project.hasInstance === false && project.canWrite && !project.archived;
if (detailed) {
row.querySelector('strong').textContent = project.name;
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)) : '';
row.querySelector('small').textContent = project.hasInstance === false ? text.noInstance : project.instanceCreatorId || '—';
row.title = firstUse ? text.createInstance : '';
row.querySelector('time').textContent = Number.isFinite(Date.parse(project.instanceCreatedAt)) ? date.format(new Date(project.instanceCreatedAt)) : '—';
} else row.textContent = firstUse ? `${project.name} · ${text.createInstance}` : project.name;
if (container.children[index] !== row) container.insertBefore(row, container.children[index] ?? null);
});
@@ -120,22 +121,28 @@ export function mountOverview(target, {client, extensionName, text, locale, onIm
const needle = search.value.trim().toLocaleLowerCase(locale);
const visible = projects.filter(p => p.name.toLocaleLowerCase(locale).includes(needle));
visible.sort((a,b) => (sort.value === 'updated' && (Date.parse(b.updatedAt) || 0) - (Date.parse(a.updatedAt) || 0)) || a.name.localeCompare(b.name,locale));
list.setAttribute('aria-busy', String(loading));
columns.hidden = !visible.length;
updateRows(list, visible, true);
status.textContent = loading ? text.loading : visible.length || failed ? '' : needle ? text.noMatches : text.noProjects;
status.textContent = hasInventory && !visible.length ? (needle ? text.noMatches : text.noProjects) : '';
updateRows(recent, recents.map(item => projects.find(project => project.id === item.id)).filter(Boolean), false);
if (!recent.childElementCount && !loading && !failed) recent.append(element('p',text.noActivity));
if (!recent.childElementCount && hasInventory) recent.append(element('p',text.noActivity));
pickFolder.disabled = busy; create.disabled = busy; importButton.disabled = busy; refreshButton.disabled = busy || loading;
}
async function refresh() {
const ticket = ++generation;
loading = true; failed = false; alert.textContent = ''; draw();
loading = true; alert.textContent = ''; draw();
try {
const inventory = await client.list();
if (alive && ticket === generation) projects = inventory.filter(p => !p.archived);
if (alive && ticket === generation) {
projects = inventory.filter(p => !p.archived);
hasInventory = true;
}
} catch (error) {
if (alive && ticket === generation) {
if (client.sharedProjectsFolder) projects = [];
failed = true; alert.textContent = error.code === 'SHARED_GROUP_PROJECTS_UNAVAILABLE' ? text.updateHost : String(error.message ?? error);
hasInventory = false;
alert.textContent = error.code === 'SHARED_GROUP_PROJECTS_UNAVAILABLE' ? text.updateHost : String(error.message ?? error);
}
} finally {
if (alive && ticket === generation) { loading = false; draw(); }