fix: users with own admin attribute were displayed as if attribute was inherited

Massimo Melina committed Jan 15, 2023 at 10:58 UTC 87a2df36e631c1569e71b17a0a5c67d6f48a0b25
4 files changed +7 -3
admin/src/AccountForm.ts
+1 -1
@@ -44,7 +44,7 @@ export default function AccountForm({ account, done, groups, close }: FormProps)
44 helperText: values.ignore_limits ? "Speed limits don't apply to this account" : "Speed limits apply to this account" },
45 { k: 'admin', comp: BoolField, xl: 6, fromField: (v:boolean) => v||null, label: "Permission to access Admin-panel",
46 helperText: "To access THIS interface you are using right now",
47 - ...account.adminActualAccess && { value: true, disabled: true, helperText: "This permission is inherited" },
47 + ...!account.admin && account.adminActualAccess && { value: true, helperText: "This permission is inherited" },
48 },
49 { k: 'belongs', comp: MultiSelectField, label: "Inherits from", options: belongsOptions,
50 helperText: "Specify groups to inherit permissions from."
admin/src/AccountsPage.ts
+1
@@ -14,6 +14,7 @@ import md from './md'
14 export interface Account {
15 username: string
16 hasPassword?: boolean
17 + admin?: boolean
18 adminActualAccess?: boolean
19 ignore_limits?: boolean
20 redirect?: string
admin/src/InstalledPlugins.ts
+4 -1
@@ -77,7 +77,10 @@ export default function InstalledPlugins({ updates }: { updates?: true }) {
77 const pl = await apiCall('get_plugin', { id })
78 const values = await formDialog({
79 title: `${id} configuration`,
80 - fields: [ h(Box, {}, row.description), ...makeFields(config) ],
80 + fields: [
81 + h(Box, {}, row.description),
82 + ...makeFields(config)
83 + ],
84 values: pl.config,
85 ...row.configDialog,
86 })
mui-grid-form/index.ts
+1 -1
@@ -132,7 +132,7 @@ export function Form<Values extends Dict>({
132 if (errMsg === true)
133 errMsg = "Not valid"
134 if (k) {
135 - const originalValue = values?.[k]
135 + const originalValue = row.hasOwnProperty('value') ? row.value : values?.[k]
136 const whole = { ...row, ...field }
137 Object.assign(field, {
138 value: toField(originalValue),