mirror of
https://github.com/ragestudio/relic.git
synced 2025-06-09 10:34:18 +00:00
move package options to a single page
This commit is contained in:
parent
7615cedeb4
commit
149a71ea08
@ -6,8 +6,6 @@ import BarLoader from "react-spinners/BarLoader"
|
|||||||
|
|
||||||
import { MdFolder, MdDelete, MdPlayArrow, MdUpdate, MdOutlineMoreVert, MdSettings, MdInfoOutline } from "react-icons/md"
|
import { MdFolder, MdDelete, MdPlayArrow, MdUpdate, MdOutlineMoreVert, MdSettings, MdInfoOutline } from "react-icons/md"
|
||||||
|
|
||||||
import PackageOptions from "../PackageOptions"
|
|
||||||
|
|
||||||
import "./index.less"
|
import "./index.less"
|
||||||
|
|
||||||
const PackageItem = (props) => {
|
const PackageItem = (props) => {
|
||||||
@ -15,6 +13,7 @@ const PackageItem = (props) => {
|
|||||||
|
|
||||||
const isLoading = manifest.status === "installing" || manifest.status === "uninstalling" || manifest.status === "loading"
|
const isLoading = manifest.status === "installing" || manifest.status === "uninstalling" || manifest.status === "loading"
|
||||||
const isInstalled = manifest.status === "installed"
|
const isInstalled = manifest.status === "installed"
|
||||||
|
const isInstalling = manifest.status === "installing"
|
||||||
const isFailed = manifest.status === "error"
|
const isFailed = manifest.status === "error"
|
||||||
|
|
||||||
const onClickUpdate = () => {
|
const onClickUpdate = () => {
|
||||||
@ -46,12 +45,15 @@ const PackageItem = (props) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const onClickOptions = () => {
|
const onClickOptions = () => {
|
||||||
app.modal.open(PackageOptions, {
|
app.location.push(`/package/${manifest.id}`)
|
||||||
manifest: manifest,
|
}
|
||||||
close: () => {
|
|
||||||
app.modal.close()
|
const onClickCancelInstall = () => {
|
||||||
}
|
ipc.exec("pkg:cancel_install", manifest.id)
|
||||||
})
|
}
|
||||||
|
|
||||||
|
const onClickRetryInstall = () => {
|
||||||
|
ipc.exec("pkg:retry_install", manifest.id)
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleUpdate(event, data) {
|
function handleUpdate(event, data) {
|
||||||
@ -148,6 +150,7 @@ const PackageItem = (props) => {
|
|||||||
{
|
{
|
||||||
isFailed && <antd.Button
|
isFailed && <antd.Button
|
||||||
type="primary"
|
type="primary"
|
||||||
|
onClick={onClickRetryInstall}
|
||||||
>
|
>
|
||||||
Retry
|
Retry
|
||||||
</antd.Button>
|
</antd.Button>
|
||||||
@ -174,6 +177,15 @@ const PackageItem = (props) => {
|
|||||||
/>
|
/>
|
||||||
</antd.Dropdown>
|
</antd.Dropdown>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
isInstalling && <antd.Button
|
||||||
|
type="primary"
|
||||||
|
onClick={onClickCancelInstall}
|
||||||
|
>
|
||||||
|
Cancel
|
||||||
|
</antd.Button>
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import React from "react"
|
import React from "react"
|
||||||
import * as antd from "antd"
|
import * as antd from "antd"
|
||||||
import { Icon } from "components/Icons"
|
import { Icons, Icon } from "components/Icons"
|
||||||
|
import { useParams } from "react-router-dom"
|
||||||
|
|
||||||
import "./index.less"
|
import "./index.less"
|
||||||
|
|
||||||
@ -27,8 +28,6 @@ const PKGConfigs = (props) => {
|
|||||||
</p>
|
</p>
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(defaultConfigs, configs)
|
|
||||||
|
|
||||||
return Object.keys(defaultConfigs).map((key, index) => {
|
return Object.keys(defaultConfigs).map((key, index) => {
|
||||||
const config = defaultConfigs[key]
|
const config = defaultConfigs[key]
|
||||||
const storagedValue = configs[key]
|
const storagedValue = configs[key]
|
||||||
@ -173,6 +172,24 @@ const PackageOptions = (props) => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function handleReinstall() {
|
||||||
|
antd.Modal.confirm({
|
||||||
|
title: "Reinstall",
|
||||||
|
content: "Are you sure you want to reinstall this package? Some data can be lost.",
|
||||||
|
onOk() {
|
||||||
|
const closeModal = props.onClose || props.close
|
||||||
|
|
||||||
|
if (closeModal) {
|
||||||
|
closeModal()
|
||||||
|
} else {
|
||||||
|
app.location.push("/")
|
||||||
|
}
|
||||||
|
|
||||||
|
ipc.exec("pkg:install", manifest)
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
function canApplyChanges() {
|
function canApplyChanges() {
|
||||||
return Object.keys(changes).length > 0
|
return Object.keys(changes).length > 0
|
||||||
}
|
}
|
||||||
@ -201,7 +218,7 @@ const PackageOptions = (props) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
manifest.patches && <div className="package_options-field">
|
manifest.patches && manifest.patches.length > 0 && <div className="package_options-field">
|
||||||
<div className="package_options-field-header">
|
<div className="package_options-field-header">
|
||||||
<p>Patches</p>
|
<p>Patches</p>
|
||||||
</div>
|
</div>
|
||||||
@ -281,15 +298,65 @@ const PackageOptions = (props) => {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="package_options-actions">
|
<div className="package_options-actions">
|
||||||
|
<antd.Button
|
||||||
|
onClick={handleReinstall}
|
||||||
|
icon={<Icons.MdReplay />}
|
||||||
|
type="default"
|
||||||
|
>
|
||||||
|
Reinstall
|
||||||
|
</antd.Button>
|
||||||
|
|
||||||
|
<antd.Button
|
||||||
|
disabled
|
||||||
|
icon={<Icons.MdCheck />}
|
||||||
|
type="default"
|
||||||
|
>
|
||||||
|
Verify
|
||||||
|
</antd.Button>
|
||||||
|
|
||||||
<antd.Button
|
<antd.Button
|
||||||
type="primary"
|
type="primary"
|
||||||
onClick={applyChanges}
|
onClick={applyChanges}
|
||||||
disabled={!canApplyChanges()}
|
disabled={!canApplyChanges()}
|
||||||
>
|
>
|
||||||
Apply
|
Apply Changes
|
||||||
</antd.Button>
|
</antd.Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
|
||||||
export default PackageOptions
|
const PackageOptionsLoader = (props) => {
|
||||||
|
const { pkg_id } = useParams()
|
||||||
|
const [manifest, setManifest] = React.useState(null)
|
||||||
|
|
||||||
|
React.useEffect(() => {
|
||||||
|
ipc.exec("pkg:get", pkg_id).then((manifest) => {
|
||||||
|
console.log(manifest)
|
||||||
|
setManifest(manifest)
|
||||||
|
})
|
||||||
|
}, [pkg_id])
|
||||||
|
|
||||||
|
if (!manifest) {
|
||||||
|
return <antd.Skeleton active />
|
||||||
|
}
|
||||||
|
|
||||||
|
return <div className="package_options-wrapper">
|
||||||
|
<div className="package_options-wrapper-header">
|
||||||
|
<div className="package_options-wrapper-header-back">
|
||||||
|
<Icons.MdChevronLeft
|
||||||
|
onClick={() => {
|
||||||
|
app.location.push("/")
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
Back
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<PackageOptions
|
||||||
|
manifest={manifest}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
|
||||||
|
export default PackageOptionsLoader
|
@ -1,3 +1,37 @@
|
|||||||
|
.package_options-wrapper {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
|
||||||
|
gap: 10px;
|
||||||
|
|
||||||
|
.package_options-wrapper-header {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
|
||||||
|
gap: 20px;
|
||||||
|
|
||||||
|
.package_options-wrapper-header-back {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
|
||||||
|
align-items: center;
|
||||||
|
|
||||||
|
gap: 10px;
|
||||||
|
|
||||||
|
svg {
|
||||||
|
color: var(--primary-color);
|
||||||
|
border: 1px solid var(--primary-color);
|
||||||
|
|
||||||
|
border-radius: 100%;
|
||||||
|
|
||||||
|
cursor: pointer;
|
||||||
|
|
||||||
|
font-size: 1.5rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.package_options {
|
.package_options {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
@ -10,6 +44,8 @@
|
|||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
|
||||||
|
gap: 10px;
|
||||||
|
|
||||||
.package_options-field-header {
|
.package_options-field-header {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
@ -34,7 +70,10 @@
|
|||||||
|
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
|
|
||||||
gap: 5px;
|
gap: 15px;
|
||||||
|
|
||||||
|
background-color: var(--background-color-secondary);
|
||||||
|
border-radius: 12px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,6 +91,12 @@
|
|||||||
|
|
||||||
font-size: 0.6rem;
|
font-size: 0.6rem;
|
||||||
|
|
||||||
|
background-color: var(--background-color-secondary);
|
||||||
|
|
||||||
|
padding: 7px;
|
||||||
|
|
||||||
|
border-radius: 12px;
|
||||||
|
|
||||||
.package_options-info-item {
|
.package_options-info-item {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
@ -105,4 +150,22 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.package_options-actions {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
|
||||||
|
gap: 10px;
|
||||||
|
|
||||||
|
// put the last button on the right
|
||||||
|
.ant-btn {
|
||||||
|
&:last-child {
|
||||||
|
margin-left: auto;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.ant-btn-default:not(.disabled) {
|
||||||
|
background-color: var(--background-color-secondary);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
@ -6,6 +6,7 @@ import GlobalStateContext from "contexts/global"
|
|||||||
|
|
||||||
import PackagesMangerPage from "pages/manager"
|
import PackagesMangerPage from "pages/manager"
|
||||||
import SettingsPage from "pages/settings"
|
import SettingsPage from "pages/settings"
|
||||||
|
import PackageOptionsPage from "pages/pkg"
|
||||||
|
|
||||||
const NavigationController = (props) => {
|
const NavigationController = (props) => {
|
||||||
if (!app.location) {
|
if (!app.location) {
|
||||||
@ -80,5 +81,6 @@ export const PageRender = () => {
|
|||||||
return <Routes>
|
return <Routes>
|
||||||
<Route exact path="/" element={<PackagesMangerPage />} />
|
<Route exact path="/" element={<PackagesMangerPage />} />
|
||||||
<Route exact path="/settings" element={<SettingsPage />} />
|
<Route exact path="/settings" element={<SettingsPage />} />
|
||||||
|
<Route exact path="/package/:pkg_id" element={<PackageOptionsPage />} />
|
||||||
</Routes>
|
</Routes>
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user