Improve csv import (#5753)

This is a small PR to improve the design of our CSV import.

I noticed the back button that was implemented in a recent PR #5625 was
broken and would need to be fixed (e.g. try to come back to the very
first upload step from the sheet selection step). cc @shashankvish0010
if you want to give a stab at fixing your PR that'd be amazing, thanks!
This commit is contained in:
Félix Malfait
2024-06-05 17:01:13 +02:00
committed by GitHub
parent e9d3ed99ca
commit 89f914ebf8
6 changed files with 29 additions and 21 deletions

View File

@ -3,35 +3,40 @@ import styled from '@emotion/styled';
import { CircularProgressBar } from '@/ui/feedback/progress-bar/components/CircularProgressBar'; import { CircularProgressBar } from '@/ui/feedback/progress-bar/components/CircularProgressBar';
import { MainButton } from '@/ui/input/button/components/MainButton'; import { MainButton } from '@/ui/input/button/components/MainButton';
import { Modal } from '@/ui/layout/modal/components/Modal'; import { Modal } from '@/ui/layout/modal/components/Modal';
import { isUndefinedOrNull } from '~/utils/isUndefinedOrNull';
const StyledFooter = styled(Modal.Footer)` const StyledFooter = styled(Modal.Footer)`
height: 60px; gap: ${({ theme }) => theme.spacing(2)};
justify-content: center; justify-content: space-between;
padding: 0px;
padding-left: ${({ theme }) => theme.spacing(30)};
padding-right: ${({ theme }) => theme.spacing(30)};
`;
const StyledButton = styled(MainButton)`
width: 200px;
`; `;
type StepNavigationButtonProps = { type StepNavigationButtonProps = {
onClick: () => void; onClick: () => void;
title: string; title: string;
isLoading?: boolean; isLoading?: boolean;
onBack?: () => void;
}; };
export const StepNavigationButton = ({ export const StepNavigationButton = ({
onClick, onClick,
title, title,
isLoading, isLoading,
onBack,
}: StepNavigationButtonProps) => ( }: StepNavigationButtonProps) => (
<StyledFooter> <StyledFooter>
<StyledButton {!isUndefinedOrNull(onBack) && (
<MainButton
Icon={isLoading ? CircularProgressBar : undefined}
title="Back"
onClick={!isLoading ? onBack : undefined}
variant="secondary"
/>
)}
<MainButton
Icon={isLoading ? CircularProgressBar : undefined} Icon={isLoading ? CircularProgressBar : undefined}
title={title} title={title}
onClick={!isLoading ? onClick : undefined} onClick={!isLoading ? onClick : undefined}
variant="primary"
/> />
</StyledFooter> </StyledFooter>
); );

View File

@ -287,11 +287,11 @@ export const MatchColumnsStep = <T extends string>({
/> />
</StyledContent> </StyledContent>
<StepNavigationButton <StepNavigationButton
onBack={onBack}
onClick={handleOnContinue} onClick={handleOnContinue}
isLoading={isLoading} isLoading={isLoading}
title="Next" title="Continue"
/> />
<StepNavigationButton onClick={onBack} title="Back" />
</> </>
); );
}; };

View File

@ -57,10 +57,10 @@ export const SelectHeaderStep = ({
</Modal.Content> </Modal.Content>
<StepNavigationButton <StepNavigationButton
onClick={handleContinue} onClick={handleContinue}
title="Next" onBack={onBack}
title="Continue"
isLoading={isLoading} isLoading={isLoading}
/> />
<StepNavigationButton onClick={onBack} title="Back" />
</> </>
); );
}; };

View File

@ -55,17 +55,17 @@ export const SelectSheetStep = ({
<StyledRadioContainer> <StyledRadioContainer>
<RadioGroup onValueChange={(value) => setValue(value)} value={value}> <RadioGroup onValueChange={(value) => setValue(value)} value={value}>
{sheetNames.map((sheetName) => ( {sheetNames.map((sheetName) => (
<Radio value={sheetName} key={sheetName} /> <Radio value={sheetName} key={sheetName} label={sheetName} />
))} ))}
</RadioGroup> </RadioGroup>
</StyledRadioContainer> </StyledRadioContainer>
</StyledContent> </StyledContent>
<StepNavigationButton <StepNavigationButton
onClick={() => handleOnContinue(value)} onClick={() => handleOnContinue(value)}
onBack={onBack}
isLoading={isLoading} isLoading={isLoading}
title="Next" title="Continue"
/> />
<StepNavigationButton onClick={onBack} title="Back" />
</> </>
); );
}; };

View File

@ -240,8 +240,11 @@ export const ValidationStep = <T extends string>({
/> />
</StyledScrollContainer> </StyledScrollContainer>
</StyledContent> </StyledContent>
<StepNavigationButton onClick={onContinue} title="Confirm" /> <StepNavigationButton
<StepNavigationButton onClick={onBack} title="Back" /> onClick={onContinue}
onBack={onBack}
title="Confirm"
/>
</> </>
); );
}; };

View File

@ -3,13 +3,13 @@ import { useTheme } from '@emotion/react';
import styled from '@emotion/styled'; import styled from '@emotion/styled';
import { IconComponent } from 'twenty-ui'; import { IconComponent } from 'twenty-ui';
type Variant = 'primary' | 'secondary'; export type MainButtonVariant = 'primary' | 'secondary';
type Props = { type Props = {
title: string; title: string;
fullWidth?: boolean; fullWidth?: boolean;
width?: number; width?: number;
variant?: Variant; variant?: MainButtonVariant;
soon?: boolean; soon?: boolean;
} & React.ComponentProps<'button'>; } & React.ComponentProps<'button'>;