Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restore tabs, set default to true for snapshot, link loader #914

Merged
merged 6 commits into from
Dec 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion ui/app/mirrors/create/cdc/fields.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const CDCFields = ({ setting, handleChange }: FieldProps) => {
}}
>
<Switch
defaultChecked={setting.default as boolean}
onCheckedChange={(state: boolean) => handleChange(state, setting)}
/>
{setting.tips && (
Expand Down Expand Up @@ -52,7 +53,7 @@ const CDCFields = ({ setting, handleChange }: FieldProps) => {
<TextField
variant='simple'
type={setting.type}
defaultValue={setting.default}
defaultValue={setting.default as string}
onChange={(e: React.ChangeEvent<HTMLInputElement>) =>
handleChange(e.target.value, setting)
}
Expand Down
3 changes: 2 additions & 1 deletion ui/app/mirrors/create/helpers/cdc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ export const cdcSettings: MirrorSetting[] = [
stateHandler: (value, setter) =>
setter((curr: CDCConfig) => ({
...curr,
doInitialCopy: (value as boolean) || false,
doInitialCopy: (value as boolean) ?? true,
})),
tips: 'Specify if you want initial load to happen for your tables.',
type: 'switch',
default: true,
},
{
label: 'Pull Batch Size',
Expand Down
4 changes: 2 additions & 2 deletions ui/app/mirrors/create/helpers/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export interface MirrorSetting {
required?: boolean;
tips?: string;
helpfulLink?: string;
default?: string | number;
default?: string | number | boolean;
advanced?: boolean; // whether it should come under an 'Advanced' section
}

Expand All @@ -29,7 +29,7 @@ export const blankCDCSetting: FlowConnectionConfigs = {
tableNameSchemaMapping: {},
metadataPeer: undefined,
maxBatchSize: 100000,
doInitialCopy: false,
doInitialCopy: true,
publicationName: '',
snapshotNumRowsPerPartition: 500000,
snapshotMaxParallelWorkers: 1,
Expand Down
2 changes: 1 addition & 1 deletion ui/app/mirrors/create/qrep/qrep.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ export default function QRepConfigForm({
defaultValue={
setting.label === 'Destination Table Name'
? mirrorConfig.destinationTableIdentifier
: setting.default
: (setting.default as string)
}
onChange={(e: React.ChangeEvent<HTMLInputElement>) =>
handleChange(e.target.value, setting)
Expand Down
19 changes: 15 additions & 4 deletions ui/app/mirrors/edit/[mirrorId]/cdc.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
'use client';

import { SyncStatusRow } from '@/app/dto/MirrorsDTO';
import TimeLabel from '@/components/TimeComponent';
import {
Expand Down Expand Up @@ -275,7 +274,13 @@ export function CDCMirror({
createdAt,
syncStatusChild,
}: CDCMirrorStatusProps) {
const [selectedTab, setSelectedTab] = useState('');
const [selectedTab, setSelectedTab] = useState(-1);
const LocalStorageTabKey = 'cdctab';

const handleTab = (index: number) => {
localStorage.setItem(LocalStorageTabKey, index.toString());
setSelectedTab(index);
};

let snapshot = <></>;
if (cdc.snapshotStatus) {
Expand All @@ -284,12 +289,18 @@ export function CDCMirror({

useEffect(() => {
if (typeof window !== 'undefined') {
setSelectedTab(localStorage?.getItem('mirrortab') || 'tab1');
setSelectedTab(
parseInt(localStorage?.getItem(LocalStorageTabKey) ?? '0') | 0
);
}
}, []);

return (
<TabGroup style={{ marginTop: '1rem' }}>
<TabGroup
index={selectedTab}
onIndexChange={handleTab}
style={{ marginTop: '1rem' }}
>
<TabList
color='neutral'
style={{ display: 'flex', justifyContent: 'space-around' }}
Expand Down
11 changes: 4 additions & 7 deletions ui/app/mirrors/tables.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
'use client';
import { DropDialog } from '@/components/DropDialog';
import MirrorLink from '@/components/MirrorLink';
import PeerButton from '@/components/PeerComponent';
import TimeLabel from '@/components/TimeComponent';
import { Label } from '@/lib/Label';
import { SearchField } from '@/lib/SearchField';
import { Table, TableCell, TableRow } from '@/lib/Table';
import Link from 'next/link';
import { useMemo, useState } from 'react';
import { MirrorError } from './mirror-status';

Expand All @@ -18,6 +18,7 @@ export function CDCFlows({ cdcFlows }: { cdcFlows: any }) {
}),
[searchQuery, cdcFlows]
);
const [isLoading, setIsLoading] = useState(false);

return (
<>
Expand Down Expand Up @@ -70,9 +71,7 @@ export function CDCFlows({ cdcFlows }: { cdcFlows: any }) {
{mirrors.map((flow: any) => (
<TableRow key={flow.id}>
<TableCell>
<Label as={Link} href={`/mirrors/edit/${flow.name}`}>
<div className='cursor-pointer underline'>{flow.name}</div>
</Label>
<MirrorLink flowName={flow?.name} />
</TableCell>
<TableCell>
<PeerButton
Expand Down Expand Up @@ -167,9 +166,7 @@ export function QRepFlows({
{mirrors.map((flow: any) => (
<TableRow key={flow.id}>
<TableCell>
<Label as={Link} href={`/mirrors/edit/${flow.name}`}>
<div className='cursor-pointer underline'>{flow.name}</div>
</Label>
<MirrorLink flowName={flow?.name} />
</TableCell>
<TableCell>
<PeerButton
Expand Down
23 changes: 23 additions & 0 deletions ui/components/MirrorLink.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
'use client';
import { Label } from '@/lib/Label';
import { ProgressCircle } from '@/lib/ProgressCircle';
import Link from 'next/link';
import { useState } from 'react';

const MirrorLink = ({ flowName }: { flowName: string }) => {
const [isLoading, setIsLoading] = useState(false);
return (
<div onClick={() => setIsLoading(true)}>
{isLoading ? (
<ProgressCircle variant='determinate_progress_circle' />
) : (
<Link href={`/mirrors/edit/${flowName}`}>
<Label>
<div className='cursor-pointer underline'>{flowName}</div>
</Label>
</Link>
)}
</div>
);
};
export default MirrorLink;
Loading