- Notifications
You must be signed in to change notification settings - Fork928
feat: Improve empty states for workspaces and templates#1950
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
7711138
d1ddfae
8796128
65678ab
d812056
df6bc50
eaf4a78
8d5e771
b7dbfff
c3ca61b
dfef339
5300bf8
114f65a
12a55cb
57e909d
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,25 @@ | ||
import{makeStyles}from"@material-ui/core/styles" | ||
import{FC}from"react" | ||
import{MONOSPACE_FONT_FAMILY}from"../../theme/constants" | ||
import{combineClasses}from"../../util/combineClasses" | ||
BrunoQuaresma marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
import{CopyButton}from"../CopyButton/CopyButton" | ||
exportinterfaceCodeExampleProps{ | ||
code:string | ||
className?:string | ||
buttonClassName?:string | ||
Comment on lines +9 to +10 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Thought: One thing to consider here is mimicking MUIs API. These use a
I'm adding this as athought because it's not required to do anything now, just wanted to pose the question. Might make sense as a FE V topic. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. I agree with you, but I see some components are already using the pattern | ||
} | ||
/** | ||
* Component to show single-line code examples, with a copy button | ||
*/ | ||
exportconstCodeExample:FC<CodeExampleProps>=({ code, className, buttonClassName})=>{ | ||
conststyles=useStyles() | ||
return( | ||
<divclassName={combineClasses([styles.root,className])}> | ||
<codeclassName={styles.code}>{code}</code> | ||
<CopyButtontext={code}buttonClassName={combineClasses([styles.button,buttonClassName])}/> | ||
</div> | ||
) | ||
} | ||
@@ -30,8 +33,17 @@ const useStyles = makeStyles((theme) => ({ | ||
background:theme.palette.background.default, | ||
color:theme.palette.primary.contrastText, | ||
fontFamily:MONOSPACE_FONT_FAMILY, | ||
fontSize:14, | ||
borderRadius:theme.shape.borderRadius, | ||
padding:theme.spacing(0.5), | ||
}, | ||
code:{ | ||
padding:`${theme.spacing(0.5)}px${theme.spacing(0.75)}px${theme.spacing(0.5)}px${theme.spacing(2)}px`, | ||
}, | ||
button:{ | ||
border:0, | ||
minWidth:42, | ||
minHeight:42, | ||
borderRadius:theme.shape.borderRadius, | ||
}, | ||
})) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -8,6 +8,8 @@ import { FC, useState } from "react" | ||
import { Link as RouterLink } from "react-router-dom" | ||
import * as Yup from "yup" | ||
import * as TypesGen from "../../api/typesGenerated" | ||
import { CodeExample } from "../../components/CodeExample/CodeExample" | ||
import { EmptyState } from "../../components/EmptyState/EmptyState" | ||
import { FormFooter } from "../../components/FormFooter/FormFooter" | ||
import { FullPageForm } from "../../components/FullPageForm/FullPageForm" | ||
import { Loader } from "../../components/Loader/Loader" | ||
@@ -18,6 +20,17 @@ import { getFormHelpers, nameValidator, onChangeTrimmed } from "../../util/formU | ||
export const Language = { | ||
templateLabel: "Template", | ||
nameLabel: "Name", | ||
emptyMessage: "Let's create your first template", | ||
emptyDescription: ( | ||
<> | ||
To create a workspace you need to have a template. You can{" "} | ||
<Link target="_blank" href="https://github.com/coder/coder/blob/main/docs/templates.md"> | ||
create one from scratch | ||
</Link>{" "} | ||
or use a built-in template by typing the following Coder CLI command: | ||
</> | ||
BrunoQuaresma marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
), | ||
templateLink: "Read more about this template", | ||
} | ||
export interface CreateWorkspacePageViewProps { | ||
@@ -98,7 +111,18 @@ export const CreateWorkspacePageView: FC<CreateWorkspacePageViewProps> = (props) | ||
{props.loadingTemplates && <Loader />} | ||
<Stack> | ||
{props.templates && props.templates.length === 0 && ( | ||
<EmptyState | ||
className={styles.emptyState} | ||
message={Language.emptyMessage} | ||
description={Language.emptyDescription} | ||
descriptionClassName={styles.emptyStateDescription} | ||
cta={ | ||
<CodeExample className={styles.code} buttonClassName={styles.codeButton} code="coder template init" /> | ||
BrunoQuaresma marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
} | ||
/> | ||
)} | ||
{props.templates && props.templates.length > 0 && ( | ||
<TextField | ||
{...getFieldHelpers("template_id")} | ||
disabled={form.isSubmitting} | ||
@@ -116,7 +140,7 @@ export const CreateWorkspacePageView: FC<CreateWorkspacePageViewProps> = (props) | ||
to={`/templates/${selectedTemplate.name}`} | ||
target="_blank" | ||
> | ||
{Language.templateLink} <OpenInNewIcon /> | ||
</Link> | ||
) | ||
} | ||
@@ -179,4 +203,21 @@ const useStyles = makeStyles((theme) => ({ | ||
marginLeft: theme.spacing(0.5), | ||
}, | ||
}, | ||
emptyState: { | ||
padding: 0, | ||
fontFamily: "inherit", | ||
textAlign: "left", | ||
minHeight: "auto", | ||
alignItems: "flex-start", | ||
}, | ||
emptyStateDescription: { | ||
lineHeight: "160%", | ||
}, | ||
code: { | ||
background: theme.palette.background.paper, | ||
width: "100%", | ||
}, | ||
codeButton: { | ||
background: theme.palette.background.paper, | ||
}, | ||
})) |
Uh oh!
There was an error while loading.Please reload this page.