Merge pull request #18852 from GuiLeme/plugin-nav-bar-fix

fix(html5): fix nav-bar plugin exception
This commit is contained in:
Ramón Souza 2023-09-26 15:29:52 -03:00 committed by GitHub
commit 98062ce979
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -58,70 +58,74 @@ const defaultProps = {
shortcuts: '',
};
const renderPluginItems = (pluginItems) => (
<>
{
pluginItems.map((pluginItem) => {
let returnComponent;
switch (pluginItem.type) {
case PluginSdk.NavBarItemType.BUTTON:
returnComponent = (
<Styled.PluginComponentWrapper
key={pluginItem.id}
>
<Button
icon={pluginItem.icon}
label={pluginItem.label}
aria-label={pluginItem.tooltip}
color="primary"
tooltip={pluginItem.tooltip}
onClick={pluginItem.onClick}
/>
</Styled.PluginComponentWrapper>
);
break;
case PluginSdk.NavBarItemType.INFO:
returnComponent = (
<Styled.PluginComponentWrapper
key={pluginItem.id}
tooltip={pluginItem.tooltip}
>
<Styled.PluginInfoComponent>
{pluginItem.label}
</Styled.PluginInfoComponent>
</Styled.PluginComponentWrapper>
);
break;
default:
returnComponent = null;
break;
const renderPluginItems = (pluginItems) => {
if (pluginItems !== undefined) {
return (
<>
{
pluginItems.map((pluginItem) => {
let returnComponent;
switch (pluginItem.type) {
case PluginSdk.NavBarItemType.BUTTON:
returnComponent = (
<Styled.PluginComponentWrapper
key={pluginItem.id}
>
<Button
icon={pluginItem.icon}
label={pluginItem.label}
aria-label={pluginItem.tooltip}
color="primary"
tooltip={pluginItem.tooltip}
onClick={pluginItem.onClick}
/>
</Styled.PluginComponentWrapper>
);
break;
case PluginSdk.NavBarItemType.INFO:
returnComponent = (
<Styled.PluginComponentWrapper
key={pluginItem.id}
tooltip={pluginItem.tooltip}
>
<Styled.PluginInfoComponent>
{pluginItem.label}
</Styled.PluginInfoComponent>
</Styled.PluginComponentWrapper>
);
break;
default:
returnComponent = null;
break;
}
if (pluginItem.hasSeparator) {
switch (pluginItem.position) {
case PluginSdk.NavBarItemPosition.RIGHT:
returnComponent = (
<>
{returnComponent}
<Styled.PluginSeparatorWrapper>|</Styled.PluginSeparatorWrapper>
</>
);
break;
default:
returnComponent = (
<>
<Styled.PluginSeparatorWrapper>|</Styled.PluginSeparatorWrapper>
{returnComponent}
</>
);
break;
}
}
return returnComponent;
})
}
if (pluginItem.hasSeparator) {
switch (pluginItem.position) {
case PluginSdk.NavBarItemPosition.RIGHT:
returnComponent = (
<>
{returnComponent}
<Styled.PluginSeparatorWrapper>|</Styled.PluginSeparatorWrapper>
</>
);
break;
default:
returnComponent = (
<>
<Styled.PluginSeparatorWrapper>|</Styled.PluginSeparatorWrapper>
{returnComponent}
</>
);
break;
}
}
return returnComponent;
})
}
</>
);
</>
);
}
return (<></>);
};
class NavBar extends Component {
constructor(props) {
super(props);