Gate replays.
This commit is contained in:
1 parent
534af98809
commit
6e1a05f686
8 files changed
+109
-6
No files matched your search
@@ -1,10 +1,10 @@
|
||||
'use client';
|
||||
import { Column, Tab, TabList, TabPanel, Tabs } from '@umami/react-zen';
|
||||
import { Button, Column, Tab, TabList, TabPanel, Tabs, Text } from '@umami/react-zen';
|
||||
import { type Key, useState } from 'react';
|
||||
import { SessionModal } from '@/app/(main)/websites/[websiteId]/sessions/SessionModal';
|
||||
import { WebsiteControls } from '@/app/(main)/websites/[websiteId]/WebsiteControls';
|
||||
import { Panel } from '@/components/common/Panel';
|
||||
import { useMessages } from '@/components/hooks';
|
||||
import { useMessages, useSubscription } from '@/components/hooks';
|
||||
import { getItem, setItem } from '@/lib/storage';
|
||||
import { ReplayModal } from './ReplayModal';
|
||||
import { ReplaysDataTable } from './ReplaysDataTable';
|
||||
@@ -14,13 +14,29 @@ const KEY_NAME = 'umami.replays.tab';
|
||||
|
||||
export function ReplaysPage({ websiteId }: { websiteId: string }) {
|
||||
const [tab, setTab] = useState(getItem(KEY_NAME) || 'replays');
|
||||
const { t, labels } = useMessages();
|
||||
const { t, labels, messages } = useMessages();
|
||||
const { hasFeature, cloudMode } = useSubscription();
|
||||
|
||||
const handleSelect = (value: Key) => {
|
||||
setItem(KEY_NAME, value);
|
||||
setTab(value);
|
||||
};
|
||||
|
||||
if (cloudMode && !hasFeature('replays')) {
|
||||
return (
|
||||
<Column gap="3">
|
||||
<Panel>
|
||||
<Column gap="4" alignItems="center" padding="10">
|
||||
<Text>{t(messages.upgradeRequired, { plan: 'Business' })}</Text>
|
||||
<Button variant="primary" onPress={() => window.open(`${process.env.cloudUrl}/settings/billing`, '_blank')}>
|
||||
{t(labels.upgrade)}
|
||||
</Button>
|
||||
</Column>
|
||||
</Panel>
|
||||
</Column>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<Column gap="3">
|
||||
<WebsiteControls websiteId={websiteId} />
|
||||
|
||||
@@ -7,10 +7,11 @@ import {
|
||||
Select,
|
||||
Slider,
|
||||
Switch,
|
||||
Text,
|
||||
TextField,
|
||||
} from '@umami/react-zen';
|
||||
import { useState } from 'react';
|
||||
import { useMessages, useUpdateQuery, useWebsite } from '@/components/hooks';
|
||||
import { useMessages, useSubscription, useUpdateQuery, useWebsite } from '@/components/hooks';
|
||||
|
||||
interface ReplayConfig {
|
||||
sampleRate?: number;
|
||||
@@ -22,6 +23,7 @@ interface ReplayConfig {
|
||||
export function WebsiteReplaySettings({ websiteId }: { websiteId: string }) {
|
||||
const website = useWebsite();
|
||||
const { t, labels, messages } = useMessages();
|
||||
const { hasFeature, cloudMode } = useSubscription();
|
||||
const { mutateAsync, touch, toast, isPending } = useUpdateQuery(`/websites/${websiteId}`);
|
||||
const [enabled, setEnabled] = useState(website?.replayEnabled ?? false);
|
||||
|
||||
@@ -75,6 +77,20 @@ export function WebsiteReplaySettings({ websiteId }: { websiteId: string }) {
|
||||
);
|
||||
};
|
||||
|
||||
if (cloudMode && !hasFeature('replays')) {
|
||||
return (
|
||||
<Column gap="4">
|
||||
<Label>{t(labels.replays)}</Label>
|
||||
<Column gap="4" alignItems="center" padding="10">
|
||||
<Text>{t(messages.upgradeRequired, { plan: 'Business' })}</Text>
|
||||
<Button variant="primary" onPress={() => window.open(`${process.env.cloudUrl}/settings/billing`, '_blank')}>
|
||||
{t(labels.upgrade)}
|
||||
</Button>
|
||||
</Column>
|
||||
</Column>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<Column gap="4">
|
||||
<Label>{t(labels.replays)}</Label>
|
||||
|
||||
Reference in new issue
Block a user