Files
fredy/ui/src/components/table/UserTable.jsx

73 lines
1.9 KiB
React
Raw Normal View History

2025-12-11 10:40:55 +01:00
/*
* Copyright (c) 2026 by Christian Kellner.
2025-12-11 10:40:55 +01:00
* Licensed under Apache-2.0 with Commons Clause and Attribution/Naming Clause
*/
2023-03-20 08:52:13 +01:00
import { IllustrationNoResult, IllustrationNoResultDark } from '@douyinfe/semi-illustrations';
import { format } from '../../services/time/timeService';
import { Table, Button, Empty } from '@douyinfe/semi-ui-19';
2023-03-20 08:52:13 +01:00
import { IconDelete, IconEdit } from '@douyinfe/semi-icons';
2023-03-20 08:52:13 +01:00
const empty = (
<Empty
image={<IllustrationNoResult />}
darkModeImage={<IllustrationNoResultDark />}
description={'No users found.'}
2023-03-20 08:52:13 +01:00
/>
);
export default function UserTable({ user = [], onUserRemoval, onUserEdit } = {}) {
return (
2023-03-20 08:52:13 +01:00
<Table
pagination={false}
empty={empty}
columns={[
{
title: 'Username',
dataIndex: 'username',
},
{
title: 'Last login',
dataIndex: 'lastLogin',
render: (value) => {
return format(value);
},
},
{
title: 'Number of jobs',
dataIndex: 'numberOfJobs',
},
2026-03-09 15:35:29 +01:00
{
title: 'MCP Token',
dataIndex: 'mcpToken',
render: (value) => {
return (
<span style={{ fontFamily: 'monospace', fontSize: '0.85em', wordBreak: 'break-all' }}>
{value || '---'}
</span>
);
},
},
2023-03-20 08:52:13 +01:00
{
title: '',
dataIndex: 'tools',
render: (value, user) => {
return (
<div style={{ float: 'right' }}>
<Button
type="danger"
icon={<IconDelete />}
onClick={() => onUserRemoval(user.id)}
style={{ marginRight: '1rem' }}
/>
<Button type="primary" icon={<IconEdit />} onClick={() => onUserEdit(user.id)} />
</div>
);
},
},
]}
dataSource={user}
/>
);
}