forked from OpenStackweb/summit-admin
-
Notifications
You must be signed in to change notification settings - Fork 4
fix: migrate email log list page into MUI/uicore components #1044
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
Open
tomrndom
wants to merge
1
commit into
master
Choose a base branch
from
fix/mui-email-log-list
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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,61 @@ | ||
| import React, { useEffect, useState } from "react"; | ||
| import { Autocomplete, CircularProgress, TextField } from "@mui/material"; | ||
|
|
||
| const AsyncSelectInput = ({ | ||
| id, | ||
| label, | ||
| value, | ||
| onChange, | ||
| queryFunction, | ||
| formatOption = (item) => ({ value: item.id, label: item.name }) | ||
| }) => { | ||
| const [options, setOptions] = useState([]); | ||
| const [loading, setLoading] = useState(false); | ||
|
|
||
| const fetchOptions = (input) => { | ||
| setLoading(true); | ||
| queryFunction(input, (results) => { | ||
| setOptions(results.map(formatOption)); | ||
| setLoading(false); | ||
| }); | ||
| }; | ||
|
|
||
| useEffect(() => { | ||
| fetchOptions(""); | ||
| }, []); | ||
|
|
||
| return ( | ||
| <Autocomplete | ||
| options={options} | ||
| value={value ? { value, label: value } : null} | ||
| loading={loading} | ||
| fullWidth | ||
| getOptionLabel={(option) => option.label || ""} | ||
| isOptionEqualToValue={(option, val) => option.value === val.value} | ||
| onInputChange={(ev, newInput) => fetchOptions(newInput)} | ||
| onChange={(ev, selected) => | ||
| onChange({ target: { id, value: selected?.value ?? "" } }) | ||
| } | ||
| renderInput={(params) => ( | ||
| <TextField | ||
| {...params} | ||
| label={label} | ||
| size="small" | ||
| slotProps={{ | ||
| input: { | ||
| ...params.InputProps, | ||
| endAdornment: ( | ||
| <> | ||
| {loading && <CircularProgress color="inherit" size={16} />} | ||
| {params.InputProps?.endAdornment} | ||
| </> | ||
| ) | ||
| } | ||
| }} | ||
| /> | ||
| )} | ||
| /> | ||
| ); | ||
| }; | ||
|
|
||
| export default AsyncSelectInput; | ||
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,56 @@ | ||
| import React from "react"; | ||
| import { | ||
| Box, | ||
| Chip, | ||
| FormControl, | ||
| InputLabel, | ||
| MenuItem, | ||
| OutlinedInput, | ||
| Select | ||
| } from "@mui/material"; | ||
| import CancelIcon from "@mui/icons-material/Cancel"; | ||
|
|
||
| const ChipMultiSelect = ({ id, label, value, onChange, options, sx }) => { | ||
| const handleDelete = (val) => | ||
| onChange({ target: { value: value.filter((v) => v !== val) } }); | ||
|
|
||
| return ( | ||
| <FormControl fullWidth size="small" sx={sx}> | ||
| <InputLabel id={`${id}-label`}>{label}</InputLabel> | ||
| <Select | ||
| labelId={`${id}-label`} | ||
| id={id} | ||
| multiple | ||
| value={value} | ||
| onChange={onChange} | ||
| input={<OutlinedInput label={label} />} | ||
| renderValue={(selected) => ( | ||
| <Box sx={{ display: "flex", flexWrap: "wrap", gap: 0.5 }}> | ||
| {selected.map((val) => { | ||
| const option = options.find((o) => o.value === val); | ||
| return option ? ( | ||
| <Chip | ||
| key={val} | ||
| label={option.label} | ||
| size="small" | ||
| onDelete={() => handleDelete(val)} | ||
| deleteIcon={ | ||
| <CancelIcon onMouseDown={(ev) => ev.stopPropagation()} /> | ||
| } | ||
| /> | ||
| ) : null; | ||
| })} | ||
| </Box> | ||
| )} | ||
| > | ||
| {options.map((option) => ( | ||
| <MenuItem key={option.value} value={option.value}> | ||
| {option.label} | ||
| </MenuItem> | ||
| ))} | ||
| </Select> | ||
| </FormControl> | ||
| ); | ||
| }; | ||
|
|
||
| export default ChipMultiSelect; |
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.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win
Settle failed option queries.
fetchOptionsclearsloadingonly in the result callback.queryTemplatescalls that callback only after a successful fetch. A token or network failure leaves the template selector in its loading state.Make the query callback contract report both success and failure. Clear
loadingon the failure path.🤖 Prompt for AI Agents