import React, { useRef,useState } from 'react' import * as Icon from 'react-feather' import { Container, Row, Col, ProgressBar, Popover, PopoverBody, } from 'react-bootstrap' import { AppButton } from './AppButton' import { DependencyModal } from './partials/Modals/Dependency' import { AppInfoAction, AppInfoSetting, AppInfoSettingProps } from './AppInfoSetting' import { ProgressColor } from '../../utils/colors' import { PackageInfo, isUpdatable, isLaunchable, isUpdateCompat } from '../../data/packageInfo' import { Notification } from '../../data/notification' import { AppStatusToCaption } from '../../utils/appStatus' import { AppInfoToolbar } from './AppInfoToolbar' import { MyImage } from '../ui/MyImage' export interface AppInfoProps { info: PackageInfo style?: object footer?: JSX.Element customActions?: AppInfoAction[] // custom secondary actions for app info isDependent?: boolean onInstall?: (pkg:PackageInfo) => void onCancel?: (pkg:PackageInfo) => void onUninstall?: (pkg:PackageInfo) => void onCheckIfDependent?: (pkg:PackageInfo) => void onUpdate?: (pkg:PackageInfo) => void onOff?: (pkg:PackageInfo) => Promise onOn?: (pkg:PackageInfo) => Promise onLaunch?: (pkg:PackageInfo) => void, onAppStateChanged ?: (pkg:PackageInfo) => void onResync?: () => void onDisable?: () => void onRestart?: () => void onBack?: () => void children?: any } interface SettingPopOverRef { popOverRef: React.RefObject setting: AppInfoSettingProps } const Notifications = (props: {data : Notification[]}) => { return (<> { props.data.map( (val:Notification) => { return (<> { val.type === "error" &&

{val.content}

} { val.type === 'info' &&

{val.content}

} { val.type === 'warning' &&

{val.content}

} ) }) } ) } const SettingPopover = (props: SettingPopOverRef) => { return ( ) } export const AppInfo = (props: AppInfoProps): JSX.Element => { const [isOpenDependencyModal,setIsOpenDependencyModal] = useState(false) const settingPopoverRef = useRef(null) const progressColor = ProgressColor(props.info.status) const info = props.info; let progress = info.progress; const updatable = isUpdatable(props.info) const sysCompatible = isUpdateCompat(props.info) if (!(progress > 0) && props.info.status === "installing") progress = 95 const handleInstall = () => { if (props.onInstall) props.onInstall(props.info) } const handleUninstall = () => { if (props.onUninstall) props.onUninstall(props.info) } const handleLaunch = (evnt:any) => { if (props.onUninstall) props.onLaunch(props.info) } const handleCancel = (evnt:any) => { if(props.onCancel) props.onCancel(props.info) } const handleUpdate = (evnt:any) => { if (props.onUninstall && sysCompatible) props.onUpdate(props.info) } const handleCheckIfDependency = (evnt:any) => { props.onCheckIfDependent(props.info) } const handleOnOpenDependencyModal = () =>{ if(props.info.dependencies && props.info.dependencies.length>0){ setIsOpenDependencyModal(true) return } setIsOpenDependencyModal(false) handleInstall() } const handleOnCloseDependencyModal = () =>{ setIsOpenDependencyModal(false) } const handleOnConfirmInstall = () =>{ setIsOpenDependencyModal(false) handleInstall() } const handleOff = () => { return props.onOff(props.info) } const handleOn = () => { return props.onOn(props.info) } return ( {/*
{props.onBack &&

Apps

}
*/}

{info.name}

{ info.notificationContents && info.notificationContents.length > 0 && } { (updatable || info.status === "uninstalled") && !sysCompatible &&

Requires latest system to install this package.

} { props.info.isService && props.info.status === "installed" && !props.info.enabled &&

Disabled

} { info.status !== "uninstalling" && info.status !== "installed" && info.status !== "uninstalled" && (

{AppStatusToCaption(info.status)}

{ progress > 0 &&
}
) } { (info.status === "uninstalling" || info.status === "wait_depends") && (

{AppStatusToCaption(info.status)}

) }

{props.info.description}

What's New

{props.info.updates}

Package details

Package Id: {props.info.id}
Version: {info.version}
Build: {info.currentBuild}

{props.children} {props.info.dependencies?.length > 0 &&

Depedencies

{props.info.dependencies?.map((dependency:any) => { return

{dependency.name}

})}
}
) }