fix: admin/fs: web link, shouldn't state "as can download" since "download" field is not displayed
Massimo Melina committed
Mar 29, 2024 at 14:56 UTC
87a92a478a48114a7be4d446e0f029786fdeeac5
1 file changed
+5
-3
admin/src/FileForm.ts
+5
-3
@@ -181,13 +181,16 @@ export default function FileForm({ file, addToBar, statusApi }: FileFormProps) {
181
if (!show[perm]) return null
182
const dontShow = [perm, ...onlyTruthy(_.map(show, (v,k) => !v && k))]
183
const others = _.difference(Object.keys(defaultPerms), dontShow)
184
+ let inherit = file.inherited?.[perm] ?? defaultPerms[perm]
185
+ if (typeof inherit === 'string' && _.get(show, inherit) === false) // if it's false, then inherit is a perm
186
+ inherit = _.get(values, inherit) ?? _.get(defaultPerms, inherit)! // ...and defaultPerms have it all
187
return {
188
comp: WhoField,
189
k: perm, sm: 6, xl: 4,
190
parent, accounts, helperText, isDir,
191
otherPerms: others.map(x => ({ value: x, label: who2desc(x) })),
192
label: "Who can " + perm2word(perm),
190
- inherit: file.inherited?.[perm] ?? defaultPerms[perm],
193
+ inherit,
194
byMasks: byMasks?.[perm],
195
fromField: (v?: Who) => v ?? null,
196
...props
@@ -197,8 +200,7 @@ export default function FileForm({ file, addToBar, statusApi }: FileFormProps) {
200
}
201
202
function perm2word(perm: string) {
200
- const word = perm.split('_')[1]
201
- return word === 'read' ? 'download' : word === 'archive' ? 'zip' : word
203
+ return xlate(perm.split('_')[1], { read: 'download', archive: 'zip' })
204
}
205
206
interface WhoFieldProps extends FieldProps<Who | undefined> {