Skip to content

Commit 0d0ed87

Browse files
committed
Fix port forward story
1 parent 836c5a4 commit 0d0ed87

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

site/src/components/Resources/AgentRow.stories.tsx

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { Story } from "@storybook/react"
22
import {
3+
MockPrimaryRegion,
4+
MockRegions,
35
MockWorkspace,
46
MockWorkspaceAgent,
57
MockWorkspaceAgentConnecting,
@@ -17,6 +19,7 @@ import {
1719
} from "testHelpers/entities"
1820
import { AgentRow, AgentRowProps } from "./AgentRow"
1921
import { ProxyContext, getURLs } from "contexts/ProxyContext"
22+
import { Region } from "api/typesGenerated"
2023

2124
export default {
2225
title: "components/AgentRow",
@@ -37,10 +40,18 @@ export default {
3740
},
3841
}
3942

40-
const Template: Story<AgentRowProps> = (args) => (
41-
<ProxyContext.Provider
43+
const Template: Story<AgentRowProps> = (args) => {
44+
return TemplateFC(args, [], undefined)
45+
}
46+
47+
const TemplateWithPortForward: Story<AgentRowProps> = (args) => {
48+
return TemplateFC(args, MockRegions, MockPrimaryRegion)
49+
}
50+
51+
const TemplateFC = (args: AgentRowProps, regions: Region[], selectedRegion?: Region) => {
52+
return <ProxyContext.Provider
4253
value={{
43-
proxy: getURLs([], undefined),
54+
proxy: getURLs(regions, selectedRegion),
4455
isLoading: false,
4556
setProxy: () => {
4657
return
@@ -49,7 +60,8 @@ const Template: Story<AgentRowProps> = (args) => (
4960
>
5061
<AgentRow {...args} />
5162
</ProxyContext.Provider>
52-
)
63+
}
64+
5365

5466
const defaultAgentMetadata = [
5567
{
@@ -234,7 +246,7 @@ Off.args = {
234246
agent: MockWorkspaceAgentOff,
235247
}
236248

237-
export const ShowingPortForward = Template.bind({})
249+
export const ShowingPortForward = TemplateWithPortForward.bind({})
238250
ShowingPortForward.args = {
239251
...Example.args,
240252
}

0 commit comments

Comments
 (0)