-
Notifications
You must be signed in to change notification settings - Fork 894
feat: Add create template from the UI #5427
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
61 commits
Select commit
Hold shift + click to select a range
300a763
feat: add examples to api
f0ssel da9fc00
add support for example id in route
f0ssel a9f04f3
move files
f0ssel 90e6a9d
fix existing tests
f0ssel 7084ceb
add tests
f0ssel 50fb405
more tests
f0ssel b00a3b9
more tests
f0ssel 86350be
Display starter templates
BrunoQuaresma c3b2e67
Add styles to the template card
BrunoQuaresma c144866
Mock entity and handler
BrunoQuaresma c133cc3
Add storybook
BrunoQuaresma e7aec29
Add loader
BrunoQuaresma 3062814
Add tests
BrunoQuaresma d7455c1
Add basic page to starter template
BrunoQuaresma 193c930
Add buttons
BrunoQuaresma 9a5b1de
Fix title
BrunoQuaresma c820f4b
Addd storybook
BrunoQuaresma 9829ad0
Add test
BrunoQuaresma c9d1c7a
Use translation
BrunoQuaresma 85266d0
add icon and tag parsing
f0ssel 9f3108f
remove extra test work
f0ssel 0dce958
Merge branch 'f0ssel/examples' of github.com:coder/coder into bq/fe-e…
BrunoQuaresma 3091bea
Merge branch 'main' of github.com:coder/coder into bq/fe-examples
BrunoQuaresma 79442ef
Add icons to page header
BrunoQuaresma 3529c74
Add filters
BrunoQuaresma efa624c
Improve markdown code
BrunoQuaresma e05a8dc
Merge branch 'main' of github.com:coder/coder into bq/fe-examples
BrunoQuaresma e05d148
Add filter
BrunoQuaresma 4fc75b7
Add basic create template form structure
BrunoQuaresma 9805c2f
Add translation
BrunoQuaresma 439ec15
Add services and actions into machine
BrunoQuaresma ce82a85
Pre-fill info from example data
BrunoQuaresma 36282fc
Create Icon fiels and remove extra console.log
BrunoQuaresma 5b01321
Add basic API for template creation
BrunoQuaresma ca606a4
Merge branch 'main' of github.com:coder/coder into bq/fe-examples
BrunoQuaresma 521803f
Fix create template from example id
BrunoQuaresma d39cabe
Show parameters
BrunoQuaresma fe71988
Add upload
BrunoQuaresma a9f3e18
Fix steps
BrunoQuaresma 9ae5ed1
Update layout
BrunoQuaresma e19bd13
Merge branch 'main' of github.com:coder/coder into bq/fe-examples
BrunoQuaresma cc3a2cb
Update verbiage
BrunoQuaresma 273a711
Merge branch 'main' of github.com:coder/coder into bq/fe-examples
BrunoQuaresma 2d8430b
Use data
BrunoQuaresma a2e07fb
Show logs on error
BrunoQuaresma 80a2989
Merge branch 'main' of github.com:coder/coder into bq/fe-examples
BrunoQuaresma 43c8faa
Add templates link
BrunoQuaresma e64db78
Fix upload
BrunoQuaresma cec4b00
Add link to starter templates
BrunoQuaresma 8b0f95b
Add empty state
BrunoQuaresma 6de5c52
Create empty state and experimental tags
BrunoQuaresma 228bc58
Add help tooltip
BrunoQuaresma 155e901
Fix tests
BrunoQuaresma 4edfed8
Lazy load starter template page
BrunoQuaresma 30e017e
Apply suggestions from code review
BrunoQuaresma 98a5f84
No need to trim display name and description
BrunoQuaresma 6aa0bfa
Return undefined it is not n api error
BrunoQuaresma f8e8d33
Display error
BrunoQuaresma 4b47137
Merge branch 'bq/fe-examples' of github.com:coder/coder into bq/fe-ex…
BrunoQuaresma be4de6a
Return error
BrunoQuaresma e75714f
Fix test
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
Add upload
- Loading branch information
commit fe71988b18f635eb77bed4e153b18a0174e7da9b
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
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,136 @@ | ||
import { makeStyles } from "@material-ui/core/styles" | ||
import { Stack } from "components/Stack/Stack" | ||
import { FC, useRef } from "react" | ||
import UploadIcon from "@material-ui/icons/CloudUploadOutlined" | ||
import { useClickable } from "hooks/useClickable" | ||
import CircularProgress from "@material-ui/core/CircularProgress" | ||
import { combineClasses } from "util/combineClasses" | ||
import IconButton from "@material-ui/core/IconButton" | ||
import RemoveIcon from "@material-ui/icons/DeleteOutline" | ||
import FileIcon from "@material-ui/icons/FolderOutlined" | ||
|
||
export interface TemplateUploadProps { | ||
isUploading: boolean | ||
onUpload: (file: File) => void | ||
onRemove: () => void | ||
file?: File | ||
} | ||
|
||
export const TemplateUpload: FC<TemplateUploadProps> = ({ | ||
isUploading, | ||
onUpload, | ||
onRemove, | ||
file, | ||
}) => { | ||
const styles = useStyles() | ||
const inputRef = useRef<HTMLInputElement>(null) | ||
const clickable = useClickable(() => { | ||
if (inputRef.current) { | ||
inputRef.current.click() | ||
} | ||
}) | ||
|
||
if (!isUploading && file) { | ||
return ( | ||
<Stack | ||
className={styles.file} | ||
direction="row" | ||
justifyContent="space-between" | ||
alignItems="center" | ||
> | ||
<Stack direction="row" alignItems="center"> | ||
<FileIcon /> | ||
<span>{file.name}</span> | ||
</Stack> | ||
|
||
<IconButton title="Remove file" size="small" onClick={onRemove}> | ||
<RemoveIcon /> | ||
</IconButton> | ||
</Stack> | ||
) | ||
} | ||
|
||
return ( | ||
<> | ||
<div | ||
className={combineClasses({ | ||
[styles.root]: true, | ||
[styles.disabled]: isUploading, | ||
})} | ||
{...clickable} | ||
> | ||
<Stack alignItems="center" spacing={1}> | ||
{isUploading ? ( | ||
<CircularProgress size={32} /> | ||
) : ( | ||
<UploadIcon className={styles.icon} /> | ||
)} | ||
|
||
<Stack alignItems="center" spacing={0.5}> | ||
<span className={styles.title}>Upload template</span> | ||
<span className={styles.description}> | ||
The template needs to be in a .tar file | ||
</span> | ||
</Stack> | ||
</Stack> | ||
</div> | ||
|
||
<input | ||
type="file" | ||
ref={inputRef} | ||
className={styles.input} | ||
accept=".tar" | ||
onChange={(event) => { | ||
const file = event.currentTarget.files?.[0] | ||
if (file) { | ||
onUpload(file) | ||
} | ||
}} | ||
/> | ||
</> | ||
) | ||
} | ||
|
||
const useStyles = makeStyles((theme) => ({ | ||
root: { | ||
display: "flex", | ||
alignItems: "center", | ||
justifyContent: "center", | ||
borderRadius: theme.shape.borderRadius, | ||
border: `2px dashed ${theme.palette.divider}`, | ||
padding: theme.spacing(6), | ||
cursor: "pointer", | ||
|
||
"&:hover": { | ||
backgroundColor: theme.palette.background.paper, | ||
}, | ||
}, | ||
|
||
disabled: { | ||
pointerEvents: "none", | ||
opacity: 0.75, | ||
}, | ||
|
||
icon: { | ||
fontSize: theme.spacing(8), | ||
}, | ||
|
||
title: { | ||
fontSize: theme.spacing(2), | ||
}, | ||
|
||
description: { | ||
color: theme.palette.text.secondary, | ||
}, | ||
|
||
input: { | ||
display: "none", | ||
}, | ||
|
||
file: { | ||
borderRadius: theme.shape.borderRadius, | ||
border: `1px solid ${theme.palette.divider}`, | ||
padding: theme.spacing(2), | ||
background: theme.palette.background.paper, | ||
}, | ||
})) |
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.
Uh oh!
There was an error while loading. Please reload this page.