navidrome/ui/src/user/UserList.jsx

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

52 lines
1.4 KiB
React
Raw Normal View History

2020-01-19 20:40:18 -05:00
import React from 'react'
import {
BooleanField,
Datagrid,
Filter,
SearchInput,
SimpleList,
TextField,
} from 'react-admin'
import { useMediaQuery } from '@material-ui/core'
2021-06-16 12:28:49 -04:00
import { List, DateField } from '../common'
2020-01-19 20:40:18 -05:00
const UserFilter = (props) => (
<Filter {...props} variant={'outlined'}>
<SearchInput id="search" source="name" alwaysOn />
2020-01-19 20:40:18 -05:00
</Filter>
)
const UserList = (props) => {
const isXsmall = useMediaQuery((theme) => theme.breakpoints.down('xs'))
return (
<List
{...props}
2020-01-20 09:54:29 -05:00
sort={{ field: 'userName', order: 'ASC' }}
2020-01-19 20:40:18 -05:00
exporter={false}
2020-06-10 16:13:02 -04:00
bulkActionButtons={false}
2020-01-19 20:40:18 -05:00
filters={<UserFilter />}
>
{isXsmall ? (
<SimpleList
2020-01-30 20:20:06 -05:00
primaryText={(record) => record.userName}
secondaryText={(record) =>
record.lastLoginAt && new Date(record.lastLoginAt).toLocaleString()
}
2020-01-19 21:39:37 -05:00
tertiaryText={(record) => (record.isAdmin ? '[admin]️' : '')}
2020-01-19 20:40:18 -05:00
/>
) : (
2020-01-19 21:39:37 -05:00
<Datagrid rowClick="edit">
2020-01-20 09:54:29 -05:00
<TextField source="userName" />
2020-01-30 20:20:06 -05:00
<TextField source="name" />
2020-01-19 20:40:18 -05:00
<BooleanField source="isAdmin" />
<DateField source="lastLoginAt" sortByOrder={'DESC'} />
<DateField source="lastAccessAt" sortByOrder={'DESC'} />
<DateField source="updatedAt" sortByOrder={'DESC'} />
2020-01-19 20:40:18 -05:00
</Datagrid>
)}
</List>
)
}
export default UserList