mirror of
https://github.com/jesseduffield/lazydocker.git
synced 2026-07-25 08:31:03 +00:00
better name: GetTableCells
This commit is contained in:
parent
d6ad538426
commit
7324254414
7 changed files with 18 additions and 15 deletions
|
|
@ -95,7 +95,7 @@ func (gui *Gui) getContainersPanel() *panels.SideListPanel[*commands.Container]
|
||||||
|
|
||||||
return true
|
return true
|
||||||
},
|
},
|
||||||
GetDisplayStrings: presentation.GetContainerDisplayStrings,
|
GetTableCells: presentation.GetContainerDisplayStrings,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,7 @@ func (gui *Gui) getImagesPanel() *panels.SideListPanel[*commands.Image] {
|
||||||
|
|
||||||
return a.ID < b.ID
|
return a.ID < b.ID
|
||||||
},
|
},
|
||||||
GetDisplayStrings: presentation.GetImageDisplayStrings,
|
GetTableCells: presentation.GetImageDisplayStrings,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,11 +19,11 @@ func (gui *Gui) getMenuPanel() *panels.SideListPanel[*types.MenuItem] {
|
||||||
List: panels.NewFilteredList[*types.MenuItem](),
|
List: panels.NewFilteredList[*types.MenuItem](),
|
||||||
View: gui.Views.Menu,
|
View: gui.Views.Menu,
|
||||||
},
|
},
|
||||||
NoItemsMessage: "",
|
NoItemsMessage: "",
|
||||||
Gui: gui.intoInterface(),
|
Gui: gui.intoInterface(),
|
||||||
OnClick: gui.onMenuPress,
|
OnClick: gui.onMenuPress,
|
||||||
Sort: nil,
|
Sort: nil,
|
||||||
GetDisplayStrings: presentation.GetMenuItemDisplayStrings,
|
GetTableCells: presentation.GetMenuItemDisplayStrings,
|
||||||
OnRerender: func() error {
|
OnRerender: func() error {
|
||||||
return gui.resizePopupPanel(gui.Views.Menu)
|
return gui.resizePopupPanel(gui.Views.Menu)
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -35,16 +35,19 @@ type SideListPanel[T comparable] struct {
|
||||||
// and it has focus. Leave empty if you don't want to render anything
|
// and it has focus. Leave empty if you don't want to render anything
|
||||||
NoItemsMessage string
|
NoItemsMessage string
|
||||||
|
|
||||||
|
// a representation of the gui
|
||||||
Gui IGui
|
Gui IGui
|
||||||
|
|
||||||
// this Filter is applied on top of additional default filters
|
// this Filter is applied on top of additional default filters
|
||||||
Filter func(T) bool
|
Filter func(T) bool
|
||||||
Sort func(a, b T) bool
|
Sort func(a, b T) bool
|
||||||
|
|
||||||
|
// a callback to invoke when the item is clicked
|
||||||
OnClick func(T) error
|
OnClick func(T) error
|
||||||
|
|
||||||
// returns the columns that we render to the view in a table formats
|
// returns the cells that we render to the view in a table format. The cells will
|
||||||
GetDisplayStrings func(T) []string
|
// be rendered with padding.
|
||||||
|
GetTableCells func(T) []string
|
||||||
|
|
||||||
// function to be called after re-rendering list. Can be nil
|
// function to be called after re-rendering list. Can be nil
|
||||||
OnRerender func() error
|
OnRerender func() error
|
||||||
|
|
@ -192,7 +195,7 @@ func (self *SideListPanel[T]) FilterAndSort() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if lo.SomeBy(self.Gui.IgnoreStrings(), func(ignore string) bool {
|
if lo.SomeBy(self.Gui.IgnoreStrings(), func(ignore string) bool {
|
||||||
return lo.SomeBy(self.GetDisplayStrings(item), func(searchString string) bool {
|
return lo.SomeBy(self.GetTableCells(item), func(searchString string) bool {
|
||||||
return strings.Contains(searchString, ignore)
|
return strings.Contains(searchString, ignore)
|
||||||
})
|
})
|
||||||
}) {
|
}) {
|
||||||
|
|
@ -200,7 +203,7 @@ func (self *SideListPanel[T]) FilterAndSort() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if filterString != "" {
|
if filterString != "" {
|
||||||
return lo.SomeBy(self.GetDisplayStrings(item), func(searchString string) bool {
|
return lo.SomeBy(self.GetTableCells(item), func(searchString string) bool {
|
||||||
return strings.Contains(searchString, filterString)
|
return strings.Contains(searchString, filterString)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
@ -219,7 +222,7 @@ func (self *SideListPanel[T]) RerenderList() error {
|
||||||
self.Gui.Update(func() error {
|
self.Gui.Update(func() error {
|
||||||
self.View.Clear()
|
self.View.Clear()
|
||||||
table := lo.Map(self.List.GetItems(), func(item T, index int) []string {
|
table := lo.Map(self.List.GetItems(), func(item T, index int) []string {
|
||||||
return self.GetDisplayStrings(item)
|
return self.GetTableCells(item)
|
||||||
})
|
})
|
||||||
renderedTable, err := utils.RenderTable(table)
|
renderedTable, err := utils.RenderTable(table)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
|
|
@ -64,7 +64,7 @@ func (gui *Gui) getProjectPanel() *panels.SideListPanel[*commands.Project] {
|
||||||
Sort: func(a *commands.Project, b *commands.Project) bool {
|
Sort: func(a *commands.Project, b *commands.Project) bool {
|
||||||
return false
|
return false
|
||||||
},
|
},
|
||||||
GetDisplayStrings: presentation.GetProjectDisplayStrings,
|
GetTableCells: presentation.GetProjectDisplayStrings,
|
||||||
// It doesn't make sense to filter a list of only one item.
|
// It doesn't make sense to filter a list of only one item.
|
||||||
DisableFilter: true,
|
DisableFilter: true,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -72,7 +72,7 @@ func (gui *Gui) getServicesPanel() *panels.SideListPanel[*commands.Service] {
|
||||||
|
|
||||||
return a.Name < b.Name
|
return a.Name < b.Name
|
||||||
},
|
},
|
||||||
GetDisplayStrings: presentation.GetServiceDisplayStrings,
|
GetTableCells: presentation.GetServiceDisplayStrings,
|
||||||
Hide: func() bool {
|
Hide: func() bool {
|
||||||
return !gui.DockerCommand.InDockerComposeProject
|
return !gui.DockerCommand.InDockerComposeProject
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@ func (gui *Gui) getVolumesPanel() *panels.SideListPanel[*commands.Volume] {
|
||||||
}
|
}
|
||||||
return a.Name < b.Name
|
return a.Name < b.Name
|
||||||
},
|
},
|
||||||
GetDisplayStrings: presentation.GetVolumeDisplayStrings,
|
GetTableCells: presentation.GetVolumeDisplayStrings,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue