Skip to content

Commit

Permalink
fix: sync creation process (#48)
Browse files Browse the repository at this point in the history
* style: layout fix for the cross icon

* fix: persist state for sync mode
  • Loading branch information
sumitd94 authored Apr 16, 2024
1 parent 0fa80c5 commit e3e71ff
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import ContentContainer from '@/components/ContentContainer';
import { SteppedFormContext } from '@/components/SteppedForm/SteppedForm';
import { ModelEntity } from '@/views/Models/types';
import { Box } from '@chakra-ui/react';
import { FormEvent, useContext, Dispatch, SetStateAction, useState } from 'react';
import { FormEvent, useContext, Dispatch, SetStateAction } from 'react';
import SelectStreams from './SelectStreams';
import { Stream, FieldMap as FieldMapType } from '@/views/Activate/Syncs/types';
import MapFields from './MapFields';
Expand All @@ -18,20 +18,23 @@ type ConfigureSyncsProps = {
selectedStream: Stream | null;
configuration: FieldMapType[] | null;
schemaMode: SchemaMode | null;
selectedSyncMode: string;
setSelectedStream: Dispatch<SetStateAction<Stream | null>>;
setConfiguration: Dispatch<SetStateAction<FieldMapType[] | null>>;
setSchemaMode: Dispatch<SetStateAction<SchemaMode | null>>;
setSelectedSyncMode: Dispatch<SetStateAction<string>>;
};

const ConfigureSyncs = ({
selectedStream,
configuration,
selectedSyncMode,
setSelectedStream,
setConfiguration,
setSchemaMode,
setSelectedSyncMode,
}: ConfigureSyncsProps): JSX.Element | null => {
const { state, stepInfo, handleMoveForward } = useContext(SteppedFormContext);
const [selectedSyncMode, setSelectedSyncMode] = useState('');
const { forms } = state;

const modelInfo = forms.find((form) => form.stepKey === 'selectModel');
Expand Down Expand Up @@ -63,9 +66,9 @@ const ConfigureSyncs = ({
};

const { data: catalogData } = useQuery({
queryKey: ['syncs', 'catalog', selectedDestination.id],
queryFn: () => getCatalog(selectedDestination.id),
enabled: !!selectedDestination.id,
queryKey: ['syncs', 'catalog', selectedDestination?.id],
queryFn: () => getCatalog(selectedDestination?.id),
enabled: !!selectedDestination?.id,
refetchOnMount: false,
refetchOnWindowFocus: false,
});
Expand Down
24 changes: 14 additions & 10 deletions ui/src/views/Activate/Syncs/SyncForm/ConfigureSyncs/MapFields.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -174,16 +174,20 @@ const MapFields = ({
isDisabled={!stream || isRequired}
selectedConfigOptions={configuration}
/>
{!isRequired && (
<Box py='20px' position='relative' top='12px' color='gray.600'>
<CloseButton
size='sm'
marginLeft='10px'
_hover={{ backgroundColor: 'none' }}
onClick={() => handleRemoveMap(index)}
/>
</Box>
)}
<Box
py='20px'
position='relative'
top='12px'
color='gray.600'
visibility={isRequired ? 'hidden' : 'visible'}
>
<CloseButton
size='sm'
marginLeft='10px'
_hover={{ backgroundColor: 'none' }}
onClick={() => handleRemoveMap(index)}
/>
</Box>
</Box>
))}
<Box>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ const TemplateMapping = ({
_placeholder={{ color: isDisabled ? 'black.500' : 'gray.600' }}
value={selectedConfig}
onClick={() => setIsPopOverOpen((prevState) => !prevState)}
autoComplete='off'
/>
</PopoverTrigger>
<PopoverContent>
Expand Down
4 changes: 4 additions & 0 deletions ui/src/views/Activate/Syncs/SyncForm/SyncForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ const SyncForm = (): JSX.Element => {
const [selectedStream, setSelectedStream] = useState<Stream | null>(null);
const [configuration, setConfiguration] = useState<FieldMapType[] | null>(null);
const [schemaMode, setSchemaMode] = useState<SchemaMode | null>(null);
const [selectedSyncMode, setSelectedSyncMode] = useState('');

const navigate = useNavigate();
const steps = [
{
Expand Down Expand Up @@ -42,9 +44,11 @@ const SyncForm = (): JSX.Element => {
selectedStream={selectedStream}
configuration={configuration}
schemaMode={schemaMode}
selectedSyncMode={selectedSyncMode}
setSelectedStream={setSelectedStream}
setConfiguration={setConfiguration}
setSchemaMode={setSchemaMode}
setSelectedSyncMode={setSelectedSyncMode}
/>
),
isRequireContinueCta: false,
Expand Down

0 comments on commit e3e71ff

Please sign in to comment.