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