()
| 170 | } |
| 171 | |
| 172 | func (m snapshotListModel) View() string { |
| 173 | if m.err != nil { |
| 174 | return errorStyleTUI.Render(fmt.Sprintf("✗ Error: %v\n", m.err)) |
| 175 | } |
| 176 | |
| 177 | var b strings.Builder |
| 178 | |
| 179 | b.WriteString(m.renderTable()) |
| 180 | b.WriteString("\n") |
| 181 | |
| 182 | if m.hasCreatingSnapshots() { |
| 183 | b.WriteString(primaryStyle.Render("Snapshot creation can take anywhere from 10 to 90 minutes.")) |
| 184 | b.WriteString("\n") |
| 185 | b.WriteString(primaryStyle.Render("You can delete your instance and snapshotting will continue in the background.")) |
| 186 | b.WriteString("\n\n") |
| 187 | } |
| 188 | |
| 189 | if m.quitting { |
| 190 | timestamp := m.lastUpdate.Format("15:04:05") |
| 191 | b.WriteString(m.styles.timestamp.Render(fmt.Sprintf("Last updated: %s", timestamp))) |
| 192 | b.WriteString("\n") |
| 193 | return b.String() |
| 194 | } |
| 195 | |
| 196 | if m.monitoring { |
| 197 | ts := m.lastUpdate.Format("15:04:05") |
| 198 | b.WriteString(m.styles.timestamp.Render(fmt.Sprintf("Last updated: %s", ts))) |
| 199 | b.WriteString(" ") |
| 200 | b.WriteString(m.spinner.View()) |
| 201 | b.WriteString("\n") |
| 202 | } |
| 203 | |
| 204 | if m.err != nil { |
| 205 | b.WriteString(errorStyleTUI.Render(fmt.Sprintf("✗ Error: %v\n", m.err))) |
| 206 | } |
| 207 | if m.cancelled { |
| 208 | b.WriteString(warningStyleTUI.Render("⚠ Cancelled\n")) |
| 209 | } |
| 210 | |
| 211 | b.WriteString("\n") |
| 212 | if m.quitting { |
| 213 | b.WriteString(helpStyleTUI.Render("Closing...\n")) |
| 214 | } else if m.monitoring { |
| 215 | b.WriteString(helpStyleTUI.Render("Press 'Q' to cancel monitoring\n")) |
| 216 | } else { |
| 217 | b.WriteString(helpStyleTUI.Render("Press 'Q' to close\n")) |
| 218 | } |
| 219 | |
| 220 | return b.String() |
| 221 | } |
| 222 | |
| 223 | func (m snapshotListModel) renderTable() string { |
| 224 | if len(m.snapshots) == 0 { |
nothing calls this directly
no test coverage detected