- Notifications
You must be signed in to change notification settings - Fork928
feat: create multi-org template creation page#13879
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
Uh oh!
There was an error while loading.Please reload this page.
Closed
Changes fromall commits
Commits
Show all changes
34 commits Select commitHold shift + click to select a range
d640312
feat: initial changes for multi org template creation
jaaydenh1c973ae
feat: styling and add template creation options
jaaydenh6b5e7ec
chore: remove unused imports
jaaydenhfbd6ca3
fix: use theme on cardTitle
jaaydenh013522b
fix: remove unused import
jaaydenhf547bfc
fix: pass key directly to JSX without using spread
jaaydenh6b6c635
fix: use correct path
jaaydenhb4e3c67
fix: fix test
jaaydenh2636753
chore: handle merge changes
jaaydenhc113979
fix: remove CreateTemplateButton
jaaydenhcb53396
fix: update template examples for multi-org
jaaydenh789699a
feat: pass along organizationId when creating templates
jaaydenh8b03b11
fix: improve organization autocomplete
jaaydenhb3aa04f
Feat: move org dropdown and add orgId search param
jaaydenh03768c4
chore: show org autocomplete if experiment is enabled
jaaydenh7baba1e
fix: remove unnecessary query param
jaaydenhf513633
fix: cleanup
jaaydenhb350b95
fix: fix tests
jaaydenh2810cd3
fix: fix create template form stories
jaaydenh6499543
fix
jaaydenhc52c3dc
fix: merge issues
jaaydenh6205129
chore: use default org for example templates
jaaydenhb721a43
feat: add organizationId to the templates route
jaaydenh41a414e
fix: add missing useMemo dependency
jaaydenhe23475b
fix: add organizationId dependency
jaaydenh53d4a3e
feat: update tests for organization in templates route
jaaydenh7d92893
feat: gate org dropdown to multiple_organizations feature
jaaydenh73ae86b
chore: set default for organization route param
jaaydenh9bb1139
feat: update template routes for organizations
jaaydenh1375b30
feat: add templates route
jaaydenhaa452fe
feat: use templates_route
jaaydenh0830dcc
Merge branch 'main' into multi-org-create-template
aslilacb637620
the whirly durly
aslilac0fc9acc
Merge branch 'main' into multi-org-create-template
aslilacFile 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
10 changes: 9 additions & 1 deletionsite/src/api/queries/templates.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
133 changes: 133 additions & 0 deletionssite/src/components/OrganizationAutocomplete/OrganizationAutocomplete.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,133 @@ | ||
import { css } from "@emotion/css"; | ||
import Autocomplete from "@mui/material/Autocomplete"; | ||
import CircularProgress from "@mui/material/CircularProgress"; | ||
import TextField from "@mui/material/TextField"; | ||
import { | ||
type ChangeEvent, | ||
type ComponentProps, | ||
type FC, | ||
useState, | ||
} from "react"; | ||
import { useQuery } from "react-query"; | ||
import { organizations } from "api/queries/organizations"; | ||
import type { Organization } from "api/typesGenerated"; | ||
import { Avatar } from "components/Avatar/Avatar"; | ||
import { AvatarData } from "components/AvatarData/AvatarData"; | ||
import { useDebouncedFunction } from "hooks/debounce"; | ||
export type OrganizationAutocompleteProps = { | ||
value: Organization | null; | ||
onChange: (organization: Organization | null) => void; | ||
label?: string; | ||
className?: string; | ||
size?: ComponentProps<typeof TextField>["size"]; | ||
required?: boolean; | ||
}; | ||
export const OrganizationAutocomplete: FC<OrganizationAutocompleteProps> = ({ | ||
value, | ||
onChange, | ||
label, | ||
className, | ||
size = "small", | ||
required, | ||
}) => { | ||
const [autoComplete, setAutoComplete] = useState<{ | ||
value: string; | ||
open: boolean; | ||
}>({ | ||
value: value?.name ?? "", | ||
open: false, | ||
}); | ||
const organizationsQuery = useQuery(organizations()); | ||
const { debounced: debouncedInputOnChange } = useDebouncedFunction( | ||
(event: ChangeEvent<HTMLInputElement>) => { | ||
setAutoComplete((state) => ({ | ||
...state, | ||
value: event.target.value, | ||
})); | ||
}, | ||
750, | ||
); | ||
return ( | ||
<Autocomplete | ||
noOptionsText="No organizations found" | ||
className={className} | ||
options={organizationsQuery.data ?? []} | ||
loading={organizationsQuery.isLoading} | ||
value={value} | ||
data-testid="organization-autocomplete" | ||
open={autoComplete.open} | ||
isOptionEqualToValue={(a, b) => a.name === b.name} | ||
getOptionLabel={(option) => option.display_name} | ||
onOpen={() => { | ||
setAutoComplete((state) => ({ | ||
...state, | ||
open: true, | ||
})); | ||
}} | ||
onClose={() => { | ||
setAutoComplete({ | ||
value: value?.name ?? "", | ||
open: false, | ||
}); | ||
}} | ||
onChange={(_, newValue) => { | ||
onChange(newValue); | ||
}} | ||
renderOption={({ key, ...props }, option) => ( | ||
<li key={key} {...props}> | ||
<AvatarData | ||
title={option.display_name} | ||
subtitle={option.name} | ||
src={option.icon} | ||
/> | ||
</li> | ||
)} | ||
renderInput={(params) => ( | ||
<TextField | ||
{...params} | ||
required={required} | ||
fullWidth | ||
size={size} | ||
label={label} | ||
autoFocus | ||
placeholder="Organization name" | ||
css={{ | ||
"&:not(:has(label))": { | ||
margin: 0, | ||
}, | ||
}} | ||
InputProps={{ | ||
...params.InputProps, | ||
onChange: debouncedInputOnChange, | ||
startAdornment: value && ( | ||
<Avatar size="sm" src={value.icon}> | ||
{value.name} | ||
</Avatar> | ||
), | ||
endAdornment: ( | ||
<> | ||
{organizationsQuery.isFetching && autoComplete.open && ( | ||
<CircularProgress size={16} /> | ||
)} | ||
{params.InputProps.endAdornment} | ||
</> | ||
), | ||
classes: { root }, | ||
}} | ||
InputLabelProps={{ | ||
shrink: true, | ||
}} | ||
/> | ||
)} | ||
/> | ||
); | ||
}; | ||
const root = css` | ||
padding-left: 14px !important; // Same padding left as input | ||
gap: 4px; | ||
`; |
22 changes: 10 additions & 12 deletionssite/src/components/UserAutocomplete/UserAutocomplete.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
17 changes: 17 additions & 0 deletionssite/src/modules/navigation.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
13 changes: 8 additions & 5 deletionssite/src/modules/templates/TemplateFiles/TemplateFiles.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
11 changes: 7 additions & 4 deletionssite/src/modules/workspaces/WorkspaceOutdatedTooltip/WorkspaceOutdatedTooltip.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
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
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.