Change dashboard tabs to use custom sub widgets
This commit is contained in:
+20
-21
@@ -50,7 +50,7 @@ var (
|
||||
|
||||
type Dashboard struct {
|
||||
Tabs []string
|
||||
TabContent []list.Model
|
||||
TabContent []tea.Model
|
||||
activeTab int
|
||||
width int
|
||||
height int
|
||||
@@ -67,8 +67,9 @@ func (m Dashboard) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||
m.width = msg.Width
|
||||
m.height = msg.Height
|
||||
for i := 0; i < len(m.TabContent); i++ {
|
||||
m.TabContent[i].SetWidth(m.width - 10)
|
||||
m.TabContent[i].SetHeight(m.height - 10)
|
||||
m.TabContent[i].Update(msg)
|
||||
// m.TabContent[i].SetWidth(m.width - 10)
|
||||
// m.TabContent[i].SetHeight(m.height - 10)
|
||||
}
|
||||
case tea.KeyMsg:
|
||||
switch keypress := msg.String(); keypress {
|
||||
@@ -160,34 +161,32 @@ func createDashboard(s CursoriusServer) (Dashboard, error) {
|
||||
client := graphql.NewClient(s.Url, http.DefaultClient)
|
||||
|
||||
tabs := []string{"Pipelines", "Secrets", "Clone Credentials", "Runners"}
|
||||
//testTabs := []list.Item{dashboardItem("Pipelines"), dashboardItem("Secrets"), dashboardItem("Clone Credentials"), dashboardItem("Runners")}
|
||||
|
||||
pipelineWidget, err := widget.CreatePipelineWidget(client)
|
||||
if err != nil {
|
||||
return Dashboard{}, fmt.Errorf("Could not create Pipelines tab: %w", err)
|
||||
}
|
||||
|
||||
secretWidget, err := widget.CreateSecretWidget(client)
|
||||
if err != nil {
|
||||
return Dashboard{}, fmt.Errorf("Could not create Secrets tab: %w", err)
|
||||
}
|
||||
//secretWidget, err := widget.CreateSecretWidget(client)
|
||||
//if err != nil {
|
||||
// return Dashboard{}, fmt.Errorf("Could not create Secrets tab: %w", err)
|
||||
//}
|
||||
|
||||
cloneCredentialWidget, err := widget.CreateCloneCredentialWidget(client)
|
||||
if err != nil {
|
||||
return Dashboard{}, fmt.Errorf("Could not create Clone Credentials tab: %w", err)
|
||||
}
|
||||
//cloneCredentialWidget, err := widget.CreateCloneCredentialWidget(client)
|
||||
//if err != nil {
|
||||
// return Dashboard{}, fmt.Errorf("Could not create Clone Credentials tab: %w", err)
|
||||
//}
|
||||
|
||||
runnerWidget, err := widget.CreateRunnerWidget(client)
|
||||
if err != nil {
|
||||
return Dashboard{}, fmt.Errorf("Could not create Runner tab: %w", err)
|
||||
}
|
||||
//runnerWidget, err := widget.CreateRunnerWidget(client)
|
||||
//if err != nil {
|
||||
// return Dashboard{}, fmt.Errorf("Could not create Runner tab: %w", err)
|
||||
//}
|
||||
|
||||
tabContent := []list.Model{
|
||||
//list.New(testTabs, dashboardItemDelegate{}, 50, 50),
|
||||
tabContent := []tea.Model{
|
||||
pipelineWidget,
|
||||
secretWidget,
|
||||
cloneCredentialWidget,
|
||||
runnerWidget,
|
||||
//secretWidget,
|
||||
//cloneCredentialWidget,
|
||||
//runnerWidget,
|
||||
}
|
||||
|
||||
return Dashboard{
|
||||
|
||||
Reference in New Issue
Block a user