fix: admin/fs: couldn't edit home

Massimo Melina committed Mar 2, 2022 at 17:02 UTC 56ee3ef822c256239516d6affec73fe0888c3d5c
2 files changed +5 -2
admin/src/FileCard.ts
+2 -2
@@ -29,7 +29,7 @@ export default function FileCard() {
29 }
30
31 function FileForm({ file }: { file: ReturnType<typeof useSnapState>['selectedFiles']['0'] }) {
32 - const { parent, children, ...rest } = file
32 + const { parent, children, isRoot, ...rest } = file
33 const [values, setValues] = useState(rest)
34 useEffect(() => {
35 setValues(Object.assign({ can_see: null, can_read: null }, rest))
@@ -82,7 +82,7 @@ function FileForm({ file }: { file: ReturnType<typeof useSnapState>['selectedFil
82 }
83 },
84 fields: [
85 - { k: 'name', helperText: source && "You can decide a name that's different from the one on your disk" },
85 + !isRoot && { k: 'name', helperText: source && "You can decide a name that's different from the one on your disk" },
86 hasSource && { k: 'source', comp: DisplayField },
87 { k: 'can_read', label:"Who can download", md: showCanSee && 6, comp: WhoField, parent, accounts, inherit: inheritedPerms.can_read,
88 helperText: "Who cannot download also cannot see in list"
admin/src/VfsPage.ts
+3
@@ -24,6 +24,7 @@ export default function VfsPage() {
24 const { root } = res
25 if (!root) return
26 recur(root) // this must be done before state change that would cause Tree to render and expecting id2node
27 + root.isRoot = true
28 state.vfs = root
29 // refresh objects of selectedFiles
30 const ids = selectOnReload || state.selectedFiles.map(x => x.id)
@@ -72,6 +73,8 @@ export type VfsNode = {
73 can_see: Who
74 can_read: Who
75 masks?: any
76 +
77 + isRoot?: true
78 }
79
80 const WHO_ANYONE = true