diff --git a/internal/tui/helpers.go b/internal/tui/helpers.go index fb2bca9..d904653 100644 --- a/internal/tui/helpers.go +++ b/internal/tui/helpers.go @@ -276,7 +276,7 @@ func (h *Helpers) CreateTasks(fn task.SpecFunc, ids ...resource.ID) tea.Cmd { if err != nil { return ReportError(fmt.Errorf("creating task: %w", err)) } - return NewNavigationMsg(TaskKind, WithParent(task)) + return NewNavigationMsg(TaskKind, WithParent(task.ID)) default: specs := make([]task.Spec, 0, len(ids)) for _, id := range ids { @@ -302,7 +302,7 @@ func (h *Helpers) CreateTasksWithSpecs(specs ...task.Spec) tea.Cmd { if err != nil { return ReportError(fmt.Errorf("creating task: %w", err)) } - return NewNavigationMsg(TaskKind, WithParent(task)) + return NewNavigationMsg(TaskKind, WithParent(task.ID)) default: return h.createTaskGroup(specs...) } @@ -314,7 +314,7 @@ func (h *Helpers) createTaskGroup(specs ...task.Spec) tea.Msg { if err != nil { return ReportError(fmt.Errorf("creating task group: %w", err)) } - return NewNavigationMsg(TaskGroupKind, WithParent(group)) + return NewNavigationMsg(TaskGroupKind, WithParent(group.ID)) } func (h *Helpers) Move(workspaceID resource.ID, from state.ResourceAddress) tea.Cmd { diff --git a/internal/tui/logs/list.go b/internal/tui/logs/list.go index a92722d..dc0808e 100644 --- a/internal/tui/logs/list.go +++ b/internal/tui/logs/list.go @@ -89,7 +89,7 @@ func (m list) Update(msg tea.Msg) (tea.Model, tea.Cmd) { switch { case key.Matches(msg, keys.Global.Enter): if row, ok := m.table.CurrentRow(); ok { - return m, tui.NavigateTo(tui.LogKind, tui.WithParent(row.Value)) + return m, tui.NavigateTo(tui.LogKind, tui.WithParent(row.ID)) } } } diff --git a/internal/tui/messages.go b/internal/tui/messages.go index 97609dc..7e17225 100644 --- a/internal/tui/messages.go +++ b/internal/tui/messages.go @@ -21,9 +21,9 @@ func NewNavigationMsg(kind Kind, opts ...NavigateOption) NavigationMsg { type NavigateOption func(msg *NavigationMsg) -func WithParent(parent resource.Resource) NavigateOption { +func WithParent(parent resource.ID) NavigateOption { return func(msg *NavigationMsg) { - msg.Page.ID = parent.GetID() + msg.Page.ID = parent } } diff --git a/internal/tui/module/list.go b/internal/tui/module/list.go index 00cd027..56d2407 100644 --- a/internal/tui/module/list.go +++ b/internal/tui/module/list.go @@ -150,7 +150,7 @@ func (m list) Update(msg tea.Msg) (tea.Model, tea.Cmd) { case key.Matches(msg, keys.Common.State): if row, ok := m.table.CurrentRow(); ok { if ws := m.helpers.ModuleCurrentWorkspace(row.Value); ws != nil { - return m, tui.NavigateTo(tui.ResourceListKind, tui.WithParent(ws)) + return m, tui.NavigateTo(tui.ResourceListKind, tui.WithParent(ws.ID)) } } case key.Matches(msg, keys.Common.PlanDestroy): diff --git a/internal/tui/task/group_list.go b/internal/tui/task/group_list.go index 067ba95..5dff3ed 100644 --- a/internal/tui/task/group_list.go +++ b/internal/tui/task/group_list.go @@ -81,7 +81,7 @@ func (m groupList) Update(msg tea.Msg) (tea.Model, tea.Cmd) { switch { case key.Matches(msg, keys.Global.Enter): if row, ok := m.table.CurrentRow(); ok { - return m, tui.NavigateTo(tui.TaskGroupKind, tui.WithParent(row.Value)) + return m, tui.NavigateTo(tui.TaskGroupKind, tui.WithParent(row.ID)) } } } diff --git a/internal/tui/task/list.go b/internal/tui/task/list.go index c804470..fdb40ab 100644 --- a/internal/tui/task/list.go +++ b/internal/tui/task/list.go @@ -136,7 +136,7 @@ func (m List) Update(msg tea.Msg) (tea.Model, tea.Cmd) { return m, cancel(m.tasks, taskIDs...) case key.Matches(msg, keys.Global.Enter): if row, ok := m.Table.CurrentRow(); ok { - return m, tui.NavigateTo(tui.TaskKind, tui.WithParent(row.Value)) + return m, tui.NavigateTo(tui.TaskKind, tui.WithParent(row.ID)) } case key.Matches(msg, keys.Common.Apply): specs, err := m.Table.Prune(func(t *task.Task) (task.Spec, error) { @@ -153,7 +153,7 @@ func (m List) Update(msg tea.Msg) (tea.Model, tea.Cmd) { case key.Matches(msg, keys.Common.State): if row, ok := m.Table.CurrentRow(); ok { if ws, ok := m.helpers.TaskWorkspace(row.Value); ok { - return m, tui.NavigateTo(tui.ResourceListKind, tui.WithParent(ws)) + return m, tui.NavigateTo(tui.ResourceListKind, tui.WithParent(ws.GetID())) } else { return m, tui.ReportError(errors.New("task not associated with a workspace")) } diff --git a/internal/tui/task/model.go b/internal/tui/task/model.go index be6e1b0..4be1aa6 100644 --- a/internal/tui/task/model.go +++ b/internal/tui/task/model.go @@ -143,7 +143,7 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { ) case key.Matches(msg, keys.Common.State): if ws, ok := m.helpers.TaskWorkspace(m.task); ok { - return m, tui.NavigateTo(tui.ResourceListKind, tui.WithParent(ws)) + return m, tui.NavigateTo(tui.ResourceListKind, tui.WithParent(ws.GetID())) } else { return m, tui.ReportError(errors.New("task not associated with a workspace")) } diff --git a/internal/tui/workspace/list.go b/internal/tui/workspace/list.go index d6d2d52..45471e0 100644 --- a/internal/tui/workspace/list.go +++ b/internal/tui/workspace/list.go @@ -152,7 +152,7 @@ func (m list) Update(msg tea.Msg) (tea.Model, tea.Cmd) { ) case key.Matches(msg, keys.Common.State): if row, ok := m.table.CurrentRow(); ok { - return m, tui.NavigateTo(tui.ResourceListKind, tui.WithParent(row.Value)) + return m, tui.NavigateTo(tui.ResourceListKind, tui.WithParent(row.ID)) } } } diff --git a/internal/tui/workspace/resource_list.go b/internal/tui/workspace/resource_list.go index d362014..91e39f6 100644 --- a/internal/tui/workspace/resource_list.go +++ b/internal/tui/workspace/resource_list.go @@ -128,7 +128,7 @@ func (m resourceList) Update(msg tea.Msg) (tea.Model, tea.Cmd) { switch { case key.Matches(msg, keys.Global.Enter): if row, ok := m.Table.CurrentRow(); ok { - return m, tui.NavigateTo(tui.ResourceKind, tui.WithParent(row.Value)) + return m, tui.NavigateTo(tui.ResourceKind, tui.WithParent(row.ID)) } case key.Matches(msg, resourcesKeys.Reload): if m.reloading {