improve patch apply

This commit is contained in:
SrGooglo 2024-03-25 08:14:13 +01:00
parent 26179d09cc
commit 3b7d37ba7f

View File

@ -1,7 +1,6 @@
import React from "react" import React from "react"
import * as antd from "antd" import * as antd from "antd"
import { Icons, Icon } from "components/Icons" import { Icons, Icon } from "components/Icons"
import { useParams } from "react-router-dom"
import PKGConfigItem from "components/PackageConfigItem" import PKGConfigItem from "components/PackageConfigItem"
@ -59,6 +58,8 @@ const PKGPatches = (props) => {
} }
const PackageOptions = (props) => { const PackageOptions = (props) => {
const [loading, setLoading] = React.useState(false)
const { manifest } = props const { manifest } = props
if (!Array.isArray(manifest.applied_patches)) { if (!Array.isArray(manifest.applied_patches)) {
@ -72,15 +73,22 @@ const PackageOptions = (props) => {
})) : null })) : null
}) })
function applyChanges() { async function applyChanges() {
if (props.onClose) { if (props.onClose) {
props.onClose() props.onClose()
} }
if (props.close) { if (props.close) {
props.close() props.close()
} }
ipc.exec("pkg:apply", manifest.id, changes) setLoading(true)
await ipc.exec("pkg:apply", manifest.id, changes).catch((err) => {
console.log(err)
})
setLoading(false)
} }
function handleChanges(field, key, value) { function handleChanges(field, key, value) {
@ -226,19 +234,11 @@ const PackageOptions = (props) => {
icon={<Icons.MdReplay />} icon={<Icons.MdReplay />}
type="default" type="default"
size="small" size="small"
disabled={loading}
> >
Reinstall Reinstall
</antd.Button> </antd.Button>
{/* <antd.Button
disabled
icon={<Icons.MdCheck />}
type="default"
size="small"
>
Verify
</antd.Button> */}
{ {
manifest.install_ask_configs && <antd.Button manifest.install_ask_configs && <antd.Button
onClick={() => { onClick={() => {
@ -247,6 +247,7 @@ const PackageOptions = (props) => {
icon={<Icons.MdSettings />} icon={<Icons.MdSettings />}
type="default" type="default"
size="small" size="small"
disabled={loading}
> >
Wizard Wizard
</antd.Button> </antd.Button>
@ -255,7 +256,8 @@ const PackageOptions = (props) => {
<antd.Button <antd.Button
type="primary" type="primary"
onClick={applyChanges} onClick={applyChanges}
disabled={!canApplyChanges()} disabled={loading || !canApplyChanges()}
loading={loading}
> >
Apply Changes Apply Changes
</antd.Button> </antd.Button>