Skip to content

Commit

Permalink
Better support for when the current AWS account doesn't have any ECS …
Browse files Browse the repository at this point in the history
…clusters to view.
  • Loading branch information
swartzrock committed Dec 14, 2020
1 parent 0fd318e commit 2089705
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions cmd/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func showPage(selectedPage *pages.ClusterDetailsPage, key int32) {
commandFooterBar.Highlight(string(key)).ScrollToHighlight()
selectedPage.Render(ecsData)
clusterDetailsPages.SwitchToPage(selectedPage.Name)
ShowRefreshTime(*ecsData.Cluster.ClusterName, ecsData.Refreshed)
showRefreshTime(*ecsData.Cluster.ClusterName, ecsData.Refreshed)

// If the page about to be hidden has focus, switch focus to the new page
if frontPageView != nil && frontPageView.HasFocus() {
Expand All @@ -73,6 +73,9 @@ func renderCurrentClusterDetailsPage() {
// Change focus between the cluster table and the cluster details page
func changeFocus() {
_, pageView := clusterDetailsPages.GetFrontPage()
if pageView == nil {
return
}
if pageView.HasFocus() {
pageView.Blur()
clusterTable.Focus(nil)
Expand Down Expand Up @@ -125,7 +128,7 @@ func getCurrentlySelectedCluster() *aws.EcsCluster {
return cluster
}

func ShowRefreshTime(what string, when time.Time) {
func showRefreshTime(what string, when time.Time) {
progressFooterBar.Clear()
fmt.Fprintf(progressFooterBar, "%s refreshed at %s", what, utils.FormatLocalTimeAmPmSecs(when))
}
Expand All @@ -152,6 +155,11 @@ func buildUIElements() {
SetTextAlign(ui.R)
progressFooterBar.SetBorderPadding(0, 0, 1, 2)

if clusterTable.GetRowCount() == 1 {
commandFooterBar.Clear()
fmt.Fprint(commandFooterBar, "No clusters found")
}

footer := tview.NewFlex().SetDirection(tview.FlexColumn).
AddItem(commandFooterBar, 0, 6, false).
AddItem(progressFooterBar, 0, 4, false)
Expand Down Expand Up @@ -197,6 +205,10 @@ func buildClusterTable() *tview.Table {
ui.AddTableData(table, 0, [][]string{headers}, alignment, expansions, tcell.ColorYellow, false)

ecsClusters := ecsview.GetClusters()
if len(ecsClusters) == 0 {
return table
}

data := funk.Map(ecsClusters, func(cluster *aws.EcsCluster) []string {

containers := ecsview.GetClusterContainers(cluster)
Expand Down

0 comments on commit 2089705

Please sign in to comment.