diff --git a/appview/issues/issues.go b/appview/issues/issues.go index 2ffeb8ac..9d35bb71 100644 --- a/appview/issues/issues.go +++ b/appview/issues/issues.go @@ -129,15 +129,14 @@ func (rp *Issues) RepoSingleIssue(w http.ResponseWriter, r *http.Request) { } rp.pages.RepoSingleIssue(w, pages.RepoSingleIssueParams{ - LoggedInUser: user, - RepoInfo: rp.repoResolver.GetRepoInfo(r, user), - Issue: issue, - CommentList: issue.CommentList(), - Backlinks: backlinks, - OrderedReactionKinds: models.OrderedReactionKinds, - Reactions: reactionMap, - UserReacted: userReactions, - LabelDefs: defs, + LoggedInUser: user, + RepoInfo: rp.repoResolver.GetRepoInfo(r, user), + Issue: issue, + CommentList: issue.CommentList(), + Backlinks: backlinks, + Reactions: reactionMap, + UserReacted: userReactions, + LabelDefs: defs, }) } diff --git a/appview/knots/knots.go b/appview/knots/knots.go index 6c3ae0e4..bd8e79dd 100644 --- a/appview/knots/knots.go +++ b/appview/knots/knots.go @@ -40,19 +40,6 @@ type Knots struct { Knotstream *eventconsumer.Consumer } -type tab = map[string]any - -var ( - knotsTabs []tab = []tab{ - {"Name": "profile", "Icon": "user"}, - {"Name": "keys", "Icon": "key"}, - {"Name": "emails", "Icon": "mail"}, - {"Name": "notifications", "Icon": "bell"}, - {"Name": "knots", "Icon": "volleyball"}, - {"Name": "spindles", "Icon": "spool"}, - } -) - func (k *Knots) Router() http.Handler { r := chi.NewRouter() @@ -84,7 +71,6 @@ func (k *Knots) knots(w http.ResponseWriter, r *http.Request) { k.Pages.Knots(w, pages.KnotsParams{ LoggedInUser: user, Registrations: registrations, - Tabs: knotsTabs, Tab: "knots", }) } @@ -148,7 +134,6 @@ func (k *Knots) dashboard(w http.ResponseWriter, r *http.Request) { Members: members, Repos: repoMap, IsOwner: true, - Tabs: knotsTabs, Tab: "knots", }) } diff --git a/appview/pages/funcmap.go b/appview/pages/funcmap.go index a65b76d6..87149d1c 100644 --- a/appview/pages/funcmap.go +++ b/appview/pages/funcmap.go @@ -32,6 +32,8 @@ import ( "tangled.org/core/crypto" ) +type tab map[string]string + func (p *Pages) funcMap() template.FuncMap { return template.FuncMap{ "split": func(s string) []string { @@ -424,6 +426,26 @@ func (p *Pages) funcMap() template.FuncMap { } return result }, + // constant values used to define a template + "const": func() map[string]any { + return map[string]any{ + "OrderedReactionKinds": models.OrderedReactionKinds, + // would be great to have ordered maps right about now + "UserSettingsTabs": []tab{ + {"Name": "profile", "Icon": "user"}, + {"Name": "keys", "Icon": "key"}, + {"Name": "emails", "Icon": "mail"}, + {"Name": "notifications", "Icon": "bell"}, + {"Name": "knots", "Icon": "volleyball"}, + {"Name": "spindles", "Icon": "spool"}, + }, + "RepoSettingsTabs": []tab{ + {"Name": "general", "Icon": "sliders-horizontal"}, + {"Name": "access", "Icon": "users"}, + {"Name": "pipelines", "Icon": "layers-2"}, + }, + } + }, } } diff --git a/appview/pages/pages.go b/appview/pages/pages.go index aa579bc5..19aa7bca 100644 --- a/appview/pages/pages.go +++ b/appview/pages/pages.go @@ -338,7 +338,6 @@ func (p *Pages) GoodFirstIssues(w io.Writer, params GoodFirstIssuesParams) error type UserProfileSettingsParams struct { LoggedInUser *oauth.MultiAccountUser - Tabs []map[string]any Tab string } @@ -377,7 +376,6 @@ func (p *Pages) NotificationCount(w io.Writer, params NotificationCountParams) e type UserKeysSettingsParams struct { LoggedInUser *oauth.MultiAccountUser PubKeys []models.PublicKey - Tabs []map[string]any Tab string } @@ -388,7 +386,6 @@ func (p *Pages) UserKeysSettings(w io.Writer, params UserKeysSettingsParams) err type UserEmailsSettingsParams struct { LoggedInUser *oauth.MultiAccountUser Emails []models.Email - Tabs []map[string]any Tab string } @@ -399,7 +396,6 @@ func (p *Pages) UserEmailsSettings(w io.Writer, params UserEmailsSettingsParams) type UserNotificationSettingsParams struct { LoggedInUser *oauth.MultiAccountUser Preferences *models.NotificationPreferences - Tabs []map[string]any Tab string } @@ -419,7 +415,6 @@ func (p *Pages) UpgradeBanner(w io.Writer, params UpgradeBannerParams) error { type KnotsParams struct { LoggedInUser *oauth.MultiAccountUser Registrations []models.Registration - Tabs []map[string]any Tab string } @@ -433,7 +428,6 @@ type KnotParams struct { Members []string Repos map[string][]models.Repo IsOwner bool - Tabs []map[string]any Tab string } @@ -452,7 +446,6 @@ func (p *Pages) KnotListing(w io.Writer, params KnotListingParams) error { type SpindlesParams struct { LoggedInUser *oauth.MultiAccountUser Spindles []models.Spindle - Tabs []map[string]any Tab string } @@ -462,8 +455,7 @@ func (p *Pages) Spindles(w io.Writer, params SpindlesParams) error { type SpindleListingParams struct { models.Spindle - Tabs []map[string]any - Tab string + Tab string } func (p *Pages) SpindleListing(w io.Writer, params SpindleListingParams) error { @@ -475,7 +467,6 @@ type SpindleDashboardParams struct { Spindle models.Spindle Members []string Repos map[string][]models.Repo - Tabs []map[string]any Tab string } @@ -886,7 +877,6 @@ type RepoGeneralSettingsParams struct { SubscribedLabels map[string]struct{} ShouldSubscribeAll bool Active string - Tabs []map[string]any Tab string Branches []types.Branch } @@ -900,7 +890,6 @@ type RepoAccessSettingsParams struct { LoggedInUser *oauth.MultiAccountUser RepoInfo repoinfo.RepoInfo Active string - Tabs []map[string]any Tab string Collaborators []Collaborator } @@ -914,7 +903,6 @@ type RepoPipelineSettingsParams struct { LoggedInUser *oauth.MultiAccountUser RepoInfo repoinfo.RepoInfo Active string - Tabs []map[string]any Tab string Spindles []string CurrentSpindle string @@ -952,9 +940,8 @@ type RepoSingleIssueParams struct { Backlinks []models.RichReferenceLink LabelDefs map[string]*models.LabelDefinition - OrderedReactionKinds []models.ReactionKind - Reactions map[models.ReactionKind]models.ReactionDisplayData - UserReacted map[models.ReactionKind]bool + Reactions map[models.ReactionKind]models.ReactionDisplayData + UserReacted map[models.ReactionKind]bool } func (p *Pages) RepoSingleIssue(w io.Writer, params RepoSingleIssueParams) error { @@ -1115,9 +1102,8 @@ type RepoSinglePullParams struct { ActiveRound int IsInterdiff bool - OrderedReactionKinds []models.ReactionKind - Reactions map[models.ReactionKind]models.ReactionDisplayData - UserReacted map[models.ReactionKind]bool + Reactions map[models.ReactionKind]models.ReactionDisplayData + UserReacted map[models.ReactionKind]bool LabelDefs map[string]*models.LabelDefinition } @@ -1128,15 +1114,14 @@ func (p *Pages) RepoSinglePull(w io.Writer, params RepoSinglePullParams) error { } type RepoPullPatchParams struct { - LoggedInUser *oauth.MultiAccountUser - RepoInfo repoinfo.RepoInfo - Pull *models.Pull - Stack models.Stack - Diff *types.NiceDiff - Round int - Submission *models.PullSubmission - OrderedReactionKinds []models.ReactionKind - DiffOpts types.DiffOpts + LoggedInUser *oauth.MultiAccountUser + RepoInfo repoinfo.RepoInfo + Pull *models.Pull + Stack models.Stack + Diff *types.NiceDiff + Round int + Submission *models.PullSubmission + DiffOpts types.DiffOpts } // this name is a mouthful @@ -1145,13 +1130,12 @@ func (p *Pages) RepoPullPatchPage(w io.Writer, params RepoPullPatchParams) error } type RepoPullInterdiffParams struct { - LoggedInUser *oauth.MultiAccountUser - RepoInfo repoinfo.RepoInfo - Pull *models.Pull - Round int - Interdiff *patchutil.InterdiffResult - OrderedReactionKinds []models.ReactionKind - DiffOpts types.DiffOpts + LoggedInUser *oauth.MultiAccountUser + RepoInfo repoinfo.RepoInfo + Pull *models.Pull + Round int + Interdiff *patchutil.InterdiffResult + DiffOpts types.DiffOpts } // this name is a mouthful diff --git a/appview/pages/templates/repo/issues/issue.html b/appview/pages/templates/repo/issues/issue.html index 8a1cd8a6..ccd9f2bd 100644 --- a/appview/pages/templates/repo/issues/issue.html +++ b/appview/pages/templates/repo/issues/issue.html @@ -109,8 +109,8 @@ {{ define "issueReactions" }}