diff --git a/appview/issues/issues.go b/appview/issues/issues.go index bc761e32..d48ff139 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 ef702bb8..75b3c1a9 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 14fdb009..192457dd 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 { @@ -385,6 +387,26 @@ func (p *Pages) funcMap() template.FuncMap { } return fp }, + // 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 883d7611..2b84e5aa 100644 --- a/appview/pages/pages.go +++ b/appview/pages/pages.go @@ -336,7 +336,6 @@ func (p *Pages) GoodFirstIssues(w io.Writer, params GoodFirstIssuesParams) error type UserProfileSettingsParams struct { LoggedInUser *oauth.User - Tabs []map[string]any Tab string } @@ -375,7 +374,6 @@ func (p *Pages) NotificationCount(w io.Writer, params NotificationCountParams) e type UserKeysSettingsParams struct { LoggedInUser *oauth.User PubKeys []models.PublicKey - Tabs []map[string]any Tab string } @@ -386,7 +384,6 @@ func (p *Pages) UserKeysSettings(w io.Writer, params UserKeysSettingsParams) err type UserEmailsSettingsParams struct { LoggedInUser *oauth.User Emails []models.Email - Tabs []map[string]any Tab string } @@ -397,7 +394,6 @@ func (p *Pages) UserEmailsSettings(w io.Writer, params UserEmailsSettingsParams) type UserNotificationSettingsParams struct { LoggedInUser *oauth.User Preferences *models.NotificationPreferences - Tabs []map[string]any Tab string } @@ -417,7 +413,6 @@ func (p *Pages) UpgradeBanner(w io.Writer, params UpgradeBannerParams) error { type KnotsParams struct { LoggedInUser *oauth.User Registrations []models.Registration - Tabs []map[string]any Tab string } @@ -431,7 +426,6 @@ type KnotParams struct { Members []string Repos map[string][]models.Repo IsOwner bool - Tabs []map[string]any Tab string } @@ -450,7 +444,6 @@ func (p *Pages) KnotListing(w io.Writer, params KnotListingParams) error { type SpindlesParams struct { LoggedInUser *oauth.User Spindles []models.Spindle - Tabs []map[string]any Tab string } @@ -460,8 +453,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 { @@ -473,7 +465,6 @@ type SpindleDashboardParams struct { Spindle models.Spindle Members []string Repos map[string][]models.Repo - Tabs []map[string]any Tab string } @@ -881,7 +872,6 @@ type RepoGeneralSettingsParams struct { SubscribedLabels map[string]struct{} ShouldSubscribeAll bool Active string - Tabs []map[string]any Tab string Branches []types.Branch } @@ -895,7 +885,6 @@ type RepoAccessSettingsParams struct { LoggedInUser *oauth.User RepoInfo repoinfo.RepoInfo Active string - Tabs []map[string]any Tab string Collaborators []Collaborator } @@ -909,7 +898,6 @@ type RepoPipelineSettingsParams struct { LoggedInUser *oauth.User RepoInfo repoinfo.RepoInfo Active string - Tabs []map[string]any Tab string Spindles []string CurrentSpindle string @@ -947,9 +935,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 { @@ -1104,9 +1091,8 @@ type RepoSinglePullParams struct { ResubmitCheck ResubmitResult Pipelines map[string]models.Pipeline - 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 } @@ -1117,15 +1103,14 @@ func (p *Pages) RepoSinglePull(w io.Writer, params RepoSinglePullParams) error { } type RepoPullPatchParams struct { - LoggedInUser *oauth.User - 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.User + 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 @@ -1134,13 +1119,12 @@ func (p *Pages) RepoPullPatchPage(w io.Writer, params RepoPullPatchParams) error } type RepoPullInterdiffParams struct { - LoggedInUser *oauth.User - RepoInfo repoinfo.RepoInfo - Pull *models.Pull - Round int - Interdiff *patchutil.InterdiffResult - OrderedReactionKinds []models.ReactionKind - DiffOpts types.DiffOpts + LoggedInUser *oauth.User + 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 8beb1fe5..825f08c7 100644 --- a/appview/pages/templates/repo/issues/issue.html +++ b/appview/pages/templates/repo/issues/issue.html @@ -109,8 +109,8 @@ {{ define "issueReactions" }}