Launcher: Shorten long url inside app instance tooltip

Change-Id: If80b8a4a519745101056e34c3535543a6c8a78d2
diff --git a/core/installer/cmd/launcher.go b/core/installer/cmd/launcher.go
index e1707bf..6a8ced5 100644
--- a/core/installer/cmd/launcher.go
+++ b/core/installer/cmd/launcher.go
@@ -14,7 +14,7 @@
 )
 
 var launcherFlags struct {
-	logoutUrl string
+	logoutURL string
 	port      int
 	repoAddr  string
 	sshKey    string
@@ -32,7 +32,7 @@
 		"",
 	)
 	cmd.Flags().StringVar(
-		&launcherFlags.logoutUrl,
+		&launcherFlags.logoutURL,
 		"logout-url",
 		"",
 		"",
@@ -80,7 +80,7 @@
 	}
 	s, err := welcome.NewLauncherServer(
 		launcherFlags.port,
-		launcherFlags.logoutUrl,
+		launcherFlags.logoutURL,
 		&welcome.AppManagerDirectory{AppManager: appManager},
 	)
 	if err != nil {
diff --git a/core/installer/welcome/fake_app_directory.go b/core/installer/welcome/fake_app_directory.go
index 6efd6f3..e47bb13 100644
--- a/core/installer/welcome/fake_app_directory.go
+++ b/core/installer/welcome/fake_app_directory.go
@@ -79,7 +79,7 @@
 				},
 			},
 		},
-		Url: "https://memberships.p.v1.dodo.cloud",
+		URL: "https://memberships.p.v1.dodo.cloud",
 	}
 	gitInfo := AppLauncherInfo{
 		Name: "Gerrit",
@@ -91,7 +91,7 @@
 				Children: nil,
 			},
 		},
-		Url: "https://code.v1.dodo.cloud/dashboard/self",
+		URL: "https://code.v1.dodo.cloud/dashboard/self",
 	}
 	forumge := AppLauncherInfo{
 		Name: "Forum",
@@ -103,7 +103,7 @@
 				Children: nil,
 			},
 		},
-		Url: "https://forum.ge",
+		URL: "https://forum.ge",
 	}
 	return []AppLauncherInfo{googleInfo, gitInfo, forumge}, nil
 }
diff --git a/core/installer/welcome/launcher-tmpl/launcher.html b/core/installer/welcome/launcher-tmpl/launcher.html
index 7219925..f4fed7f 100644
--- a/core/installer/welcome/launcher-tmpl/launcher.html
+++ b/core/installer/welcome/launcher-tmpl/launcher.html
@@ -14,21 +14,21 @@
                 <p>{{ GetUserInitials .LoggedInUsername }}</p>
                 <div class="tooltip-user" id="tooltip-user">
                     <p>{{ .LoggedInUsername }}</p>
-                    <a href="{{ .LogoutUrl }}" role="button" id="logout-button">Log Out</a>
+                    <a href="{{ .LogoutURL }}" role="button" id="logout-button">Log Out</a>
                 </div>
             </div>
         </div>
         <hr class="separator">
         <div class="app-list">
             {{range .AllAppsInfo}}
-                <div class="app-icon-tooltip" data-app-url="{{ .Url }}">
+                <div class="app-icon-tooltip" data-app-url="{{ .URL }}">
                     <div class="icon">
                         {{.Icon}}
                     </div>
                     <div class="tooltip">
                         <p>{{ .Name }}</p>
-                        {{ if .Url }}
-                            <p>{{ .Url }}</p>
+                        {{ if .DisplayURL }}
+                            <p>{{ .DisplayURL }}</p>
                         {{ end }}
                         {{ if .Help }}
                             <button class="help-button" id="help-button-{{ CleanAppName .Id }}">Help</button>
diff --git a/core/installer/welcome/launcher.go b/core/installer/welcome/launcher.go
index 8619459..3dd70b9 100644
--- a/core/installer/welcome/launcher.go
+++ b/core/installer/welcome/launcher.go
@@ -22,11 +22,12 @@
 var files embed.FS
 
 type AppLauncherInfo struct {
-	Id   string
-	Name string
-	Icon template.HTML
-	Help []HelpDocumentRendered
-	Url  string
+	Id         string
+	Name       string
+	Icon       template.HTML
+	Help       []HelpDocumentRendered
+	URL        string
+	DisplayURL string
 }
 
 type HelpDocumentRendered struct {
@@ -54,11 +55,12 @@
 			continue
 		}
 		ret = append(ret, AppLauncherInfo{
-			Id:   a.Id,
-			Name: a.AppId,
-			Icon: template.HTML(a.Icon),
-			Help: toMarkdown(a.Help),
-			Url:  a.URL,
+			Id:         a.Id,
+			Name:       a.AppId,
+			Icon:       template.HTML(a.Icon),
+			Help:       toMarkdown(a.Help),
+			URL:        a.URL,
+			DisplayURL: shortenURL(a.URL, a.Env.Domain),
 		})
 	}
 	sort.Slice(ret, func(i, j int) bool {
@@ -81,14 +83,14 @@
 
 type LauncherServer struct {
 	port         int
-	logoutUrl    string
+	logoutURL    string
 	appDirectory AppDirectory
 	homeTmpl     *template.Template
 }
 
 func NewLauncherServer(
 	port int,
-	logoutUrl string,
+	logoutURL string,
 	appDirectory AppDirectory,
 ) (*LauncherServer, error) {
 	tmpl, err := indexHTML.ReadFile("launcher-tmpl/launcher.html")
@@ -105,7 +107,7 @@
 	}
 	return &LauncherServer{
 		port,
-		logoutUrl,
+		logoutURL,
 		appDirectory,
 		t,
 	}, nil
@@ -124,6 +126,10 @@
 	return cleanName
 }
 
+func shortenURL(url, domain string) string {
+	return strings.Replace(url, domain, "..", 1)
+}
+
 func getLoggedInUser(r *http.Request) (string, error) {
 	if user := r.Header.Get("X-User"); user != "" {
 		return user, nil
@@ -142,7 +148,7 @@
 type homeHandlerData struct {
 	LoggedInUsername string
 	AllAppsInfo      []AppLauncherInfo
-	LogoutUrl        string
+	LogoutURL        string
 }
 
 func (s *LauncherServer) homeHandler(w http.ResponseWriter, r *http.Request) {
@@ -158,7 +164,7 @@
 	data := homeHandlerData{
 		LoggedInUsername: loggedInUsername,
 		AllAppsInfo:      allAppsInfo,
-		LogoutUrl:        s.logoutUrl,
+		LogoutURL:        s.logoutURL,
 	}
 	if err := s.homeTmpl.Execute(w, data); err != nil {
 		http.Error(w, err.Error(), http.StatusInternalServerError)