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

Commit6e1032c

Browse files
committed
Add Storybook
1 parentb1b3fcb commit6e1032c

File tree

4 files changed

+40
-12
lines changed

4 files changed

+40
-12
lines changed

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,18 @@ Starting.args = {
100100
workspace:MockWorkspace,
101101
applicationsHost:"",
102102
showApps:true,
103+
104+
storybookStartupLogs:[
105+
"Cloning Git repository...",
106+
"Starting Docker Daemon...",
107+
"Adding some 🧙magic🧙...",
108+
"Starting VS Code...",
109+
].map((line,index)=>({
110+
id:index,
111+
level:"info",
112+
output:line,
113+
time:"",
114+
})),
103115
}
104116

105117
exportconstStartTimeout=Template.bind({})

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

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@ import { Prism as SyntaxHighlighter } from "react-syntax-highlighter"
2525
import{darcula}from"react-syntax-highlighter/dist/cjs/styles/prism"
2626
importAutoSizerfrom"react-virtualized-auto-sizer"
2727
import{FixedSizeListasList,ListOnScrollProps}from"react-window"
28-
import{workspaceAgentLogsMachine}from"xServices/workspaceAgentLogs/workspaceAgentLogsXService"
28+
import{
29+
LineWithID,
30+
workspaceAgentLogsMachine,
31+
}from"xServices/workspaceAgentLogs/workspaceAgentLogsXService"
2932
import{Workspace,WorkspaceAgent}from"../../api/typesGenerated"
3033
import{AppLink}from"../AppLink/AppLink"
3134
import{SSHButton}from"../SSHButton/SSHButton"
@@ -44,6 +47,8 @@ export interface AgentRowProps {
4447
hideVSCodeDesktopButton?:boolean
4548
serverVersion:string
4649
onUpdateAgent:()=>void
50+
51+
storybookStartupLogs?:LineWithID[]
4752
}
4853

4954
exportconstAgentRow:FC<AgentRowProps>=({
@@ -55,15 +60,28 @@ export const AgentRow: FC<AgentRowProps> = ({
5560
hideVSCodeDesktopButton,
5661
serverVersion,
5762
onUpdateAgent,
63+
storybookStartupLogs,
5864
})=>{
5965
conststyles=useStyles()
6066
const{ t}=useTranslation("agent")
67+
6168
const[logsMachine,sendLogsEvent]=useMachine(workspaceAgentLogsMachine,{
6269
context:{agentID:agent.id},
70+
services:process.env.STORYBOOK
71+
?{
72+
getStartupLogs:async()=>{
73+
returnstorybookStartupLogs||[]
74+
},
75+
streamStartupLogs:()=>async()=>{
76+
// noop
77+
},
78+
}
79+
:undefined,
6380
})
6481
consttheme=useTheme()
6582
conststartupScriptAnchorRef=useRef<HTMLLinkElement>(null)
6683
const[startupScriptOpen,setStartupScriptOpen]=useState(false)
84+
6785
consthasStartupFeatures=
6886
Boolean(agent.startup_script)||
6987
Boolean(logsMachine.context.startupLogs?.length)
@@ -73,6 +91,14 @@ export const AgentRow: FC<AgentRowProps> = ({
7391
useEffect(()=>{
7492
setShowStartupLogs(agent.lifecycle_state!=="ready"&&hasStartupFeatures)
7593
},[agent.lifecycle_state,hasStartupFeatures])
94+
// External applications can provide startup logs for an agent during it's spawn.
95+
// These could be Kubernetes logs, or other logs that are useful to the user.
96+
// For this reason, we want to fetch these logs when the agent is starting.
97+
useEffect(()=>{
98+
if(agent.lifecycle_state==="starting"){
99+
sendLogsEvent("FETCH_STARTUP_LOGS")
100+
}
101+
},[sendLogsEvent,agent.lifecycle_state])
76102
useEffect(()=>{
77103
// We only want to fetch logs when they are actually shown,
78104
// otherwise we can make a lot of requests that aren't necessary.

‎site/src/components/Workspace/Workspace.stories.tsx

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -122,13 +122,3 @@ CancellationError.args = {
122122
}),
123123
},
124124
}
125-
126-
exportconstStartupLogsError=Template.bind({})
127-
StartupLogsError.args={
128-
StartupLogs:newError("Unable to fetch startup logs"),
129-
}
130-
131-
exportconstStartupLogs=Template.bind({})
132-
StartupLogs.args={
133-
StartupLogs:[{agent_id:"agent",job_id:"job",output:"startup logs"}],
134-
}

‎site/src/xServices/workspaceAgentLogs/workspaceAgentLogsXService.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { Line } from "components/Logs/Logs"
66
// Logs are stored as the Line interface to make rendering
77
// much more efficient. Instead of mapping objects each time, we're
88
// able to just pass the array of logs to the component.
9-
interfaceLineWithIDextendsLine{
9+
exportinterfaceLineWithIDextendsLine{
1010
id:number
1111
}
1212

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp