···
9
+
"github.com/bluesky-social/indigo/atproto/syntax"
10
+
"tangled.sh/tangled.sh/core/appview/db"
11
+
"tangled.sh/tangled.sh/core/appview/state/userutil"
14
+
func (r RepoInfo) OwnerWithAt() string {
15
+
if r.OwnerHandle != "" {
16
+
return fmt.Sprintf("@%s", r.OwnerHandle)
22
+
func (r RepoInfo) FullName() string {
23
+
return path.Join(r.OwnerWithAt(), r.Name)
26
+
func (r RepoInfo) OwnerWithoutAt() string {
27
+
if strings.HasPrefix(r.OwnerWithAt(), "@") {
28
+
return strings.TrimPrefix(r.OwnerWithAt(), "@")
30
+
return userutil.FlattenDid(r.OwnerDid)
34
+
func (r RepoInfo) FullNameWithoutAt() string {
35
+
return path.Join(r.OwnerWithoutAt(), r.Name)
38
+
func (r RepoInfo) GetTabs() [][]string {
40
+
{"overview", "/", "square-chart-gantt"},
41
+
{"issues", "/issues", "circle-dot"},
42
+
{"pulls", "/pulls", "git-pull-request"},
45
+
if r.Roles.SettingsAllowed() {
46
+
tabs = append(tabs, []string{"settings", "/settings", "cog"})
52
+
type RepoInfo struct {
68
+
// each tab on a repo could have some metadata:
70
+
// issues -> number of open issues etc.
71
+
// settings -> a warning icon to setup branch protection? idk
73
+
// we gather these bits of info here, because go templates
74
+
// are difficult to program in
75
+
func (r RepoInfo) TabMetadata() map[string]any {
76
+
meta := make(map[string]any)
78
+
if r.Stats.PullCount.Open > 0 {
79
+
meta["pulls"] = r.Stats.PullCount.Open
82
+
if r.Stats.IssueCount.Open > 0 {
83
+
meta["issues"] = r.Stats.IssueCount.Open
91
+
type RolesInRepo struct {
95
+
func (r RolesInRepo) SettingsAllowed() bool {
96
+
return slices.Contains(r.Roles, "repo:settings")
99
+
func (r RolesInRepo) CollaboratorInviteAllowed() bool {
100
+
return slices.Contains(r.Roles, "repo:invite")
103
+
func (r RolesInRepo) RepoDeleteAllowed() bool {
104
+
return slices.Contains(r.Roles, "repo:delete")
107
+
func (r RolesInRepo) IsOwner() bool {
108
+
return slices.Contains(r.Roles, "repo:owner")
111
+
func (r RolesInRepo) IsCollaborator() bool {
112
+
return slices.Contains(r.Roles, "repo:collaborator")
115
+
func (r RolesInRepo) IsPushAllowed() bool {
116
+
return slices.Contains(r.Roles, "repo:push")