1
1
import { Story } from "@storybook/react"
2
2
import {
3
+ MockPrimaryRegion ,
4
+ MockRegions ,
3
5
MockWorkspace ,
4
6
MockWorkspaceAgent ,
5
7
MockWorkspaceAgentConnecting ,
@@ -17,6 +19,7 @@ import {
17
19
} from "testHelpers/entities"
18
20
import { AgentRow , AgentRowProps } from "./AgentRow"
19
21
import { ProxyContext , getURLs } from "contexts/ProxyContext"
22
+ import { Region } from "api/typesGenerated"
20
23
21
24
export default {
22
25
title : "components/AgentRow" ,
@@ -37,10 +40,18 @@ export default {
37
40
} ,
38
41
}
39
42
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
42
53
value = { {
43
- proxy : getURLs ( [ ] , undefined ) ,
54
+ proxy : getURLs ( regions , selectedRegion ) ,
44
55
isLoading : false ,
45
56
setProxy : ( ) => {
46
57
return
@@ -49,7 +60,8 @@ const Template: Story<AgentRowProps> = (args) => (
49
60
>
50
61
< AgentRow { ...args } />
51
62
</ ProxyContext . Provider >
52
- )
63
+ }
64
+
53
65
54
66
const defaultAgentMetadata = [
55
67
{
@@ -234,7 +246,7 @@ Off.args = {
234
246
agent : MockWorkspaceAgentOff ,
235
247
}
236
248
237
- export const ShowingPortForward = Template . bind ( { } )
249
+ export const ShowingPortForward = TemplateWithPortForward . bind ( { } )
238
250
ShowingPortForward . args = {
239
251
...Example . args ,
240
252
}
0 commit comments