fix toggle behavior and reorder replays table with play at beginning. Add missing messages script
This commit is contained in:
1 parent
72bb63fe5e
commit
38577a9c0c
7 files changed
+109
-24
No files matched your search
@@ -20,6 +20,15 @@ export function ReplaysTable({ ...props }: DataTableProps) {
|
||||
|
||||
return (
|
||||
<DataTable {...props}>
|
||||
<DataColumn id="play" label="" width="80px">
|
||||
{(row: any) => (
|
||||
<Button variant="quiet" onClick={() => router.push(updateParams({ replay: row.id }))}>
|
||||
<Icon>
|
||||
<Play />
|
||||
</Icon>
|
||||
</Button>
|
||||
)}
|
||||
</DataColumn>
|
||||
<DataColumn id="id" label={t(labels.session)} width="100px">
|
||||
{(row: any) => (
|
||||
<Link href={updateParams({ session: row.sessionId })}>
|
||||
@@ -63,15 +72,6 @@ export function ReplaysTable({ ...props }: DataTableProps) {
|
||||
<DataColumn id="createdAt" label={t(labels.recordedAt)} width="140px">
|
||||
{(row: any) => <DateDistance date={new Date(row.createdAt)} />}
|
||||
</DataColumn>
|
||||
<DataColumn id="play" label="" width="80px">
|
||||
{(row: any) => (
|
||||
<Button variant="quiet" onClick={() => router.push(updateParams({ replay: row.id }))}>
|
||||
<Icon>
|
||||
<Play />
|
||||
</Icon>
|
||||
</Button>
|
||||
)}
|
||||
</DataColumn>
|
||||
</DataTable>
|
||||
);
|
||||
}
|
||||
@@ -19,14 +19,6 @@ export function SessionReplaysTable({
|
||||
|
||||
return (
|
||||
<DataTable {...props}>
|
||||
<DataColumn id="id" label={t(labels.replayId)} />
|
||||
<DataColumn id="duration" label={t(labels.duration)} width="100px">
|
||||
{(row: any) => formatDuration(row.duration || 0)}
|
||||
</DataColumn>
|
||||
<DataColumn id="eventCount" label={t(labels.actions)} width="80px" />
|
||||
<DataColumn id="createdAt" label={t(labels.recordedAt)} width="140px">
|
||||
{(row: any) => <DateDistance date={new Date(row.createdAt)} />}
|
||||
</DataColumn>
|
||||
<DataColumn id="play" label="" width="80px">
|
||||
{(row: any) => (
|
||||
<Button
|
||||
@@ -39,6 +31,14 @@ export function SessionReplaysTable({
|
||||
</Button>
|
||||
)}
|
||||
</DataColumn>
|
||||
<DataColumn id="id" label={t(labels.replayId)} />
|
||||
<DataColumn id="duration" label={t(labels.duration)} width="100px">
|
||||
{(row: any) => formatDuration(row.duration || 0)}
|
||||
</DataColumn>
|
||||
<DataColumn id="eventCount" label={t(labels.actions)} width="80px" />
|
||||
<DataColumn id="createdAt" label={t(labels.recordedAt)} width="140px">
|
||||
{(row: any) => <DateDistance date={new Date(row.createdAt)} />}
|
||||
</DataColumn>
|
||||
</DataTable>
|
||||
);
|
||||
}
|
||||
@@ -32,6 +32,28 @@ export function WebsiteReplaySettings({ websiteId }: { websiteId: string }) {
|
||||
const [maxDuration, setMaxDuration] = useState(String(config.maxDuration ?? 300000));
|
||||
const [blockSelector, setBlockSelector] = useState(config.blockSelector ?? '');
|
||||
|
||||
const handleToggle = async (value: boolean) => {
|
||||
const previous = enabled;
|
||||
setEnabled(value);
|
||||
|
||||
try {
|
||||
await mutateAsync(
|
||||
{
|
||||
replayEnabled: value,
|
||||
},
|
||||
{
|
||||
onSuccess: async () => {
|
||||
toast(t(messages.saved));
|
||||
touch('websites');
|
||||
touch(`website:${websiteId}`);
|
||||
},
|
||||
},
|
||||
);
|
||||
} catch {
|
||||
setEnabled(previous);
|
||||
}
|
||||
};
|
||||
|
||||
const handleSave = async () => {
|
||||
await mutateAsync(
|
||||
{
|
||||
@@ -47,7 +69,7 @@ export function WebsiteReplaySettings({ websiteId }: { websiteId: string }) {
|
||||
onSuccess: async () => {
|
||||
toast(t(messages.saved));
|
||||
touch('websites');
|
||||
touch(`website:${website.id}`);
|
||||
touch(`website:${websiteId}`);
|
||||
},
|
||||
},
|
||||
);
|
||||
@@ -56,7 +78,7 @@ export function WebsiteReplaySettings({ websiteId }: { websiteId: string }) {
|
||||
return (
|
||||
<Column gap="4">
|
||||
<Label>{t(labels.replays)}</Label>
|
||||
<Switch isSelected={enabled} onChange={setEnabled}>
|
||||
<Switch isSelected={enabled} onChange={handleToggle} isDisabled={isPending}>
|
||||
{t(labels.replayEnabled)}
|
||||
</Switch>
|
||||
{enabled && (
|
||||
@@ -92,13 +114,13 @@ export function WebsiteReplaySettings({ websiteId }: { websiteId: string }) {
|
||||
<Label>{t(labels.blockSelector)}</Label>
|
||||
<TextField value={blockSelector} onChange={setBlockSelector} />
|
||||
</Column>
|
||||
<Row>
|
||||
<Button variant="primary" onPress={handleSave} isDisabled={isPending}>
|
||||
{t(labels.save)}
|
||||
</Button>
|
||||
</Row>
|
||||
</>
|
||||
)}
|
||||
<Row>
|
||||
<Button variant="primary" onPress={handleSave} isDisabled={isPending}>
|
||||
{t(labels.save)}
|
||||
</Button>
|
||||
</Row>
|
||||
</Column>
|
||||
);
|
||||
}
|
||||
@@ -358,6 +358,7 @@ export const labels: Record<string, string> = {
|
||||
needsImprovement: 'label.needs-improvement',
|
||||
poor: 'label.poor',
|
||||
sampleSize: 'label.sample-size',
|
||||
play: 'label.play',
|
||||
replays: 'label.replays',
|
||||
replay: 'label.replay',
|
||||
replayId: 'label.replay-id',
|
||||
|
||||
Reference in new issue
Block a user