mirror of
https://github.com/jesseduffield/lazydocker.git
synced 2026-07-21 23:01: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
|
||||
},
|
||||
GetDisplayStrings: presentation.GetContainerDisplayStrings,
|
||||
GetTableCells: presentation.GetContainerDisplayStrings,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ func (gui *Gui) getImagesPanel() *panels.SideListPanel[*commands.Image] {
|
|||
|
||||
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](),
|
||||
View: gui.Views.Menu,
|
||||
},
|
||||
NoItemsMessage: "",
|
||||
Gui: gui.intoInterface(),
|
||||
OnClick: gui.onMenuPress,
|
||||
Sort: nil,
|
||||
GetDisplayStrings: presentation.GetMenuItemDisplayStrings,
|
||||
NoItemsMessage: "",
|
||||
Gui: gui.intoInterface(),
|
||||
OnClick: gui.onMenuPress,
|
||||
Sort: nil,
|
||||
GetTableCells: presentation.GetMenuItemDisplayStrings,
|
||||
OnRerender: func() error {
|
||||
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
|
||||
NoItemsMessage string
|
||||
|
||||
// a representation of the gui
|
||||
Gui IGui
|
||||
|
||||
// this Filter is applied on top of additional default filters
|
||||
Filter func(T) bool
|
||||
Sort func(a, b T) bool
|
||||
|
||||
// a callback to invoke when the item is clicked
|
||||
OnClick func(T) error
|
||||
|
||||
// returns the columns that we render to the view in a table formats
|
||||
GetDisplayStrings func(T) []string
|
||||
// returns the cells that we render to the view in a table format. The cells will
|
||||
// be rendered with padding.
|
||||
GetTableCells func(T) []string
|
||||
|
||||
// function to be called after re-rendering list. Can be nil
|
||||
OnRerender func() error
|
||||
|
|
@ -192,7 +195,7 @@ func (self *SideListPanel[T]) FilterAndSort() {
|
|||
}
|
||||
|
||||
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)
|
||||
})
|
||||
}) {
|
||||
|
|
@ -200,7 +203,7 @@ func (self *SideListPanel[T]) FilterAndSort() {
|
|||
}
|
||||
|
||||
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)
|
||||
})
|
||||
}
|
||||
|
|
@ -219,7 +222,7 @@ func (self *SideListPanel[T]) RerenderList() error {
|
|||
self.Gui.Update(func() error {
|
||||
self.View.Clear()
|
||||
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)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ func (gui *Gui) getProjectPanel() *panels.SideListPanel[*commands.Project] {
|
|||
Sort: func(a *commands.Project, b *commands.Project) bool {
|
||||
return false
|
||||
},
|
||||
GetDisplayStrings: presentation.GetProjectDisplayStrings,
|
||||
GetTableCells: presentation.GetProjectDisplayStrings,
|
||||
// It doesn't make sense to filter a list of only one item.
|
||||
DisableFilter: true,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ func (gui *Gui) getServicesPanel() *panels.SideListPanel[*commands.Service] {
|
|||
|
||||
return a.Name < b.Name
|
||||
},
|
||||
GetDisplayStrings: presentation.GetServiceDisplayStrings,
|
||||
GetTableCells: presentation.GetServiceDisplayStrings,
|
||||
Hide: func() bool {
|
||||
return !gui.DockerCommand.InDockerComposeProject
|
||||
},
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ func (gui *Gui) getVolumesPanel() *panels.SideListPanel[*commands.Volume] {
|
|||
}
|
||||
return a.Name < b.Name
|
||||
},
|
||||
GetDisplayStrings: presentation.GetVolumeDisplayStrings,
|
||||
GetTableCells: presentation.GetVolumeDisplayStrings,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue