Implement authorization import and revocation checks (T-503)

This commit is contained in:
ila
2026-07-20 09:07:30 +08:00
parent b4453130de
commit 76f6108496
36 changed files with 2197 additions and 68 deletions
+39 -10
View File
@@ -24,19 +24,25 @@ type AppShell struct {
viewAll widget.Clickable
viewInstalled widget.Clickable
viewUpdates widget.Clickable
viewLicense widget.Clickable
resetFilters widget.Clickable
closeDetail widget.Clickable
importLicense widget.Clickable
categoryControls map[string]*widget.Clickable
rows map[string]*rowControls
icons map[string]paint.ImageOp
iconReferences map[string]string
iconRequests map[string]application.IconEventIdentity
iconApplied map[string]application.IconEventIdentity
iconFailures map[string]iconFailureState
catalogState catalogPresentationState
lastRendered int
detailRendered bool
categoryControls map[string]*widget.Clickable
rows map[string]*rowControls
icons map[string]paint.ImageOp
iconReferences map[string]string
iconRequests map[string]application.IconEventIdentity
iconApplied map[string]application.IconEventIdentity
iconFailures map[string]iconFailureState
catalogState catalogPresentationState
authorization application.AuthorizationSnapshot
authorizationLoaded bool
showLicense bool
licenseImportRequested bool
lastRendered int
detailRendered bool
}
// NewAppShell creates the catalog shell with an optional in-memory snapshot.
@@ -56,6 +62,7 @@ func NewAppShell(
iconRequests: make(map[string]application.IconEventIdentity),
iconApplied: make(map[string]application.IconEventIdentity),
iconFailures: make(map[string]iconFailureState),
authorization: application.AuthorizationSnapshot{Products: []application.AuthorizedProduct{}},
}
shell.search.SingleLine = true
shell.SetItems(items)
@@ -164,14 +171,26 @@ func (shell *AppShell) drainInput(gtx layout.Context) {
shell.model.SetQuery(shell.search.Text())
for shell.viewAll.Clicked(gtx) {
shell.showLicense = false
shell.model.SetView(application.CatalogViewAll)
}
for shell.viewInstalled.Clicked(gtx) {
shell.showLicense = false
shell.model.SetView(application.CatalogViewInstalled)
}
for shell.viewUpdates.Clicked(gtx) {
shell.showLicense = false
shell.model.SetView(application.CatalogViewUpdates)
}
for shell.viewLicense.Clicked(gtx) {
shell.showLicense = true
shell.model.Select("")
}
for shell.importLicense.Clicked(gtx) {
if shell.canImportLicense() {
shell.licenseImportRequested = true
}
}
for category, control := range shell.categoryControls {
for control.Clicked(gtx) {
shell.model.SetCategory(category)
@@ -190,3 +209,13 @@ func (shell *AppShell) drainInput(gtx layout.Context) {
shell.model.Select("")
}
}
// TakeLicenseImportRequest consumes one UI-only import request. Composition
// must perform any picker, file I/O and verification in a background task.
func (shell *AppShell) TakeLicenseImportRequest() bool {
if shell == nil || !shell.licenseImportRequested {
return false
}
shell.licenseImportRequested = false
return true
}