Skip to content

Commit

Permalink
tabs, default snapshot, link load
Browse files Browse the repository at this point in the history
  • Loading branch information
Amogh-Bharadwaj committed Dec 27, 2023
1 parent 4425e20 commit 7170b84
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 16 deletions.
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')
);
}
}, []);

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;

0 comments on commit 7170b84

Please sign in to comment.