Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
suchak1 committed Feb 7, 2024
1 parent 9424646 commit 78c6ec2
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 65 deletions.
17 changes: 0 additions & 17 deletions tui/appMenu.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,6 @@ func (m AppMenu) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
case "enter":
switch m.list.SelectedItem().(AppMenuItem).id {
case attributeMenu:
// l := list.New([]list.Item{}, list.NewDefaultDelegate(), constants.WindowSize.Width, constants.WindowSize.Height)
// var al AttributeList
item := AttributeItem{
id: "8a6755f2-efa8-4758-b893-af9a488e0bea",
namespace: "demo.com",
Expand All @@ -86,21 +84,6 @@ func (m AppMenu) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
values: []string{"USA", "GBR"},
}
al, cmd := InitAttributeList([]list.Item{item}, 0)
// // al = al.(AttributeList)
// l := al.(AttributeList).list
// l.SetItems([]list.Item{
// AttributeItem{
// id: "8a6755f2-efa8-4758-b893-af9a488e0bea",
// namespace: "demo.com",
// name: "relto",
// rule: "hierarchical",
// description: "The relto attribute is used to describe the relationship of the resource to the country of origin.",
// values: []string{"USA", "GBR"},
// },
// })
// // al = al.(AttributeList)
// al.list = l
// m := al.(tea.Model)
return al, cmd
}
}
Expand Down
18 changes: 0 additions & 18 deletions tui/attributeList.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,24 +43,6 @@ func InitAttributeList(items []list.Item, selectIdx int) (tea.Model, tea.Cmd) {
}
m.list.Title = "Attributes"
m.list.SetItems(items)
// if len(items) > 0 {
// var newItems []list.Item
// for _, item := range items {
// newItems = append(newItems, item)
// }
// m.list.SetItems(newItems)
// } else {
// // m.list.SetItems([]list.Item{
// // AttributeItem{
// // id: "8a6755f2-efa8-4758-b893-af9a488e0bea",
// // namespace: "demo.com",
// // name: "relto",
// // rule: "hierarchical",
// // description: "The relto attribute is used to describe the relationship of the resource to the country of origin.",
// // values: []string{"USA", "GBR"},
// // },
// // })
// }
return m.Update(WindowMsg())
}

Expand Down
33 changes: 3 additions & 30 deletions tui/attributeView.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import (
"fmt"
"strings"

// "log"

"github.com/charmbracelet/bubbles/list"
"github.com/charmbracelet/bubbles/textarea"
"github.com/charmbracelet/bubbles/textinput"
Expand All @@ -16,10 +14,6 @@ import (
"github.com/opentdf/tructl/tui/constants"
)

// type (
// errMsg error
// )

const (
id = iota
name
Expand Down Expand Up @@ -83,9 +77,7 @@ func SetupViewport(m AttributeView, msg tea.WindowSizeMsg) (AttributeView, []tea
footerHeight := lipgloss.Height(m.CreateFooter())
verticalMarginHeight := headerHeight + footerHeight
m.width = msg.Width
// area := m.inputs[description].(textarea.Model)
// area.SetWidth(msg.Width)
// m.inputs[description] = area

if !m.ready {
// Since this program is using the full size of the viewport we
// need to wait until we've received the window dimensions before
Expand All @@ -106,11 +98,7 @@ func SetupViewport(m AttributeView, msg tea.WindowSizeMsg) (AttributeView, []tea
m.viewport.Width = msg.Width
m.viewport.Height = msg.Height - verticalMarginHeight
}
// var cmd tea.Cmd
// m.viewport, cmd = m.viewport.Update(tea.KeyPgDown)
// cmds = append(cmds, cmd)
// m.viewport.GotoBottom()
// cmds = append(cmds, viewport.Sync(m.viewport))

if useHighPerformanceRenderer {
// Render (or re-render) the whole viewport. Necessary both to
// initialize the viewport and when the window is resized.
Expand Down Expand Up @@ -158,10 +146,6 @@ func InitAttributeView(items []list.Item, idx int) (tea.Model, tea.Cmd) {
ti5 := textinput.New()
ti5.SetValue(strings.Join(item.values, ","))
inputs = append(inputs, ti5)
// var attrItems []AttributeItem
// for _, item := range items {
// attrItems = append(attrItems, item.(AttributeItem))
// }

m := AttributeView{
keys: attr_keys,
Expand All @@ -185,11 +169,6 @@ func (m AttributeView) IsNew() bool {
}

func (m AttributeView) ChangeMode() AttributeView {
// if m.idx < len(m.list) {
// m.editMode = !m.editMode
// } else {
// m.editMode = true
// }
m.editMode = m.IsNew() || !m.editMode
return m
}
Expand All @@ -205,30 +184,24 @@ func (m AttributeView) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
description: m.inputs[description].(textarea.Model).Value(),
values: strings.Split(m.inputs[values].(textinput.Model).Value(), ","),
}
// saveModel, saveCmd := InitAttributeList([]AttributeItem{item})
switch msg := msg.(type) {
case tea.KeyMsg:
switch msg.Type {
case tea.KeyShiftLeft: //, tea.KeyBackspace:
case tea.KeyShiftLeft:
listIdx := m.idx
if m.IsNew() {
listIdx -= 1
}
return InitAttributeList(m.list, listIdx)
case tea.KeyShiftRight:
// return saveModel, saveCmd
if !m.IsNew() {
m.list[m.idx] = list.Item(item)
} else {
m.list = append(m.list, list.Item(item))
}

return InitAttributeList(m.list, m.idx)
// return InitAttributeList()
case tea.KeyEnter:
// if m.focused == len(m.inputs)-1 {
// return saveModel, saveCmd
// }
m.nextInput()
case tea.KeyCtrlC, tea.KeyEsc:
if m.editMode {
Expand Down

0 comments on commit 78c6ec2

Please sign in to comment.