Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat: add tooltip field to workspace app#435

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
rafrdz merged 4 commits intomainfromrafrdz/tooltip-support
Sep 10, 2025
Merged
Show file tree
Hide file tree
Changes fromall 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
2 changes: 2 additions & 0 deletionsdocs/resources/app.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -31,6 +31,7 @@ resource "coder_app" "code-server" {
display_name = "VS Code"
icon = "${data.coder_workspace.me.access_url}/icon/code.svg"
url = "http://localhost:13337"
tooltip = "You need to [Install Coder Desktop](https://coder.com/docs/user-guides/desktop#install-coder-desktop) to use this button."
share = "owner"
subdomain = false
open_in = "window"
Expand DownExpand Up@@ -71,6 +72,7 @@ resource "coder_app" "vim" {
- `order` (Number) The order determines the position of app in the UI presentation. The lowest order is shown first and apps with equal order are sorted by name (ascending order).
- `share` (String) Determines the level which the application is shared at. Valid levels are `"owner"` (default), `"authenticated"` and `"public"`. Level `"owner"` disables sharing on the app, so only the workspace owner can access it. Level `"authenticated"` shares the app with all authenticated users. Level `"public"` shares it with any user, including unauthenticated users. Permitted application sharing levels can be configured site-wide via a flag on `coder server` (Enterprise only).
- `subdomain` (Boolean) Determines whether the app will be accessed via it's own subdomain or whether it will be accessed via a path on Coder. If wildcards have not been setup by the administrator then apps with `subdomain` set to `true` will not be accessible. Defaults to `false`.
- `tooltip` (String) Markdown text that is displayed when hovering over workspace apps.
- `url` (String) An external url if `external=true` or a URL to be proxied to from inside the workspace. This should be of the form `http://localhost:PORT[/SUBPATH]`. Either `command` or `url` may be specified, but not both.

### Read-Only
Expand Down
1 change: 1 addition & 0 deletionsexamples/resources/coder_app/resource.tf
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -16,6 +16,7 @@ resource "coder_app" "code-server" {
display_name = "VS Code"
icon = "${data.coder_workspace.me.access_url}/icon/code.svg"
url = "http://localhost:13337"
tooltip = "You need to [Install Coder Desktop](https://coder.com/docs/user-guides/desktop#install-coder-desktop) to use this button."
share = "owner"
subdomain = false
open_in = "window"
Expand Down
18 changes: 18 additions & 0 deletionsprovider/app.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -27,6 +27,7 @@ var (
const (
appDisplayNameMaxLength = 64 // database column limit
appGroupNameMaxLength = 64
appTooltipMaxLength = 2048
)

func appResource() *schema.Resource {
Expand DownExpand Up@@ -273,6 +274,23 @@ func appResource() *schema.Resource {
return diag.Errorf(`invalid "coder_app" open_in value, must be one of "tab", "slim-window": %q`, valStr)
},
},
"tooltip": {
Type: schema.TypeString,
Description: "Markdown text that is displayed when hovering over workspace apps.",
ForceNew: true,
Optional: true,
ValidateDiagFunc: func(val any, c cty.Path) diag.Diagnostics {
valStr, ok := val.(string)
if !ok {
return diag.Errorf("expected string, got %T", val)
}

if len(valStr) > appTooltipMaxLength {
return diag.Errorf("tooltip is too long (max %d characters)", appTooltipMaxLength)
}
return nil
},
},
},
}
}
61 changes: 61 additions & 0 deletionsprovider/app_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,6 +4,7 @@ import (
"fmt"
"regexp"
"strconv"
"strings"
"testing"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
Expand DownExpand Up@@ -44,6 +45,7 @@ func TestApp(t *testing.T) {
order = 4
hidden = false
open_in = "slim-window"
tooltip = "You need to [Install Coder Desktop](https://coder.com/docs/user-guides/desktop#install-coder-desktop) to use this button."
}
`,
Check: func(state *terraform.State) error {
Expand All@@ -68,6 +70,7 @@ func TestApp(t *testing.T) {
"order",
"hidden",
"open_in",
"tooltip",
} {
value := resource.Primary.Attributes[key]
t.Logf("%q = %q", key, value)
Expand DownExpand Up@@ -535,4 +538,62 @@ func TestApp(t *testing.T) {
})
}
})

t.Run("Tooltip", func(t *testing.T) {
t.Parallel()

cases := []struct {
name string
tooltip string
expectError *regexp.Regexp
}{
{
name: "Empty",
tooltip: "",
},
{
name: "ValidTooltip",
tooltip: "You need to [Install Coder Desktop](https://coder.com/docs/user-guides/desktop" +
"#install-coder-desktop) to use this button.",
},
{
name: "TooltipTooLong",
tooltip: strings.Repeat("a", 2049),
expectError: regexp.MustCompile("tooltip is too long"),
},
}

for _, c := range cases {
c := c

t.Run(c.name, func(t *testing.T) {
t.Parallel()

config := fmt.Sprintf(`
provider "coder" {}
resource "coder_agent" "dev" {
os = "linux"
arch = "amd64"
}
resource "coder_app" "code-server" {
agent_id = coder_agent.dev.id
slug = "code-server"
display_name = "Testing"
url = "http://localhost:13337"
open_in = "slim-window"
tooltip = "%s"
}
`, c.tooltip)

resource.Test(t, resource.TestCase{
ProviderFactories: coderFactory(),
IsUnitTest: true,
Steps: []resource.TestStep{{
Config: config,
ExpectError: c.expectError,
}},
})
})
}
})
}

[8]ページ先頭

©2009-2025 Movatter.jp