mirror of
https://github.com/kremalicious/umami.git
synced 2025-02-14 21:10:34 +01:00
Update team remove button.
This commit is contained in:
parent
dc3818baaa
commit
288836d4a5
@ -1,11 +1,11 @@
|
||||
import TeamWebsitesTable from './TeamWebsitesTable';
|
||||
import useApi from 'components/hooks/useApi';
|
||||
import useUser from 'components/hooks/useUser';
|
||||
import useFilterQuery from 'components/hooks/useFilterQuery';
|
||||
import DataTable from 'components/common/DataTable';
|
||||
import useApi from 'components/hooks/useApi';
|
||||
import useUser from 'components/hooks/useUser';
|
||||
import useCache from 'store/cache';
|
||||
import WebsitesTable from '../../websites/WebsitesTable';
|
||||
|
||||
export function TeamWebsites({ teamId, readOnly }: { teamId: string; readOnly: boolean }) {
|
||||
export function TeamWebsites({ teamId }: { teamId: string; readOnly: boolean }) {
|
||||
const { user } = useUser();
|
||||
const { get } = useApi();
|
||||
const modified = useCache(state => state?.['team:websites']);
|
||||
@ -19,14 +19,8 @@ export function TeamWebsites({ teamId, readOnly }: { teamId: string; readOnly: b
|
||||
enabled: !!user,
|
||||
});
|
||||
|
||||
const handleChange = () => {
|
||||
queryResult.query.refetch();
|
||||
};
|
||||
|
||||
return (
|
||||
<DataTable queryResult={queryResult}>
|
||||
{({ data }) => <TeamWebsitesTable data={data} onRemove={handleChange} readOnly={readOnly} />}
|
||||
</DataTable>
|
||||
<DataTable queryResult={queryResult}>{({ data }) => <WebsitesTable data={data} />}</DataTable>
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -1,45 +1,31 @@
|
||||
import Link from 'next/link';
|
||||
import { Button, GridColumn, GridTable, Icon, Icons, Text } from 'react-basics';
|
||||
import useMessages from 'components/hooks/useMessages';
|
||||
import useUser from 'components/hooks/useUser';
|
||||
import TeamWebsiteRemoveButton from './TeamWebsiteRemoveButton';
|
||||
|
||||
export function TeamWebsitesTable({
|
||||
data = [],
|
||||
readOnly,
|
||||
onRemove,
|
||||
}: {
|
||||
data: any[];
|
||||
readOnly: boolean;
|
||||
onRemove: () => void;
|
||||
}) {
|
||||
const { formatMessage, labels } = useMessages();
|
||||
const { user } = useUser();
|
||||
|
||||
return (
|
||||
<GridTable data={data}>
|
||||
<GridColumn name="name" label={formatMessage(labels.name)} />
|
||||
<GridColumn name="domain" label={formatMessage(labels.domain)} />
|
||||
<GridColumn name="action" label=" " alignment="end">
|
||||
{row => {
|
||||
const { id: teamId, teamUser } = row.teamWebsite[0].team;
|
||||
const { id: websiteId, userId } = row;
|
||||
const owner = teamUser[0];
|
||||
const canRemove = !readOnly && (user.id === userId || user.id === owner.userId);
|
||||
const { id: websiteId } = row;
|
||||
return (
|
||||
<>
|
||||
{canRemove && (
|
||||
<TeamWebsiteRemoveButton teamId={teamId} websiteId={websiteId} onSave={onRemove} />
|
||||
)}
|
||||
<Link href={`/websites/${websiteId}`}>
|
||||
<Button>
|
||||
<Icon>
|
||||
<Icons.External />
|
||||
</Icon>
|
||||
<Text>{formatMessage(labels.view)}</Text>
|
||||
</Button>
|
||||
</Link>
|
||||
</>
|
||||
<Link href={`/websites/${websiteId}`}>
|
||||
<Button>
|
||||
<Icon>
|
||||
<Icons.External />
|
||||
</Icon>
|
||||
<Text>{formatMessage(labels.view)}</Text>
|
||||
</Button>
|
||||
</Link>
|
||||
);
|
||||
}}
|
||||
</GridColumn>
|
||||
|
@ -239,7 +239,7 @@ export async function resetWebsite(
|
||||
}
|
||||
|
||||
export async function deleteWebsite(
|
||||
websiteId,
|
||||
websiteId: string,
|
||||
): Promise<[Prisma.BatchPayload, Prisma.BatchPayload, Website]> {
|
||||
const { client, transaction } = prisma;
|
||||
const cloudMode = process.env.CLOUD_MODE;
|
||||
@ -254,11 +254,6 @@ export async function deleteWebsite(
|
||||
client.session.deleteMany({
|
||||
where: { websiteId },
|
||||
}),
|
||||
client.teamWebsite.deleteMany({
|
||||
where: {
|
||||
websiteId,
|
||||
},
|
||||
}),
|
||||
client.report.deleteMany({
|
||||
where: {
|
||||
websiteId,
|
||||
|
Loading…
x
Reference in New Issue
Block a user