Merge pull request #634 from ente-io/upload-choice-screen

Upload type choice screen
This commit is contained in:
Manav 2022-07-05 20:03:14 +05:30 committed by GitHub
commit d89dd46228
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 74 additions and 96 deletions

View file

@ -1,6 +1,10 @@
import React from 'react'; import React from 'react';
import { Box, DialogTitle, IconButton, Stack, Typography } from '@mui/material'; import { Box, DialogTitle, Stack, Typography } from '@mui/material';
import { FlexWrapper, FluidContainer } from 'components/Container'; import {
FlexWrapper,
FluidContainer,
IconButtonWithBG,
} from 'components/Container';
import CollectionSort from 'components/Collections/AllCollections/CollectionSort'; import CollectionSort from 'components/Collections/AllCollections/CollectionSort';
import constants from 'utils/strings/constants'; import constants from 'utils/strings/constants';
import Close from '@mui/icons-material/Close'; import Close from '@mui/icons-material/Close';
@ -29,13 +33,9 @@ export default function AllCollectionsHeader({
activeSortBy={collectionSortBy} activeSortBy={collectionSortBy}
setCollectionSortBy={setCollectionSortBy} setCollectionSortBy={setCollectionSortBy}
/> />
<IconButton <IconButtonWithBG onClick={onClose}>
onClick={onClose}
sx={{
background: (theme) => theme.palette.fill.dark,
}}>
<Close /> <Close />
</IconButton> </IconButtonWithBG>
</Stack> </Stack>
</FlexWrapper> </FlexWrapper>
</DialogTitle> </DialogTitle>

View file

@ -11,7 +11,7 @@ import {
import CollectionListBarCard from 'components/Collections/CollectionListBar/CollectionCard'; import CollectionListBarCard from 'components/Collections/CollectionListBar/CollectionCard';
import useComponentScroll, { SCROLL_DIRECTION } from 'hooks/useComponentScroll'; import useComponentScroll, { SCROLL_DIRECTION } from 'hooks/useComponentScroll';
import useWindowSize from 'hooks/useWindowSize'; import useWindowSize from 'hooks/useWindowSize';
import { SpaceBetweenFlex } from 'components/Container'; import { IconButtonWithBG, SpaceBetweenFlex } from 'components/Container';
import ExpandMore from '@mui/icons-material/ExpandMore'; import ExpandMore from '@mui/icons-material/ExpandMore';
import { AppContext } from 'pages/_app'; import { AppContext } from 'pages/_app';
import { CollectionSummary } from 'types/collection'; import { CollectionSummary } from 'types/collection';
@ -114,13 +114,9 @@ export default function CollectionListBar(props: IProps) {
setCollectionSortBy={props.setCollectionSortBy} setCollectionSortBy={props.setCollectionSortBy}
activeSortBy={props.collectionSortBy} activeSortBy={props.collectionSortBy}
/> />
<IconButton <IconButtonWithBG onClick={showAllCollections}>
onClick={showAllCollections}
sx={{
background: (theme) => theme.palette.fill.dark,
}}>
<ExpandMore /> <ExpandMore />
</IconButton> </IconButtonWithBG>
</Box> </Box>
)} )}
</Box> </Box>

View file

@ -1,4 +1,4 @@
import { Box } from '@mui/material'; import { Box, IconButton } from '@mui/material';
import { styled } from '@mui/material'; import { styled } from '@mui/material';
const VerticallyCentered = styled(Box)` const VerticallyCentered = styled(Box)`
@ -69,3 +69,7 @@ export const Overlay = styled(Box)`
top: 0; top: 0;
left: 0; left: 0;
`; `;
export const IconButtonWithBG = styled(IconButton)(({ theme }) => ({
backgroundColor: theme.palette.fill.dark,
}));

View file

@ -21,7 +21,8 @@ const DialogTitleWithCloseButton = (props) => {
<IconButton <IconButton
aria-label="close" aria-label="close"
onClick={onClose} onClick={onClose}
sx={{ float: 'right' }}> sx={{ float: 'right' }}
color="secondary">
<CloseIcon /> <CloseIcon />
</IconButton> </IconButton>
)} )}

View file

@ -1,24 +1,13 @@
import React, { useContext } from 'react'; import React, { useContext } from 'react';
import Close from '@mui/icons-material/Close'; import Close from '@mui/icons-material/Close';
import { import { DialogTitle, Box, Typography, Stack } from '@mui/material';
DialogTitle, import { IconButtonWithBG, SpaceBetweenFlex } from 'components/Container';
Box,
Typography,
IconButton,
styled,
Stack,
} from '@mui/material';
import { SpaceBetweenFlex } from 'components/Container';
import { UPLOAD_STAGES } from 'constants/upload'; import { UPLOAD_STAGES } from 'constants/upload';
import constants from 'utils/strings/constants'; import constants from 'utils/strings/constants';
import UploadProgressContext from 'contexts/uploadProgress'; import UploadProgressContext from 'contexts/uploadProgress';
import UnfoldLessIcon from '@mui/icons-material/UnfoldLess'; import UnfoldLessIcon from '@mui/icons-material/UnfoldLess';
import UnfoldMoreIcon from '@mui/icons-material/UnfoldMore'; import UnfoldMoreIcon from '@mui/icons-material/UnfoldMore';
const IconButtonWithBG = styled(IconButton)(({ theme }) => ({
backgroundColor: theme.palette.secondary.main,
}));
const UploadProgressTitleText = ({ expanded }) => ( const UploadProgressTitleText = ({ expanded }) => (
<Typography variant={expanded ? 'title' : 'subtitle'}> <Typography variant={expanded ? 'title' : 'subtitle'}>
{constants.FILE_UPLOAD} {constants.FILE_UPLOAD}

View file

@ -5,7 +5,7 @@ import { default as FolderUploadIcon } from '@mui/icons-material/PermMediaOutlin
import GoogleIcon from '@mui/icons-material/Google'; import GoogleIcon from '@mui/icons-material/Google';
import { UploadTypeOption } from './option'; import { UploadTypeOption } from './option';
import DialogTitleWithCloseButton from 'components/DialogBox/TitleWithCloseButton'; import DialogTitleWithCloseButton from 'components/DialogBox/TitleWithCloseButton';
import { Dialog, DialogContent, Stack } from '@mui/material'; import { Box, Dialog, Stack, Typography } from '@mui/material';
export default function UploadTypeSelector({ export default function UploadTypeSelector({
onHide, onHide,
@ -17,30 +17,39 @@ export default function UploadTypeSelector({
return ( return (
<Dialog <Dialog
open={show} open={show}
PaperProps={{ sx: { maxWidth: '375px' } }} PaperProps={{
sx: (theme) => ({
maxWidth: '375px',
p: 1,
[theme.breakpoints.down(360)]: { p: 0 },
}),
}}
onClose={onHide}> onClose={onHide}>
<DialogTitleWithCloseButton onClose={onHide}> <DialogTitleWithCloseButton onClose={onHide}>
{constants.UPLOAD} {constants.UPLOAD}
</DialogTitleWithCloseButton> </DialogTitleWithCloseButton>
<DialogContent sx={{ '&&&&': { pt: 0 } }}> <Box p={1.5} pt={0.5}>
<Stack spacing={1}> <Stack spacing={0.5}>
<UploadTypeOption <UploadTypeOption
uploadFunc={uploadFiles} onClick={uploadFiles}
Icon={FileUploadIcon} startIcon={<FileUploadIcon />}>
uploadName={constants.UPLOAD_FILES} {constants.UPLOAD_FILES}
/> </UploadTypeOption>
<UploadTypeOption <UploadTypeOption
uploadFunc={uploadFolders} onClick={uploadFolders}
Icon={FolderUploadIcon} startIcon={<FolderUploadIcon />}>
uploadName={constants.UPLOAD_DIRS} {constants.UPLOAD_DIRS}
/> </UploadTypeOption>
<UploadTypeOption <UploadTypeOption
uploadFunc={uploadGoogleTakeoutZips} onClick={uploadGoogleTakeoutZips}
Icon={GoogleIcon} startIcon={<GoogleIcon />}>
uploadName={constants.UPLOAD_GOOGLE_TAKEOUT} {constants.UPLOAD_GOOGLE_TAKEOUT}
/> </UploadTypeOption>
</Stack> </Stack>
</DialogContent> <Typography p={1.5} pt={4} color="text.secondary">
{constants.DRAG_AND_DROP_HINT}
</Typography>
</Box>
</Dialog> </Dialog>
); );
} }

View file

@ -1,15 +1,18 @@
import React from 'react'; import React from 'react';
import { Button } from '@mui/material'; import { Button, ButtonProps } from '@mui/material';
import ChevronRight from '@mui/icons-material/ChevronRight';
import { FluidContainer } from 'components/Container';
export function UploadTypeOption({ uploadFunc, Icon, uploadName }) { type Iprops = ButtonProps<'button'>;
export function UploadTypeOption({ children, ...props }: Iprops) {
return ( return (
<Button <Button
size="large" size="large"
sx={{ justifyContent: 'flex-start' }}
onClick={uploadFunc}
color="secondary" color="secondary"
startIcon={<Icon />}> endIcon={<ChevronRight />}
{uploadName} {...props}>
<FluidContainer>{children}</FluidContainer>
</Button> </Button>
); );
} }

View file

@ -22,7 +22,7 @@ export default function PaidSubscriptionPlanSelectorCard({
}) { }) {
return ( return (
<> <>
<Box px={1.5} py={0.5}> <Box pl={1.5} py={0.5}>
<SpaceBetweenFlex> <SpaceBetweenFlex>
<Box> <Box>
<Typography variant="h3" fontWeight={'bold'}> <Typography variant="h3" fontWeight={'bold'}>
@ -33,7 +33,7 @@ export default function PaidSubscriptionPlanSelectorCard({
{constants.GB} {constants.GB}
</Typography> </Typography>
</Box> </Box>
<IconButton onClick={closeModal}> <IconButton onClick={closeModal} color="secondary">
<Close /> <Close />
</IconButton> </IconButton>
</SpaceBetweenFlex> </SpaceBetweenFlex>

View file

@ -4,13 +4,7 @@ import { FluidContainer } from 'components/Container';
import React from 'react'; import React from 'react';
const ManageSubscriptionButton = ({ children, ...props }: ButtonProps) => ( const ManageSubscriptionButton = ({ children, ...props }: ButtonProps) => (
<Button <Button size="large" endIcon={<ChevronRight />} {...props}>
{...props}
endIcon={<ChevronRight />}
sx={{
...props.sx,
justifyContent: 'flex-start',
}}>
<FluidContainer>{children}</FluidContainer> <FluidContainer>{children}</FluidContainer>
</Button> </Button>
); );

View file

@ -7,7 +7,6 @@ import {
cancelSubscription, cancelSubscription,
updatePaymentMethod, updatePaymentMethod,
manageFamilyMethod, manageFamilyMethod,
hasPaidSubscription,
hasStripeSubscription, hasStripeSubscription,
isSubscriptionCancelled, isSubscriptionCancelled,
} from 'utils/billing'; } from 'utils/billing';
@ -24,15 +23,24 @@ export function ManageSubscription({
closeModal, closeModal,
setLoading, setLoading,
}: Iprops) { }: Iprops) {
const appContext = useContext(AppContext);
const openFamilyPortal = () =>
manageFamilyMethod(appContext.setDialogMessage, setLoading);
return ( return (
<Stack spacing={1}> <Stack spacing={1}>
{hasPaidSubscription(subscription) && ( {hasStripeSubscription(subscription) && (
<PaidSubscriptionOptions <StripeSubscriptionOptions
subscription={subscription} subscription={subscription}
setLoading={setLoading}
closeModal={closeModal} closeModal={closeModal}
setLoading={setLoading}
/> />
)} )}
<ManageSubscriptionButton
color="secondary"
onClick={openFamilyPortal}>
{constants.MANAGE_FAMILY_PORTAL}
</ManageSubscriptionButton>
</Stack> </Stack>
); );
} }
@ -110,30 +118,3 @@ function StripeSubscriptionOptions({
</> </>
); );
} }
function PaidSubscriptionOptions({
subscription,
setLoading,
closeModal,
}: Iprops) {
const appContext = useContext(AppContext);
const openFamilyPortal = () =>
manageFamilyMethod(appContext.setDialogMessage, setLoading);
return (
<>
{hasStripeSubscription(subscription) && (
<StripeSubscriptionOptions
subscription={subscription}
closeModal={closeModal}
setLoading={setLoading}
/>
)}
<ManageSubscriptionButton
color="secondary"
onClick={openFamilyPortal}>
{constants.MANAGE_FAMILY_PORTAL}
</ManageSubscriptionButton>
</>
);
}

View file

@ -700,9 +700,9 @@ const englishConstants = {
LOCK: 'Lock', LOCK: 'Lock',
DOWNLOAD_UPLOAD_LOGS: 'Debug logs', DOWNLOAD_UPLOAD_LOGS: 'Debug logs',
CHOOSE_UPLOAD_TYPE: 'Upload', CHOOSE_UPLOAD_TYPE: 'Upload',
UPLOAD_FILES: 'File Upload', UPLOAD_FILES: 'File',
UPLOAD_DIRS: 'Folder Upload', UPLOAD_DIRS: 'Folder',
UPLOAD_GOOGLE_TAKEOUT: 'Google Takeout', UPLOAD_GOOGLE_TAKEOUT: 'Google takeout',
CANCEL_UPLOADS: 'Cancel uploads', CANCEL_UPLOADS: 'Cancel uploads',
DEDUPLICATE_FILES: 'Deduplicate files', DEDUPLICATE_FILES: 'Deduplicate files',
NO_DUPLICATES_FOUND: "You've no duplicate files that can be cleared", NO_DUPLICATES_FOUND: "You've no duplicate files that can be cleared",
@ -778,6 +778,7 @@ const englishConstants = {
), ),
WEAK_DEVICE: WEAK_DEVICE:
"The web browser you're using is not powerful enough to encrypt your photos. Please try to log in to ente on your computer, or download the ente mobile/desktop app.", "The web browser you're using is not powerful enough to encrypt your photos. Please try to log in to ente on your computer, or download the ente mobile/desktop app.",
DRAG_AND_DROP_HINT: 'Or drag and drop into the ente window',
}; };
export default englishConstants; export default englishConstants;