Fix version panel showing 'null' instead of timestamp, exclude current version from list, auto-refresh versions after upload
This commit is contained in:
@@ -1301,12 +1301,14 @@ def object_versions(bucket_name: str, object_key: str):
|
|||||||
for v in resp.get("Versions", []):
|
for v in resp.get("Versions", []):
|
||||||
if v.get("Key") != object_key:
|
if v.get("Key") != object_key:
|
||||||
continue
|
continue
|
||||||
|
if v.get("IsLatest", False):
|
||||||
|
continue
|
||||||
versions.append({
|
versions.append({
|
||||||
"version_id": v.get("VersionId", ""),
|
"version_id": v.get("VersionId", ""),
|
||||||
"last_modified": v["LastModified"].isoformat() if v.get("LastModified") else None,
|
"last_modified": v["LastModified"].isoformat() if v.get("LastModified") else None,
|
||||||
"size": v.get("Size", 0),
|
"size": v.get("Size", 0),
|
||||||
"etag": v.get("ETag", "").strip('"'),
|
"etag": v.get("ETag", "").strip('"'),
|
||||||
"is_latest": v.get("IsLatest", False),
|
"is_latest": False,
|
||||||
})
|
})
|
||||||
return jsonify({"versions": versions})
|
return jsonify({"versions": versions})
|
||||||
except (ClientError, EndpointConnectionError, ConnectionClosedError) as exc:
|
except (ClientError, EndpointConnectionError, ConnectionClosedError) as exc:
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
APP_VERSION = "0.3.0"
|
APP_VERSION = "0.3.1"
|
||||||
|
|
||||||
|
|
||||||
def get_version() -> str:
|
def get_version() -> str:
|
||||||
|
|||||||
@@ -1537,7 +1537,7 @@
|
|||||||
|
|
||||||
const confirmVersionRestore = (row, version, label = null, onConfirm) => {
|
const confirmVersionRestore = (row, version, label = null, onConfirm) => {
|
||||||
if (!version) return;
|
if (!version) return;
|
||||||
const timestamp = version.archived_at ? new Date(version.archived_at).toLocaleString() : version.version_id;
|
const timestamp = (version.archived_at || version.last_modified) ? new Date(version.archived_at || version.last_modified).toLocaleString() : version.version_id;
|
||||||
const sizeLabel = formatBytes(Number(version.size) || 0);
|
const sizeLabel = formatBytes(Number(version.size) || 0);
|
||||||
const reasonLabel = describeVersionReason(version.reason);
|
const reasonLabel = describeVersionReason(version.reason);
|
||||||
const targetLabel = label || row?.dataset.key || 'this object';
|
const targetLabel = label || row?.dataset.key || 'this object';
|
||||||
@@ -1610,7 +1610,7 @@
|
|||||||
|
|
||||||
const latestCell = document.createElement('td');
|
const latestCell = document.createElement('td');
|
||||||
if (item.latest) {
|
if (item.latest) {
|
||||||
const ts = item.latest.archived_at ? new Date(item.latest.archived_at).toLocaleString() : item.latest.version_id;
|
const ts = (item.latest.archived_at || item.latest.last_modified) ? new Date(item.latest.archived_at || item.latest.last_modified).toLocaleString() : item.latest.version_id;
|
||||||
const sizeLabel = formatBytes(Number(item.latest.size) || 0);
|
const sizeLabel = formatBytes(Number(item.latest.size) || 0);
|
||||||
latestCell.innerHTML = `<div class="small">${ts}</div><div class="text-muted small">${sizeLabel} · ${describeVersionReason(item.latest.reason)}</div>`;
|
latestCell.innerHTML = `<div class="small">${ts}</div><div class="text-muted small">${sizeLabel} · ${describeVersionReason(item.latest.reason)}</div>`;
|
||||||
} else {
|
} else {
|
||||||
@@ -1785,7 +1785,7 @@
|
|||||||
badge.textContent = `#${versionNumber}`;
|
badge.textContent = `#${versionNumber}`;
|
||||||
const title = document.createElement('div');
|
const title = document.createElement('div');
|
||||||
title.className = 'fw-semibold small';
|
title.className = 'fw-semibold small';
|
||||||
const timestamp = entry.archived_at ? new Date(entry.archived_at).toLocaleString() : entry.version_id;
|
const timestamp = (entry.archived_at || entry.last_modified) ? new Date(entry.archived_at || entry.last_modified).toLocaleString() : entry.version_id;
|
||||||
title.textContent = timestamp;
|
title.textContent = timestamp;
|
||||||
heading.appendChild(badge);
|
heading.appendChild(badge);
|
||||||
heading.appendChild(title);
|
heading.appendChild(title);
|
||||||
@@ -2816,7 +2816,16 @@
|
|||||||
uploadFileInput.value = '';
|
uploadFileInput.value = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
loadObjects(false);
|
const previousKey = activeRow?.dataset.key || null;
|
||||||
|
loadObjects(false).then(() => {
|
||||||
|
if (previousKey) {
|
||||||
|
const newRow = document.querySelector(`[data-object-row][data-key="${CSS.escape(previousKey)}"]`);
|
||||||
|
if (newRow) {
|
||||||
|
selectRow(newRow);
|
||||||
|
if (versioningEnabled) loadObjectVersions(newRow, { force: true });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
const successCount = uploadSuccessFiles.length;
|
const successCount = uploadSuccessFiles.length;
|
||||||
const errorCount = uploadErrorFiles.length;
|
const errorCount = uploadErrorFiles.length;
|
||||||
|
|||||||
Reference in New Issue
Block a user