Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add circleDot capability #1549

Merged
merged 2 commits into from
Jan 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions ee/desktop/user/menu/menu_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const (
funcRelativeTime = "relativeTime"
errorlessTemplateVars = "errorlessTemplateVars" // capability to evaluate undefined template vars without failing
errorlessActions = "errorlessActions" // capability to evaluate undefined menu item actions without failing
circleDot = "circleDot" // capability to use circle-dot icon

// TemplateData keys
LauncherVersion string = "LauncherVersion"
Expand Down Expand Up @@ -56,6 +57,8 @@ func (tp *templateParser) Parse(text string) (string, error) {
return true
case errorlessActions:
return true
case circleDot:
return true
}
return false
},
Expand Down
12 changes: 12 additions & 0 deletions ee/desktop/user/menu/menu_template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,18 @@ func Test_Parse(t *testing.T) {
text: "This capability is {{if hasCapability `bad capability`}}supported{{else}}unsupported{{end}}.",
output: "This capability is unsupported.",
},
{
name: "circleDot capability",
td: &TemplateData{},
text: "\"icon\":\"{{if not (hasCapability `circleDot`)}}triangle-exclamation{{else}}circle-dot{{end}}\"",
output: "\"icon\":\"circle-dot\"",
},
{
name: "icon fallback capability",
td: &TemplateData{},
text: "\"icon\":\"{{if not (hasCapability `asOfYetUnknownIconType`)}}triangle-exclamation{{else}}new-icon-type{{end}}\"",
output: "\"icon\":\"triangle-exclamation\"",
},
{
name: "relativeTime 2 hours ago",
td: &TemplateData{LastMenuUpdateTime: time.Now().Add(-2 * time.Hour).Unix()},
Expand Down
Loading