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

Commit568641f

Browse files
committed
Add stories!
1 parent396c069 commit568641f

File tree

3 files changed

+60
-50
lines changed

3 files changed

+60
-50
lines changed

‎site/src/components/Resources/AgentMetadata.tsx‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,14 +228,19 @@ export const AgentMetadataView: FC<AgentMetadataViewProps> = ({ metadata }) => {
228228

229229
exportconstAgentMetadata:FC<{
230230
agent:WorkspaceAgent
231-
}>=({ agent})=>{
231+
storybookMetadata?:WorkspaceAgentMetadata[]
232+
}>=({ agent, storybookMetadata})=>{
232233
const[metadata,setMetadata]=useState<
233234
WorkspaceAgentMetadata[]|undefined
234235
>(undefined)
235236

236237
constwatchAgentMetadata=useContext(WatchAgentMetadataContext)
237238

238239
useEffect(()=>{
240+
if(storybookMetadata!==undefined){
241+
setMetadata(storybookMetadata)
242+
return
243+
}
239244
constsource=watchAgentMetadata(agent.id)
240245

241246
source.onerror=(e)=>{
@@ -248,7 +253,7 @@ export const AgentMetadata: FC<{
248253
return()=>{
249254
source.close()
250255
}
251-
},[agent.id,watchAgentMetadata])
256+
},[agent.id,watchAgentMetadata,storybookMetadata])
252257

253258
if(metadata===undefined){
254259
return(

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

Lines changed: 41 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -24,37 +24,48 @@ export default {
2424

2525
constTemplate:Story<AgentRowProps>=(args)=><AgentRow{...args}/>
2626

27+
constdefaultAgentMetadata=[
28+
{
29+
result:{
30+
collected_at:"2021-05-05T00:00:00Z",
31+
error:"",
32+
value:"defvalue",
33+
age:5,
34+
},
35+
description:{
36+
display_name:"DisPlay",
37+
key:"defkey",
38+
interval:10,
39+
timeout:10,
40+
script:"some command",
41+
},
42+
},
43+
]
44+
2745
exportconstExample=Template.bind({})
2846
Example.args={
2947
agent:MockWorkspaceAgent,
3048
workspace:MockWorkspace,
3149
applicationsHost:"",
3250
showApps:true,
51+
storybookAgentMetadata:defaultAgentMetadata,
3352
}
3453

3554
exportconstHideSSHButton=Template.bind({})
3655
HideSSHButton.args={
37-
agent:MockWorkspaceAgent,
38-
workspace:MockWorkspace,
39-
applicationsHost:"",
40-
showApps:true,
56+
...Example.args,
4157
hideSSHButton:true,
4258
}
4359

4460
exportconstHideVSCodeDesktopButton=Template.bind({})
4561
HideVSCodeDesktopButton.args={
46-
agent:MockWorkspaceAgent,
47-
workspace:MockWorkspace,
48-
applicationsHost:"",
49-
showApps:true,
62+
...Example.args,
5063
hideVSCodeDesktopButton:true,
5164
}
5265

5366
exportconstNotShowingApps=Template.bind({})
5467
NotShowingApps.args={
55-
agent:MockWorkspaceAgent,
56-
workspace:MockWorkspace,
57-
applicationsHost:"",
68+
...Example.args,
5869
showApps:false,
5970
}
6071

@@ -81,26 +92,21 @@ BunchOfApps.args = {
8192

8293
exportconstConnecting=Template.bind({})
8394
Connecting.args={
95+
...Example.args,
8496
agent:MockWorkspaceAgentConnecting,
85-
workspace:MockWorkspace,
86-
applicationsHost:"",
87-
showApps:true,
97+
storybookAgentMetadata:[],
8898
}
8999

90100
exportconstTimeout=Template.bind({})
91101
Timeout.args={
102+
...Example.args,
92103
agent:MockWorkspaceAgentTimeout,
93-
workspace:MockWorkspace,
94-
applicationsHost:"",
95-
showApps:true,
96104
}
97105

98106
exportconstStarting=Template.bind({})
99107
Starting.args={
108+
...Example.args,
100109
agent:MockWorkspaceAgentStarting,
101-
workspace:MockWorkspace,
102-
applicationsHost:"",
103-
showApps:true,
104110

105111
storybookStartupLogs:[
106112
"Cloning Git repository...",
@@ -117,13 +123,11 @@ Starting.args = {
117123

118124
exportconstStarted=Template.bind({})
119125
Started.args={
126+
...Example.args,
120127
agent:{
121128
...MockWorkspaceAgentReady,
122129
startup_logs_length:1,
123130
},
124-
workspace:MockWorkspace,
125-
applicationsHost:"",
126-
showApps:true,
127131

128132
storybookStartupLogs:[
129133
"Cloning Git repository...",
@@ -138,67 +142,58 @@ Started.args = {
138142
})),
139143
}
140144

145+
exportconstStartedNoMetadata=Template.bind({})
146+
StartedNoMetadata.args={
147+
...Started.args,
148+
storybookAgentMetadata:[],
149+
}
150+
141151
exportconstStartTimeout=Template.bind({})
142152
StartTimeout.args={
153+
...Example.args,
143154
agent:MockWorkspaceAgentStartTimeout,
144-
workspace:MockWorkspace,
145-
applicationsHost:"",
146-
showApps:true,
147155
}
148156

149157
exportconstStartError=Template.bind({})
150158
StartError.args={
159+
...Example.args,
151160
agent:MockWorkspaceAgentStartError,
152-
workspace:MockWorkspace,
153-
applicationsHost:"",
154-
showApps:true,
155161
}
156162

157163
exportconstShuttingDown=Template.bind({})
158164
ShuttingDown.args={
165+
...Example.args,
159166
agent:MockWorkspaceAgentShuttingDown,
160-
workspace:MockWorkspace,
161-
applicationsHost:"",
162-
showApps:true,
163167
}
164168

165169
exportconstShutdownTimeout=Template.bind({})
166170
ShutdownTimeout.args={
171+
...Example.args,
167172
agent:MockWorkspaceAgentShutdownTimeout,
168-
workspace:MockWorkspace,
169-
applicationsHost:"",
170-
showApps:true,
171173
}
172174

173175
exportconstShutdownError=Template.bind({})
174176
ShutdownError.args={
177+
...Example.args,
175178
agent:MockWorkspaceAgentShutdownError,
176-
workspace:MockWorkspace,
177-
applicationsHost:"",
178-
showApps:true,
179179
}
180180

181181
exportconstOff=Template.bind({})
182182
Off.args={
183+
...Example.args,
183184
agent:MockWorkspaceAgentOff,
184-
workspace:MockWorkspace,
185-
applicationsHost:"",
186-
showApps:true,
187185
}
188186

189187
exportconstShowingPortForward=Template.bind({})
190188
ShowingPortForward.args={
191-
agent:MockWorkspaceAgent,
192-
workspace:MockWorkspace,
189+
...Example.args,
193190
applicationsHost:"https://coder.com",
194-
showApps:true,
195191
}
196192

197193
exportconstOutdated=Template.bind({})
198194
Outdated.args={
195+
...Example.args,
199196
agent:MockWorkspaceAgentOutdated,
200197
workspace:MockWorkspace,
201-
applicationsHost:"",
202-
showApps:true,
203198
serverVersion:"v99.999.9999+c1cdf14",
204199
}

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

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,12 @@ import {
2929
LineWithID,
3030
workspaceAgentLogsMachine,
3131
}from"xServices/workspaceAgentLogs/workspaceAgentLogsXService"
32-
import{Workspace,WorkspaceAgent}from"../../api/typesGenerated"
32+
import{
33+
Workspace,
34+
WorkspaceAgent,
35+
WorkspaceAgentMetadata,
36+
WorkspaceAgentMetadataDescription,
37+
}from"../../api/typesGenerated"
3338
import{AppLink}from"../AppLink/AppLink"
3439
import{SSHButton}from"../SSHButton/SSHButton"
3540
import{Stack}from"../Stack/Stack"
@@ -51,6 +56,7 @@ export interface AgentRowProps {
5156
onUpdateAgent:()=>void
5257

5358
storybookStartupLogs?:LineWithID[]
59+
storybookAgentMetadata?:WorkspaceAgentMetadata[]
5460
}
5561

5662
exportconstAgentRow:FC<AgentRowProps>=({
@@ -63,6 +69,7 @@ export const AgentRow: FC<AgentRowProps> = ({
6369
serverVersion,
6470
onUpdateAgent,
6571
storybookStartupLogs,
72+
storybookAgentMetadata,
6673
sshPrefix,
6774
})=>{
6875
conststyles=useStyles()
@@ -287,7 +294,10 @@ export const AgentRow: FC<AgentRowProps> = ({
287294
)}
288295
</Stack>
289296
</Stack>
290-
<AgentMetadataagent={agent}/>
297+
<AgentMetadata
298+
storybookMetadata={storybookAgentMetadata}
299+
agent={agent}
300+
/>
291301
{hasStartupFeatures&&(
292302
<Stack
293303
direction="row"

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp