feat: update button (download, verify, stage)

This commit is contained in:
fsylvain committed 2026-10-01 18:13:45 +02:00
1 parent 834493a4f5
commit 70460e4170
41 files changed
+5345 -97

No files matched your search

@@ -4,17 +4,29 @@ import "RenewCMS/internal/domain/update"
type GetUpdateStatusUseCase struct {
store update.StatusStore
jobs update.JobStore
helper update.HelperDetector
currentVersion string
}
func NewGetUpdateStatusUseCase(store update.StatusStore, currentVersion string) *GetUpdateStatusUseCase {
return &GetUpdateStatusUseCase{store: store, currentVersion: currentVersion}
func NewGetUpdateStatusUseCase(store update.StatusStore, jobs update.JobStore, helper update.HelperDetector, currentVersion string) *GetUpdateStatusUseCase {
return &GetUpdateStatusUseCase{store: store, jobs: jobs, helper: helper, currentVersion: currentVersion}
}
func (g *GetUpdateStatusUseCase) GetStatus() update.UpdateStatus {
result, found := g.store.Load()
if !found {
return update.NewStatus(g.currentVersion, nil)
func (g *GetUpdateStatusUseCase) GetStatus(isOwner bool) update.UpdateStatus {
return buildUpdateStatus(g.store, g.jobs, g.currentVersion, isOwner && g.helper.Installed())
}
func buildUpdateStatus(store update.StatusStore, jobs update.JobStore, currentVersion string, canApply bool) update.UpdateStatus {
var status update.UpdateStatus
if result, found := store.Load(); found {
status = update.NewStatus(currentVersion, &result)
} else {
status = update.NewStatus(currentVersion, nil)
}
return update.NewStatus(g.currentVersion, &result)
if job, found := jobs.Load(); found {
status = status.WithJob(job)
}
status.CanApply = canApply
return status
}