Skip to content

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

Draft
wants to merge 15 commits into
base: master
Choose a base branch
from
Draft

Conversation

sanyam43
Copy link
Collaborator

What changes were proposed in this pull request?

  • (Please fill in changes proposed in this fix)

How was this patch tested?

  • (Please explain how this patch was tested. Ex: unit tests, manual tests)
  • (If this patch involves UI changes, please attach a screen-shot; otherwise, remove this)

Please review Hue Contributing Guide before opening a pull request.

@sanyam43 sanyam43 marked this pull request as draft May 19, 2025 12:05
Copy link

github-actions bot commented May 19, 2025

⚠️ No test files modified. Please ensure that changes are properly tested. ⚠️

Copy link

github-actions bot commented May 19, 2025

Python Code Coverage

Python Coverage Report •
FileStmtsMissCoverMissing
TOTAL541852707850% 
report-only-changed-files is enabled. No files were changed during this commit :)

Pytest Report

Tests Skipped Failures Errors Time
1186 106 💤 0 ❌ 0 🔥 5m 58s ⏱️

@sanyam43 sanyam43 requested a review from ramprasadagarwal May 30, 2025 11:34
Copy link

github-actions bot commented Jun 9, 2025

UI Coverage Report

Lines Statements Branches Functions
Coverage: 32%
39.15% (30527/77959) 31.01% (14247/45936) 23.89% (2130/8915)

Copy link

github-actions bot commented Jun 9, 2025

Python Code Coverage

Python Coverage Report •
FileStmtsMissCoverMissing
TOTAL541852707850% 
report-only-changed-files is enabled. No files were changed during this commit :)

Pytest Report

Tests Skipped Failures Errors Time
1186 106 💤 0 ❌ 0 🔥 5m 58s ⏱️

Copy link
Collaborator

@ramprasadagarwal ramprasadagarwal left a 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"
Copy link
Collaborator

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> => {
Copy link
Collaborator

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);
};
Copy link
Collaborator

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 ?? [];
Copy link
Collaborator

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[]>([]);
Copy link
Collaborator

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)}
/>
<>
Copy link
Collaborator

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,

  1. showing the modal, when conflictingFiles.length !== 0
  2. 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
Copy link
Collaborator

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;
Copy link
Collaborator

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);
Copy link
Collaborator

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(
Copy link
Collaborator

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants