Skip to content

Commit a2a65de

Browse files
committed
Merge branch 'main' into feat/issue-6267/add-vscode-insiders
2 parents 26e1486 + 00a3077 commit a2a65de

File tree

6 files changed

+74
-33
lines changed

6 files changed

+74
-33
lines changed

site/src/components/Dialogs/DeleteDialog/DeleteDialog.tsx

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -41,20 +41,29 @@ export const DeleteDialog: FC<PropsWithChildren<DeleteDialogProps>> = ({
4141
</Maybe>
4242
<p>{t("deleteDialog.confirm", { entity })}</p>
4343

44-
<TextField
45-
fullWidth
46-
autoFocus
47-
className={styles.textField}
48-
name="confirmation"
49-
autoComplete="off"
50-
id="confirmation"
51-
placeholder={name}
52-
value={nameValue}
53-
onChange={handleChange}
54-
label={t("deleteDialog.confirmLabel", { entity })}
55-
error={hasError}
56-
helperText={hasError && t("deleteDialog.incorrectName", { entity })}
57-
/>
44+
<form
45+
onSubmit={(e) => {
46+
e.preventDefault()
47+
if (confirmed) {
48+
onConfirm()
49+
}
50+
}}
51+
>
52+
<TextField
53+
fullWidth
54+
autoFocus
55+
className={styles.textField}
56+
name="confirmation"
57+
autoComplete="off"
58+
id="confirmation"
59+
placeholder={name}
60+
value={nameValue}
61+
onChange={handleChange}
62+
label={t("deleteDialog.confirmLabel", { entity })}
63+
error={hasError}
64+
helperText={hasError && t("deleteDialog.incorrectName", { entity })}
65+
/>
66+
</form>
5867
</>
5968
)
6069

site/src/components/Navbar/NavbarView.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import Divider from "@mui/material/Divider"
2323
import HelpOutline from "@mui/icons-material/HelpOutline"
2424
import Tooltip from "@mui/material/Tooltip"
2525
import Skeleton from "@mui/material/Skeleton"
26+
import { BUTTON_SM_HEIGHT } from "theme/theme"
2627

2728
export const USERS_LINK = `/users?filter=${encodeURIComponent("status:active")}`
2829

@@ -195,7 +196,7 @@ const ProxyMenu: FC<{ proxyContextValue: ProxyContextValue }> = ({
195196
return (
196197
<Skeleton
197198
width="160px"
198-
height={30}
199+
height={BUTTON_SM_HEIGHT}
199200
sx={{ borderRadius: "4px", transform: "none" }}
200201
/>
201202
)

site/src/components/UserDropdown/UsersDropdown.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { BorderedMenu } from "../BorderedMenu/BorderedMenu"
99
import { CloseDropdown, OpenDropdown } from "../DropdownArrows/DropdownArrows"
1010
import { UserAvatar } from "../UserAvatar/UserAvatar"
1111
import { UserDropdownContent } from "../UserDropdownContent/UserDropdownContent"
12+
import { BUTTON_SM_HEIGHT } from "theme/theme"
1213

1314
export interface UserDropdownProps {
1415
user: TypesGen.User
@@ -42,7 +43,15 @@ export const UserDropdown: FC<PropsWithChildren<UserDropdownProps>> = ({
4243
>
4344
<div className={styles.inner}>
4445
<Badge overlap="circular">
45-
<UserAvatar username={user.username} avatarURL={user.avatar_url} />
46+
<UserAvatar
47+
sx={{
48+
width: BUTTON_SM_HEIGHT,
49+
height: BUTTON_SM_HEIGHT,
50+
fontSize: 16,
51+
}}
52+
username={user.username}
53+
avatarURL={user.avatar_url}
54+
/>
4655
</Badge>
4756
{anchorEl ? (
4857
<CloseDropdown color={colors.gray[6]} />

site/src/components/WorkspaceActions/WorkspaceActions.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,7 @@ export const WorkspaceActions: FC<WorkspaceActionsProps> = ({
102102
? buttonMapping[ButtonTypesEnum.updating]
103103
: buttonMapping[ButtonTypesEnum.update])}
104104
{isRestarting && buttonMapping[ButtonTypesEnum.restarting]}
105-
{!isRestarting &&
106-
actionsByStatus.map((action) => (
107-
<span key={action}>{buttonMapping[action]}</span>
108-
))}
105+
{!isRestarting && actionsByStatus.map((action) => buttonMapping[action])}
109106
{canCancel && <CancelButton handleAction={handleCancel} />}
110107
<div>
111108
<IconButton

site/src/pages/WorkspacesPage/filter/autocompletes.ts

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { useQuery } from "@tanstack/react-query"
99
import { getTemplates, getUsers } from "api/api"
1010
import { WorkspaceStatuses } from "api/typesGenerated"
1111
import { getDisplayWorkspaceStatus } from "utils/workspace"
12+
import { useMe } from "hooks"
1213

1314
type UseAutocompleteOptions<TOption extends BaseOption> = {
1415
id: string
@@ -50,7 +51,7 @@ const useAutocomplete = <TOption extends BaseOption = BaseOption>({
5051
})
5152
const selectedOption = selectedOptionQuery.data
5253
const searchOptionsQuery = useQuery({
53-
queryKey: [id, "autocomplete", "search"],
54+
queryKey: [id, "autocomplete", "search", query],
5455
queryFn: () => getOptions(query),
5556
enabled,
5657
})
@@ -114,8 +115,18 @@ export const useUsersAutocomplete = (
114115
value: string | undefined,
115116
onChange: (option: OwnerOption | undefined) => void,
116117
enabled?: boolean,
117-
) =>
118-
useAutocomplete({
118+
) => {
119+
const me = useMe()
120+
121+
const addMeAsFirstOption = (options: OwnerOption[]) => {
122+
options = options.filter((option) => option.value !== me.username)
123+
return [
124+
{ label: me.username, value: me.username, avatarUrl: me.avatar_url },
125+
...options,
126+
]
127+
}
128+
129+
return useAutocomplete({
119130
onChange,
120131
enabled,
121132
value,
@@ -134,13 +145,16 @@ export const useUsersAutocomplete = (
134145
},
135146
getOptions: async (query) => {
136147
const usersRes = await getUsers({ q: query, limit: 25 })
137-
return usersRes.users.map((user) => ({
148+
let options: OwnerOption[] = usersRes.users.map((user) => ({
138149
label: user.username,
139150
value: user.username,
140151
avatarUrl: user.avatar_url,
141152
}))
153+
options = addMeAsFirstOption(options)
154+
return options
142155
},
143156
})
157+
}
144158

145159
export type UsersAutocomplete = ReturnType<typeof useUsersAutocomplete>
146160

site/src/theme/theme.ts

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ import { ThemeOptions, createTheme, Theme } from "@mui/material/styles"
33
import { BODY_FONT_FAMILY, borderRadius } from "./constants"
44

55
// MUI does not have aligned heights for buttons and inputs so we have to "hack" it a little bit
6-
const BUTTON_LG_HEIGHT = 42
7-
const BUTTON_MD_HEIGHT = 36
8-
const BUTTON_SM_HEIGHT = 30
6+
export const BUTTON_LG_HEIGHT = 40
7+
export const BUTTON_MD_HEIGHT = 36
8+
export const BUTTON_SM_HEIGHT = 32
99

1010
export type PaletteIndex = keyof Theme["palette"]
1111
export type PaletteStatusIndex = Extract<
@@ -110,6 +110,8 @@ dark = createTheme(dark, {
110110
},
111111
},
112112
},
113+
// Button styles are based on
114+
// https://tailwindui.com/components/application-ui/elements/buttons
113115
MuiButtonBase: {
114116
defaultProps: {
115117
disableRipple: true,
@@ -127,20 +129,26 @@ dark = createTheme(dark, {
127129
fontWeight: 500,
128130
height: BUTTON_MD_HEIGHT,
129131
padding: theme.spacing(1, 2),
132+
borderRadius: "6px",
133+
fontSize: 14,
130134

131135
whiteSpace: "nowrap",
132136
":focus-visible": {
133137
outline: `2px solid ${theme.palette.primary.main}`,
134138
},
139+
140+
"& .MuiLoadingButton-loadingIndicator": {
141+
width: 14,
142+
height: 14,
143+
},
144+
145+
"& .MuiLoadingButton-loadingIndicator .MuiCircularProgress-root": {
146+
width: "inherit !important",
147+
height: "inherit !important",
148+
},
135149
}),
136150
sizeSmall: {
137-
borderRadius: 6,
138151
height: BUTTON_SM_HEIGHT,
139-
140-
"& .MuiCircularProgress-root": {
141-
width: "14px !important",
142-
height: "14px !important",
143-
},
144152
},
145153
sizeLarge: {
146154
height: BUTTON_LG_HEIGHT,
@@ -174,6 +182,9 @@ dark = createTheme(dark, {
174182
fontSize: 13,
175183
},
176184
},
185+
startIcon: {
186+
marginLeft: "-2px",
187+
},
177188
},
178189
},
179190
MuiTableContainer: {

0 commit comments

Comments
 (0)