MCPcopy Create free account
hub / github.com/devnullvoid/pvetui / refreshVMSelection

Method refreshVMSelection

internal/ui/components/search.go:189–217  ·  view source on GitHub ↗
(currentPage string)

Source from the content-addressed store, hash-verified

187}
188
189func (a *App) refreshVMSelection(currentPage string) {
190 // Update VM list with filtered VMs
191 a.vmList.SetVMs(models.GlobalState.FilteredVMs)
192
193 // Update selected index if needed
194 if len(models.GlobalState.FilteredVMs) > 0 {
195 idx := 0
196 if state, exists := models.GlobalState.SearchStates[currentPage]; exists {
197 idx = state.SelectedIndex
198 if idx < 0 || idx >= len(models.GlobalState.FilteredVMs) {
199 idx = 0
200 }
201
202 state.SelectedIndex = idx
203 }
204
205 a.vmList.SetCurrentItem(idx)
206 // Manually trigger the VM changed callback to update details
207 if selectedVM := a.vmList.GetSelectedVM(); selectedVM != nil {
208 a.vmDetails.Update(selectedVM)
209 }
210 } else {
211 a.vmDetails.Clear()
212
213 if state, exists := models.GlobalState.SearchStates[currentPage]; exists {
214 state.SelectedIndex = 0
215 }
216 }
217}
218
219func uniqueSortedVMStatuses(vms []*api.VM) []string {
220 set := map[string]struct{}{}

Callers 2

activateSearchMethod · 0.95

Calls 5

SetVMsMethod · 0.65
SetCurrentItemMethod · 0.65
GetSelectedVMMethod · 0.65
UpdateMethod · 0.65
ClearMethod · 0.65

Tested by

no test coverage detected