admin/fs: clearer indication of home item

Massimo Melina committed Mar 18, 2022 at 13:36 UTC cce5113792724ae635fac9c2650a4abe28cf696b
2 files changed +7 -5
admin/src/FileCard.ts
+3 -2
@@ -2,7 +2,7 @@
2
3 import { state, useSnapState } from './state'
4 import { createElement as h, useEffect, useMemo, useState } from 'react'
5 -import { Button, Card, CardContent, List, ListItem, ListItemText } from '@mui/material'
5 +import { Alert, Button, Card, CardContent, List, ListItem, ListItemText } from '@mui/material'
6 import { BoolField, DisplayField, Field, FieldProps, Form, MultiSelectField, SelectField } from './Form'
7 import { apiCall, useApi } from './api'
8 import { formatBytes, isEqualLax, modifiedSx, onlyTruthy } from './misc'
@@ -87,7 +87,8 @@ function FileForm({ file }: { file: ReturnType<typeof useSnapState>['selectedFil
87 }
88 },
89 fields: [
90 - !isRoot && { k: 'name', validate: x => x>'' || `Required`,
90 + isRoot ? h(Alert,{ severity: 'info' }, "This is Home, the root of your shared files. Options set here will be applied to all files.") : {
91 + k: 'name', validate: x => x>'' || `Required`,
92 helperText: source && "You can decide a name that's different from the one on your disk",
93 },
94 hasSource && { k: 'source', comp: DisplayField, multiline: true },
admin/src/VfsTree.ts
+4 -3
@@ -56,7 +56,7 @@ export default function VfsTree({ id2node }:{ id2node: Map<string, VfsNode> }) {
56 }
57
58 function recur(node: Readonly<VfsNode>): ReactElement {
59 - let { id, name, source } = node
59 + let { id, name, source, isRoot } = node
60 if (!id)
61 debugger
62 const folder = node.type === 'folder'
@@ -71,7 +71,8 @@ export default function VfsTree({ id2node }:{ id2node: Map<string, VfsNode> }) {
71 isRestricted(node.can_read) && iconTooltip(Lock, "Restrictions on who can download"),
72 node.default && iconTooltip(Web, "Act as website"),
73 node.masks && iconTooltip(Face, "Masks"),
74 - !source?.endsWith(name) ? name
74 + isRoot ? "Home"
75 + : !source?.endsWith(name) ? name
76 : h('span', {},
77 h('span', { className:styles.path }, source.slice(0,-name.length)),
78 h('span', {}, source.slice(-name.length)),
@@ -93,7 +94,7 @@ export default function VfsTree({ id2node }:{ id2node: Map<string, VfsNode> }) {
94 }
95 }),
96 nodeId: id
96 - }, node.children?.map(recur))
97 + }, isRoot && !node.children?.length ? "nothing here" : node.children?.map(recur))
98 }
99
100 }