Merge pull request #125 from ente-io/first-upload-ux

dont show collection namer if not neccessary
This commit is contained in:
Abhinav-grd 2021-08-28 20:21:02 +05:30 committed by GitHub
commit 7e921b85db
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 35 additions and 19 deletions

View file

@ -18,7 +18,7 @@ export const CollectionIcon = styled.div`
export interface CollectionSelectorAttributes { export interface CollectionSelectorAttributes {
callback: (collection) => void; callback: (collection) => void;
showNextModal: () => void; showNextModal: (firstAlbum?: boolean) => void;
title: string; title: string;
} }
export type SetCollectionSelectorAttributes = React.Dispatch< export type SetCollectionSelectorAttributes = React.Dispatch<
@ -47,7 +47,7 @@ function CollectionSelector({
useEffect(() => { useEffect(() => {
if (directlyShowNextModal && attributes) { if (directlyShowNextModal && attributes) {
props.onHide(); props.onHide();
attributes.showNextModal(); attributes.showNextModal(true);
} }
}, [attributes]); }, [attributes]);

View file

@ -23,6 +23,8 @@ import UploadManager, {
import uploadManager from 'services/upload/uploadManager'; import uploadManager from 'services/upload/uploadManager';
import { METADATA_FOLDER_NAME } from 'services/exportService'; import { METADATA_FOLDER_NAME } from 'services/exportService';
const FIRST_ALBUM_NAME = 'my first album';
interface Props { interface Props {
syncWithRemote: (force?: boolean, silent?: boolean) => Promise<void>; syncWithRemote: (force?: boolean, silent?: boolean) => Promise<void>;
setBannerMessage; setBannerMessage;
@ -93,7 +95,7 @@ export default function Upload(props: Props) {
) { ) {
props.setLoading(true); props.setLoading(true);
let fileAnalysisResult; let fileAnalysisResult: AnalysisResult;
if (props.acceptedFiles?.length > 0) { if (props.acceptedFiles?.length > 0) {
// File selection by drag and drop or selection of file. // File selection by drag and drop or selection of file.
fileAnalysisResult = analyseUploadFiles(); fileAnalysisResult = analyseUploadFiles();
@ -106,7 +108,7 @@ export default function Upload(props: Props) {
props.setCollectionSelectorAttributes({ props.setCollectionSelectorAttributes({
callback: uploadFilesToExistingCollection, callback: uploadFilesToExistingCollection,
showNextModal: nextModal.bind(null, fileAnalysisResult), showNextModal: nextModal.bind(null, fileAnalysisResult),
title: 'upload to collection', title: constants.UPLOAD_TO_COLLECTION,
}); });
props.setLoading(false); props.setLoading(false);
} }
@ -120,25 +122,38 @@ export default function Upload(props: Props) {
setPercentComplete(0); setPercentComplete(0);
setProgressView(true); setProgressView(true);
}; };
const showCreateCollectionModal = (fileAnalysisResult?: AnalysisResult) => { const showCreateCollectionModal = (
props.setCollectionNamerAttributes({ fileAnalysisResult: AnalysisResult,
title: constants.CREATE_COLLECTION, isFirstAlbum?: boolean
buttonText: constants.CREATE, ) => {
autoFilledName: fileAnalysisResult?.suggestedCollectionName, const uploadToNewCollection = async (collectionName: string) => {
callback: async (collectionName) => {
props.closeCollectionSelector(); props.closeCollectionSelector();
await uploadFilesToNewCollections( await uploadFilesToNewCollections(
UPLOAD_STRATEGY.SINGLE_COLLECTION, UPLOAD_STRATEGY.SINGLE_COLLECTION,
collectionName collectionName
); );
}, };
if (fileAnalysisResult.suggestedCollectionName) {
uploadToNewCollection(fileAnalysisResult.suggestedCollectionName);
} else if (isFirstAlbum) {
uploadToNewCollection(FIRST_ALBUM_NAME);
} else {
props.setCollectionNamerAttributes({
title: constants.CREATE_COLLECTION,
buttonText: constants.CREATE,
autoFilledName: fileAnalysisResult?.suggestedCollectionName,
callback: uploadToNewCollection,
}); });
}
}; };
const nextModal = (fileAnalysisResult: AnalysisResult) => { const nextModal = (
fileAnalysisResult: AnalysisResult,
isFirstAlbum: boolean
) => {
fileAnalysisResult?.multipleFolders fileAnalysisResult?.multipleFolders
? setChoiceModalView(true) ? setChoiceModalView(true)
: showCreateCollectionModal(fileAnalysisResult); : showCreateCollectionModal(fileAnalysisResult, isFirstAlbum);
}; };
function analyseUploadFiles(): AnalysisResult { function analyseUploadFiles(): AnalysisResult {

View file

@ -518,6 +518,7 @@ const englishConstants = {
INPROGRESS_UPLOADS: 'uploads in progress', INPROGRESS_UPLOADS: 'uploads in progress',
FILE_TOO_LARGE: FILE_TOO_LARGE:
'the file you are trying to upload is larger than the storage available, please upgrade your plan and try again', 'the file you are trying to upload is larger than the storage available, please upgrade your plan and try again',
UPLOAD_TO_COLLECTION: 'upload to collection',
}; };
export default englishConstants; export default englishConstants;