From 6fcd260583b75a2a3eaacf4a9dd40423c3348f87 Mon Sep 17 00:00:00 2001 From: Tolga Ozen Date: Thu, 26 Dec 2024 16:16:44 +0300 Subject: [PATCH] refactor: Improve resource and service handling in controller Next method. --- pkg/aws/groups/controller.go | 9 +++++++++ pkg/aws/roles/controller.go | 9 +++++++++ pkg/aws/users/controller.go | 9 +++++++++ 3 files changed, 27 insertions(+) diff --git a/pkg/aws/groups/controller.go b/pkg/aws/groups/controller.go index da1dc3d..e611e50 100644 --- a/pkg/aws/groups/controller.go +++ b/pkg/aws/groups/controller.go @@ -302,6 +302,15 @@ func (c *Controller) Next() tea.Model { return NewServiceList(c) } } else { + // Handle case where resource is defined + if c.State.resource != nil { + return NewCreatePolicy(c) + } + + // Handle case where service is defined + if c.State.service != nil { + return NewResourceList(c) + } // If no policy option is selected return NewPolicyOptionList(c) } diff --git a/pkg/aws/roles/controller.go b/pkg/aws/roles/controller.go index ee2ec67..a46eb5e 100644 --- a/pkg/aws/roles/controller.go +++ b/pkg/aws/roles/controller.go @@ -303,6 +303,15 @@ func (c *Controller) Next() tea.Model { return NewServiceList(c) } } else { + // Handle case where resource is defined + if c.State.resource != nil { + return NewCreatePolicy(c) + } + + // Handle case where service is defined + if c.State.service != nil { + return NewResourceList(c) + } // If no policy option is selected return NewPolicyOptionList(c) } diff --git a/pkg/aws/users/controller.go b/pkg/aws/users/controller.go index 6e95479..8ddb5ec 100644 --- a/pkg/aws/users/controller.go +++ b/pkg/aws/users/controller.go @@ -366,6 +366,15 @@ func (c *Controller) Next() tea.Model { return NewServiceList(c) } } else { + // Handle case where resource is defined + if c.State.resource != nil { + return NewCreatePolicy(c) + } + + // Handle case where service is defined + if c.State.service != nil { + return NewResourceList(c) + } // If no policy option is selected return NewPolicyOptionList(c) }