- Notifications
You must be signed in to change notification settings - Fork928
Styling pass at filter/kira pilot#2009
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
Closed
Kira-Pilot wants to merge11 commits intof0ssel/workspace-filterfromstyling-pass-at-filter/kira-pilot
Uh oh!
There was an error while loading.Please reload this page.
Closed
Changes fromall commits
Commits
Show all changes
11 commits Select commitHold shift + click to select a range
e769722
feat: Workspaces filtering
f0ssel2c576a6
Remove error handling
f0sseldf15018
styling
f0sselbc2ed33
Apply suggestions from code review
f0sseld43a15a
pr fixes
f0ssel49c9bb1
language
f0ssel7117ac5
push up what I have
f0ssel9597345
Add name filter to backend
f0ssel6a6a7e6
Add name filter
f0ssele47b601
add backend
f0ssel114c9bc
some styling ideas
Kira-PilotFile filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
14 changes: 13 additions & 1 deletioncoderd/database/queries.sql.go
Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
6 changes: 6 additions & 0 deletionscoderd/database/queries/workspaces.sql
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
23 changes: 10 additions & 13 deletionscoderd/workspaces.go
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
8 changes: 6 additions & 2 deletionscodersdk/workspaces.go
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
6 changes: 3 additions & 3 deletionssite/src/api/api.test.ts
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
11 changes: 7 additions & 4 deletionssite/src/api/api.ts
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
19 changes: 10 additions & 9 deletionssite/src/api/typesGenerated.ts
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
167 changes: 158 additions & 9 deletionssite/src/pages/WorkspacesPage/WorkspacesPage.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 |
---|---|---|
@@ -1,20 +1,169 @@ | ||
import Button from "@material-ui/core/Button" | ||
import Fade from "@material-ui/core/Fade" | ||
import InputAdornment from "@material-ui/core/InputAdornment" | ||
import Link from "@material-ui/core/Link" | ||
import Menu from "@material-ui/core/Menu" | ||
import MenuItem from "@material-ui/core/MenuItem" | ||
import { makeStyles } from "@material-ui/core/styles" | ||
import TextField from "@material-ui/core/TextField" | ||
import AddCircleOutline from "@material-ui/icons/AddCircleOutline" | ||
import SearchIcon from "@material-ui/icons/Search" | ||
import { useMachine } from "@xstate/react" | ||
import { FormikErrors, useFormik } from "formik" | ||
import { FC, useState } from "react" | ||
import { Link as RouterLink } from "react-router-dom" | ||
import { CloseDropdown, OpenDropdown } from "../../components/DropdownArrows/DropdownArrows" | ||
import { Margins } from "../../components/Margins/Margins" | ||
import { Stack } from "../../components/Stack/Stack" | ||
import { getFormHelpers, onChangeTrimmed } from "../../util/formUtils" | ||
import { workspacesMachine } from "../../xServices/workspaces/workspacesXService" | ||
import { WorkspacesPageView } from "./WorkspacesPageView" | ||
interface FilterFormValues { | ||
query: string | ||
} | ||
const Language = { | ||
filterName: "Filters", | ||
createWorkspaceButton: "Create workspace", | ||
yourWorkspacesButton: "Your workspaces", | ||
allWorkspacesButton: "All workspaces", | ||
} | ||
export type FilterFormErrors = FormikErrors<FilterFormValues> | ||
const WorkspacesPage: FC = () => { | ||
const styles = useStyles() | ||
const [workspacesState, send] = useMachine(workspacesMachine) | ||
const form = useFormik<FilterFormValues>({ | ||
initialValues: { | ||
query: workspacesState.context.filter || "", | ||
}, | ||
onSubmit: (values) => { | ||
send({ | ||
type: "SET_FILTER", | ||
query: values.query, | ||
}) | ||
}, | ||
}) | ||
const getFieldHelpers = getFormHelpers<FilterFormValues>(form) | ||
const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null) | ||
const handleClick = (event: React.MouseEvent<HTMLButtonElement>) => { | ||
setAnchorEl(event.currentTarget) | ||
} | ||
const handleClose = () => { | ||
setAnchorEl(null) | ||
} | ||
const setYourWorkspaces = () => { | ||
void form.setFieldValue("query", "owner:me") | ||
void form.submitForm() | ||
handleClose() | ||
} | ||
const setAllWorkspaces = () => { | ||
void form.setFieldValue("query", "") | ||
void form.submitForm() | ||
handleClose() | ||
} | ||
return ( | ||
<Margins> | ||
<Stack direction="row" className={styles.workspacesHeaderContainer}> | ||
<Stack direction="column" className={styles.filterColumn}> | ||
<Stack direction="row" spacing={0} className={styles.filterContainer}> | ||
<Button | ||
aria-controls="filter-menu" | ||
aria-haspopup="true" | ||
onClick={handleClick} | ||
className={styles.buttonRoot} | ||
> | ||
{Language.filterName} {anchorEl ? <CloseDropdown /> : <OpenDropdown />} | ||
</Button> | ||
<form onSubmit={form.handleSubmit} className={styles.filterForm}> | ||
<TextField | ||
{...getFieldHelpers("query")} | ||
className={styles.textFieldRoot} | ||
onChange={onChangeTrimmed(form)} | ||
fullWidth | ||
variant="outlined" | ||
InputProps={{ | ||
startAdornment: ( | ||
<InputAdornment position="start"> | ||
<SearchIcon fontSize="small" /> | ||
</InputAdornment> | ||
), | ||
}} | ||
/> | ||
</form> | ||
<Menu | ||
id="filter-menu" | ||
anchorEl={anchorEl} | ||
keepMounted | ||
open={Boolean(anchorEl)} | ||
onClose={handleClose} | ||
TransitionComponent={Fade} | ||
anchorOrigin={{ | ||
vertical: "bottom", | ||
horizontal: "left", | ||
}} | ||
transformOrigin={{ | ||
vertical: "top", | ||
horizontal: "left", | ||
}} | ||
> | ||
<MenuItem onClick={setYourWorkspaces}>{Language.yourWorkspacesButton}</MenuItem> | ||
<MenuItem onClick={setAllWorkspaces}>{Language.allWorkspacesButton}</MenuItem> | ||
</Menu> | ||
</Stack> | ||
</Stack> | ||
<Link underline="none" component={RouterLink} to="/workspaces/new"> | ||
<Button startIcon={<AddCircleOutline />} style={{ height: "44px" }}> | ||
{Language.createWorkspaceButton} | ||
</Button> | ||
</Link> | ||
</Stack> | ||
<WorkspacesPageView loading={workspacesState.hasTag("loading")} workspaces={workspacesState.context.workspaces} /> | ||
</Margins> | ||
) | ||
} | ||
const useStyles = makeStyles((theme) => ({ | ||
workspacesHeaderContainer: { | ||
marginTop: theme.spacing(3), | ||
marginBottom: theme.spacing(3), | ||
justifyContent: "space-between", | ||
}, | ||
filterColumn: { | ||
width: "60%", | ||
cursor: "text", | ||
}, | ||
filterContainer: { | ||
border: `1px solid ${theme.palette.divider}`, | ||
borderRadius: "6px", | ||
}, | ||
filterForm: { | ||
width: "100%", | ||
}, | ||
buttonRoot: { | ||
border: "none", | ||
borderRight: `1px solid ${theme.palette.divider}`, | ||
borderRadius: "6px 0px 0px 6px", | ||
}, | ||
textFieldRoot: { | ||
margin: "0px", | ||
"& fieldset": { | ||
border: "none", | ||
}, | ||
}, | ||
})) | ||
export default WorkspacesPage |
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
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.