Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Tag dialog redesign to allow batch add Some Refactoring Signed-off-by: andreas-unleash <andreas@getunleash.ai> <!-- Thanks for creating a PR! To make it easier for reviewers and everyone else to understand what your changes relate to, please add some relevant content to the headings below. Feel free to ignore or delete sections that you don't think are relevant. Thank you! ❤️ --> ## About the changes <!-- Describe the changes introduced. What are they and why are they being introduced? Feel free to also add screenshots or steps to view the changes if they're visual. --> <!-- Does it close an issue? Multiple? --> Closes [1-611](https://linear.app/unleash/issue/1-611/create-a-auto-complete-component-for-tags) <!-- (For internal contributors): Does it relate to an issue on public roadmap? --> <!-- Relates to [roadmap](https://github.com/orgs/Unleash/projects/10) item: # --> ### Important files <!-- PRs can contain a lot of changes, but not all changes are equally important. Where should a reviewer start looking to get an overview of the changes? Are any files particularly important? --> ## Discussion points <!-- Anything about the PR you'd like to discuss before it gets merged? Got any questions or doubts? --> https://user-images.githubusercontent.com/104830839/216286897-4e392822-57c2-4e50-a5d8-e89d006b3fa5.mov --------- Signed-off-by: andreas-unleash <andreas@getunleash.ai>
- Loading branch information
1 parent
a7cb20c
commit e589e56
Showing
13 changed files
with
412 additions
and
135 deletions.
There are no files selected for viewing
This file contains 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 was deleted.
Oops, something went wrong.
203 changes: 127 additions & 76 deletions
203
frontend/src/component/feature/FeatureView/FeatureOverview/AddTagDialog/AddTagDialog.tsx
This file contains 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
58 changes: 58 additions & 0 deletions
58
frontend/src/component/feature/FeatureView/FeatureOverview/AddTagDialog/TagTypeSelect.tsx
This file contains 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,58 @@ | ||
import React from 'react'; | ||
import useTagTypes from 'hooks/api/getters/useTagTypes/useTagTypes'; | ||
import { | ||
Autocomplete, | ||
AutocompleteProps, | ||
styled, | ||
TextField, | ||
Typography, | ||
useTheme, | ||
} from '@mui/material'; | ||
import { ITagType } from 'interfaces/tags'; | ||
|
||
interface ITagSelect { | ||
value: ITagType; | ||
onChange: AutocompleteProps<ITagType, false, any, any>['onChange']; | ||
autoFocus?: boolean; | ||
} | ||
|
||
const ListItem = styled('li')({ | ||
flexDirection: 'column', | ||
}); | ||
const TagTypeSelect = ({ value, onChange }: ITagSelect) => { | ||
const { tagTypes } = useTagTypes(); | ||
const theme = useTheme(); | ||
|
||
return ( | ||
<Autocomplete | ||
disablePortal | ||
id="tag-type-select" | ||
sx={{ marginTop: theme => theme.spacing(2), width: 500 }} | ||
options={tagTypes} | ||
disableClearable | ||
value={value} | ||
getOptionLabel={option => option.name} | ||
renderOption={(props, option) => ( | ||
<ListItem | ||
{...props} | ||
style={{ | ||
alignItems: 'flex-start', | ||
gap: theme.spacing(0.5), | ||
}} | ||
> | ||
<Typography variant="body1">{option.name}</Typography> | ||
<Typography variant="caption"> | ||
{option.description} | ||
</Typography> | ||
</ListItem> | ||
)} | ||
renderInput={params => ( | ||
<TextField {...params} label="Tag type" value={value} /> | ||
)} | ||
onChange={onChange} | ||
ListboxProps={{ style: { maxHeight: 200, overflow: 'auto' } }} | ||
/> | ||
); | ||
}; | ||
|
||
export default TagTypeSelect; |
Oops, something went wrong.