Skip to content

refactor(site): Group app and agent actions together #7267

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 3 additions & 22 deletions site/src/components/AppLink/AppLink.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import Button from "@material-ui/core/Button"
import CircularProgress from "@material-ui/core/CircularProgress"
import Link from "@material-ui/core/Link"
import { makeStyles } from "@material-ui/core/styles"
import Tooltip from "@material-ui/core/Tooltip"
import ErrorOutlineIcon from "@material-ui/icons/ErrorOutline"
import { PrimaryAgentButton } from "components/Resources/AgentButton"
import { FC } from "react"
import { combineClasses } from "utils/combineClasses"
import * as TypesGen from "../../api/typesGenerated"
Expand Down Expand Up @@ -83,16 +83,15 @@ export const AppLink: FC<AppLinkProps> = ({
const isPrivateApp = app.sharing_level === "owner"

const button = (
<Button
<PrimaryAgentButton
startIcon={icon}
endIcon={isPrivateApp ? undefined : <ShareIcon app={app} />}
className={styles.button}
disabled={!canClick}
>
<span className={combineClasses({ [styles.appName]: !isPrivateApp })}>
{appDisplayName}
</span>
</Button>
</PrimaryAgentButton>
)

return (
Expand Down Expand Up @@ -132,24 +131,6 @@ const useStyles = makeStyles((theme) => ({
textDecoration: "none !important",
},

button: {
whiteSpace: "nowrap",
backgroundColor: theme.palette.background.default,
padding: theme.spacing(0, 3),
height: 44,
borderRadius: 6,

"&:hover": {
backgroundColor: `${theme.palette.background.paper} !important`,
},

"& .MuiButton-startIcon": {
width: 16,
height: 16,
marginRight: theme.spacing(1.5),
},
},

unhealthyIcon: {
color: theme.palette.warning.light,
},
Expand Down
16 changes: 3 additions & 13 deletions site/src/components/PortForwardButton/PortForwardButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
import { Maybe } from "components/Conditionals/Maybe"
import { useMachine } from "@xstate/react"
import { portForwardMachine } from "xServices/portForward/portForwardXService"
import { SecondaryAgentButton } from "components/Resources/AgentButton"

export interface PortForwardButtonProps {
host: string
Expand Down Expand Up @@ -147,17 +148,14 @@ export const PortForwardButton: React.FC<PortForwardButtonProps> = (props) => {

return (
<>
<Button
variant="outlined"
className={styles.button}
size="small"
<SecondaryAgentButton
ref={anchorRef}
onClick={() => {
setIsOpen(true)
}}
>
Port forward
</Button>
</SecondaryAgentButton>
<Popover
classes={{ paper: styles.popoverPaper }}
id={id}
Expand Down Expand Up @@ -208,12 +206,4 @@ const useStyles = makeStyles((theme) => ({
form: {
margin: theme.spacing(1.5, 0, 0),
},

button: {
fontSize: 12,
fontWeight: 500,
height: theme.spacing(4),
minHeight: theme.spacing(4),
borderRadius: 4,
},
}))
68 changes: 68 additions & 0 deletions site/src/components/Resources/AgentButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import { makeStyles } from "@material-ui/core/styles"
import Button, { ButtonProps } from "@material-ui/core/Button"
import { FC } from "react"
import { combineClasses } from "utils/combineClasses"

export const PrimaryAgentButton: FC<ButtonProps> = ({
className,
...props
}) => {
const styles = useStyles()

return (
<Button
className={combineClasses([styles.primaryButton, className])}
{...props}
/>
)
}

export const SecondaryAgentButton: FC<ButtonProps> = ({
className,
...props
}) => {
const styles = useStyles()

return (
<Button
variant="outlined"
className={combineClasses([styles.secondaryButton, className])}
{...props}
/>
)
}

const useStyles = makeStyles((theme) => ({
primaryButton: {
whiteSpace: "nowrap",
backgroundColor: theme.palette.background.default,
height: 36,
minHeight: 36,
borderRadius: 4,
fontWeight: 500,
fontSize: 14,

"&:hover": {
backgroundColor: `${theme.palette.background.paper} !important`,
},

"& .MuiButton-startIcon": {
width: 12,
height: 12,
marginRight: theme.spacing(1.5),

"& svg": {
width: "100%",
height: "100%",
},
},
},

secondaryButton: {
fontSize: 14,
fontWeight: 500,
height: 36,
minHeight: 36,
borderRadius: 4,
},
}))
8 changes: 8 additions & 0 deletions site/src/components/Resources/AgentMetadata.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -181,14 +181,22 @@ const useStyles = makeStyles((theme) => ({
padding: theme.spacing(2.5, 4),
borderTop: `1px solid ${theme.palette.divider}`,
background: theme.palette.background.paper,
overflowX: "auto",
scrollPadding: theme.spacing(0, 4),
},

metadata: {
fontSize: 12,
lineHeight: "normal",
display: "flex",
flexDirection: "column",
gap: theme.spacing(0.5),
overflow: "visible",

// Because of scrolling
"&:last-child": {
paddingRight: theme.spacing(4),
},
},

metadataLabel: {
Expand Down
Loading