-
Notifications
You must be signed in to change notification settings - Fork 14
roger - no ticket - Multiple file upload #428
base: master
Are you sure you want to change the base?
Conversation
Two things
|
} | ||
|
||
export interface IFileUploadState { | ||
height: number | undefined; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean optional instead of undefined?
case SET_INITIAL_HEIGHT_PLUS_VALUES: | ||
return { | ||
...state, | ||
height: undefined, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this just default height? Or don't set it at all?
so you mean to process files in parallel? |
Correct. No need to do step by step. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code quality
return { | ||
...value_, | ||
isSuccess: { | ||
...value_.isSuccess, | ||
value: false, | ||
}, | ||
isFailure: { | ||
...value_.isFailure, | ||
value: true, | ||
}, | ||
isUploading: { | ||
...value_.isUploading, | ||
value: false, | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Duplicate code with piece below abstract to function to reduce code duplicate. Use parameters for function to solve issue
...value_, | ||
isSuccess: { | ||
...value_.isSuccess, | ||
value: true, | ||
}, | ||
isFailure: { | ||
...value_.isFailure, | ||
value: false, | ||
}, | ||
isUploading: { | ||
...value_.isUploading, | ||
value: false, | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Duplicate as above
<IsFailureIsSuccessPanel | ||
message={failureMessage} | ||
iconColor={MainTheme.colors.statusColors.red} | ||
IconToShow={TimesCircle} | ||
transitionDuration={animationDuration} | ||
/> | ||
); | ||
} | ||
if (value.isSuccess.value) { | ||
return ( | ||
<IsFailureIsSuccessPanel | ||
message={successMessage} | ||
iconColor={MainTheme.colors.statusColors.green} | ||
IconToShow={CheckCircle} | ||
transitionDuration={animationDuration} | ||
/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use one Return Statement and just edit the Props Object since duplicate JSX
opacity={ | ||
value.isUploading.opacity || | ||
value.isSuccess.opacity || | ||
value.isFailure.opacity | ||
} | ||
position={ | ||
value.isUploading.isPosition && | ||
value.isFailure.isPosition && | ||
value.isSuccess.isPosition | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do
Const {isFailure, IsSuccees} = value
So we don't right value. 100 times
src/Containers/FileUpload/reducer.ts
Outdated
if(index===action.index)return false | ||
return true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove duplicate code @roggc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also why not
return A == B
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is A!==B, because I want all elements except the one for which A===B
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More code quality
@@ -1,16 +1,16 @@ | |||
import React, { useState, useEffect } from 'react'; | |||
import { TextLayout } from '@Layouts'; | |||
import { StyledIcon } from '@styled-icons/styled-icon'; | |||
import { Container, Icon } from './StyledComponents'; | |||
import { Container, Icon, IContainerProps } from './StyledComponents'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this component have its own story? Where is it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no, I don't have a story for this styled component
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a story for this component
doWithBase64StringFile(base64StringFile); | ||
setInformativePanelsState((prev) => ({ | ||
...prev, | ||
values: prev.values.map((value_) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
value_ is an unclear name
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's because there exists already a value in scope. both value and value_ are of the same type (IValue)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So is one the previous value? And old value. Etc
if(value_.name===value.name)return false | ||
return true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Return A == B?
Or !(A == B)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure
ref={loadingContainerRef} | ||
overflow="hidden" | ||
width={ | ||
value.isFailure.value || value.isSuccess.value |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code is duplicated in the next few lines why not make a function called
IsSuccessOrError?
@@ -19,6 +20,8 @@ export interface IContainerProps { | |||
margin?: string; | |||
positionTop?: number; | |||
flexGrow?: boolean; | |||
/** transition duration in ms; applied on height and opacity properties; */ | |||
transitionDuration:number; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Transition of what duration??
/** if true, failure message will appear even after success operation; its purpose is to test the appearance of the failure message during development */ | ||
isTestIsFailure?: boolean; | ||
/** height and fade in-fade out animation duration in ms; default value: 200 */ | ||
animationDuration?: number; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Animation fo what duration?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<FileUpload
animationDuration - Affect The Secondary Componet that Appears when you upload a file.
/>
<FileUpload
onUploadShowComponent - {JSX.Element} It's own Animation
/>
if (isFailureIsSuccessPanelProps) { | ||
return ( | ||
<IsFailureIsSuccessPanel | ||
{...isFailureIsSuccessPanelProps} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does ...null work?
[], | ||
); | ||
|
||
/** cancel uploading; terminate worker and remove informative panel */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use JSDOC format
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is jsdoc
/** if true, failure message will appear even after success operation; its purpose is to test the appearance of the failure message during development */ | ||
isTestIsFailure?: boolean; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should not be needed.
/** | ||
* load array of informative panels (values) and send order to start workers | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JSDOC missing Doc for Paramters / Return Type
/** | ||
* terminate worker and set state of informative panel to success or failure and | ||
* send order to remove informative panel in the future. also do whatever user | ||
* wants to do with the file read in case of success | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing paramter / return
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Incorrect
@ralph-dev, what is incorrect? |
Create a NeW PR should be doing two work in same PR |
but it is related work |
It is very difficult to review 15 files everytime when you are only changing a few. It's different work. One is modifying the existing, one is creating a new component entirely |
Let's close this PR if we don't need it @roggc |
multiple file upload in parallel