Skip to content

fix: Remove 'Create Project' button, replace with CLI prompt #245

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 4 commits into from
Feb 11, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
Fix up
  • Loading branch information
bryphe-coder committed Feb 11, 2022
commit 5f683ea6ba3b7a17beeb194d95564ddc815d861b
2 changes: 0 additions & 2 deletions site/.eslintrc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,6 @@ rules:
message:
"Use path imports to avoid pulling in unused modules. See:
https://material-ui.com/guides/minimizing-bundle-size/"
- name: "@material-ui/core/Tooltip"
message: "Use the custom Tooltip on componens/Tooltip"
no-storage/no-browser-storage: error
no-unused-vars: "off"
"object-curly-spacing": "off"
Expand Down
19 changes: 10 additions & 9 deletions site/components/Button/CopyButton.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { makeStyles } from "@material-ui/core/styles"
import Button from "@material-ui/core/Button"
import Tooltip from "@material-ui/core/Tooltip"
import React from "react"
import Check from "@material-ui/icons/Check"
import React, { useState } from "react"
import { FileCopy } from "../Icons"

interface CopyButtonProps {
Expand All @@ -14,11 +15,16 @@ interface CopyButtonProps {
*/
export const CopyButton: React.FC<CopyButtonProps> = ({ className = "", text }) => {
const styles = useStyles()

const [isCopied, setIsCopied] = useState<boolean>(false)

const copyToClipboard = async (): Promise<void> => {
try {
await window.navigator.clipboard.writeText(text)
setIsCopied(true)

window.setTimeout(() => {
setIsCopied(false)
}, 1000)
} catch (err) {
const wrappedErr = new Error("copyToClipboard: failed to copy text to clipboard")
if (err instanceof Error) {
Expand All @@ -31,12 +37,8 @@ export const CopyButton: React.FC<CopyButtonProps> = ({ className = "", text })
return (
<Tooltip title="Copy to Clipboard" placement="top">
<div className={`${styles.copyButtonWrapper} ${className}`}>
<Button
className={styles.copyButton}
onClick={copyToClipboard}
size="small"
>
<FileCopy className={styles.fileCopyIcon} />
<Button className={styles.copyButton} onClick={copyToClipboard} size="small">
{isCopied ? <Check className={styles.fileCopyIcon} /> : <FileCopy className={styles.fileCopyIcon} />}
</Button>
</div>
</Tooltip>
Expand Down Expand Up @@ -64,4 +66,3 @@ const useStyles = makeStyles((theme) => ({
height: 20,
},
}))

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Story } from "@storybook/react"
import React from "react"
import { CodeExample, CodeExampleProps } from "./index"
import { CodeExample, CodeExampleProps } from "./CodeExample"

const sampleCode = `echo "Hello, world"`

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { screen } from "@testing-library/react"
import { render } from "../../test_helpers"
import React from "react"
import { CodeExample } from "./index"
import { CodeExample } from "./CodeExample"

describe("CodeExample", () => {
it("renders code", async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@ import { makeStyles } from "@material-ui/core/styles"
import React from "react"
import { MONOSPACE_FONT_FAMILY } from "../../theme/constants"

import { CopyButton } from "./../Button"
import { CopyButton } from "../Button"

export interface CodeExampleProps {
code: string
}

/**
* Component to show single-line code examples, with a copy button
*/
export const CodeExample: React.FC<CodeExampleProps> = ({ code }) => {
const styles = useStyles()

Expand All @@ -23,7 +26,8 @@ const useStyles = makeStyles((theme) => ({
root: {
display: "flex",
flexDirection: "row",
justifyContent: "flex-start",
justifyContent: "space-between",
alignItems: "center",
background: theme.palette.background.default,
color: theme.palette.codeBlock.contrastText,
fontFamily: MONOSPACE_FONT_FAMILY,
Expand Down
1 change: 1 addition & 0 deletions site/components/CodeExample/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./CodeExample"
2 changes: 1 addition & 1 deletion site/components/Icons/FileCopy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ export const FileCopy: typeof SvgIcon = (props) => (
fill="currentColor"
/>
</SvgIcon>
)
)
27 changes: 12 additions & 15 deletions site/pages/projects/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React from "react"
import { makeStyles } from "@material-ui/core/styles"
import Paper from "@material-ui/core/Paper"
import { useRouter } from "next/router"
import Link from "next/link"
import { EmptyState } from "../../components"
import { ErrorSummary } from "../../components/ErrorSummary"
Expand All @@ -14,11 +13,10 @@ import { FullScreenLoader } from "../../components/Loader/FullScreenLoader"

import { Organization, Project } from "./../../api"
import useSWR from "swr"
import { CodeExample } from "../../components/CodeExample"
import { CodeExample } from "../../components/CodeExample/CodeExample"

const ProjectsPage: React.FC = () => {
const styles = useStyles()
const router = useRouter()
const { me, signOut } = useUser(true)
const { data: projects, error } = useSWR<Project[] | null, Error>("/api/v2/projects")
const { data: orgs, error: orgsError } = useSWR<Organization[], Error>("/api/v2/users/me/organizations")
Expand All @@ -35,10 +33,6 @@ const ProjectsPage: React.FC = () => {
return <FullScreenLoader />
}

const createProject = () => {
void router.push("/projects/create")
}

// Create a dictionary of organization ID -> organization Name
// Needed to properly construct links to dive into a project
const orgDictionary = orgs.reduce((acc: Record<string, string>, curr: Organization) => {
Expand All @@ -58,14 +52,14 @@ const ProjectsPage: React.FC = () => {
},
]

const description = <div>
<div>Run the following command to get started:</div>
<CodeExample code="coder project create" />
</div>
const description = (
<div>
<div className={styles.descriptionLabel}>Run the following command to get started:</div>
<CodeExample code="coder project create" />
</div>
)

const emptyState = <EmptyState
message="No projects have been created yet"
description={description} />
const emptyState = <EmptyState message="No projects have been created yet" description={description} />

const tableProps = {
title: "All Projects",
Expand All @@ -88,11 +82,14 @@ const ProjectsPage: React.FC = () => {
)
}

const useStyles = makeStyles(() => ({
const useStyles = makeStyles((theme) => ({
root: {
display: "flex",
flexDirection: "column",
},
descriptionLabel: {
marginBottom: theme.spacing(1),
},
}))

export default ProjectsPage