umami/components/pages/settings/websites/WebsitesTable.js

48 lines
1.3 KiB
JavaScript
Raw Normal View History

import Link from 'next/link';
2023-04-12 22:40:19 +02:00
import { Button, Text, Icon, Icons } from 'react-basics';
import SettingsTable from 'components/common/SettingsTable';
2023-03-22 22:05:55 +01:00
import useMessages from 'hooks/useMessages';
import useConfig from 'hooks/useConfig';
2023-01-21 02:12:53 +01:00
2023-04-21 17:00:42 +02:00
export function WebsitesTable({ data = [] }) {
2023-03-22 22:05:55 +01:00
const { formatMessage, labels } = useMessages();
const { openExternal } = useConfig();
2023-01-25 16:42:46 +01:00
const columns = [
2023-04-12 22:40:19 +02:00
{ name: 'name', label: formatMessage(labels.name) },
2023-01-31 06:44:07 +01:00
{ name: 'domain', label: formatMessage(labels.domain) },
2023-04-12 22:40:19 +02:00
{ name: 'action', label: ' ' },
2023-01-25 16:42:46 +01:00
];
return (
2023-04-12 22:40:19 +02:00
<SettingsTable columns={columns} data={data}>
{row => {
const { id } = row;
2023-04-12 22:40:19 +02:00
return (
<>
<Link href={`/settings/websites/${id}`}>
<Button>
<Icon>
<Icons.Edit />
</Icon>
<Text>{formatMessage(labels.edit)}</Text>
</Button>
</Link>
<Link href={`/websites/${id}`} target={openExternal ? '_blank' : null}>
<Button>
<Icon>
<Icons.External />
</Icon>
<Text>{formatMessage(labels.view)}</Text>
</Button>
</Link>
</>
);
}}
</SettingsTable>
);
}
2023-04-21 17:00:42 +02:00
export default WebsitesTable;