Skip to content

Commit 4d8bd1c

Browse files
committed
yay
1 parent 294281c commit 4d8bd1c

File tree

2 files changed

+43
-34
lines changed

2 files changed

+43
-34
lines changed

site/src/components/Tabs/Tabs.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,11 @@ interface TabLinkProps extends NavLinkProps {
2929
className?: string;
3030
}
3131

32-
export const TabLink: FC<TabLinkProps> = ({ className, ...linkProps }) => {
32+
export const TabLink: FC<TabLinkProps> = ({
33+
className,
34+
children,
35+
...linkProps
36+
}) => {
3337
const tabLink = useClassName(classNames.tabLink, []);
3438
const activeTabLink = useClassName(classNames.activeTabLink, []);
3539

site/src/pages/WorkspacePage/WorkspaceActions/Buttons.tsx

Lines changed: 38 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
import { type FC } from "react";
2-
import type { Workspace, WorkspaceBuildParameter } from "api/typesGenerated";
3-
import { BuildParametersPopover } from "./BuildParametersPopover";
4-
51
import Tooltip from "@mui/material/Tooltip";
62
import Button from "@mui/material/Button";
73
import LoadingButton from "@mui/lab/LoadingButton";
@@ -15,15 +11,18 @@ import OutlinedBlockIcon from "@mui/icons-material/BlockOutlined";
1511
import PowerSettingsNewIcon from "@mui/icons-material/PowerSettingsNew";
1612
import RetryIcon from "@mui/icons-material/BuildOutlined";
1713
import RetryDebugIcon from "@mui/icons-material/BugReportOutlined";
14+
import { type FC } from "react";
15+
import type { Workspace, WorkspaceBuildParameter } from "api/typesGenerated";
16+
import { BuildParametersPopover } from "./BuildParametersPopover";
1817

19-
interface WorkspaceActionProps {
18+
interface ActionButtonProps {
2019
loading?: boolean;
21-
handleAction: () => void;
20+
handleAction: (buildParameters?: WorkspaceBuildParameter[]) => void;
2221
disabled?: boolean;
2322
tooltipText?: string;
2423
}
2524

26-
export const UpdateButton: FC<WorkspaceActionProps> = ({
25+
export const UpdateButton: FC<ActionButtonProps> = ({
2726
handleAction,
2827
loading,
2928
}) => {
@@ -33,14 +32,14 @@ export const UpdateButton: FC<WorkspaceActionProps> = ({
3332
loadingPosition="start"
3433
data-testid="workspace-update-button"
3534
startIcon={<CloudQueueIcon />}
36-
onClick={handleAction}
35+
onClick={() => handleAction()}
3736
>
3837
{loading ? <>Updating&hellip;</> : <>Update&hellip;</>}
3938
</LoadingButton>
4039
);
4140
};
4241

43-
export const ActivateButton: FC<WorkspaceActionProps> = ({
42+
export const ActivateButton: FC<ActionButtonProps> = ({
4443
handleAction,
4544
loading,
4645
}) => {
@@ -49,30 +48,29 @@ export const ActivateButton: FC<WorkspaceActionProps> = ({
4948
loading={loading}
5049
loadingPosition="start"
5150
startIcon={<PowerSettingsNewIcon />}
52-
onClick={handleAction}
51+
onClick={() => handleAction()}
5352
>
5453
{loading ? <>Activating&hellip;</> : "Activate"}
5554
</LoadingButton>
5655
);
5756
};
5857

59-
type StartButtonProps = Omit<WorkspaceActionProps, "handleAction"> & {
58+
interface ActionButtonPropsWithWorkspace extends ActionButtonProps {
6059
workspace: Workspace;
61-
handleAction: (buildParameters?: WorkspaceBuildParameter[]) => void;
62-
};
60+
}
6361

64-
export const StartButton: FC<StartButtonProps> = ({
62+
export const StartButton: FC<ActionButtonPropsWithWorkspace> = ({
6563
handleAction,
6664
workspace,
6765
loading,
6866
disabled,
6967
tooltipText,
7068
}) => {
71-
return (
69+
const buttonContent = (
7270
<ButtonGroup
7371
variant="outlined"
74-
css={{
75-
// Workaround to make the border transitions smmothly on button groups
72+
sx={{
73+
// Workaround to make the border transitions smoothly on button groups
7674
"& > button:hover + button": {
7775
borderLeft: "1px solid #FFF",
7876
},
@@ -95,9 +93,15 @@ export const StartButton: FC<StartButtonProps> = ({
9593
/>
9694
</ButtonGroup>
9795
);
96+
97+
return tooltipText ? (
98+
<Tooltip title={tooltipText}>{buttonContent}</Tooltip>
99+
) : (
100+
buttonContent
101+
);
98102
};
99103

100-
export const StopButton: FC<WorkspaceActionProps> = ({
104+
export const StopButton: FC<ActionButtonProps> = ({
101105
handleAction,
102106
loading,
103107
}) => {
@@ -106,31 +110,26 @@ export const StopButton: FC<WorkspaceActionProps> = ({
106110
loading={loading}
107111
loadingPosition="start"
108112
startIcon={<CropSquareIcon />}
109-
onClick={handleAction}
113+
onClick={() => handleAction()}
110114
data-testid="workspace-stop-button"
111115
>
112116
{loading ? <>Stopping&hellip;</> : "Stop"}
113117
</LoadingButton>
114118
);
115119
};
116120

117-
type RestartButtonProps = Omit<WorkspaceActionProps, "handleAction"> & {
118-
workspace: Workspace;
119-
handleAction: (buildParameters?: WorkspaceBuildParameter[]) => void;
120-
};
121-
122-
export const RestartButton: FC<RestartButtonProps> = ({
121+
export const RestartButton: FC<ActionButtonPropsWithWorkspace> = ({
123122
handleAction,
124123
loading,
125124
workspace,
126125
disabled,
127126
tooltipText,
128127
}) => {
129-
return (
128+
const buttonContent = (
130129
<ButtonGroup
131130
variant="outlined"
132131
css={{
133-
// Workaround to make the border transitions smmothly on button groups
132+
// Workaround to make the border transitions smoothly on button groups
134133
"& > button:hover + button": {
135134
borderLeft: "1px solid #FFF",
136135
},
@@ -154,21 +153,27 @@ export const RestartButton: FC<RestartButtonProps> = ({
154153
/>
155154
</ButtonGroup>
156155
);
156+
157+
return tooltipText ? (
158+
<Tooltip title={tooltipText}>{buttonContent}</Tooltip>
159+
) : (
160+
buttonContent
161+
);
157162
};
158163

159-
export const CancelButton: FC<WorkspaceActionProps> = ({ handleAction }) => {
164+
export const CancelButton: FC<ActionButtonProps> = ({ handleAction }) => {
160165
return (
161-
<Button startIcon={<BlockIcon />} onClick={handleAction}>
166+
<Button startIcon={<BlockIcon />} onClick={() => handleAction()}>
162167
Cancel
163168
</Button>
164169
);
165170
};
166171

167-
interface DisabledProps {
172+
interface DisabledButtonProps {
168173
label: string;
169174
}
170175

171-
export const DisabledButton: FC<DisabledProps> = ({ label }) => {
176+
export const DisabledButton: FC<DisabledButtonProps> = ({ label }) => {
172177
return (
173178
<Button startIcon={<OutlinedBlockIcon />} disabled>
174179
{label}
@@ -188,7 +193,7 @@ export const ActionLoadingButton: FC<LoadingProps> = ({ label }) => {
188193
);
189194
};
190195

191-
type RetryButtonProps = Omit<WorkspaceActionProps, "loading"> & {
196+
type RetryButtonProps = Omit<ActionButtonProps, "loading"> & {
192197
debug?: boolean;
193198
};
194199

@@ -199,7 +204,7 @@ export const RetryButton: FC<RetryButtonProps> = ({
199204
return (
200205
<Button
201206
startIcon={debug ? <RetryDebugIcon /> : <RetryIcon />}
202-
onClick={handleAction}
207+
onClick={() => handleAction()}
203208
>
204209
Retry{debug && " (Debug)"}
205210
</Button>

0 commit comments

Comments
 (0)