Skip to content

Commit 3b66096

Browse files
committed
Say on a project's detail view whether it has a logo
The logo's only field is a signed-in redirect URL, no use to read in a terminal, so the view says the logo is set and leaves the URL to JSON.
1 parent 76e7356 commit 3b66096

3 files changed

Lines changed: 30 additions & 1 deletion

File tree

‎internal/presenter/format.go‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ func FormatField(spec FieldSpec, key string, val any, locale Locale) string {
3030
return formatDock(val)
3131
case "steps":
3232
return formatSteps(val)
33+
case "logo":
34+
return formatLogo(val)
3335
case "wallpaper":
3436
return formatWallpaper(val)
3537
default:
@@ -48,6 +50,15 @@ func formatWallpaper(val any) string {
4850
return ""
4951
}
5052

53+
// formatLogo says a project has a logo. The logo has nothing to show in a
54+
// terminal but its URL, which is a signed-in redirect.
55+
func formatLogo(val any) string {
56+
if m, ok := val.(map[string]any); ok && m["url"] != nil {
57+
return "set"
58+
}
59+
return ""
60+
}
61+
5162
// formatSteps renders a CardStep array as a multi-line checklist.
5263
// Each step prefixes its title with [x] for completed, [ ] for active.
5364
func formatSteps(val any) string {

‎internal/presenter/presenter_test.go‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -705,6 +705,20 @@ func TestProjectDetailNamesTheWallpaperMode(t *testing.T) {
705705
assert.NotContains(t, with.String(), "/wallpaper")
706706
}
707707

708+
func TestProjectDetailSaysWhetherThereIsALogo(t *testing.T) {
709+
project := map[string]any{"id": float64(123), "name": "Launch", "status": "active"}
710+
711+
var without strings.Builder
712+
require.True(t, PresentWithTheme(&without, project, "project", ModeMarkdown, tui.NoColorTheme(), enUS))
713+
assert.NotContains(t, without.String(), "Logo")
714+
715+
project["logo"] = map[string]any{"url": "https://3.basecampapi.com/1/projects/123/logo?v=1"}
716+
var with strings.Builder
717+
require.True(t, PresentWithTheme(&with, project, "project", ModeMarkdown, tui.NoColorTheme(), enUS))
718+
assert.Contains(t, with.String(), "**Logo:** set")
719+
assert.NotContains(t, with.String(), "/logo")
720+
}
721+
708722
// =============================================================================
709723
// Collapse Tests
710724
// =============================================================================

‎internal/presenter/schemas/project.yaml‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ fields:
2929
role: detail
3030
format: text
3131

32+
logo:
33+
role: detail
34+
format: logo
35+
3236
wallpaper:
3337
role: detail
3438
format: wallpaper
@@ -56,7 +60,7 @@ views:
5660
sections:
5761
- fields: [name, description]
5862
- heading: Info
59-
fields: [status, bookmarked, wallpaper]
63+
fields: [status, bookmarked, logo, wallpaper]
6064
- heading: Dock
6165
fields: [dock]
6266
- heading: Metadata

0 commit comments

Comments
 (0)