Skip to content

refactor(site): refactor resource and agents #11647

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 28 commits into from
Jan 19, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
06c9bef
Refactor resource metadata
BrunoQuaresma Jan 16, 2024
f2346e6
Fix scrolling
BrunoQuaresma Jan 16, 2024
2c58d16
Refactor agent apps
BrunoQuaresma Jan 16, 2024
0a2cb43
Refactor metadata and logs button
BrunoQuaresma Jan 16, 2024
7db1022
Refactor ssh and open port actions
BrunoQuaresma Jan 16, 2024
91fe9f2
Add terminal icon to the terminal button
BrunoQuaresma Jan 16, 2024
0438f3a
Add simple message for agentless resources
BrunoQuaresma Jan 16, 2024
c3411b3
Add back agent status
BrunoQuaresma Jan 16, 2024
bc1a216
Make agent header thiner
BrunoQuaresma Jan 16, 2024
0490e89
rowback the changes on latency color
BrunoQuaresma Jan 16, 2024
e4b2aa1
Remove non apps from preview
BrunoQuaresma Jan 16, 2024
2e542ca
rowback a few decisions
BrunoQuaresma Jan 16, 2024
2b270ec
Solve a few visual issues
BrunoQuaresma Jan 17, 2024
b0f773d
More visual fixes
BrunoQuaresma Jan 17, 2024
295f8f7
Refactor agent buttons and links
BrunoQuaresma Jan 17, 2024
9136c14
Merge branch 'main' of https://github.com/coder/coder into bq/imrefac…
BrunoQuaresma Jan 17, 2024
05fae9c
Fix conflict
BrunoQuaresma Jan 17, 2024
223f36b
Merge branch 'main' of https://github.com/coder/coder into bq/imrefac…
BrunoQuaresma Jan 18, 2024
f55397e
Remove unecessary checks
BrunoQuaresma Jan 18, 2024
f362353
Add agent row visibility test
BrunoQuaresma Jan 18, 2024
def0f70
Improve AppLink code structure
BrunoQuaresma Jan 18, 2024
0dba1cd
Add comment about icons spacing
BrunoQuaresma Jan 18, 2024
21b0c1f
Use right metadata reference
BrunoQuaresma Jan 18, 2024
d663f30
Avoid metadata mutation
BrunoQuaresma Jan 18, 2024
e8c7322
Improve 'p' component name
BrunoQuaresma Jan 18, 2024
90ce45a
Use better var name
BrunoQuaresma Jan 18, 2024
f8e56bc
Remove unecessary word
BrunoQuaresma Jan 18, 2024
5edc204
Improve nesting click handler
BrunoQuaresma Jan 18, 2024
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
Prev Previous commit
Next Next commit
Refactor metadata and logs button
  • Loading branch information
BrunoQuaresma committed Jan 16, 2024
commit 0a2cb43f5889a1c6c41f21a97066be8e7cb7d4f6
60 changes: 29 additions & 31 deletions site/src/components/Resources/AgentMetadata.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,16 +98,14 @@ export const AgentMetadataView: FC<AgentMetadataViewProps> = ({ metadata }) => {
return null;
}
return (
<div css={styles.root}>
<Stack alignItems="baseline" direction="row" spacing={6}>
{metadata.map((m) => {
if (m.description === undefined) {
throw new Error("Metadata item description is undefined");
}
return <MetadataItem key={m.description.key} item={m} />;
})}
</Stack>
</div>
<section css={styles.root}>
{metadata.map((m) => {
if (m.description === undefined) {
throw new Error("Metadata item description is undefined");
}
return <MetadataItem key={m.description.key} item={m} />;
})}
</section>
);
};

Expand Down Expand Up @@ -162,13 +160,19 @@ export const AgentMetadata: FC<AgentMetadataProps> = ({

if (metadata === undefined) {
return (
<div css={styles.root}>
<section css={styles.root}>
<AgentMetadataSkeleton />
</div>
</section>
);
}

return <AgentMetadataView metadata={metadata} />;
return (
<AgentMetadataView
metadata={[...metadata].sort((a, b) =>
a.description.display_name.localeCompare(b.description.display_name),
)}
/>
);
};

export const AgentMetadataSkeleton: FC = () => {
Expand Down Expand Up @@ -221,33 +225,29 @@ const StaticWidth: FC<HTMLAttributes<HTMLDivElement>> = ({
// These are more or less copied from
// site/src/components/Resources/ResourceCard.tsx
const styles = {
root: (theme) => ({
padding: "20px 32px",
borderTop: `1px solid ${theme.palette.divider}`,
overflowX: "auto",
scrollPadding: "0 32px",
}),
root: {
padding: "0 24px 32px",
display: "flex",
alignItems: "baseline",
flexWrap: "wrap",
gap: 32,
rowGap: 16,
},

metadata: {
fontSize: 12,
lineHeight: "normal",
lineHeight: "1.6",
display: "flex",
flexDirection: "column",
gap: 4,
overflow: "visible",

// Because of scrolling
"&:last-child": {
paddingRight: 32,
},
flexShrink: 0,
},

metadataLabel: (theme) => ({
color: theme.palette.text.secondary,
textOverflow: "ellipsis",
overflow: "hidden",
whiteSpace: "nowrap",
fontWeight: 500,
fontSize: 13,
}),

metadataValue: {
Expand All @@ -259,9 +259,7 @@ const styles = {
},

metadataValueSuccess: (theme) => ({
// color: theme.palette.success.light,
color: theme.experimental.roles.success.fill,
// color: theme.experimental.roles.success.text,
color: theme.experimental.roles.success.outline,
}),

metadataValueError: (theme) => ({
Expand Down
33 changes: 14 additions & 19 deletions site/src/components/Resources/AgentRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ export const AgentRow: FC<AgentRowProps> = ({
)}

{agent.status === "connecting" && (
<div css={styles.apps}>
<section css={styles.apps}>
<Skeleton
width={80}
height={32}
Expand All @@ -256,13 +256,13 @@ export const AgentRow: FC<AgentRowProps> = ({
variant="rectangular"
css={styles.buttonSkeleton}
/>
</div>
</section>
)}

<AgentMetadata storybookMetadata={storybookAgentMetadata} agent={agent} />

{hasStartupFeatures && (
<div css={styles.logsPanel}>
<section>
<Collapse in={showLogs}>
<AutoSizer disableHeight>
{({ width }) => (
Expand Down Expand Up @@ -417,16 +417,14 @@ export const AgentRow: FC<AgentRowProps> = ({
</AutoSizer>
</Collapse>

<div css={{ display: "flex" }}>
<button
css={styles.logsPanelButton}
onClick={() => setShowLogs((v) => !v)}
>
<DropdownArrow close={showLogs} />
{showLogs ? "Hide" : "Show"} logs
</button>
</div>
</div>
<button
css={styles.logsPanelButton}
onClick={() => setShowLogs((v) => !v)}
>
<DropdownArrow close={showLogs} margin={false} />
{showLogs ? "Hide" : "Show"} logs
</button>
</section>
)}
</Stack>
);
Expand Down Expand Up @@ -583,7 +581,7 @@ const styles = {
}),

apps: (theme) => ({
padding: 24,
padding: "32px 24px",
display: "flex",
gap: 16,
flexWrap: "wrap",
Expand All @@ -602,6 +600,7 @@ const styles = {
startupLogs: (theme) => ({
maxHeight: 256,
borderBottom: `1px solid ${theme.palette.divider}`,
borderTop: `1px solid ${theme.palette.divider}`,
backgroundColor: theme.palette.background.paper,
paddingTop: 16,

Expand Down Expand Up @@ -654,16 +653,12 @@ const styles = {
},
}),

logsPanel: (theme) => ({
borderTop: `1px solid ${theme.palette.divider}`,
}),

logsPanelButton: (theme) => ({
textAlign: "left",
background: "transparent",
border: 0,
fontFamily: "inherit",
padding: "12px 32px",
padding: "16px 24px",
color: theme.palette.text.secondary,
cursor: "pointer",
display: "flex",
Expand Down