ux: admin/accounts: invite user to create an admin account when there are none
Massimo Melina committed
Aug 29, 2022 at 17:08 UTC
e861fd26279ba1682b1aad33b19ca6d5deda1182
3 files changed
+8
-4
admin/src/AccountForm.ts
+1
-1
@@ -42,7 +42,7 @@ export default function AccountForm({ account, done, groups, close }: FormProps)
42
{ k: 'ignore_limits', comp: BoolField, xl: 6,
43
helperText: values.ignore_limits ? "Speed limits don't apply to this account" : "Speed limits apply to this account" },
44
{ k: 'admin', comp: BoolField, xl: 6, fromField: (v:boolean) => v||null, label: "Permission to access Admin interface",
45
- helperText: "It's THIS interface you are using right now.",
45
+ helperText: "To access THIS interface you are using right now",
46
...account.adminActualAccess && { value: true, disabled: true, helperText: "This permission is inherited" },
47
},
48
{ k: 'belongs', comp: MultiSelectField, label: "Inherits from", options: belongsOptions,
admin/src/AccountsPage.ts
+4
-2
@@ -2,13 +2,14 @@
2
3
import { createElement as h, useState, useEffect, Fragment } from "react"
4
import { apiCall, useApiEx } from './api'
5
-import { Box, Button, Card, CardContent, Grid, List, ListItem, ListItemText, Typography } from '@mui/material'
5
+import { Alert, Box, Button, Card, CardContent, Grid, List, ListItem, ListItemText, Typography } from '@mui/material'
6
import { Delete, Group, MilitaryTech, Person, PersonAdd, Refresh } from '@mui/icons-material'
7
import { alertDialog, confirmDialog } from './dialog'
8
import { iconTooltip, onlyTruthy } from './misc'
9
import { TreeItem, TreeView } from '@mui/lab'
10
import MenuButton from './MenuButton'
11
import AccountForm from './AccountForm'
12
+import md from './md'
13
14
export interface Account {
15
username: string
@@ -68,9 +69,10 @@ export default function AccountsPage() {
69
}
70
}, "Remove"),
71
h(Button, { onClick: reload, startIcon: h(Refresh) }, "Reload"),
71
- h(Typography, { p: 1 }, `${list.length} account(s)`),
72
+ list.length > 0 && h(Typography, { p: 1 }, `${list.length} account(s)`),
73
) ),
74
h(Grid, { item: true, md: 5 },
75
+ !list.length && h(Alert, { severity: 'info' }, md`To access administration _remotely_ you will need to create a user account with admin permission`),
76
h(TreeView, {
77
multiSelect: true,
78
sx: { pr: 4, pb: 2, minWidth: '15em' },
admin/src/md.ts
+3
-1
@@ -3,7 +3,9 @@
3
import { createElement as h, Fragment } from 'react'
4
5
// markdown inspired syntax to transform text into react elements: * for bold, / for italic, _ for underline, ` for code
6
-export default function md(text: string) {
6
+export default function md(text: string | TemplateStringsArray) {
7
+ if (typeof text !== 'string')
8
+ text = text[0]
9
const re = /([`*/_])(.+)\1|(\n)/g
10
const res = []
11
let last = 0