BlueGit

timfa filemanager

bulletpoint list for access users

timfa Tim Falken · pushed by timfa

Authored 2026-05-04 · 6 months ago

Hash
1257aca5adb2a80e86becd302294bb6dc36387fb
Parent
3dbfd3d9
5 files changed +39 −5
public/app.js +13 −1
@@ -1244,7 +1244,19 @@ async function fetchRootAccessList (rootPath)
1244 1244 function formatRootAccessList (users)
1245 1245 {
1246 1246 if (!Array.isArray(users) || users.length === 0) return 'No users';
1247 return users.map(u => `${u.username} ${u.mode}`).join(', ');
1247
1248 const sorted = [...users].sort((a, b) =>
1249 {
1250 const modeRank = (mode) => mode === 'R+W' ? 0 : 1;
1251 const byMode = modeRank(a.mode) - modeRank(b.mode);
1252 if (byMode !== 0) return byMode;
1253 return String(a.username).localeCompare(String(b.username));
1254 });
1255
1256 const items = sorted
1257 .map((u) => `<li>${escapeHtml(String(u.username || ''))} ${escapeHtml(String(u.mode || 'R'))}</li>`)
1258 .join('');
1259 return `<ul class="root-access-list">${items}</ul>`;
1248 1260 }
1249 1261
1250 1262 function rootPermissionLabel (root)
@@ -1244,7 +1244,19 @@ async function fetchRootAccessList (rootPath)
1244function formatRootAccessList (users)
1244function formatRootAccessList (users)
1245{
1245{
1246 if (!Array.isArray(users) || users.length === 0) return 'No users';
1246 if (!Array.isArray(users) || users.length === 0) return 'No users';
1247 return users.map(u => `${u.username} ${u.mode}`).join(', ');
1247
1248 const sorted = [...users].sort((a, b) =>
1249 {
1250 const modeRank = (mode) => mode === 'R+W' ? 0 : 1;
1251 const byMode = modeRank(a.mode) - modeRank(b.mode);
1252 if (byMode !== 0) return byMode;
1253 return String(a.username).localeCompare(String(b.username));
1254 });
1255
1256 const items = sorted
1257 .map((u) => `<li>${escapeHtml(String(u.username || ''))} ${escapeHtml(String(u.mode || 'R'))}</li>`)
1258 .join('');
1259 return `<ul class="root-access-list">${items}</ul>`;
1248}
1260}
1249
1261
1250function rootPermissionLabel (root)
1262function rootPermissionLabel (root)
public/style.css +12 −2
@@ -316,13 +316,14 @@ button.danger:hover {
316 316 position: absolute;
317 317 width: 14px;
318 318 height: 14px;
319 right: -2px;
320 bottom: -2px;
319 left: 50%;
320 top: 50%;
321 321 border: 2px solid rgba(232, 234, 240, 0.35);
322 322 border-top-color: var(--accent);
323 323 border-radius: 50%;
324 324 animation: icon-thumb-spin 0.75s linear infinite;
325 325 background: rgba(15, 17, 23, 0.85);
326 transform: translate(-50%, -50%);
326 327 }
327 328
328 329 @keyframes icon-thumb-spin {
@@ -415,6 +416,15 @@ button.danger:hover {
415 416 word-break: break-all;
416 417 }
417 418
419 #sidebar-meta .root-access-list {
420 margin: 0;
421 padding-left: 1rem;
422 }
423
424 #sidebar-meta .root-access-list li {
425 margin: 0.12rem 0;
426 }
427
418 428 #sidebar-actions {
419 429 display: flex;
420 430 flex-direction: column;
@@ -316,13 +316,14 @@ button.danger:hover {
316 position: absolute;
316 position: absolute;
317 width: 14px;
317 width: 14px;
318 height: 14px;
318 height: 14px;
319 right: -2px;
319 left: 50%;
320 bottom: -2px;
320 top: 50%;
321 border: 2px solid rgba(232, 234, 240, 0.35);
321 border: 2px solid rgba(232, 234, 240, 0.35);
322 border-top-color: var(--accent);
322 border-top-color: var(--accent);
323 border-radius: 50%;
323 border-radius: 50%;
324 animation: icon-thumb-spin 0.75s linear infinite;
324 animation: icon-thumb-spin 0.75s linear infinite;
325 background: rgba(15, 17, 23, 0.85);
325 background: rgba(15, 17, 23, 0.85);
326 transform: translate(-50%, -50%);
326}
327}
327
328
328@keyframes icon-thumb-spin {
329@keyframes icon-thumb-spin {
@@ -415,6 +416,15 @@ button.danger:hover {
415 word-break: break-all;
416 word-break: break-all;
416}
417}
417
418
419#sidebar-meta .root-access-list {
420 margin: 0;
421 padding-left: 1rem;
422}
423
424#sidebar-meta .root-access-list li {
425 margin: 0.12rem 0;
426}
427
418#sidebar-actions {
428#sidebar-actions {
419 display: flex;
429 display: flex;
420 flex-direction: column;
430 flex-direction: column;
server/routes/files.js +7 −1
@@ -248,7 +248,13 @@ router.get('/root-access', requireAuth, (req, res) =>
248 248 users.push({ username: row.username, mode: canWriteRoot ? 'R+W' : 'R' });
249 249 }
250 250
251 users.sort((a, b) => String(a.username).localeCompare(String(b.username)));
251 users.sort((a, b) =>
252 {
253 const modeRank = (mode) => mode === 'R+W' ? 0 : 1;
254 const byMode = modeRank(a.mode) - modeRank(b.mode);
255 if (byMode !== 0) return byMode;
256 return String(a.username).localeCompare(String(b.username));
257 });
252 258
253 259 const rootAliases = rootAliasesFromConfig(config);
254 260 const alias = String(rootAliases[path.resolve(info.root)] || '').trim();
@@ -248,7 +248,13 @@ router.get('/root-access', requireAuth, (req, res) =>
248 users.push({ username: row.username, mode: canWriteRoot ? 'R+W' : 'R' });
248 users.push({ username: row.username, mode: canWriteRoot ? 'R+W' : 'R' });
249 }
249 }
250
250
251 users.sort((a, b) => String(a.username).localeCompare(String(b.username)));
251 users.sort((a, b) =>
252 {
253 const modeRank = (mode) => mode === 'R+W' ? 0 : 1;
254 const byMode = modeRank(a.mode) - modeRank(b.mode);
255 if (byMode !== 0) return byMode;
256 return String(a.username).localeCompare(String(b.username));
257 });
252
258
253 const rootAliases = rootAliasesFromConfig(config);
259 const rootAliases = rootAliasesFromConfig(config);
254 const alias = String(rootAliases[path.resolve(info.root)] || '').trim();
260 const alias = String(rootAliases[path.resolve(info.root)] || '').trim();
tests/files.routes.test.js +1 −1
@@ -321,8 +321,8 @@ describe('GET /api/files/root-access', () =>
321 321 expect(body.root).toMatchObject({ path: rootDir, originalName: label });
322 322 expect(body.users).toEqual([
323 323 { username: 'admin', mode: 'R+W' },
324 { username: 'alice', mode: 'R' },
325 324 { username: 'bob', mode: 'R+W' },
325 { username: 'alice', mode: 'R' },
326 326 ]);
327 327 });
328 328
@@ -321,8 +321,8 @@ describe('GET /api/files/root-access', () =>
321 expect(body.root).toMatchObject({ path: rootDir, originalName: label });
321 expect(body.root).toMatchObject({ path: rootDir, originalName: label });
322 expect(body.users).toEqual([
322 expect(body.users).toEqual([
323 { username: 'admin', mode: 'R+W' },
323 { username: 'admin', mode: 'R+W' },
324 { username: 'alice', mode: 'R' },
325 { username: 'bob', mode: 'R+W' },
324 { username: 'bob', mode: 'R+W' },
325 { username: 'alice', mode: 'R' },
326 ]);
326 ]);
327 });
327 });
328
328
tests/page.load.test.js +6 −0
@@ -320,6 +320,9 @@ describe('page load smoke test', () =>
320 320 expect(sidebarText).toContain('alice R');
321 321 expect(sidebarText).toContain('bob R+W');
322 322
323 const accessItems = Array.from(dom.window.document.querySelectorAll('#sidebar-meta .root-access-list li')).map(li => li.textContent.trim());
324 expect(accessItems).toEqual(['bob R+W', 'alice R']);
325
323 326 const actionButtons = Array.from(dom.window.document.querySelectorAll('#sidebar-actions button')).map(b => b.textContent);
324 327 expect(actionButtons).toContain('Rename');
325 328 expect(actionButtons).not.toContain('Move to');
@@ -346,6 +349,9 @@ describe('page load smoke test', () =>
346 349 expect(sidebarText).toContain('tim R+W');
347 350 expect(sidebarText).toContain('guest R');
348 351
352 const accessItems = Array.from(dom.window.document.querySelectorAll('#sidebar-meta .root-access-list li')).map(li => li.textContent.trim());
353 expect(accessItems).toEqual(['tim R+W', 'guest R']);
354
349 355 dom.window.close();
350 356 });
351 357
@@ -320,6 +320,9 @@ describe('page load smoke test', () =>
320 expect(sidebarText).toContain('alice R');
320 expect(sidebarText).toContain('alice R');
321 expect(sidebarText).toContain('bob R+W');
321 expect(sidebarText).toContain('bob R+W');
322
322
323 const accessItems = Array.from(dom.window.document.querySelectorAll('#sidebar-meta .root-access-list li')).map(li => li.textContent.trim());
324 expect(accessItems).toEqual(['bob R+W', 'alice R']);
325
323 const actionButtons = Array.from(dom.window.document.querySelectorAll('#sidebar-actions button')).map(b => b.textContent);
326 const actionButtons = Array.from(dom.window.document.querySelectorAll('#sidebar-actions button')).map(b => b.textContent);
324 expect(actionButtons).toContain('Rename');
327 expect(actionButtons).toContain('Rename');
325 expect(actionButtons).not.toContain('Move to');
328 expect(actionButtons).not.toContain('Move to');
@@ -346,6 +349,9 @@ describe('page load smoke test', () =>
346 expect(sidebarText).toContain('tim R+W');
349 expect(sidebarText).toContain('tim R+W');
347 expect(sidebarText).toContain('guest R');
350 expect(sidebarText).toContain('guest R');
348
351
352 const accessItems = Array.from(dom.window.document.querySelectorAll('#sidebar-meta .root-access-list li')).map(li => li.textContent.trim());
353 expect(accessItems).toEqual(['tim R+W', 'guest R']);
354
349 dom.window.close();
355 dom.window.close();
350 });
356 });
351
357