-
Notifications
You must be signed in to change notification settings - Fork 523
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
Update Sample File Upload and upgrade buttons to Shadcn button #9157
Merged
rithviknishad
merged 29 commits into
ohcnetwork:develop
from
nithish1018:issues/9153/addclearimage
Dec 3, 2024
Merged
Changes from 3 commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
8448989
Added Clear Image functionality
nithish1018 662f437
removed unneccessary line
nithish1018 cef5438
Added bot suggestions
nithish1018 ec36ef5
Merge branch 'develop' into issues/9153/addclearimage
nithish1018 a7043f6
Merge branch 'develop' into issues/9153/addclearimage
nithish1018 a341da1
Fixed search icon overlay
nithish1018 5403593
removing unrelated change
nithish1018 9d3de71
Updated file upload with useFileUpload hook
nithish1018 bae2649
Merge branch 'develop' into issues/9153/addclearimage
nithish1018 52100c4
Merge branch 'develop' into issues/9153/addclearimage
nithish1018 18ad9b5
Added types for sample
nithish1018 180fa67
Merge branch 'develop' into issues/9153/addclearimage
shivankacker ceba9fb
\Merge branch 'develop' into issues/9153/addclearimage
nithish1018 c972c5b
Merge branch 'develop' into issues/9153/addclearimage
nithish1018 5489cb6
Merge branch 'develop' into issues/9153/addclearimage
nithish1018 3c6eb0e
Updated the file upload UI
nithish1018 b48a7e3
Merge branch 'develop' into issues/9153/addclearimage
nithish1018 3801776
Updated Button to shadcn button
nithish1018 6e180b3
removed unnecessary line
nithish1018 4598c0c
Merge branch 'develop' into issues/9153/addclearimage
nithish1018 28ccbc4
Merge branch 'develop' into issues/9153/addclearimage
nithish1018 fd0bf27
removed remove icon in favour of discard button
nithish1018 e86f229
Merge branch 'develop' into issues/9153/addclearimage
nithish1018 66cf623
updated primary button color
nithish1018 48a604f
Merge branch 'develop' into issues/9153/addclearimage
nithish1018 37cfc0e
fixed eslint issues
nithish1018 76ebf4f
Merge branch 'develop' into issues/9153/addclearimage
nithish1018 0af4cf0
Merge branch 'develop' into issues/9153/addclearimage
nithish1018 cd09c74
removed button array
nithish1018 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -69,7 +69,6 @@ const UpdateStatusDialog = (props: Props) => { | |
const [contentType, setcontentType] = useState<string>(""); | ||
const [uploadPercent, setUploadPercent] = useState(0); | ||
const [uploadStarted, setUploadStarted] = useState<boolean>(false); | ||
const [uploadDone, setUploadDone] = useState<boolean>(false); | ||
|
||
const currentStatus = SAMPLE_TEST_STATUS.find( | ||
(i) => i.text === sample.status, | ||
|
@@ -123,7 +122,6 @@ const UpdateStatusDialog = (props: Props) => { | |
(xhr: XMLHttpRequest) => { | ||
if (xhr.status >= 200 && xhr.status < 300) { | ||
setUploadStarted(false); | ||
setUploadDone(true); | ||
request(routes.editUpload, { | ||
pathParams: { | ||
id: data.id, | ||
|
@@ -156,13 +154,15 @@ const UpdateStatusDialog = (props: Props) => { | |
); | ||
return e.target.files[0]; | ||
}; | ||
const removeFile = () => { | ||
setfile(undefined); | ||
}; | ||
const handleUpload = async () => { | ||
const f = file; | ||
if (f === undefined) return; | ||
const category = "UNSPECIFIED"; | ||
const name = f.name; | ||
setUploadStarted(true); | ||
setUploadDone(false); | ||
|
||
const { data } = await request(routes.createUpload, { | ||
body: { | ||
|
@@ -236,11 +236,14 @@ const UpdateStatusDialog = (props: Props) => { | |
hidden | ||
/> | ||
</label> | ||
<Submit | ||
type="submit" | ||
onClick={handleUpload} | ||
disabled={uploadDone} | ||
> | ||
{file && ( | ||
<CareIcon | ||
icon="l-times" | ||
className="text-lg cursor-pointer mt-2 mr-4" | ||
onClick={removeFile} | ||
/> | ||
)} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Enhance accessibility for the clear file button The clear file icon button needs accessibility improvements to help screen reader users understand its purpose. {file && (
<CareIcon
icon="l-times"
className="text-lg cursor-pointer mt-2 mr-4"
onClick={removeFile}
+ role="button"
+ aria-label={t("clear_file")}
+ title={t("clear_file")}
/>
)}
|
||
<Submit type="submit" onClick={handleUpload} disabled={!file}> | ||
<CareIcon icon="l-cloud-upload" className="text-lg" /> | ||
<span>Upload</span> | ||
</Submit> | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
💡 Codebase verification
🛠️ Refactor suggestion
Add upload state check to prevent file removal during upload
The verification reveals that
uploadStarted
state is properly managed in the component and is used during file uploads. However, theremoveFile
function currently lacks this check, which could lead to inconsistent state if a file is removed during upload.removeFile
function to prevent file removal during active uploadsThe suggested changes in the review comment are valid and necessary:
🔗 Analysis chain
Verify clear file behavior during upload
Please ensure that the clear file functionality is properly disabled when a file upload is in progress to prevent potential issues.
Consider adding an upload state check:
const removeFile = () => { + if (uploadStarted) return; setfile(undefined); setcontentType(""); };
Also applies to: 239-246
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
Length of output: 65
Script:
Length of output: 1590