mirror of
https://github.com/umami-software/umami.git
synced 2026-02-11 16:17:13 +01:00
Admin section updates.
This commit is contained in:
parent
87449ece9e
commit
1b81074752
20 changed files with 274 additions and 647 deletions
|
|
@ -1,11 +0,0 @@
|
|||
.filters {
|
||||
display: flex;
|
||||
justify-content: flex-start;
|
||||
align-items: flex-start;
|
||||
}
|
||||
|
||||
.tag {
|
||||
text-align: center;
|
||||
margin-bottom: 10px;
|
||||
margin-inline-end: 20px;
|
||||
}
|
||||
|
|
@ -1,38 +0,0 @@
|
|||
import { Button, Icon, Text } from '@umami/react-zen';
|
||||
import { Close } from '@/components/icons';
|
||||
import styles from './WebsiteTags.module.css';
|
||||
|
||||
export function WebsiteTags({
|
||||
items = [],
|
||||
websites = [],
|
||||
onClick,
|
||||
}: {
|
||||
items: any[];
|
||||
websites: any[];
|
||||
onClick: (e: Event) => void;
|
||||
}) {
|
||||
if (websites.length === 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<div className={styles.filters}>
|
||||
{websites.map(websiteId => {
|
||||
const website = items.find(a => a.id === websiteId);
|
||||
|
||||
return (
|
||||
<div key={websiteId} className={styles.tag}>
|
||||
<Button onPress={() => onClick(websiteId)} variant="primary" size="sm">
|
||||
<Text>
|
||||
<b>{`${website.name}`}</b>
|
||||
</Text>
|
||||
<Icon>
|
||||
<Close />
|
||||
</Icon>
|
||||
</Button>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
@ -19,19 +19,21 @@ export function WebsiteData({ websiteId, onSave }: { websiteId: string; onSave?:
|
|||
const { touch } = useModified();
|
||||
const { teamId, renderUrl } = useNavigation();
|
||||
const router = useRouter();
|
||||
const { data } = useUserTeamsQuery(user.id);
|
||||
const { data: teams } = useUserTeamsQuery(user.id);
|
||||
|
||||
const canTransferWebsite =
|
||||
(
|
||||
!teamId &&
|
||||
data.filter(({ teamUser }) =>
|
||||
teamUser.find(
|
||||
({ role, userId }) =>
|
||||
[ROLES.teamOwner, ROLES.teamManager].includes(role) && userId === user.id,
|
||||
),
|
||||
)
|
||||
(!teamId &&
|
||||
teams?.data?.filter(({ teamUser }) =>
|
||||
teamUser.find(
|
||||
({ role, userId }) =>
|
||||
[ROLES.teamOwner, ROLES.teamManager].includes(role) && userId === user.id,
|
||||
),
|
||||
)) ||
|
||||
[]
|
||||
).length > 0 ||
|
||||
(teamId &&
|
||||
!!data
|
||||
!!teams?.data
|
||||
?.find(({ id }) => id === teamId)
|
||||
?.teamUser.find(({ role, userId }) => role === ROLES.teamOwner && userId === user.id));
|
||||
|
||||
|
|
|
|||
|
|
@ -6,17 +6,13 @@ import {
|
|||
Switch,
|
||||
FormSubmitButton,
|
||||
Column,
|
||||
Icon,
|
||||
Grid,
|
||||
Label,
|
||||
useToast,
|
||||
TooltipTrigger,
|
||||
Tooltip,
|
||||
Row,
|
||||
} from '@umami/react-zen';
|
||||
import { useState } from 'react';
|
||||
import { getRandomChars } from '@/lib/crypto';
|
||||
import { useApi, useMessages, useModified } from '@/components/hooks';
|
||||
import { Refresh } from '@/components/icons';
|
||||
|
||||
const generateId = () => getRandomChars(16);
|
||||
|
||||
|
|
@ -70,24 +66,19 @@ export function WebsiteShareForm({ websiteId, shareId, onSave, onClose }: Websit
|
|||
{id && (
|
||||
<Column>
|
||||
<Label>{formatMessage(labels.shareUrl)}</Label>
|
||||
<Grid columns="1fr auto" gap>
|
||||
<TextField value={url} isReadOnly allowCopy />
|
||||
<TooltipTrigger>
|
||||
<Button onPress={handleGenerate} variant="quiet" size="sm">
|
||||
<Icon>
|
||||
<Refresh />
|
||||
</Icon>
|
||||
</Button>
|
||||
<Tooltip>{formatMessage(labels.regenerate)}</Tooltip>
|
||||
</TooltipTrigger>
|
||||
</Grid>
|
||||
<TextField value={url} isReadOnly allowCopy />
|
||||
</Column>
|
||||
)}
|
||||
<FormButtons>
|
||||
<Button onPress={onClose}>{formatMessage(labels.cancel)}</Button>
|
||||
<FormSubmitButton isDisabled={false} isLoading={isPending}>
|
||||
{formatMessage(labels.save)}
|
||||
</FormSubmitButton>
|
||||
<FormButtons justifyContent="space-between">
|
||||
<Row>
|
||||
{id && <Button onPress={handleGenerate}>{formatMessage(labels.regenerate)}</Button>}
|
||||
</Row>
|
||||
<Row>
|
||||
{onClose && <Button onPress={onClose}>{formatMessage(labels.cancel)}</Button>}
|
||||
<FormSubmitButton isDisabled={false} isLoading={isPending}>
|
||||
{formatMessage(labels.save)}
|
||||
</FormSubmitButton>
|
||||
</Row>
|
||||
</FormButtons>
|
||||
</Column>
|
||||
</Form>
|
||||
|
|
|
|||
|
|
@ -31,15 +31,16 @@ export function WebsiteTransferForm({
|
|||
const { mutate, error } = useMutation({
|
||||
mutationFn: (data: any) => post(`/websites/${websiteId}/transfer`, data),
|
||||
});
|
||||
const { result, query } = useUserTeamsQuery(user.id);
|
||||
const { data: teams, isLoading } = useUserTeamsQuery(user.id);
|
||||
const isTeamWebsite = !!website?.teamId;
|
||||
|
||||
const items = result.data.filter(({ teamUser }) =>
|
||||
teamUser.find(
|
||||
({ role, userId }) =>
|
||||
[ROLES.teamOwner, ROLES.teamManager].includes(role) && userId === user.id,
|
||||
),
|
||||
);
|
||||
const items =
|
||||
teams?.data?.filter(({ teamUser }) =>
|
||||
teamUser.find(
|
||||
({ role, userId }) =>
|
||||
[ROLES.teamOwner, ROLES.teamManager].includes(role) && userId === user.id,
|
||||
),
|
||||
) || [];
|
||||
|
||||
const handleSubmit = async () => {
|
||||
mutate(
|
||||
|
|
@ -60,7 +61,7 @@ export function WebsiteTransferForm({
|
|||
setTeamId(key as string);
|
||||
};
|
||||
|
||||
if (query.isLoading) {
|
||||
if (isLoading) {
|
||||
return <Loading icon="dots" position="center" />;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue