-
Notifications
You must be signed in to change notification settings - Fork 939
feat: Add create workspace page #1589
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 all commits
Commits
Show all changes
38 commits
Select commit
Hold shift + click to select a range
a72ba40
feat: Add template page
kylecarbs c2699a8
Create xService
kylecarbs eb6644f
Update column names
kylecarbs 3d70c67
Show create template conditionally
kylecarbs c63c563
Add template description
kylecarbs 08069d3
Route to templates
kylecarbs 584d3a3
Add empty states
kylecarbs 15637bd
Add tests
kylecarbs a22f1ab
Add single template
kylecarbs 09e8a27
Add tests
kylecarbs 547a33f
Add state machine for single-page template
kylecarbs db9ea20
Add loading indicator
kylecarbs eb2ae84
Merge templatepage
kylecarbs 9ca9db6
Merge branch 'main' into singletemplate
kylecarbs 1ce3996
Merge branch 'main' into singletemplate
kylecarbs c88199a
Add endpoint for fetching latest templates
kylecarbs ec28c3d
Embed markdown
kylecarbs 2f2bf0d
Add workspace create page
kylecarbs c70d6a4
feat: Expose the values contained in an HCL validation string to the API
kylecarbs c4a07a1
Update codersdk/parameters.go
kylecarbs d3e33c8
Call a spade a space
kylecarbs 2843818
Add API req
kylecarbs f422e7b
Fix linting errors with type conversion
kylecarbs fc85f98
Merge branch 'paramcontains' into singletemplate
kylecarbs 9cfe7d7
Add create workspace page
kylecarbs a825ece
Add stories for inputs
kylecarbs aa4c8ac
Merge branch 'main' into singletemplate
kylecarbs 88f367d
Remove react-markdown dependency
kylecarbs ebf36c2
Improve tests
kylecarbs fd6aaf0
Merge branch 'main' into singletemplate
kylecarbs c522122
Remove old code
kylecarbs 72df0ac
Fix test case
kylecarbs 6273639
Merge branch 'main' into singletemplate
kylecarbs 507f2f4
Fix linting error
kylecarbs 2d67bf7
Fix test
kylecarbs e5490a7
Merge branch 'main' into singletemplate
BrunoQuaresma 726ff53
Fix entities
BrunoQuaresma 3f418a9
Fix storybook
BrunoQuaresma 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
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
52 changes: 52 additions & 0 deletions
52
site/src/components/ParameterInput/ParameterInput.stories.tsx
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,52 @@ | ||
import { Story } from "@storybook/react" | ||
import React from "react" | ||
import { ParameterSchema } from "../../api/typesGenerated" | ||
import { ParameterInput, ParameterInputProps } from "./ParameterInput" | ||
|
||
export default { | ||
title: "components/ParameterInput", | ||
component: ParameterInput, | ||
} | ||
|
||
const Template: Story<ParameterInputProps> = (args: ParameterInputProps) => <ParameterInput {...args} /> | ||
|
||
const createParameterSchema = (partial: Partial<ParameterSchema>): ParameterSchema => { | ||
return { | ||
id: "000000", | ||
job_id: "000000", | ||
allow_override_destination: false, | ||
allow_override_source: true, | ||
created_at: "", | ||
default_destination_scheme: "none", | ||
default_refresh: "", | ||
default_source_scheme: "data", | ||
default_source_value: "default-value", | ||
name: "parameter name", | ||
description: "Some description!", | ||
redisplay_value: false, | ||
validation_condition: "", | ||
validation_contains: [], | ||
validation_error: "", | ||
validation_type_system: "", | ||
validation_value_type: "", | ||
...partial, | ||
} | ||
} | ||
|
||
export const Basic = Template.bind({}) | ||
Basic.args = { | ||
schema: createParameterSchema({ | ||
name: "project_name", | ||
description: "Customize the name of a Google Cloud project that will be created!", | ||
}), | ||
} | ||
|
||
export const Contains = Template.bind({}) | ||
Contains.args = { | ||
schema: createParameterSchema({ | ||
name: "region", | ||
default_source_value: "🏈 US Central", | ||
description: "Where would you like your workspace to live?", | ||
validation_contains: ["🏈 US Central", "⚽ Brazil East", "💶 EU West", "🦘 Australia South"], | ||
}), | ||
} |
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,94 @@ | ||
import FormControlLabel from "@material-ui/core/FormControlLabel" | ||
import Paper from "@material-ui/core/Paper" | ||
import Radio from "@material-ui/core/Radio" | ||
import RadioGroup from "@material-ui/core/RadioGroup" | ||
import { lighten, makeStyles } from "@material-ui/core/styles" | ||
import TextField from "@material-ui/core/TextField" | ||
import React from "react" | ||
import { ParameterSchema } from "../../api/typesGenerated" | ||
import { MONOSPACE_FONT_FAMILY } from "../../theme/constants" | ||
|
||
export interface ParameterInputProps { | ||
disabled?: boolean | ||
schema: ParameterSchema | ||
onChange: (value: string) => void | ||
} | ||
|
||
export const ParameterInput: React.FC<ParameterInputProps> = ({ disabled, onChange, schema }) => { | ||
const styles = useStyles() | ||
return ( | ||
<Paper className={styles.paper}> | ||
<div className={styles.title}> | ||
<h2>var.{schema.name}</h2> | ||
{schema.description && <span>{schema.description}</span>} | ||
</div> | ||
<div className={styles.input}> | ||
<ParameterField disabled={disabled} onChange={onChange} schema={schema} /> | ||
</div> | ||
</Paper> | ||
) | ||
} | ||
|
||
const ParameterField: React.FC<ParameterInputProps> = ({ disabled, onChange, schema }) => { | ||
if (schema.validation_contains.length > 0) { | ||
return ( | ||
<RadioGroup | ||
defaultValue={schema.default_source_value} | ||
onChange={(event) => { | ||
onChange(event.target.value) | ||
}} | ||
> | ||
{schema.validation_contains.map((item) => ( | ||
<FormControlLabel | ||
disabled={disabled} | ||
key={item} | ||
value={item} | ||
control={<Radio color="primary" size="small" disableRipple />} | ||
label={item} | ||
/> | ||
))} | ||
</RadioGroup> | ||
) | ||
} | ||
|
||
// A text field can technically handle all cases! | ||
// As other cases become more prominent (like filtering for numbers), | ||
// we should break this out into more finely scoped input fields. | ||
return ( | ||
<TextField | ||
size="small" | ||
disabled={disabled} | ||
placeholder={schema.default_source_value} | ||
onChange={(event) => { | ||
onChange(event.target.value) | ||
}} | ||
/> | ||
) | ||
} | ||
|
||
const useStyles = makeStyles((theme) => ({ | ||
paper: { | ||
display: "flex", | ||
flexDirection: "column", | ||
fontFamily: MONOSPACE_FONT_FAMILY, | ||
}, | ||
title: { | ||
background: lighten(theme.palette.background.default, 0.1), | ||
borderBottom: `1px solid ${theme.palette.divider}`, | ||
padding: theme.spacing(3), | ||
display: "flex", | ||
flexDirection: "column", | ||
"& h2": { | ||
margin: 0, | ||
}, | ||
"& span": { | ||
paddingTop: theme.spacing(2), | ||
}, | ||
}, | ||
input: { | ||
padding: theme.spacing(3), | ||
display: "flex", | ||
flexDirection: "column", | ||
maxWidth: 480, | ||
}, | ||
})) |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.