Skip to content

Commit

Permalink
auto expand first entry of selected category
Browse files Browse the repository at this point in the history
- and respect line breaks in message
  • Loading branch information
foxriver76 committed Oct 28, 2023
1 parent 870d7fe commit ca055d6
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/src/dialogs/HostWarningDialog.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ const useStyles = makeStyles(theme => ({
fontFamily: 'monospace',
fontSize: 14,
marginLeft: 20,
whiteSpace: 'pre-wrap',
},
img2: {
width: 25,
Expand Down Expand Up @@ -248,9 +249,13 @@ const HostWarningDialog = ({
const [value, setValue] = useState(0);
const [disabled, setDisabled] = useState([]);
const [expanded, setExpanded] = useState(false);
const [autoCollapse, setAutoCollapse] = useState(true);

const handleChange = (event, newValue) =>
const handleChange = (event, newValue) => {
setAutoCollapse(true);
setValue(newValue);
setExpanded(false);
};

const handleChangeAccordion = panel => (event, isExpanded) =>
setExpanded(isExpanded ? panel : false);
Expand Down Expand Up @@ -281,7 +286,7 @@ const HostWarningDialog = ({
style={black ? null : { color: 'white' }}
disabled={disabled.includes(name)}
key={name}
label={I18n.t(name)}
label={entry.name[I18n.getLanguage()]}
icon={<Status name={name} severity={entry.severity} />}
{...a11yProps(idx)}
/>)}
Expand All @@ -303,6 +308,13 @@ const HostWarningDialog = ({
</div>
<div>
{messages[name].instances ? Object.keys(messages[name].instances).map(nameInst => {
const index = Object.keys(messages).indexOf(name);

if (autoCollapse && value === index) {
handleChangeAccordion(`${name}-${nameInst}`)(_, true);
setAutoCollapse(false);
}

const currentInstance = instances && instances[nameInst];
let icon = 'img/no-image.png';
if (currentInstance?.common?.icon && currentInstance?.common?.name) {
Expand Down

0 comments on commit ca055d6

Please sign in to comment.