Feat v0.5.4 package updates (#34)
All checks were successful
All checks were successful
Co-authored-by: Jeffrey Smith <jasafpro@gmail.com> Co-committed-by: Jeffrey Smith <jasafpro@gmail.com>
This commit was merged in pull request #34.
This commit is contained in:
@@ -116,6 +116,27 @@ export default function PackagesSection() {
|
||||
window.open(`${BASE}/api/v1/admin/packages/${id}/export`, '_blank');
|
||||
}
|
||||
|
||||
function updatePkg(pkg) {
|
||||
const input = document.createElement('input');
|
||||
input.type = 'file';
|
||||
input.accept = '.pkg,.surface,.zip';
|
||||
input.onchange = async () => {
|
||||
const file = input.files[0];
|
||||
if (!file) return;
|
||||
const ok = await sw.confirm(`Update "${pkg.title}" from v${pkg.version}?\n\nExport a backup first if needed.`, { destructive: true });
|
||||
if (!ok) return;
|
||||
setInstalling(true);
|
||||
try {
|
||||
const res = await sw.api.admin.packages.update(pkg.id, file);
|
||||
const data = res?.data || res || {};
|
||||
sw.toast(`Updated to v${data.version || '?'}`, 'success');
|
||||
load();
|
||||
} catch (e) { sw.toast(e.message, 'error'); }
|
||||
finally { setInstalling(false); }
|
||||
};
|
||||
input.click();
|
||||
}
|
||||
|
||||
// ── Settings drawer ─────────────────────────
|
||||
async function toggleSettings(pkgId) {
|
||||
if (expandedId === pkgId) {
|
||||
@@ -271,6 +292,9 @@ export default function PackagesSection() {
|
||||
${permsId === pkg.id ? 'Close' : 'Permissions'}
|
||||
</button>
|
||||
`}
|
||||
${pkg.source !== 'core' && html`
|
||||
<button class="btn-small" onClick=${() => updatePkg(pkg)}>Update</button>
|
||||
`}
|
||||
<button class="btn-small" onClick=${() => exportPkg(pkg.id)}>Export</button>
|
||||
${pkg.source !== 'core' && !pkg.is_system && html`
|
||||
<button class="btn-small btn-danger" onClick=${() => deletePkg(pkg)}>Delete</button>
|
||||
|
||||
Reference in New Issue
Block a user