From 02181e53e1dbb23a1b59fd91299ca24f64d25b85 Mon Sep 17 00:00:00 2001 From: Ross Trottier Date: Fri, 28 Jun 2024 09:09:41 -0600 Subject: [PATCH] app links in alpha order --- cmd/web/app-links.go | 25 ++++++++++++++++++++----- cmd/web/handlers.go | 4 +++- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/cmd/web/app-links.go b/cmd/web/app-links.go index 67e789e..8af8af8 100644 --- a/cmd/web/app-links.go +++ b/cmd/web/app-links.go @@ -1,5 +1,10 @@ package main +import ( + "slices" + "strings" +) + type AppLink struct { Title string Url string @@ -8,22 +13,32 @@ type AppLink struct { } func getAppLinks(tier, baseUri string) []AppLink { + var output []AppLink + + //Get Links Based on Tier if tier == "enterprise" { - return getEnterpriseLinks(baseUri) + output = getEnterpriseLinks(baseUri) } else if tier == "creator" { - return getCreatorLinks(baseUri) + output = getCreatorLinks(baseUri) } else if tier == "teams" { - return getTeamsLinks(baseUri) + output = getTeamsLinks(baseUri) + } else { + output = getStarterLinks(baseUri) } - return getStarterLinks(baseUri) + //Sort in alphabetical order + slices.SortFunc(output, func(a, b AppLink) int { + return strings.Compare(a.Title, b.Title) + }) + + return output } func getStarterLinks(baseUri string) []AppLink { return []AppLink { { Title: "User Management", - Description: "Create users and manage their access", + Description: "Create and Manage Users", Image: "/static/img/users.png", Url: "https://panel." + baseUri, }, diff --git a/cmd/web/handlers.go b/cmd/web/handlers.go index 6d113a1..f1b22df 100644 --- a/cmd/web/handlers.go +++ b/cmd/web/handlers.go @@ -5,8 +5,10 @@ import ( ) func (app *application) home(writer http.ResponseWriter, request *http.Request) { + appLinks := getAppLinks(app.tier, app.host) + data := templateData{ - AppLinks: getAppLinks(app.tier, app.host), + AppLinks: appLinks, Tier: app.tier, BaseUri: app.host, }