Skip to content

Commit

Permalink
admin/fs: comment #662
Browse files Browse the repository at this point in the history
  • Loading branch information
rejetto committed Jul 9, 2024
1 parent 2fc4516 commit ebe4cf5
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
7 changes: 4 additions & 3 deletions admin/src/FileForm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,17 +171,18 @@ export default function FileForm({ file, addToBar, statusApi, accounts, saved }:
showTimestamps && { k: 'mtime', comp: DisplayField, sm: 6, lg: showSize && 4, label: "Modified", toField: formatTimestamp },
showAccept && { k: 'accept', label: "Accept on upload", placeholder: "anything", xl: showWebsite ? 4 : 12,
helperText: h(Link, { href: ACCEPT_LINK, target: '_blank' }, "Example: .zip") },
showWebsite && { k: 'default', comp: BoolField, xl: true,
showWebsite && { k: 'default', comp: BoolField, xl: showWebsite ? 8 : 12,
label: "Serve as web-page if index.html is found" + (inheritedDefault && values.default == null ? ' (inherited)' : ''),
value: values.default ?? inheritedDefault,
toField: Boolean, fromField: (v:boolean) => v && !inheritedDefault ? 'index.html' : v ? null : false,
helperText: md("...instead of showing list of files")
},
isDir && { k: 'masks', multiline: true,
{ k: 'comment', multiline: true, xl: true },
isDir && { k: 'masks', multiline: true, xl: 6,
toField: yaml.stringify, fromField: v => v ? yaml.parse(v) : undefined,
sx: { '& textarea': { fontFamily: 'monospace' } },
helperText: ["Special field, leave empty unless you know what you are doing. YAML syntax. ", wikiLink('Masks-field', "(examples)")]
}
},
]
})

Expand Down
4 changes: 2 additions & 2 deletions src/api.get_file_list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export const get_file_list: ApiHandler = async ({ uri='/', offset, limit, search
const can_archive = admin || hasPermission(fakeChild, 'can_archive', ctx)
const can_comment = can_upload && areCommentsEnabled()
const can_overwrite = can_upload && (can_delete || !dontOverwriteUploading.get())
const comment = await getCommentFor(node.source)
const comment = node.comment ?? await getCommentFor(node.source)
const props = { can_archive, can_upload, can_delete, can_overwrite, can_comment, comment, accept: node.accept }
ctx.state.browsing = uri.replace(/\/{2,}/g, '/')
updateConnectionForCtx(ctx)
Expand Down Expand Up @@ -126,7 +126,7 @@ export const get_file_list: ApiHandler = async ({ uri='/', offset, limit, search
m: !st || Math.abs(+st.mtime - +st.ctime) < 1000 ? undefined : st.mtime,
s: isFolder ? undefined : st?.size,
p: (pr + pl + pd + pa) || undefined,
comment: await getCommentFor(source),
comment: node.comment ?? await getCommentFor(source),
web: await hasDefaultFile(node, ctx) ? true : undefined,
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/api.vfs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ async function urlToNodeOriginal(uri: string) {
return n?.isTemp ? n.original : n
}

const ALLOWED_KEYS = ['name','source','masks','default','accept','rename','mime','url','target', ...PERM_KEYS]
const ALLOWED_KEYS = ['name','source','masks','default','accept','rename','mime','url','target','comment', ...PERM_KEYS]

const apis: ApiHandlers = {

Expand Down
1 change: 1 addition & 0 deletions src/vfs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export interface VfsNodeStored extends VfsPerms {
rename?: Record<string, string>
masks?: Masks // express fields for descendants that are not in the tree
accept?: string
comment?: string
}
export interface VfsNode extends VfsNodeStored { // include fields that are only filled at run-time
isTemp?: true // this node doesn't belong to the tree and was created by necessity
Expand Down

0 comments on commit ebe4cf5

Please sign in to comment.