| 1 | package control |
| 2 | |
| 3 | import "reasonix/internal/jobs" |
| 4 | |
| 5 | // ModelApplicationDetails contains only user-facing state; never credentials, |
| 6 | // request bodies, internal paths, or mutable resolver configuration. |
| 7 | type ModelApplicationDetails struct { |
| 8 | Code string `json:"code"` |
| 9 | RuntimeIdentity string `json:"runtimeIdentity"` |
| 10 | ConfirmationToken string `json:"confirmationToken,omitempty"` |
| 11 | AppliedRevision string `json:"appliedRevision"` |
| 12 | DesiredRevision string `json:"desiredRevision"` |
| 13 | Model string `json:"model"` |
| 14 | ConnectionTarget string `json:"connectionTarget,omitempty"` |
| 15 | BlockingJobs []jobs.View `json:"blockingJobs"` |
| 16 | CanUseApplied bool `json:"canUseApplied"` |
| 17 | ContinuationUnavailable string `json:"continuationUnavailable,omitempty"` |
| 18 | Applying bool `json:"applying"` |
| 19 | AvailableActions []string `json:"availableActions"` |
| 20 | } |
| 21 | |
| 22 | func (d *ModelApplicationDetails) SetAvailableActions() { |
| 23 | d.AvailableActions = []string{} |
| 24 | if d.Applying { |
| 25 | return |
| 26 | } |
| 27 | d.AvailableActions = append(d.AvailableActions, "retry") |
| 28 | if len(d.BlockingJobs) > 0 { |
| 29 | d.AvailableActions = append(d.AvailableActions, "view_blockers", "stop_selected") |
| 30 | } |
| 31 | if d.CanUseApplied { |
| 32 | d.AvailableActions = append(d.AvailableActions, "applied_once") |
| 33 | } |
| 34 | } |
| 35 |