Replace Fyne GUI with Walk (Win32 native, no OpenGL)
All checks were successful
release / build-and-release (push) Successful in 22s
All checks were successful
release / build-and-release (push) Successful in 22s
Walk uses Win32 controls directly — no GPU/OpenGL dependency — so the app renders correctly on VMware ESXi, Hyper-V and any other VM. No MinGW needed in CI; pure cross-compile with GOOS=windows. - internal/gui/gui.go: rewrite with Walk declarative API (3 phases: form → live run → summary); load/save config via native FileDialog; Closing event cancels running scripts cleanly - cmd/xetup/app.manifest: UAC requireAdministrator + ComCtl32 v6 + per-monitor DPI awareness (rsrc generates rsrc.syso in CI) - .forgejo/workflows/release.yml: drop MinGW, add rsrc generation step - go.mod/go.sum: remove Fyne and all its deps; only Walk (3 deps total) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
54ea9a1b0d
commit
cf2037ae7d
5 changed files with 379 additions and 335 deletions
|
|
@ -10,6 +10,7 @@ on:
|
|||
- 'scripts/**'
|
||||
- 'assets/**'
|
||||
- 'embed.go'
|
||||
- 'cmd/xetup/app.manifest'
|
||||
- '.forgejo/workflows/release.yml'
|
||||
|
||||
jobs:
|
||||
|
|
@ -25,16 +26,21 @@ jobs:
|
|||
- name: Setup
|
||||
working-directory: /
|
||||
run: |
|
||||
apk add --no-cache git curl jq mingw-w64-gcc
|
||||
apk add --no-cache git curl jq
|
||||
git clone --depth=1 \
|
||||
"http://x9:${{ secrets.FORGEJO_TOKEN }}@xetup-forgejo:3000/${{ github.repository }}.git" \
|
||||
/repo
|
||||
cd /repo
|
||||
git checkout "${{ github.sha }}"
|
||||
|
||||
- name: Generate rsrc.syso (manifest + UAC)
|
||||
run: |
|
||||
go install github.com/akavel/rsrc@latest
|
||||
rsrc -manifest cmd/xetup/app.manifest -o cmd/xetup/rsrc.syso
|
||||
echo "rsrc.syso: $(ls -lh cmd/xetup/rsrc.syso | awk '{print $5}')"
|
||||
|
||||
- name: Build xetup.exe
|
||||
run: |
|
||||
CGO_ENABLED=1 CC=x86_64-w64-mingw32-gcc \
|
||||
GOOS=windows GOARCH=amd64 \
|
||||
go build -ldflags="-s -w -H windowsgui" -o xetup.exe ./cmd/xetup/
|
||||
echo "Built: $(ls -lh xetup.exe | awk '{print $5}')"
|
||||
|
|
@ -73,4 +79,3 @@ jobs:
|
|||
--data-binary @xetup.exe
|
||||
|
||||
echo "Released xetup.exe (commit ${SHORT})"
|
||||
|
||||
|
|
|
|||
41
cmd/xetup/app.manifest
Normal file
41
cmd/xetup/app.manifest
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
|
||||
<assemblyIdentity
|
||||
version="1.0.0.0"
|
||||
processorArchitecture="amd64"
|
||||
name="xetup"
|
||||
type="win32"
|
||||
/>
|
||||
<description>xetup Windows deployment tool</description>
|
||||
|
||||
<!-- Request administrator privileges -->
|
||||
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
|
||||
<security>
|
||||
<requestedPrivileges>
|
||||
<requestedExecutionLevel level="requireAdministrator" uiAccess="false"/>
|
||||
</requestedPrivileges>
|
||||
</security>
|
||||
</trustInfo>
|
||||
|
||||
<!-- Enable modern ComCtl32 v6 (themed controls, proper checkboxes, etc.) -->
|
||||
<dependency>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity
|
||||
type="win32"
|
||||
name="Microsoft.Windows.Common-Controls"
|
||||
version="6.0.0.0"
|
||||
processorArchitecture="*"
|
||||
publicKeyToken="6595b64144ccf1df"
|
||||
language="*"
|
||||
/>
|
||||
</dependentAssembly>
|
||||
</dependency>
|
||||
|
||||
<!-- DPI awareness: system-DPI aware (no blurry scaling) -->
|
||||
<application xmlns="urn:schemas-microsoft-com:asm.v3">
|
||||
<windowsSettings>
|
||||
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware>
|
||||
<dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitorV2, PerMonitor</dpiAwareness>
|
||||
</windowsSettings>
|
||||
</application>
|
||||
</assembly>
|
||||
35
go.mod
35
go.mod
|
|
@ -2,39 +2,10 @@ module git.xetup.x9.cz/x9/xetup
|
|||
|
||||
go 1.24.0
|
||||
|
||||
require fyne.io/fyne/v2 v2.7.3
|
||||
require github.com/lxn/walk v0.0.0-20210112085537-c389da54e794
|
||||
|
||||
require (
|
||||
fyne.io/systray v1.12.0 // indirect
|
||||
github.com/BurntSushi/toml v1.5.0 // indirect
|
||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||
github.com/fredbi/uri v1.1.1 // indirect
|
||||
github.com/fsnotify/fsnotify v1.9.0 // indirect
|
||||
github.com/fyne-io/gl-js v0.2.0 // indirect
|
||||
github.com/fyne-io/glfw-js v0.3.0 // indirect
|
||||
github.com/fyne-io/image v0.1.1 // indirect
|
||||
github.com/fyne-io/oksvg v0.2.0 // indirect
|
||||
github.com/go-gl/gl v0.0.0-20231021071112-07e5d0ea2e71 // indirect
|
||||
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20240506104042-037f3cc74f2a // indirect
|
||||
github.com/go-text/render v0.2.0 // indirect
|
||||
github.com/go-text/typesetting v0.3.3 // indirect
|
||||
github.com/godbus/dbus/v5 v5.1.0 // indirect
|
||||
github.com/hack-pad/go-indexeddb v0.3.2 // indirect
|
||||
github.com/hack-pad/safejs v0.1.0 // indirect
|
||||
github.com/jeandeaual/go-locale v0.0.0-20250612000132-0ef82f21eade // indirect
|
||||
github.com/jsummers/gobmp v0.0.0-20230614200233-a9de23ed2e25 // indirect
|
||||
github.com/kr/text v0.2.0 // indirect
|
||||
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 // indirect
|
||||
github.com/nicksnyder/go-i18n/v2 v2.5.1 // indirect
|
||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||
github.com/rymdport/portal v0.4.2 // indirect
|
||||
github.com/srwiley/oksvg v0.0.0-20221011165216-be6e8873101c // indirect
|
||||
github.com/srwiley/rasterx v0.0.0-20220730225603-2ab79fcdd4ef // indirect
|
||||
github.com/stretchr/testify v1.11.1 // indirect
|
||||
github.com/yuin/goldmark v1.7.8 // indirect
|
||||
golang.org/x/image v0.24.0 // indirect
|
||||
golang.org/x/net v0.35.0 // indirect
|
||||
github.com/lxn/win v0.0.0-20210218163916-a377121e959e // indirect
|
||||
golang.org/x/sys v0.36.0 // indirect
|
||||
golang.org/x/text v0.23.0 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
gopkg.in/Knetic/govaluate.v3 v3.0.0 // indirect
|
||||
)
|
||||
|
|
|
|||
85
go.sum
85
go.sum
|
|
@ -1,80 +1,9 @@
|
|||
fyne.io/fyne/v2 v2.7.3 h1:xBT/iYbdnNHONWO38fZMBrVBiJG8rV/Jypmy4tVfRWE=
|
||||
fyne.io/fyne/v2 v2.7.3/go.mod h1:gu+dlIcZWSzKZmnrY8Fbnj2Hirabv2ek+AKsfQ2bBlw=
|
||||
fyne.io/systray v1.12.0 h1:CA1Kk0e2zwFlxtc02L3QFSiIbxJ/P0n582YrZHT7aTM=
|
||||
fyne.io/systray v1.12.0/go.mod h1:RVwqP9nYMo7h5zViCBHri2FgjXF7H2cub7MAq4NSoLs=
|
||||
github.com/BurntSushi/toml v1.5.0 h1:W5quZX/G/csjUnuI8SUYlsHs9M38FC7znL0lIO+DvMg=
|
||||
github.com/BurntSushi/toml v1.5.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho=
|
||||
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/felixge/fgprof v0.9.3 h1:VvyZxILNuCiUCSXtPtYmmtGvb65nqXh2QFWc0Wpf2/g=
|
||||
github.com/felixge/fgprof v0.9.3/go.mod h1:RdbpDgzqYVh/T9fPELJyV7EYJuHB55UTEULNun8eiPw=
|
||||
github.com/fredbi/uri v1.1.1 h1:xZHJC08GZNIUhbP5ImTHnt5Ya0T8FI2VAwI/37kh2Ko=
|
||||
github.com/fredbi/uri v1.1.1/go.mod h1:4+DZQ5zBjEwQCDmXW5JdIjz0PUA+yJbvtBv+u+adr5o=
|
||||
github.com/fsnotify/fsnotify v1.9.0 h1:2Ml+OJNzbYCTzsxtv8vKSFD9PbJjmhYF14k/jKC7S9k=
|
||||
github.com/fsnotify/fsnotify v1.9.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0=
|
||||
github.com/fyne-io/gl-js v0.2.0 h1:+EXMLVEa18EfkXBVKhifYB6OGs3HwKO3lUElA0LlAjs=
|
||||
github.com/fyne-io/gl-js v0.2.0/go.mod h1:ZcepK8vmOYLu96JoxbCKJy2ybr+g1pTnaBDdl7c3ajI=
|
||||
github.com/fyne-io/glfw-js v0.3.0 h1:d8k2+Y7l+zy2pc7wlGRyPfTgZoqDf3AI4G+2zOWhWUk=
|
||||
github.com/fyne-io/glfw-js v0.3.0/go.mod h1:Ri6te7rdZtBgBpxLW19uBpp3Dl6K9K/bRaYdJ22G8Jk=
|
||||
github.com/fyne-io/image v0.1.1 h1:WH0z4H7qfvNUw5l4p3bC1q70sa5+YWVt6HCj7y4VNyA=
|
||||
github.com/fyne-io/image v0.1.1/go.mod h1:xrfYBh6yspc+KjkgdZU/ifUC9sPA5Iv7WYUBzQKK7JM=
|
||||
github.com/fyne-io/oksvg v0.2.0 h1:mxcGU2dx6nwjJsSA9PCYZDuoAcsZ/OuJlvg/Q9Njfo8=
|
||||
github.com/fyne-io/oksvg v0.2.0/go.mod h1:dJ9oEkPiWhnTFNCmRgEze+YNprJF7YRbpjgpWS4kzoI=
|
||||
github.com/go-gl/gl v0.0.0-20231021071112-07e5d0ea2e71 h1:5BVwOaUSBTlVZowGO6VZGw2H/zl9nrd3eCZfYV+NfQA=
|
||||
github.com/go-gl/gl v0.0.0-20231021071112-07e5d0ea2e71/go.mod h1:9YTyiznxEY1fVinfM7RvRcjRHbw2xLBJ3AAGIT0I4Nw=
|
||||
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20240506104042-037f3cc74f2a h1:vxnBhFDDT+xzxf1jTJKMKZw3H0swfWk9RpWbBbDK5+0=
|
||||
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20240506104042-037f3cc74f2a/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
|
||||
github.com/go-text/render v0.2.0 h1:LBYoTmp5jYiJ4NPqDc2pz17MLmA3wHw1dZSVGcOdeAc=
|
||||
github.com/go-text/render v0.2.0/go.mod h1:CkiqfukRGKJA5vZZISkjSYrcdtgKQWRa2HIzvwNN5SU=
|
||||
github.com/go-text/typesetting v0.3.3 h1:ihGNJU9KzdK2QRDy1Bm7FT5RFQoYb+3n3EIhI/4eaQc=
|
||||
github.com/go-text/typesetting v0.3.3/go.mod h1:vIRUT25mLQaSh4C8H/lIsKppQz/Gdb8Pu/tNwpi52ts=
|
||||
github.com/go-text/typesetting-utils v0.0.0-20250618110550-c820a94c77b8 h1:4KCscI9qYWMGTuz6BpJtbUSRzcBrUSSE0ENMJbNSrFs=
|
||||
github.com/go-text/typesetting-utils v0.0.0-20250618110550-c820a94c77b8/go.mod h1:3/62I4La/HBRX9TcTpBj4eipLiwzf+vhI+7whTc9V7o=
|
||||
github.com/godbus/dbus/v5 v5.1.0 h1:4KLkAxT3aOY8Li4FRJe/KvhoNFFxo0m6fNuFUO8QJUk=
|
||||
github.com/godbus/dbus/v5 v5.1.0/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
|
||||
github.com/google/pprof v0.0.0-20211214055906-6f57359322fd h1:1FjCyPC+syAzJ5/2S8fqdZK1R22vvA0J7JZKcuOIQ7Y=
|
||||
github.com/google/pprof v0.0.0-20211214055906-6f57359322fd/go.mod h1:KgnwoLYCZ8IQu3XUZ8Nc/bM9CCZFOyjUNOSygVozoDg=
|
||||
github.com/hack-pad/go-indexeddb v0.3.2 h1:DTqeJJYc1usa45Q5r52t01KhvlSN02+Oq+tQbSBI91A=
|
||||
github.com/hack-pad/go-indexeddb v0.3.2/go.mod h1:QvfTevpDVlkfomY498LhstjwbPW6QC4VC/lxYb0Kom0=
|
||||
github.com/hack-pad/safejs v0.1.0 h1:qPS6vjreAqh2amUqj4WNG1zIw7qlRQJ9K10eDKMCnE8=
|
||||
github.com/hack-pad/safejs v0.1.0/go.mod h1:HdS+bKF1NrE72VoXZeWzxFOVQVUSqZJAG0xNCnb+Tio=
|
||||
github.com/jeandeaual/go-locale v0.0.0-20250612000132-0ef82f21eade h1:FmusiCI1wHw+XQbvL9M+1r/C3SPqKrmBaIOYwVfQoDE=
|
||||
github.com/jeandeaual/go-locale v0.0.0-20250612000132-0ef82f21eade/go.mod h1:ZDXo8KHryOWSIqnsb/CiDq7hQUYryCgdVnxbj8tDG7o=
|
||||
github.com/jsummers/gobmp v0.0.0-20230614200233-a9de23ed2e25 h1:YLvr1eE6cdCqjOe972w/cYF+FjW34v27+9Vo5106B4M=
|
||||
github.com/jsummers/gobmp v0.0.0-20230614200233-a9de23ed2e25/go.mod h1:kLgvv7o6UM+0QSf0QjAse3wReFDsb9qbZJdfexWlrQw=
|
||||
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 h1:zYyBkD/k9seD2A7fsi6Oo2LfFZAehjjQMERAvZLEDnQ=
|
||||
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646/go.mod h1:jpp1/29i3P1S/RLdc7JQKbRpFeM1dOBd8T9ki5s+AY8=
|
||||
github.com/nicksnyder/go-i18n/v2 v2.5.1 h1:IxtPxYsR9Gp60cGXjfuR/llTqV8aYMsC472zD0D1vHk=
|
||||
github.com/nicksnyder/go-i18n/v2 v2.5.1/go.mod h1:DrhgsSDZxoAfvVrBVLXoxZn/pN5TXqaDbq7ju94viiQ=
|
||||
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs=
|
||||
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
|
||||
github.com/pkg/profile v1.7.0 h1:hnbDkaNWPCLMO9wGLdBFTIZvzDrDfBM2072E1S9gJkA=
|
||||
github.com/pkg/profile v1.7.0/go.mod h1:8Uer0jas47ZQMJ7VD+OHknK4YDY07LPUC6dEvqDjvNo=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/rymdport/portal v0.4.2 h1:7jKRSemwlTyVHHrTGgQg7gmNPJs88xkbKcIL3NlcmSU=
|
||||
github.com/rymdport/portal v0.4.2/go.mod h1:kFF4jslnJ8pD5uCi17brj/ODlfIidOxlgUDTO5ncnC4=
|
||||
github.com/srwiley/oksvg v0.0.0-20221011165216-be6e8873101c h1:km8GpoQut05eY3GiYWEedbTT0qnSxrCjsVbb7yKY1KE=
|
||||
github.com/srwiley/oksvg v0.0.0-20221011165216-be6e8873101c/go.mod h1:cNQ3dwVJtS5Hmnjxy6AgTPd0Inb3pW05ftPSX7NZO7Q=
|
||||
github.com/srwiley/rasterx v0.0.0-20220730225603-2ab79fcdd4ef h1:Ch6Q+AZUxDBCVqdkI8FSpFyZDtCVBc2VmejdNrm5rRQ=
|
||||
github.com/srwiley/rasterx v0.0.0-20220730225603-2ab79fcdd4ef/go.mod h1:nXTWP6+gD5+LUJ8krVhhoeHjvHTutPxMYl5SvkcnJNE=
|
||||
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
|
||||
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
|
||||
github.com/yuin/goldmark v1.7.8 h1:iERMLn0/QJeHFhxSt3p6PeN9mGnvIKSpG9YYorDMnic=
|
||||
github.com/yuin/goldmark v1.7.8/go.mod h1:uzxRWxtg69N339t3louHJ7+O03ezfj6PlliRlaOzY1E=
|
||||
golang.org/x/image v0.24.0 h1:AN7zRgVsbvmTfNyqIbbOraYL8mSwcKncEj8ofjgzcMQ=
|
||||
golang.org/x/image v0.24.0/go.mod h1:4b/ITuLfqYq1hqZcjofwctIhi7sZh2WaCjvsBNjjya8=
|
||||
golang.org/x/net v0.35.0 h1:T5GQRQb2y08kTAByq9L4/bz8cipCdA8FbRTXewonqY8=
|
||||
golang.org/x/net v0.35.0/go.mod h1:EglIi67kWsHKlRzzVMUD93VMSWGFOMSZgxFjparz1Qk=
|
||||
github.com/lxn/walk v0.0.0-20210112085537-c389da54e794 h1:NVRJ0Uy0SOFcXSKLsS65OmI1sgCCfiDUPj+cwnH7GZw=
|
||||
github.com/lxn/walk v0.0.0-20210112085537-c389da54e794/go.mod h1:E23UucZGqpuUANJooIbHWCufXvOcT6E7Stq81gU+CSQ=
|
||||
github.com/lxn/win v0.0.0-20210218163916-a377121e959e h1:H+t6A/QJMbhCSEH5rAuRxh+CtW96g0Or0Fxa9IKr4uc=
|
||||
github.com/lxn/win v0.0.0-20210218163916-a377121e959e/go.mod h1:KxxjdtRkfNoYDCUP5ryK7XJJNTnpC8atvtmTheChOtk=
|
||||
golang.org/x/sys v0.0.0-20201018230417-eeed37f84f13/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.36.0 h1:KVRy2GtZBrk1cBYA7MKu5bEZFxQk4NIDV6RLVcC8o0k=
|
||||
golang.org/x/sys v0.36.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
|
||||
golang.org/x/text v0.23.0 h1:D71I7dUrlY+VX0gQShAThNGHFxZ13dGLBHQLVl1mJlY=
|
||||
golang.org/x/text v0.23.0/go.mod h1:/BLNzu4aZCJ1+kcD0DNRotWKage4q2rGVAg4o22unh4=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f h1:BLraFXnmrev5lT+xlilqcH8XK9/i0At2xKjWk4p6zsU=
|
||||
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/Knetic/govaluate.v3 v3.0.0 h1:18mUyIt4ZlRlFZAAfVetz4/rzlJs9yhN+U02F4u1AOc=
|
||||
gopkg.in/Knetic/govaluate.v3 v3.0.0/go.mod h1:csKLBORsPbafmSCGTEh3U7Ozmsuq8ZSIlKk1bcqph0E=
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
// Package gui implements the Fyne-based graphical interface for xetup.
|
||||
//go:build windows
|
||||
|
||||
// Package gui implements the Walk-based graphical interface for xetup.
|
||||
//
|
||||
// Three phases, one window:
|
||||
// 1. Config form – PC name, product key, profile, step selection,
|
||||
// Three sequential phases, each with its own window:
|
||||
// 1. Config form – PC name, product key, profile, step checkboxes,
|
||||
// load/save config buttons for per-client presets
|
||||
// 2. Live run – real-time log streamed from PowerShell scripts
|
||||
// 3. Summary – per-step OK / ERROR / SKIPPED with elapsed time
|
||||
|
|
@ -11,262 +13,325 @@ import (
|
|||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"fyne.io/fyne/v2"
|
||||
"fyne.io/fyne/v2/app"
|
||||
"fyne.io/fyne/v2/container"
|
||||
"fyne.io/fyne/v2/dialog"
|
||||
"fyne.io/fyne/v2/storage"
|
||||
"fyne.io/fyne/v2/theme"
|
||||
"fyne.io/fyne/v2/widget"
|
||||
"github.com/lxn/walk"
|
||||
. "github.com/lxn/walk/declarative"
|
||||
|
||||
"git.xetup.x9.cz/x9/xetup/internal/config"
|
||||
"git.xetup.x9.cz/x9/xetup/internal/runner"
|
||||
)
|
||||
|
||||
// Run opens the xetup window and blocks until the user closes it.
|
||||
// cfgPath is the default config.json path (next to the exe).
|
||||
func Run(cfg config.Config, runCfg runner.RunConfig, cfgPath string) {
|
||||
// Force software (CPU/GDI) rendering so the app works on VMs and machines
|
||||
// without proper OpenGL support (VMware SVGA, Hyper-V basic display, etc.).
|
||||
// The UI is simple enough that GPU acceleration gives no benefit.
|
||||
os.Setenv("FYNE_RENDERER", "software") //nolint:errcheck
|
||||
|
||||
a := app.New()
|
||||
a.Settings().SetTheme(theme.DarkTheme())
|
||||
|
||||
w := a.NewWindow("xetup — Windows deployment")
|
||||
w.Resize(fyne.NewSize(740, 680))
|
||||
w.SetMaster() // closing this window quits the app
|
||||
|
||||
showForm(w, cfg, runCfg, cfgPath)
|
||||
w.ShowAndRun()
|
||||
for {
|
||||
res := formPhase(cfg, runCfg, cfgPath)
|
||||
switch res.action {
|
||||
case "quit":
|
||||
return
|
||||
case "reload":
|
||||
cfg = res.cfg
|
||||
cfgPath = res.cfgPath
|
||||
case "run":
|
||||
runCfg.ProfileType = res.cfg.Deployment.ProfileType
|
||||
results := runPhase(runCfg, res.steps)
|
||||
donePhase(results)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Phase 1 – Config form
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
func showForm(w fyne.Window, cfg config.Config, runCfg runner.RunConfig, cfgPath string) {
|
||||
// ── Text inputs ─────────────────────────────────────────────────────────
|
||||
pcName := widget.NewEntry()
|
||||
pcName.SetPlaceHolder("napr. NB-KLIENT-01 (prazdne = neprejmenovat)")
|
||||
pcName.SetText(cfg.Deployment.PCName)
|
||||
|
||||
pcDesc := widget.NewEntry()
|
||||
pcDesc.SetPlaceHolder("napr. PC recepce")
|
||||
pcDesc.SetText(cfg.Deployment.PCDescription)
|
||||
|
||||
productKey := widget.NewEntry()
|
||||
productKey.SetPlaceHolder("prazdne = OA3 / GVLK fallback")
|
||||
productKey.SetText(cfg.Activation.ProductKey)
|
||||
|
||||
profileSel := widget.NewSelect([]string{"default", "admin", "user"}, nil)
|
||||
profileSel.SetSelected(cfg.Deployment.ProfileType)
|
||||
|
||||
// ── Step checkboxes ─────────────────────────────────────────────────────
|
||||
items := runner.AllSelectableItems()
|
||||
checks := make([]*widget.Check, len(items))
|
||||
checkObjs := make([]fyne.CanvasObject, len(items))
|
||||
for i, item := range items {
|
||||
c := widget.NewCheck(item.Label, nil)
|
||||
c.SetChecked(itemEnabled(cfg, item))
|
||||
checks[i] = c
|
||||
checkObjs[i] = c
|
||||
type formResult struct {
|
||||
action string // "run", "reload", "quit"
|
||||
cfg config.Config
|
||||
cfgPath string
|
||||
steps []runner.Step
|
||||
}
|
||||
|
||||
stepsScroll := container.NewVScroll(container.NewVBox(checkObjs...))
|
||||
stepsScroll.SetMinSize(fyne.NewSize(0, 290))
|
||||
func formPhase(cfg config.Config, runCfg runner.RunConfig, cfgPath string) formResult {
|
||||
var mw *walk.MainWindow
|
||||
result := formResult{action: "quit", cfgPath: cfgPath}
|
||||
|
||||
var (
|
||||
pcNameLE *walk.LineEdit
|
||||
pcDescLE *walk.LineEdit
|
||||
productKeyLE *walk.LineEdit
|
||||
profileCB *walk.ComboBox
|
||||
)
|
||||
|
||||
items := runner.AllSelectableItems()
|
||||
checkPtrs := make([]*walk.CheckBox, len(items))
|
||||
checkWidgets := make([]Widget, len(items))
|
||||
for i, item := range items {
|
||||
i := i // capture for closure
|
||||
checkWidgets[i] = CheckBox{
|
||||
AssignTo: &checkPtrs[i],
|
||||
Text: item.Label,
|
||||
Checked: itemEnabled(cfg, item),
|
||||
}
|
||||
}
|
||||
|
||||
// ── collectCfg reads current form state into a Config ───────────────────
|
||||
collectCfg := func() config.Config {
|
||||
out := cfg // start from loaded config (preserves fields not shown in form)
|
||||
out.Deployment.PCName = pcName.Text
|
||||
out.Deployment.PCDescription = pcDesc.Text
|
||||
out.Activation.ProductKey = productKey.Text
|
||||
out.Deployment.ProfileType = profileSel.Selected
|
||||
|
||||
out := cfg
|
||||
out.Deployment.PCName = pcNameLE.Text()
|
||||
out.Deployment.PCDescription = pcDescLE.Text()
|
||||
out.Activation.ProductKey = productKeyLE.Text()
|
||||
profiles := []string{"default", "admin", "user"}
|
||||
if idx := profileCB.CurrentIndex(); idx >= 0 && idx < len(profiles) {
|
||||
out.Deployment.ProfileType = profiles[idx]
|
||||
}
|
||||
selected := make(map[string]bool, len(items))
|
||||
for i, item := range items {
|
||||
selected[item.Key] = checks[i].Checked
|
||||
selected[item.Key] = checkPtrs[i].Checked()
|
||||
}
|
||||
_, features := buildStepsAndFeatures(selected)
|
||||
out.Features = features
|
||||
return out
|
||||
}
|
||||
|
||||
// ── Toolbar: Load / Save config ─────────────────────────────────────────
|
||||
jsonFilter := storage.NewExtensionFileFilter([]string{".json"})
|
||||
|
||||
loadBtn := widget.NewButton("Nacist config...", func() {
|
||||
d := dialog.NewFileOpen(func(rc fyne.URIReadCloser, err error) {
|
||||
if err != nil || rc == nil {
|
||||
if err := (MainWindow{
|
||||
AssignTo: &mw,
|
||||
Title: "xetup \u2014 Windows deployment",
|
||||
Size: Size{Width: 760, Height: 740},
|
||||
Layout: VBox{},
|
||||
Children: []Widget{
|
||||
// ── Form fields ──────────────────────────────────────────────────
|
||||
Composite{
|
||||
Layout: Grid{Columns: 2},
|
||||
Children: []Widget{
|
||||
Label{Text: "PC jmeno:"},
|
||||
LineEdit{
|
||||
AssignTo: &pcNameLE,
|
||||
Text: cfg.Deployment.PCName,
|
||||
CueBanner: "napr. NB-KLIENT-01 (prazdne = neprejmenovat)",
|
||||
},
|
||||
Label{Text: "Popis PC:"},
|
||||
LineEdit{
|
||||
AssignTo: &pcDescLE,
|
||||
Text: cfg.Deployment.PCDescription,
|
||||
CueBanner: "napr. PC recepce",
|
||||
},
|
||||
Label{Text: "Product Key:"},
|
||||
LineEdit{
|
||||
AssignTo: &productKeyLE,
|
||||
Text: cfg.Activation.ProductKey,
|
||||
CueBanner: "prazdne = OA3 / GVLK fallback",
|
||||
},
|
||||
Label{Text: "Profil:"},
|
||||
ComboBox{
|
||||
AssignTo: &profileCB,
|
||||
Model: []string{"default", "admin", "user"},
|
||||
CurrentIndex: profileIndex(cfg.Deployment.ProfileType),
|
||||
},
|
||||
},
|
||||
},
|
||||
HSeparator{},
|
||||
// ── Step checkboxes ──────────────────────────────────────────────
|
||||
Label{Text: "Kroky a nastaveni (odskrtnete co nechcete spustit):"},
|
||||
ScrollView{
|
||||
MinSize: Size{Height: 400},
|
||||
Layout: VBox{MarginsZero: true},
|
||||
Children: checkWidgets,
|
||||
},
|
||||
HSeparator{},
|
||||
// ── Buttons ──────────────────────────────────────────────────────
|
||||
Composite{
|
||||
Layout: HBox{MarginsZero: true},
|
||||
Children: []Widget{
|
||||
PushButton{
|
||||
Text: "Nacist config...",
|
||||
OnClicked: func() {
|
||||
dlg := new(walk.FileDialog)
|
||||
dlg.Filter = "JSON soubory (*.json)|*.json|Vsechny soubory (*.*)|*.*"
|
||||
dlg.Title = "Nacist konfiguraci"
|
||||
ok, err := dlg.ShowOpen(mw)
|
||||
if err != nil || !ok {
|
||||
return
|
||||
}
|
||||
defer rc.Close()
|
||||
data, err := io.ReadAll(rc)
|
||||
data, err := os.ReadFile(dlg.FilePath)
|
||||
if err != nil {
|
||||
dialog.ShowError(err, w)
|
||||
walk.MsgBox(mw, "Chyba", err.Error(), walk.MsgBoxIconError)
|
||||
return
|
||||
}
|
||||
newCfg := config.DefaultConfig()
|
||||
if err := json.Unmarshal(data, &newCfg); err != nil {
|
||||
dialog.ShowError(err, w)
|
||||
walk.MsgBox(mw, "Chyba", err.Error(), walk.MsgBoxIconError)
|
||||
return
|
||||
}
|
||||
// Reload the entire form with the new config
|
||||
showForm(w, newCfg, runCfg, rc.URI().Path())
|
||||
}, w)
|
||||
d.SetFilter(jsonFilter)
|
||||
d.Show()
|
||||
})
|
||||
|
||||
saveBtn := widget.NewButton("Ulozit config...", func() {
|
||||
d := dialog.NewFileSave(func(wc fyne.URIWriteCloser, err error) {
|
||||
if err != nil || wc == nil {
|
||||
result = formResult{
|
||||
action: "reload",
|
||||
cfg: newCfg,
|
||||
cfgPath: dlg.FilePath,
|
||||
}
|
||||
mw.Close()
|
||||
},
|
||||
},
|
||||
PushButton{
|
||||
Text: "Ulozit config...",
|
||||
OnClicked: func() {
|
||||
dlg := new(walk.FileDialog)
|
||||
dlg.Filter = "JSON soubory (*.json)|*.json|Vsechny soubory (*.*)|*.*"
|
||||
dlg.Title = "Ulozit konfiguraci"
|
||||
dlg.FilePath = "config.json"
|
||||
ok, err := dlg.ShowSave(mw)
|
||||
if err != nil || !ok {
|
||||
return
|
||||
}
|
||||
defer wc.Close()
|
||||
data, err := json.MarshalIndent(collectCfg(), "", " ")
|
||||
if err != nil {
|
||||
dialog.ShowError(err, w)
|
||||
walk.MsgBox(mw, "Chyba", err.Error(), walk.MsgBoxIconError)
|
||||
return
|
||||
}
|
||||
if _, err := wc.Write(data); err != nil {
|
||||
dialog.ShowError(err, w)
|
||||
if err := os.WriteFile(dlg.FilePath, data, 0644); err != nil {
|
||||
walk.MsgBox(mw, "Chyba", err.Error(), walk.MsgBoxIconError)
|
||||
}
|
||||
}, w)
|
||||
d.SetFilter(jsonFilter)
|
||||
d.SetFileName("config.json")
|
||||
d.Show()
|
||||
})
|
||||
|
||||
// ── SPUSTIT ─────────────────────────────────────────────────────────────
|
||||
startBtn := widget.NewButton(" SPUSTIT ", func() {
|
||||
},
|
||||
},
|
||||
HSpacer{},
|
||||
PushButton{
|
||||
Text: " SPUSTIT ",
|
||||
OnClicked: func() {
|
||||
finalCfg := collectCfg()
|
||||
runCfg.ProfileType = finalCfg.Deployment.ProfileType
|
||||
|
||||
selected := make(map[string]bool, len(items))
|
||||
for i, item := range items {
|
||||
selected[item.Key] = checks[i].Checked
|
||||
selected[item.Key] = checkPtrs[i].Checked()
|
||||
}
|
||||
steps, features := buildStepsAndFeatures(selected)
|
||||
finalCfg.Features = features
|
||||
_ = config.Save(finalCfg, cfgPath)
|
||||
result = formResult{
|
||||
action: "run",
|
||||
cfg: finalCfg,
|
||||
cfgPath: cfgPath,
|
||||
steps: steps,
|
||||
}
|
||||
mw.Close()
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}.Create()); err != nil {
|
||||
walk.MsgBox(nil, "Chyba", fmt.Sprintf("Nelze vytvorit okno: %v", err), walk.MsgBoxIconError)
|
||||
return result
|
||||
}
|
||||
|
||||
_ = config.Save(finalCfg, cfgPath) // auto-save to default path
|
||||
|
||||
showRun(w, runCfg, steps)
|
||||
})
|
||||
startBtn.Importance = widget.HighImportance
|
||||
|
||||
// ── Layout ───────────────────────────────────────────────────────────────
|
||||
form := widget.NewForm(
|
||||
widget.NewFormItem("PC jmeno", pcName),
|
||||
widget.NewFormItem("Popis PC", pcDesc),
|
||||
widget.NewFormItem("Product Key", productKey),
|
||||
widget.NewFormItem("Profil", profileSel),
|
||||
)
|
||||
|
||||
toolbar := container.NewHBox(loadBtn, saveBtn)
|
||||
|
||||
w.SetContent(container.NewBorder(
|
||||
form,
|
||||
container.NewVBox(
|
||||
widget.NewSeparator(),
|
||||
container.NewBorder(nil, nil, toolbar, container.NewCenter(startBtn)),
|
||||
),
|
||||
nil, nil,
|
||||
container.NewVBox(
|
||||
widget.NewSeparator(),
|
||||
widget.NewLabel("Kroky a nastaveni (odskrtnete co nechcete spustit):"),
|
||||
stepsScroll,
|
||||
),
|
||||
))
|
||||
mw.Run()
|
||||
return result
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Phase 2 – Live run view
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
func showRun(w fyne.Window, runCfg runner.RunConfig, steps []runner.Step) {
|
||||
statusLabel := widget.NewLabel("Spoustim...")
|
||||
|
||||
// Virtualised list – efficient for thousands of log lines
|
||||
func runPhase(runCfg runner.RunConfig, steps []runner.Step) []runner.Result {
|
||||
var (
|
||||
mu sync.Mutex
|
||||
logLines []string
|
||||
mw *walk.MainWindow
|
||||
statusLbl *walk.Label
|
||||
logTE *walk.TextEdit
|
||||
cancelFn context.CancelFunc
|
||||
)
|
||||
|
||||
logList := widget.NewList(
|
||||
func() int {
|
||||
mu.Lock()
|
||||
defer mu.Unlock()
|
||||
return len(logLines)
|
||||
if err := (MainWindow{
|
||||
AssignTo: &mw,
|
||||
Title: "xetup \u2014 probiha instalace",
|
||||
Size: Size{Width: 760, Height: 740},
|
||||
Layout: VBox{},
|
||||
Children: []Widget{
|
||||
Label{AssignTo: &statusLbl, Text: "Spoustim..."},
|
||||
HSeparator{},
|
||||
TextEdit{
|
||||
AssignTo: &logTE,
|
||||
ReadOnly: true,
|
||||
VScroll: true,
|
||||
Font: Font{Family: "Consolas", PointSize: 9},
|
||||
MinSize: Size{Height: 590},
|
||||
},
|
||||
func() fyne.CanvasObject {
|
||||
return widget.NewLabel("")
|
||||
},
|
||||
func(id widget.ListItemID, obj fyne.CanvasObject) {
|
||||
mu.Lock()
|
||||
defer mu.Unlock()
|
||||
if id < len(logLines) {
|
||||
obj.(*widget.Label).SetText(logLines[id])
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
var cancelFn context.CancelFunc
|
||||
|
||||
stopBtn := widget.NewButton(" ZASTAVIT ", func() {
|
||||
HSeparator{},
|
||||
Composite{
|
||||
Layout: HBox{MarginsZero: true},
|
||||
Children: []Widget{
|
||||
HSpacer{},
|
||||
PushButton{
|
||||
Text: " ZASTAVIT ",
|
||||
OnClicked: func() {
|
||||
if cancelFn != nil {
|
||||
cancelFn()
|
||||
}
|
||||
})
|
||||
stopBtn.Importance = widget.DangerImportance
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}.Create()); err != nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
w.SetContent(container.NewBorder(
|
||||
container.NewVBox(statusLabel, widget.NewSeparator()),
|
||||
container.NewCenter(container.NewPadded(stopBtn)),
|
||||
nil, nil,
|
||||
logList,
|
||||
))
|
||||
var (
|
||||
mu sync.Mutex
|
||||
results []runner.Result
|
||||
done = make(chan struct{})
|
||||
)
|
||||
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
cancelFn = cancel
|
||||
|
||||
// Cancel running scripts when user closes the window.
|
||||
mw.Closing().Attach(func(_ *bool, _ walk.CloseReason) {
|
||||
cancelFn()
|
||||
})
|
||||
|
||||
r := runner.New(
|
||||
runCfg,
|
||||
func(l runner.LogLine) {
|
||||
mu.Lock()
|
||||
logLines = append(logLines, l.Text)
|
||||
mu.Unlock()
|
||||
logList.Refresh()
|
||||
logList.ScrollToBottom()
|
||||
mw.Synchronize(func() {
|
||||
logTE.AppendText(l.Text + "\r\n")
|
||||
})
|
||||
},
|
||||
func(res runner.Result) {
|
||||
statusLabel.SetText(fmt.Sprintf(
|
||||
"Krok %s – %s: %s", res.Step.Num, res.Step.Name, res.Status,
|
||||
mw.Synchronize(func() {
|
||||
statusLbl.SetText(fmt.Sprintf(
|
||||
"Krok %s \u2013 %s: %s", res.Step.Num, res.Step.Name, res.Status,
|
||||
))
|
||||
})
|
||||
},
|
||||
)
|
||||
|
||||
go func() {
|
||||
results := r.Run(ctx, steps)
|
||||
showDone(w, results)
|
||||
defer close(done)
|
||||
res := r.Run(ctx, steps)
|
||||
mu.Lock()
|
||||
results = res
|
||||
mu.Unlock()
|
||||
mw.Synchronize(func() {
|
||||
mw.Close()
|
||||
})
|
||||
}()
|
||||
|
||||
mw.Run()
|
||||
cancel() // stop scripts if window was closed by user
|
||||
<-done // wait for goroutine to exit cleanly
|
||||
|
||||
mu.Lock()
|
||||
defer mu.Unlock()
|
||||
return results
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Phase 3 – Summary
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
func showDone(w fyne.Window, results []runner.Result) {
|
||||
func donePhase(results []runner.Result) {
|
||||
var mw *walk.MainWindow
|
||||
|
||||
ok, errs, skipped := 0, 0, 0
|
||||
rows := make([]fyne.CanvasObject, 0, len(results))
|
||||
rows := make([]Widget, 0, len(results))
|
||||
|
||||
for _, res := range results {
|
||||
var icon string
|
||||
|
|
@ -279,42 +344,68 @@ func showDone(w fyne.Window, results []runner.Result) {
|
|||
icon = "ERR "
|
||||
default:
|
||||
skipped++
|
||||
icon = "– "
|
||||
icon = "\u2013 "
|
||||
}
|
||||
text := icon + res.Step.Num + " – " + res.Step.Name
|
||||
text := icon + res.Step.Num + " \u2013 " + res.Step.Name
|
||||
if res.Elapsed > 0 {
|
||||
text += fmt.Sprintf(" (%s)", res.Elapsed.Round(time.Second))
|
||||
}
|
||||
rows = append(rows, widget.NewLabel(text))
|
||||
rows = append(rows, Label{
|
||||
Text: text,
|
||||
Font: Font{Family: "Consolas", PointSize: 9},
|
||||
})
|
||||
}
|
||||
|
||||
summary := widget.NewLabel(fmt.Sprintf(
|
||||
"OK: %d CHYBY: %d PRESKOCENO: %d", ok, errs, skipped,
|
||||
))
|
||||
summary.TextStyle = fyne.TextStyle{Bold: true}
|
||||
summaryText := fmt.Sprintf("OK: %d CHYBY: %d PRESKOCENO: %d", ok, errs, skipped)
|
||||
|
||||
closeBtn := widget.NewButton(" ZAVRIT ", func() {
|
||||
fyne.CurrentApp().Quit()
|
||||
})
|
||||
if err := (MainWindow{
|
||||
AssignTo: &mw,
|
||||
Title: "xetup \u2014 hotovo",
|
||||
Size: Size{Width: 760, Height: 740},
|
||||
Layout: VBox{},
|
||||
Children: []Widget{
|
||||
Label{
|
||||
Text: "Hotovo",
|
||||
Alignment: AlignHCenterVNear,
|
||||
Font: Font{Bold: true, PointSize: 12},
|
||||
},
|
||||
HSeparator{},
|
||||
ScrollView{
|
||||
MinSize: Size{Height: 560},
|
||||
Layout: VBox{MarginsZero: true},
|
||||
Children: rows,
|
||||
},
|
||||
HSeparator{},
|
||||
Label{
|
||||
Text: summaryText,
|
||||
Alignment: AlignHCenterVNear,
|
||||
Font: Font{Bold: true},
|
||||
},
|
||||
Composite{
|
||||
Layout: HBox{MarginsZero: true},
|
||||
Children: []Widget{
|
||||
HSpacer{},
|
||||
PushButton{
|
||||
Text: " ZAVRIT ",
|
||||
OnClicked: func() {
|
||||
mw.Close()
|
||||
},
|
||||
},
|
||||
HSpacer{},
|
||||
},
|
||||
},
|
||||
},
|
||||
}.Create()); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
w.SetContent(container.NewBorder(
|
||||
widget.NewLabelWithStyle("Hotovo", fyne.TextAlignCenter, fyne.TextStyle{Bold: true}),
|
||||
container.NewVBox(
|
||||
widget.NewSeparator(),
|
||||
container.NewCenter(summary),
|
||||
container.NewCenter(container.NewPadded(closeBtn)),
|
||||
),
|
||||
nil, nil,
|
||||
container.NewVScroll(container.NewVBox(rows...)),
|
||||
))
|
||||
mw.Run()
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Helpers
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
// itemEnabled returns the initial checked state for a checkbox row,
|
||||
// reading from the loaded config (defaults to true / enabled when absent).
|
||||
func itemEnabled(cfg config.Config, item runner.SelectableItem) bool {
|
||||
if item.FeatureID == "" {
|
||||
if v, ok := cfg.Steps[item.StepID]; ok {
|
||||
|
|
@ -330,8 +421,6 @@ func itemEnabled(cfg config.Config, item runner.SelectableItem) bool {
|
|||
return true
|
||||
}
|
||||
|
||||
// buildStepsAndFeatures converts the flat checkbox map into the structures
|
||||
// that runner.Runner and config.Config expect.
|
||||
func buildStepsAndFeatures(selected map[string]bool) ([]runner.Step, config.Features) {
|
||||
items := runner.AllSelectableItems()
|
||||
features := make(config.Features)
|
||||
|
|
@ -339,10 +428,8 @@ func buildStepsAndFeatures(selected map[string]bool) ([]runner.Step, config.Feat
|
|||
|
||||
for _, item := range items {
|
||||
if item.FeatureID == "" {
|
||||
// Simple step: enabled iff its own checkbox is checked
|
||||
stepOn[item.StepID] = selected[item.Key]
|
||||
} else {
|
||||
// Feature checkbox: at least one checked feature enables the step
|
||||
if features[item.StepID] == nil {
|
||||
features[item.StepID] = make(map[string]bool)
|
||||
}
|
||||
|
|
@ -361,3 +448,14 @@ func buildStepsAndFeatures(selected map[string]bool) ([]runner.Step, config.Feat
|
|||
}
|
||||
return steps, features
|
||||
}
|
||||
|
||||
func profileIndex(p string) int {
|
||||
switch p {
|
||||
case "admin":
|
||||
return 1
|
||||
case "user":
|
||||
return 2
|
||||
default:
|
||||
return 0
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue