mirror of
https://github.com/Studio-Saelix/sencho.git
synced 2026-08-26 02:06:49 +00:00
feat(resources): render anonymous volume names readably in the volume browser (#1429)
Anonymous Docker volumes carry a raw 64-character hex name, which is correct data but unreadable in the volume browser crumb, sheet title, and table row. Detect 64-hex names and show a short prefix (e.g. 079dfda49f2c…) in the table cell and sheet title, with the full name available on hover and an "anonymous" chip so the truncation is self-explanatory. The volume browser sheet adds a band that keeps the full hash visible and copyable. Named volumes still display in full. The name is passed verbatim to the API; only the rendered label changes.
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { isAnonymousVolumeName, shortVolumeLabel } from '../volumeName';
|
||||
|
||||
const ANON = '079dfda49f2c483f80f1d4f6b1865be55af54a0298507a0e588aae551134ba62';
|
||||
|
||||
describe('isAnonymousVolumeName', () => {
|
||||
it('treats a 64 lowercase hex name as anonymous', () => {
|
||||
expect(isAnonymousVolumeName(ANON)).toBe(true);
|
||||
});
|
||||
|
||||
it('treats a friendly named volume as not anonymous', () => {
|
||||
expect(isAnonymousVolumeName('app_pgdata')).toBe(false);
|
||||
});
|
||||
|
||||
it('rejects names that are not exactly 64 chars', () => {
|
||||
expect(isAnonymousVolumeName(ANON.slice(0, 63))).toBe(false);
|
||||
expect(isAnonymousVolumeName(ANON + 'a')).toBe(false);
|
||||
});
|
||||
|
||||
it('rejects uppercase hex and non-hex characters', () => {
|
||||
expect(isAnonymousVolumeName(ANON.toUpperCase())).toBe(false);
|
||||
expect(isAnonymousVolumeName('z'.repeat(64))).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('shortVolumeLabel', () => {
|
||||
it('truncates an anonymous name to a 12-char prefix plus an ellipsis', () => {
|
||||
expect(shortVolumeLabel(ANON)).toBe('079dfda49f2c…');
|
||||
});
|
||||
|
||||
it('returns a named volume verbatim', () => {
|
||||
expect(shortVolumeLabel('app_pgdata')).toBe('app_pgdata');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user