From eb79654ef8768819afd066e0e6b3a0c77ceaaee6 Mon Sep 17 00:00:00 2001 From: RunDevelopment Date: Thu, 4 Apr 2024 21:41:48 +0200 Subject: [PATCH] Improved UI for dependency manager --- src/renderer/contexts/DependencyContext.tsx | 329 +++++++++++--------- 1 file changed, 178 insertions(+), 151 deletions(-) diff --git a/src/renderer/contexts/DependencyContext.tsx b/src/renderer/contexts/DependencyContext.tsx index 8836eab9a..09ad94a90 100644 --- a/src/renderer/contexts/DependencyContext.tsx +++ b/src/renderer/contexts/DependencyContext.tsx @@ -1,4 +1,4 @@ -import { DeleteIcon, DownloadIcon, InfoIcon } from '@chakra-ui/icons'; +import { CopyIcon, DeleteIcon, DownloadIcon, InfoIcon } from '@chakra-ui/icons'; import { Accordion, AccordionButton, @@ -13,6 +13,7 @@ import { Flex, HStack, Icon, + IconButton, Modal, ModalBody, ModalCloseButton, @@ -32,8 +33,9 @@ import { useDisclosure, } from '@chakra-ui/react'; import { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react'; -import { BsQuestionCircle, BsTerminalFill } from 'react-icons/bs'; +import { BsQuestionCircle } from 'react-icons/bs'; import { HiOutlineRefresh } from 'react-icons/hi'; +import { MdSettings } from 'react-icons/md'; import { useQuery } from 'react-query'; import { createContext, useContext } from 'use-context-selector'; import { @@ -43,6 +45,7 @@ import { Package, PyPiName, PyPiPackage, + PythonInfo, Version, } from '../../common/common-types'; import { log } from '../../common/log'; @@ -75,6 +78,18 @@ enum InstallMode { COPY = 'copy', } +const getInstallCommand = (pkg: Package, pythonInfo: PythonInfo): string => { + const deps = pkg.dependencies.map((p) => `${p.pypiName}==${p.version}`); + const findLinks = getFindLinks(pkg.dependencies).flatMap((l) => ['--extra-index-url', l]); + const args = [pythonInfo.python, '-m', 'pip', 'install', '--upgrade', ...deps, ...findLinks]; + return args.join(' '); +}; +const getUninstallCommand = (pkg: Package, pythonInfo: PythonInfo): string => { + const deps = pkg.dependencies.map((p) => p.pypiName); + const args = [pythonInfo.python, '-m', 'pip', 'uninstall', ...deps]; + return args.join(' '); +}; + const formatBytes = (bytes: number): string => { const KB = 1024 ** 1; const MB = 1024 ** 2; @@ -196,10 +211,7 @@ const PackageView = memo( {missingPackages.length === 0 ? ( - + {outdatedPackages.length > 0 && ( + + +
+ + + + +
+ Installation mode +
- {'The dependency install mode. ChaiNNer supports 2 ways of installing packages:\n\n' + + {'ChaiNNer supports 2 ways of installing packages:\n\n' + '- Normal: This is the default installation mode. This mode will automatically handle the dependency install for you and will report progress along the way.\n' + - '- Manual/Copy: Copy the pip install command to your clipboard for you to run in your own terminal. You will have to manually restart chaiNner afterwards.'} + '- Manual/Copy: Copy the pip install command to your clipboard for you to run in your own terminal. You will have to manually restart chaiNNer afterwards.'} } openDelay={500} - px={2} - py={0} >
- - - - -
+ + + + + + +
+
+