import React from "react"; import classnames from "classnames"; import { IFileDetails } from "utilities/file/fileUtils"; import Button from "components/buttons/Button"; import { ISupportedGraphicNames } from "components/FileUploader/FileUploader"; import Graphic from "components/Graphic"; import Icon from "components/Icon"; import GitOpsModeTooltipWrapper from "components/GitOpsModeTooltipWrapper"; export type IFileDetailsSupportedGraphicNames = | ISupportedGraphicNames | "app-store"; // For VPP apps (non-editable) interface IFileDetailsProps { graphicNames: | IFileDetailsSupportedGraphicNames | IFileDetailsSupportedGraphicNames[]; fileDetails: IFileDetails; canEdit: boolean; /** If present, will show a trash icon */ onDeleteFile?: () => void; onFileSelect?: (e: React.ChangeEvent) => void; accept?: string; progress?: number; /** Set to false for one instance we allow users to edit a file as it shows them the YAML */ gitopsCompatible?: boolean; gitOpsModeEnabled?: boolean; } const baseClass = "file-details"; const FileDetails = ({ graphicNames, fileDetails, canEdit, onDeleteFile, onFileSelect, accept, progress, gitopsCompatible = true, gitOpsModeEnabled = false, }: IFileDetailsProps) => { const infoClasses = classnames(`${baseClass}__info`, { [`${baseClass}__info--disabled-by-gitops-mode`]: gitOpsModeEnabled && gitopsCompatible, }); return (
{/* disabling at this level preserves funcitonality of GitOpsModeTooltipWrapper around the edit icon */}
{fileDetails.name}
{fileDetails.description && (
{fileDetails.description}
)}
{!progress && canEdit && onFileSelect && (gitopsCompatible ? ( (
)} /> ) : (
))} {!progress && onDeleteFile && (
)} {!!progress && (
{Math.round(progress * 100)}%
)}
); }; export default FileDetails;