-
Notifications
You must be signed in to change notification settings - Fork 397
Changes for skip/overwrite files in filebrowser #4143
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
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.
Good work!
Please check the comments below.
onCancel={() => setIsModalVisible(false)} | ||
secondaryButtonText={t('Skip Upload')} | ||
onSecondary={() => handleModalOk(false)} | ||
className="hue-modal" |
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.
Give the className more specificity; otherwise, it might create a conflict in the future and can result in unpredictable CSS changes.
const [conflictFiles, setConflictFiles] = useState<RegularFile[]>([]); | ||
const [isModalVisible, setIsModalVisible] = useState<boolean>(false); | ||
|
||
const checkFileExists = async (filePath: string): Promise<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.
Add a todo note to change this function with a new endpoint.
} | ||
return false; | ||
} | ||
}; | ||
const onComplete = () => { | ||
huePubSub.publish(FILE_UPLOAD_SUCCESS_EVENT); | ||
}; |
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.
Have blank lines after the function definitions. or logical block of code.
Please revert all the removal of blank lines in the code.
addFiles(data.files); | ||
callback: async (data?: FileUploadEvent) => { | ||
if ((data?.files ?? []).length > 0) { | ||
const newFiles = data?.files ?? []; |
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.
const newFiles = data.files;
As we are already checking the condition, a line above.
const [expandQueue, setExpandQueue] = useState<boolean>(true); | ||
const [isVisible, setIsVisible] = useState<boolean>(false); | ||
|
||
const [conflictFiles, setConflictFiles] = useState<RegularFile[]>([]); |
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.
[conflictingFiles, setConflictingFiles]
data={row} | ||
onCancel={() => cancelFile(row)} | ||
/> | ||
<> |
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.
Break this return into two parts,
- showing the modal, when
conflictingFiles.length !== 0
- showing the queue when
isVisible === true
@@ -87,6 +92,7 @@ export const getChunkItemPayload = (chunkItem: ChunkedFile): FileUploadApiPayloa | |||
|
|||
const payload = new FormData(); | |||
payload.append('hdfs_file', chunkItem.file); | |||
payload.append('overwrite', chunkItem.overwrite ? 'true' : 'false'); // Pass overwrite flag |
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 comment is self-explanatory. Can be removed.
@@ -45,7 +45,7 @@ import { | |||
import { GET_TASKS_URL } from 'reactComponents/TaskServer/constants'; | |||
|
|||
interface UseChunkUploadResponse { | |||
addFiles: (item: RegularFile[]) => void; | |||
addFiles: (items: RegularFile[], overwrite?: boolean) => void; |
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.
Once you set the overwrite flag in the items themselves, then this argument will not be required.
Same for other places too.
|
||
const handleModalOk = (overwrite: boolean) => { | ||
if (overwrite) { | ||
addFiles(conflictFiles, 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.
Instead of sending true as another argument, can we set the overwrite true in each file itself?
addToRegularUpload(fileItems); | ||
} | ||
files.forEach(file => { | ||
const existingFileIndex = updatedQueue.findIndex( |
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 check is already in place in FileUploadQueue
, hence it can be removed.
This function should be generic; it should take what comes in as an argument and send it to the appropriate queue.
What changes were proposed in this pull request?
How was this patch tested?
Please review Hue Contributing Guide before opening a pull request.