Skip to content

Commit 69dd35d

Browse files
committed
feat: add description to flags
1 parent c4e7464 commit 69dd35d

File tree

3 files changed

+44
-1
lines changed

3 files changed

+44
-1
lines changed

server/features.templ

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,14 @@ templ feature(flag overleash.Feature, o *overleash.OverleashContext, showDetail
7070
}
7171
</div>
7272

73+
if flag.Description != "" {
74+
<div class="description">
75+
@templ.Raw(renderJiraLink(flag.Description))
76+
</div>
77+
}
78+
79+
<div class="separator"></div>
80+
7381
<div class="current-status">
7482
<div>
7583
<span class="label">Feature flag:</span>

server/helpers.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@ import (
44
"fmt"
55
"github.com/Iandenh/overleash/internal/version"
66
"github.com/Iandenh/overleash/overleash"
7+
"html"
78
"net/url"
9+
"regexp"
10+
"strings"
811
)
912

1013
func constraintsOfStrategy(strategy overleash.Strategy, segments map[int][]overleash.Constraint) []overleash.Constraint {
@@ -120,3 +123,18 @@ func (list *featureList) isSelected(key, value string) bool {
120123

121124
return urlValues.Get(key) == value
122125
}
126+
127+
func renderJiraLink(text string) string {
128+
text = html.EscapeString(strings.TrimSpace(text))
129+
130+
re := regexp.MustCompile(`https://[a-zA-Z0-9\-]+\.atlassian\.net/browse/([A-Z]+-\d+)`)
131+
132+
return re.ReplaceAllStringFunc(text, func(match string) string {
133+
subMatch := re.FindStringSubmatch(match)
134+
if len(subMatch) < 2 {
135+
return match
136+
}
137+
ticket := subMatch[1]
138+
return fmt.Sprintf(`<a target="_black" href="%s">%s</a>`, match, ticket)
139+
})
140+
}

server/static/style.css

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,10 @@ body {
150150
letter-spacing: .5px;
151151
}
152152

153+
a {
154+
color: var(--text-color);
155+
}
156+
153157
header {
154158
padding: 5px 16px;
155159
box-shadow: inset 0 -1px 0 var(--border-color-muted);
@@ -227,12 +231,25 @@ header {
227231
}
228232
}
229233

234+
.description {
235+
margin-top: 6px;
236+
color: var(--status-background-color);
237+
font-size: 0.75rem;
238+
}
239+
240+
.separator {
241+
margin: 1rem -1.25rem;
242+
width: auto;
243+
background-color: var(--border-color-muted);
244+
height: 1px;
245+
}
246+
230247
.current-status {
231248
font-family: inherit;
232249
font-weight: 400;
233250
line-height: 1.3;
234251
font-size: 0.85rem;
235-
margin-bottom: .5rem;
252+
margin-bottom: 1rem;
236253
color: var(--status-background-color);
237254

238255
.text {

0 commit comments

Comments
 (0)