diff --git a/openmetadata-ui-core-components/src/main/resources/ui/package.json b/openmetadata-ui-core-components/src/main/resources/ui/package.json index b398ddfb1d96..669ab219c816 100644 --- a/openmetadata-ui-core-components/src/main/resources/ui/package.json +++ b/openmetadata-ui-core-components/src/main/resources/ui/package.json @@ -75,7 +75,9 @@ "author": "OpenMetadata", "license": "Apache-2.0", "dependencies": { - "@material/material-color-utilities": "^0.3.0" + "@material/material-color-utilities": "^0.3.0", + "@untitledui/file-icons": "^0.0.9", + "motion": "^12.38.0" }, "peerDependencies": { "@emotion/react": ">=11.0.0", diff --git a/openmetadata-ui-core-components/src/main/resources/ui/src/components/application/file-upload/file-upload.tsx b/openmetadata-ui-core-components/src/main/resources/ui/src/components/application/file-upload/file-upload.tsx index 09462d8a8b5c..c66230c0c1f9 100644 --- a/openmetadata-ui-core-components/src/main/resources/ui/src/components/application/file-upload/file-upload.tsx +++ b/openmetadata-ui-core-components/src/main/resources/ui/src/components/application/file-upload/file-upload.tsx @@ -15,12 +15,19 @@ * Source: https://github.com/untitleduico/react/blob/main/components/application/file-upload/file-upload-base.tsx */ -import { UploadCloud02 } from '@untitledui/icons'; -import type { DragEvent, ChangeEvent } from 'react'; -import { useId, useRef, useState } from 'react'; import { Button } from '@/components/base/buttons/button'; +import { ButtonUtility } from '@/components/base/buttons/button-utility'; +import { ProgressBar } from '@/components/base/progress-indicators/progress-indicators'; import { FeaturedIcon } from '@/components/foundations/featured-icon/featured-icon'; import { cx } from '@/utils/cx'; +import { + CheckCircle, + Trash01, + UploadCloud02, + XCircle, +} from '@untitledui/icons'; +import type { ChangeEvent, ComponentPropsWithRef, DragEvent } from 'react'; +import { useId, useRef, useState } from 'react'; export const getReadableFileSize = (bytes: number): string => { if (bytes === 0) { @@ -240,3 +247,236 @@ export const FileUploadDropZone = ({ }; FileUploadDropZone.displayName = 'FileUploadDropZone'; + +export interface FileListItemProps { + name: string; + size: number; + progress: number; + failed?: boolean; + className?: string; + completeLabel?: string; + uploadingLabel?: string; + failedLabel?: string; + tryAgainLabel?: string; + deleteLabel?: string; + onDelete?: () => void; + onRetry?: () => void; +} + +export const FileListItemProgressBar = ({ + className, + completeLabel = 'Complete', + deleteLabel = 'Delete', + failed, + failedLabel = 'Failed', + name, + onDelete, + onRetry, + progress, + size, + tryAgainLabel = 'Try again', + uploadingLabel = 'Uploading...', +}: FileListItemProps) => { + const isComplete = progress === 100; + + return ( +
  • +
    + +
    + +
    +
    +
    +

    + {name} +

    +
    +

    + {getReadableFileSize(size)} +

    +
    +
    + {isComplete && !failed && ( + <> + +

    + {completeLabel} +

    + + )} + {!isComplete && !failed && ( + <> + +

    + {uploadingLabel} +

    + + )} + {failed && ( + <> + +

    + {failedLabel} +

    + + )} +
    +
    +
    + +
    + + {!failed && ( +
    + +
    + )} + + {failed && ( + + )} +
    +
  • + ); +}; + +export const FileListItemProgressFill = ({ + className, + deleteLabel = 'Delete', + failed, + failedLabel = 'Upload failed, please try again', + name, + onDelete, + onRetry, + progress, + size, + tryAgainLabel = 'Try again', +}: FileListItemProps) => { + const isComplete = progress === 100; + + return ( +
  • +
    +
    +
    + +
    + +
    +
    +
    +

    + {name} +

    +
    +

    + {failed ? failedLabel : getReadableFileSize(size)} +

    + {!failed && ( + <> +
    +
    + {isComplete ? ( + + ) : ( + + )} +

    {progress}%

    +
    + + )} +
    +
    + {failed && ( + + )} +
    + +
    +
  • + ); +}; + +const FileUploadRoot = (props: ComponentPropsWithRef<'div'>) => ( +
    +); + +const FileUploadList = (props: ComponentPropsWithRef<'ul'>) => ( +