mirror of
https://github.com/umami-software/umami.git
synced 2026-02-15 01:55:36 +01:00
Remove invalid 3rd parameter from GET handler and parse report type from query params instead. Pass teamId to WebsiteSelect in BoardEditHeader so it shows team websites in team context. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
103 lines
2.8 KiB
TypeScript
103 lines
2.8 KiB
TypeScript
import {
|
|
Button,
|
|
Column,
|
|
Grid,
|
|
Heading,
|
|
LoadingButton,
|
|
Row,
|
|
Text,
|
|
TextField,
|
|
} from '@umami/react-zen';
|
|
import { useBoard, useMessages, useNavigation } from '@/components/hooks';
|
|
import { WebsiteSelect } from '@/components/input/WebsiteSelect';
|
|
|
|
export function BoardEditHeader() {
|
|
const { board, updateBoard, saveBoard, isPending } = useBoard();
|
|
const { formatMessage, labels } = useMessages();
|
|
const { teamId, router, renderUrl } = useNavigation();
|
|
const defaultName = formatMessage(labels.untitled);
|
|
|
|
const handleNameChange = (value: string) => {
|
|
updateBoard({ name: value });
|
|
};
|
|
|
|
const handleDescriptionChange = (value: string) => {
|
|
updateBoard({ description: value });
|
|
};
|
|
|
|
const handleWebsiteChange = (websiteId: string) => {
|
|
updateBoard({ parameters: { ...board.parameters, websiteId } });
|
|
};
|
|
|
|
const handleSave = async () => {
|
|
await saveBoard();
|
|
if (board.id) {
|
|
router.push(renderUrl(`/boards/${board.id}`));
|
|
}
|
|
};
|
|
|
|
const handleCancel = () => {
|
|
if (board.id) {
|
|
router.push(renderUrl(`/boards/${board.id}`));
|
|
} else {
|
|
router.push(renderUrl('/boards'));
|
|
}
|
|
};
|
|
|
|
return (
|
|
<Grid
|
|
columns={{ base: '1fr', md: '1fr 1fr' }}
|
|
paddingY="4"
|
|
marginBottom="6"
|
|
border="bottom"
|
|
gapX="6"
|
|
>
|
|
<Column>
|
|
<Row>
|
|
<TextField
|
|
variant="quiet"
|
|
name="name"
|
|
value={board?.name ?? ''}
|
|
placeholder={defaultName}
|
|
onChange={handleNameChange}
|
|
autoComplete="off"
|
|
style={{ fontSize: '2rem', fontWeight: 700, width: '100%' }}
|
|
>
|
|
<Heading size="xl">{board?.name}</Heading>
|
|
</TextField>
|
|
</Row>
|
|
<Row>
|
|
<TextField
|
|
variant="quiet"
|
|
name="description"
|
|
value={board?.description ?? ''}
|
|
placeholder={`+ ${formatMessage(labels.addDescription)}`}
|
|
autoComplete="off"
|
|
onChange={handleDescriptionChange}
|
|
style={{ width: '100%' }}
|
|
>
|
|
{board?.description}
|
|
</TextField>
|
|
</Row>
|
|
<Row alignItems="center" gap="3">
|
|
<Text>{formatMessage(labels.website)}</Text>
|
|
<WebsiteSelect
|
|
websiteId={board?.parameters?.websiteId}
|
|
teamId={teamId}
|
|
onChange={handleWebsiteChange}
|
|
/>
|
|
</Row>
|
|
</Column>
|
|
<Column justifyContent="center" alignItems="flex-end">
|
|
<Row gap="3">
|
|
<Button variant="quiet" onPress={handleCancel}>
|
|
{formatMessage(labels.cancel)}
|
|
</Button>
|
|
<LoadingButton variant="primary" onPress={handleSave} isLoading={isPending}>
|
|
{formatMessage(labels.save)}
|
|
</LoadingButton>
|
|
</Row>
|
|
</Column>
|
|
</Grid>
|
|
);
|
|
}
|