Skip to content

Commit fe3aecc

Browse files
committed
Merge branch 'main' into apps
2 parents b056400 + 2b12bee commit fe3aecc

31 files changed

+337
-180
lines changed

.vscode/settings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@
8282
"workspaceagent",
8383
"workspaceapp",
8484
"workspaceapps",
85+
"workspacebuilds",
8586
"wsconncache",
8687
"xerrors",
8788
"xstate",

site/can-ndjson-stream.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
declare module "can-ndjson-stream" {
2+
function ndjsonStream<TValueType>(body: ReadableStream<Uint8Array> | null): Promise<ReadableStream<TValueType>>
3+
export default ndjsonStream
4+
}

site/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@
3535
"@xstate/inspect": "0.6.5",
3636
"@xstate/react": "3.0.0",
3737
"axios": "0.26.1",
38+
"can-ndjson-stream": "1.0.2",
39+
"cron-parser": "4.4.0",
3840
"cronstrue": "2.5.0",
3941
"dayjs": "1.11.2",
4042
"formik": "2.2.9",

site/src/api/api.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import axios, { AxiosRequestHeaders } from "axios"
2+
import ndjsonStream from "can-ndjson-stream"
23
import * as Types from "./types"
34
import { WorkspaceBuildTransition } from "./types"
45
import * as TypesGen from "./typesGenerated"
@@ -271,6 +272,20 @@ export const getWorkspaceBuildLogs = async (buildname: string): Promise<TypesGen
271272
return response.data
272273
}
273274

275+
export const streamWorkspaceBuildLogs = async (
276+
buildname: string,
277+
): Promise<ReadableStreamDefaultReader<TypesGen.ProvisionerJobLog>> => {
278+
// Axios does not support HTTP stream in the browser
279+
// https://github.com/axios/axios/issues/1474
280+
// So we are going to use window.fetch and return a "stream" reader
281+
const reader = await window
282+
.fetch(`/api/v2/workspacebuilds/${buildname}/logs?follow=true`)
283+
.then((res) => ndjsonStream<TypesGen.ProvisionerJobLog>(res.body))
284+
.then((stream) => stream.getReader())
285+
286+
return reader
287+
}
288+
274289
export const putWorkspaceExtension = async (
275290
workspaceId: string,
276291
extendWorkspaceRequest: TypesGen.PutExtendWorkspaceRequest,

site/src/components/BorderedMenu/BorderedMenu.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ const useStyles = makeStyles((theme) => ({
3131
},
3232
paperRoot: {
3333
width: "292px",
34-
border: `2px solid ${theme.palette.primary.main}`,
34+
border: `2px solid ${theme.palette.secondary.dark}`,
3535
borderRadius: 7,
36-
boxShadow: `4px 4px 0px ${fade(theme.palette.primary.main, 0.2)}`,
36+
boxShadow: `4px 4px 0px ${fade(theme.palette.secondary.dark, 0.2)}`,
3737
},
3838
}))

site/src/components/BorderedMenuRow/BorderedMenuRow.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,12 @@ const useStyles = makeStyles((theme) => ({
7878
},
7979

8080
"&[data-status='active']": {
81-
color: theme.palette.primary.main,
81+
color: theme.palette.secondary.dark,
8282
"& .BorderedMenuRow-description": {
8383
color: theme.palette.text.primary,
8484
},
8585
"& .BorderedMenuRow-icon": {
86-
color: theme.palette.primary.main,
86+
color: theme.palette.secondary.dark,
8787
},
8888
},
8989
},

site/src/components/BuildsTable/BuildsTable.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ const useStyles = makeStyles((theme) => ({
106106
},
107107

108108
"&:focus": {
109-
outline: `1px solid ${theme.palette.primary.dark}`,
109+
outline: `1px solid ${theme.palette.secondary.dark}`,
110110
},
111111
},
112112
}))

site/src/components/ConfirmDialog/ConfirmDialog.stories.tsx

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,24 @@ InfoDialog.args = {
3636
hideCancel: true,
3737
type: "info",
3838
}
39+
40+
export const InfoDialogWithCancel = Template.bind({})
41+
InfoDialogWithCancel.args = {
42+
description: "Information can be cool!",
43+
hideCancel: false,
44+
type: "info",
45+
}
46+
47+
export const SuccessDialog = Template.bind({})
48+
SuccessDialog.args = {
49+
description: "I am successful.",
50+
hideCancel: true,
51+
type: "success",
52+
}
53+
54+
export const SuccessDialogWithCancel = Template.bind({})
55+
SuccessDialogWithCancel.args = {
56+
description: "I may be successful.",
57+
hideCancel: false,
58+
type: "success",
59+
}

site/src/components/ConfirmDialog/ConfirmDialog.tsx

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ const CONFIRM_DIALOG_DEFAULTS: Record<ConfirmDialogType, ConfirmDialogTypeConfig
1919
confirmText: "OK",
2020
hideCancel: true,
2121
},
22+
success: {
23+
confirmText: "OK",
24+
hideCancel: true,
25+
},
2226
}
2327

2428
export interface ConfirmDialogProps extends Omit<DialogActionButtonsProps, "color" | "confirmDialog" | "onCancel"> {
@@ -41,40 +45,32 @@ export interface ConfirmDialogProps extends Omit<DialogActionButtonsProps, "colo
4145
readonly title: string
4246
}
4347

44-
interface StyleProps {
45-
type: ConfirmDialogType
46-
}
47-
4848
const useStyles = makeStyles((theme) => ({
49-
dialogWrapper: (props: StyleProps) => ({
49+
dialogWrapper: {
5050
"& .MuiPaper-root": {
51-
background: props.type === "info" ? theme.palette.primary.main : theme.palette.background.paper,
51+
background: theme.palette.background.paper,
5252
border: `1px solid ${theme.palette.divider}`,
5353
},
5454
"& .MuiDialogActions-spacing": {
5555
padding: `0 ${theme.spacing(3.75)}px ${theme.spacing(3.75)}px`,
5656
},
57-
}),
58-
dialogContent: (props: StyleProps) => ({
59-
color: props.type === "info" ? theme.palette.primary.contrastText : theme.palette.text.secondary,
57+
},
58+
dialogContent: {
59+
color: theme.palette.text.secondary,
6060
padding: theme.spacing(6),
6161
textAlign: "center",
62-
}),
62+
},
6363
titleText: {
6464
marginBottom: theme.spacing(3),
6565
},
66-
description: (props: StyleProps) => ({
67-
color:
68-
props.type === "info" ? fade(theme.palette.primary.contrastText, 0.75) : fade(theme.palette.text.secondary, 0.75),
66+
description: {
67+
color: fade(theme.palette.text.secondary, 0.75),
6968
lineHeight: "160%",
7069

7170
"& strong": {
72-
color:
73-
props.type === "info"
74-
? fade(theme.palette.primary.contrastText, 0.95)
75-
: fade(theme.palette.text.secondary, 0.95),
71+
color: fade(theme.palette.text.secondary, 0.95),
7672
},
77-
}),
73+
},
7874
}))
7975

8076
/**

site/src/components/Dialog/Dialog.tsx

Lines changed: 56 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -126,11 +126,12 @@ export const DialogActionButtons: React.FC<DialogActionButtonsProps> = ({
126126
color={typeToColor(type)}
127127
loading={confirmLoading}
128128
type="submit"
129-
className={combineClasses([
130-
styles.dialogButton,
131-
styles.submitButton,
132-
type === "delete" ? styles.errorButton : "",
133-
])}
129+
className={combineClasses({
130+
[styles.dialogButton]: true,
131+
[styles.submitButton]: true,
132+
[styles.errorButton]: type === "delete",
133+
[styles.successButton]: type === "success",
134+
})}
134135
>
135136
{confirmText}
136137
</LoadingButton>
@@ -246,6 +247,56 @@ const useButtonStyles = makeStyles((theme) => ({
246247
},
247248
},
248249
},
250+
successButton: {
251+
"&.MuiButton-contained": {
252+
backgroundColor: theme.palette.success.main,
253+
color: theme.palette.primary.contrastText,
254+
"&:hover": {
255+
backgroundColor: darken(theme.palette.success.main, 0.3),
256+
"@media (hover: none)": {
257+
backgroundColor: "transparent",
258+
},
259+
"&.Mui-disabled": {
260+
backgroundColor: "transparent",
261+
},
262+
},
263+
"&.Mui-disabled": {
264+
backgroundColor: theme.palette.action.disabledBackground,
265+
color: fade(theme.palette.text.disabled, 0.5),
266+
},
267+
},
268+
269+
"&.MuiButton-outlined": {
270+
color: theme.palette.success.main,
271+
borderColor: theme.palette.success.main,
272+
"&:hover": {
273+
backgroundColor: fade(theme.palette.success.main, theme.palette.action.hoverOpacity),
274+
"@media (hover: none)": {
275+
backgroundColor: "transparent",
276+
},
277+
"&.Mui-disabled": {
278+
backgroundColor: "transparent",
279+
},
280+
},
281+
"&.Mui-disabled": {
282+
color: fade(theme.palette.text.disabled, 0.5),
283+
borderColor: theme.palette.action.disabled,
284+
},
285+
},
286+
287+
"&.MuiButton-text": {
288+
color: theme.palette.success.main,
289+
"&:hover": {
290+
backgroundColor: fade(theme.palette.success.main, theme.palette.action.hoverOpacity),
291+
"@media (hover: none)": {
292+
backgroundColor: "transparent",
293+
},
294+
},
295+
"&.Mui-disabled": {
296+
color: fade(theme.palette.text.disabled, 0.5),
297+
},
298+
},
299+
},
249300
}))
250301

251302
export type DialogSearchProps = Omit<OutlinedInputProps, "className" | "fullWidth" | "labelWidth" | "startAdornment">

0 commit comments

Comments
 (0)