()
| 129 | } |
| 130 | |
| 131 | func (m snapshotDeleteModel) View() string { |
| 132 | if m.err != nil { |
| 133 | return errorStyleTUI.Render(fmt.Sprintf("✗ Error: %v\n", m.err)) |
| 134 | } |
| 135 | |
| 136 | if m.quitting { |
| 137 | return "" |
| 138 | } |
| 139 | |
| 140 | if m.step == snapshotDeleteStepComplete { |
| 141 | return "" |
| 142 | } |
| 143 | |
| 144 | var s strings.Builder |
| 145 | |
| 146 | s.WriteString(m.styles.Title.Render("⚡ Delete Snapshot")) |
| 147 | s.WriteString("\n\n") |
| 148 | |
| 149 | switch m.step { |
| 150 | case snapshotDeleteStepSelect: |
| 151 | s.WriteString("Select a snapshot to delete:\n\n") |
| 152 | |
| 153 | for i, snapshot := range m.snapshots { |
| 154 | cursor := " " |
| 155 | if m.cursor == i { |
| 156 | cursor = m.styles.Cursor.Render("▶ ") |
| 157 | } |
| 158 | |
| 159 | // Determine status style |
| 160 | var statusStyle lipgloss.Style |
| 161 | status := snapshot.Status |
| 162 | switch status { |
| 163 | case "READY": |
| 164 | statusStyle = SuccessStyle() |
| 165 | case "CREATING": |
| 166 | statusStyle = WarningStyle() |
| 167 | case "FAILED": |
| 168 | statusStyle = ErrorStyle() |
| 169 | default: |
| 170 | statusStyle = lipgloss.NewStyle() |
| 171 | } |
| 172 | |
| 173 | createdTime := time.Unix(snapshot.CreatedAt, 0) |
| 174 | display := fmt.Sprintf("%s - %s - %d GB", |
| 175 | snapshot.Name, |
| 176 | createdTime.Format("2006-01-02 15:04"), |
| 177 | snapshot.MinimumDiskSizeGB, |
| 178 | ) |
| 179 | if m.cursor == i { |
| 180 | display = m.styles.Selected.Render(display) |
| 181 | } |
| 182 | |
| 183 | statusText := statusStyle.Render(fmt.Sprintf("(%s)", status)) |
| 184 | |
| 185 | s.WriteString(fmt.Sprintf("%s%s %s\n", cursor, display, statusText)) |
| 186 | } |
| 187 | |
| 188 | s.WriteString("\n") |
no test coverage detected