-
Notifications
You must be signed in to change notification settings - Fork 993
fix: give more room to lonely resource metadata items #9832
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
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
e8bb034
better story for resource metadata designs
aslilac 185b8b0
allow single metadata items to fill entire grid width
aslilac 05d2c0a
minor tweaks to `ResourceCard` layout
aslilac fe794e3
fix tests and stories
aslilac b449f4e
🧹
aslilac File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next
Next commit
better story for resource metadata designs
- Loading branch information
commit e8bb034d78aeac96caf3c5daa809f75cb8c17eb3
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,148 @@ | ||
import { action } from "@storybook/addon-actions"; | ||
import { | ||
MockProxyLatencies, | ||
MockWorkspace, | ||
MockWorkspaceResource, | ||
} from "testHelpers/entities"; | ||
import { AgentRow } from "./AgentRow"; | ||
import { Resources } from "./Resources"; | ||
import { ProxyContext, getPreferredProxy } from "contexts/ProxyContext"; | ||
import type { Meta, StoryObj } from "@storybook/react"; | ||
import { type WorkspaceAgent } from "api/typesGenerated"; | ||
|
||
const meta: Meta<typeof Resources> = { | ||
title: "components/Resources/Resources", | ||
component: Resources, | ||
args: { | ||
resources: [MockWorkspaceResource], | ||
agentRow: getAgentRow, | ||
}, | ||
}; | ||
|
||
export default meta; | ||
type Story = StoryObj<typeof Resources>; | ||
|
||
export const Example: Story = {}; | ||
|
||
const nullDevice = { | ||
created_at: "", | ||
job_id: "", | ||
workspace_transition: "start", | ||
type: "null_resource", | ||
hide: false, | ||
icon: "", | ||
daily_cost: 0, | ||
} as const; | ||
|
||
const short = { | ||
key: "Short", | ||
value: "Hi!", | ||
sensitive: false, | ||
}; | ||
const long = { | ||
key: "Long", | ||
value: "The quick brown fox jumped over the lazy dog", | ||
sensitive: false, | ||
}; | ||
const reallyLong = { | ||
key: "Really long", | ||
value: | ||
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.", | ||
sensitive: false, | ||
}; | ||
|
||
export const BunchOfDevicesWithMetadata: Story = { | ||
args: { | ||
resources: [ | ||
MockWorkspaceResource, | ||
{ | ||
...nullDevice, | ||
id: "e8c846da", | ||
name: "device1", | ||
metadata: [short], | ||
}, | ||
{ | ||
...nullDevice, | ||
id: "a1b11343", | ||
name: "device3", | ||
metadata: [long], | ||
}, | ||
{ | ||
...nullDevice, | ||
id: "09ab7e8c", | ||
name: "device3", | ||
metadata: [reallyLong], | ||
}, | ||
{ | ||
...nullDevice, | ||
id: "0a09fa91", | ||
name: "device2", | ||
metadata: Array.from({ length: 8 }, (_, i) => ({ | ||
...short, | ||
key: `Short ${i}`, | ||
})), | ||
}, | ||
{ | ||
...nullDevice, | ||
id: "d0b9eb9d", | ||
name: "device4", | ||
metadata: Array.from({ length: 4 }, (_, i) => ({ | ||
...long, | ||
key: `Short ${i}`, | ||
})), | ||
}, | ||
{ | ||
...nullDevice, | ||
id: "a6c69587", | ||
name: "device5", | ||
metadata: Array.from({ length: 8 }, (_, i) => | ||
i % 2 === 0 | ||
? { ...short, key: `Short ${i}` } | ||
: { ...long, key: `Long ${i}` }, | ||
), | ||
}, | ||
{ | ||
...nullDevice, | ||
id: "3af84e31", | ||
name: "device6", | ||
metadata: Array.from({ length: 8 }, (_, i) => ({ | ||
...reallyLong, | ||
key: `Really long ${i}`, | ||
})), | ||
}, | ||
], | ||
agentRow: getAgentRow, | ||
}, | ||
}; | ||
|
||
function getAgentRow(agent: WorkspaceAgent): JSX.Element { | ||
return ( | ||
<ProxyContext.Provider | ||
value={{ | ||
proxyLatencies: MockProxyLatencies, | ||
proxy: getPreferredProxy([], undefined), | ||
proxies: [], | ||
isLoading: false, | ||
isFetched: true, | ||
setProxy: () => { | ||
return; | ||
}, | ||
clearProxy: () => { | ||
return; | ||
}, | ||
refetchProxyLatencies: (): Date => { | ||
return new Date(); | ||
}, | ||
}} | ||
> | ||
<AgentRow | ||
showApps | ||
key={agent.id} | ||
agent={agent} | ||
workspace={MockWorkspace} | ||
serverVersion="" | ||
onUpdateAgent={action("updateAgent")} | ||
/> | ||
</ProxyContext.Provider> | ||
); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not create a component instead of having a
getAgentRow
?ExampleAgentRow
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
idk, this is just the way that it's already set up. 😅