-
Notifications
You must be signed in to change notification settings - Fork 3.6k
[WEB-2717] chore: implemented issue attachment upload progress #5901
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
Changes from all commits
d99c964
65af4de
49693d0
c909aa9
5f31921
ea5156b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,45 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "use client"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { observer } from "mobx-react"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // ui | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { CircularProgressIndicator, Tooltip } from "@plane/ui"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // components | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { getFileIcon } from "@/components/icons"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // helpers | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { getFileExtension } from "@/helpers/attachment.helper"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // hooks | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { usePlatformOS } from "@/hooks/use-platform-os"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // types | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { TAttachmentUploadStatus } from "@/store/issue/issue-details/attachment.store"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| type Props = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| uploadStatus: TAttachmentUploadStatus; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export const IssueAttachmentsUploadItem: React.FC<Props> = observer((props) => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // props | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const { uploadStatus } = props; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // derived values | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const fileName = uploadStatus.name; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const fileExtension = getFileExtension(uploadStatus.name ?? ""); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const fileIcon = getFileIcon(fileExtension, 18); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+23
to
+25
Contributor
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 Add null checks and memoize derived values. The file name and extension calculations should be memoized and protected against undefined values. - const fileName = uploadStatus.name;
- const fileExtension = getFileExtension(uploadStatus.name ?? "");
- const fileIcon = getFileIcon(fileExtension, 18);
+ const fileName = useMemo(() => uploadStatus.name ?? "", [uploadStatus.name]);
+ const fileExtension = useMemo(
+ () => getFileExtension(fileName),
+ [fileName]
+ );
+ const fileIcon = useMemo(
+ () => getFileIcon(fileExtension, 18),
+ [fileExtension]
+ );📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // hooks | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const { isMobile } = usePlatformOS(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <div className="flex items-center justify-between gap-3 h-11 bg-custom-background-90 pl-9 pr-2 pointer-events-none"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <div className="flex items-center gap-3 text-sm truncate"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <div className="flex-shrink-0">{fileIcon}</div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <Tooltip tooltipContent={fileName} isMobile={isMobile}> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <p className="text-custom-text-200 font-medium truncate">{fileName}</p> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </Tooltip> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <div className="flex-shrink-0 flex items-center gap-2"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <span className="flex-shrink-0"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <CircularProgressIndicator size={20} strokeWidth={3} percentage={uploadStatus.progress} /> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </span> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <div className="flex-shrink-0 text-sm font-medium">{uploadStatus.progress}% done</div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
aaryan610 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+29
to
+43
Contributor
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. Enhance accessibility attributes. The upload item should have proper ARIA attributes for better screen reader support. - <div className="flex items-center justify-between gap-3 h-11 bg-custom-background-90 pl-9 pr-2 pointer-events-none">
+ <div
+ role="status"
+ aria-label={`Uploading ${fileName}, ${uploadStatus.progress}% complete`}
+ className="flex items-center justify-between gap-3 h-11 bg-custom-background-90 pl-9 pr-2 pointer-events-none"
+ >📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,54 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "use client"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { observer } from "mobx-react"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // ui | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { CircularProgressIndicator, Tooltip } from "@plane/ui"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // icons | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { getFileIcon } from "@/components/icons"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // helpers | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { getFileExtension } from "@/helpers/attachment.helper"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { truncateText } from "@/helpers/string.helper"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // hooks | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { usePlatformOS } from "@/hooks/use-platform-os"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // types | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { TAttachmentUploadStatus } from "@/store/issue/issue-details/attachment.store"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| type Props = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| uploadStatus: TAttachmentUploadStatus; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export const IssueAttachmentsUploadDetails: React.FC<Props> = observer((props) => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // props | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const { uploadStatus } = props; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // derived values | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const fileName = uploadStatus.name; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const fileExtension = getFileExtension(uploadStatus.name ?? ""); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const fileIcon = getFileIcon(fileExtension, 28); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // hooks | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const { isMobile } = usePlatformOS(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+20
to
+29
Contributor
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. Consider adding error handling for edge cases. The component should handle cases where Apply this diff to add error handling: - const fileName = uploadStatus.name;
- const fileExtension = getFileExtension(uploadStatus.name ?? "");
+ const fileName = uploadStatus.name || "Unknown file";
+ const fileExtension = getFileExtension(fileName);📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <div className="flex h-[60px] items-center justify-between gap-1 rounded-md border-[2px] border-custom-border-200 bg-custom-background-90 px-4 py-2 text-sm pointer-events-none"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <div className="flex-shrink-0 flex items-center gap-3"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <div className="h-7 w-7">{fileIcon}</div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <div className="flex flex-col gap-1"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <div className="flex items-center gap-2"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <Tooltip tooltipContent={fileName} isMobile={isMobile}> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <span className="text-sm">{truncateText(`${fileName}`, 10)}</span> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </Tooltip> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <div className="flex items-center gap-3 text-xs text-custom-text-200"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <span>{fileExtension.toUpperCase()}</span> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+31
to
+45
Contributor
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. Improve accessibility and user interaction.
Apply these improvements: - <div className="flex h-[60px] items-center justify-between gap-1 rounded-md border-[2px] border-custom-border-200 bg-custom-background-90 px-4 py-2 text-sm pointer-events-none">
+ <div className="flex h-[60px] items-center justify-between gap-1 rounded-md border-[2px] border-custom-border-200 bg-custom-background-90 px-4 py-2 text-sm">
<div className="flex-shrink-0 flex items-center gap-3">
<div className="h-7 w-7">{fileIcon}</div>
<div className="flex flex-col gap-1">
<div className="flex items-center gap-2">
<Tooltip tooltipContent={fileName} isMobile={isMobile}>
- <span className="text-sm">{truncateText(`${fileName}`, 10)}</span>
+ <span className="text-sm">{truncateText(`${fileName}`, 20)}</span>
</Tooltip>📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <div className="flex-shrink-0 flex items-center gap-2"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <span className="flex-shrink-0"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <CircularProgressIndicator size={20} strokeWidth={3} percentage={uploadStatus.progress} /> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </span> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <div className="flex-shrink-0 text-sm font-medium">{uploadStatus.progress}% done</div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+46
to
+52
Contributor
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 progress indicator accessibility. The circular progress indicator should include ARIA attributes for better screen reader support. Apply this improvement: <div className="flex-shrink-0 flex items-center gap-2">
<span className="flex-shrink-0">
- <CircularProgressIndicator size={20} strokeWidth={3} percentage={uploadStatus.progress} />
+ <CircularProgressIndicator
+ size={20}
+ strokeWidth={3}
+ percentage={uploadStatus.progress}
+ aria-label={`Upload progress: ${uploadStatus.progress}%`}
+ role="progressbar"
+ aria-valuenow={uploadStatus.progress}
+ aria-valuemin={0}
+ aria-valuemax={100}
+ />
</span>
- <div className="flex-shrink-0 text-sm font-medium">{uploadStatus.progress}% done</div>
+ <div className="flex-shrink-0 text-sm font-medium" aria-hidden="true">{uploadStatus.progress}% done</div>
</div>📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+20
to
+54
Contributor
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 Consider performance optimizations. The component could benefit from performance optimizations to prevent unnecessary re-renders.
+ const derivedValues = useMemo(() => ({
+ fileName: uploadStatus.name || "Unknown file",
+ fileExtension: getFileExtension(uploadStatus.name ?? ""),
+ fileIcon: getFileIcon(fileExtension, 28)
+ }), [uploadStatus.name]);
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.