Skip to content

Commit e044850

Browse files
authored
feat(registry): show tooltip for secrets and env var (#620)
1 parent 02b9afe commit e044850

File tree

3 files changed

+22
-4
lines changed

3 files changed

+22
-4
lines changed

renderer/src/common/components/ui/tooltip-info-icon.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@ export function TooltipInfoIcon({
1313
return (
1414
<Tooltip>
1515
<TooltipTrigger asChild autoFocus={false}>
16-
<InfoIcon className="text-muted-foreground size-4 rounded-full" />
16+
<InfoIcon
17+
className="text-muted-foreground size-4 rounded-full"
18+
data-testid="tooltip-info-icon"
19+
/>
1720
</TooltipTrigger>
1821
<TooltipContent className={className}>{children}</TooltipContent>
1922
</Tooltip>

renderer/src/features/registry-servers/components/__tests__/form-run-from-registry.test.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type {
22
RegistryEnvVar,
33
RegistryImageMetadata,
44
} from '@/common/api/generated'
5-
import { render, screen, waitFor, act } from '@testing-library/react'
5+
import { render, screen, waitFor, act, within } from '@testing-library/react'
66
import { it, expect, vi, describe, beforeEach } from 'vitest'
77
import { FormRunFromRegistry } from '../form-run-from-registry'
88
import userEvent from '@testing-library/user-event'
@@ -55,7 +55,7 @@ const REGISTRY_SERVER: RegistryImageMetadata = {
5555
const ENV_VARS_OPTIONAL = [
5656
{
5757
name: 'ENV_VAR',
58-
description: 'foo bar',
58+
description: 'description of env var',
5959
required: false,
6060
},
6161

@@ -120,6 +120,14 @@ describe('FormRunFromRegistry', () => {
120120
expect(screen.getByLabelText('Command arguments')).toBeInTheDocument()
121121
expect(screen.getByLabelText('SECRET value')).toBeInTheDocument()
122122
expect(screen.getByLabelText('ENV_VAR value')).toBeInTheDocument()
123+
const formLabel = screen.getByText(/env_var/i).closest('label')
124+
const tooltipIcon = within(formLabel!).getByTestId('tooltip-info-icon')
125+
await userEvent.hover(tooltipIcon)
126+
await waitFor(() => {
127+
const tooltip = screen.getByRole('tooltip')
128+
expect(tooltip).toBeInTheDocument()
129+
expect(tooltip).toHaveTextContent('description of env var')
130+
})
123131
expect(
124132
screen.getByRole('button', { name: 'Install server' })
125133
).toBeInTheDocument()

renderer/src/features/registry-servers/components/form-run-from-registry/configuration-tab-content.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import type { GroupedEnvVars } from '../../lib/group-env-vars'
1515
import type { RegistryEnvVar } from '@/common/api/generated/types.gen'
1616
import { cn } from '@/common/lib/utils'
1717
import { FormComboboxSecretStore } from '@/common/components/secrets/form-combobox-secrets-store'
18+
import { TooltipInfoIcon } from '@/common/components/ui/tooltip-info-icon'
1819

1920
interface ConfigurationTabContentProps {
2021
error: string | null
@@ -51,6 +52,9 @@ function SecretRow({
5152
)}
5253
>
5354
{secret.name}
55+
<TooltipInfoIcon className="m-w-90">
56+
{secret.description}
57+
</TooltipInfoIcon>
5458
</FormLabel>
5559
</FormControl>
5660
</div>
@@ -127,10 +131,13 @@ function EnvVarRow({
127131
htmlFor={`envVar.${index}.value`}
128132
className={cn(
129133
`text-muted-foreground !border-input flex h-full
130-
items-center gap-1 font-mono !ring-0`
134+
items-center gap-2 font-mono !ring-0`
131135
)}
132136
>
133137
{envVar.name}
138+
<TooltipInfoIcon className="w-90">
139+
{envVar.description}
140+
</TooltipInfoIcon>
134141
</FormLabel>
135142
</FormControl>
136143
</div>

0 commit comments

Comments
 (0)