Skip to content

Commit

Permalink
feat(admin-ui): design the layout for api role management #327
Browse files Browse the repository at this point in the history
  • Loading branch information
syntrydy committed Dec 3, 2021
1 parent 2403ff0 commit d121479
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 9 deletions.
31 changes: 23 additions & 8 deletions app/components/SidebarMenu/SidebarMenuItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ import { MenuContext } from './MenuContext'
const SidebarMenuItemLink = (props) =>
props.to || props.href ? (
props.to ? (
<Link to={props.to} style={props.textStyle} className={`${props.classBase}__entry__link`}>
<Link
to={props.to}
style={props.textStyle}
className={`${props.classBase}__entry__link`}
>
{props.children}
</Link>
) : (
Expand Down Expand Up @@ -42,7 +46,7 @@ SidebarMenuItemLink.propTypes = {
onToggle: PropTypes.func,
children: PropTypes.node,
classBase: PropTypes.string,
textStyle: PropTypes.object
textStyle: PropTypes.object,
}

/**
Expand All @@ -68,7 +72,7 @@ export class SidebarMenuItem extends React.Component {
href: PropTypes.string,
exact: PropTypes.bool,
noCaret: PropTypes.bool,
textStyle: PropTypes.object
textStyle: PropTypes.object,
}

static defaultProps = {
Expand Down Expand Up @@ -119,11 +123,11 @@ export class SidebarMenuItem extends React.Component {
active: entry && entry.active,
})
const activeMenu = {
color: 'white !important',
backgroundColor: 'rgb(3, 169, 109)',
}
const nonaActiveMenu = {
color: '#ffffff',
background: 'linear-gradient(90deg, #00C9FF 0%, #92FE9D 100%)',
fontWeight: 'bold',
}
const nonaActiveMenu = {}

function getStyle(itemClass) {
if (
Expand All @@ -135,6 +139,17 @@ export class SidebarMenuItem extends React.Component {
}
return nonaActiveMenu
}

function getTextStyle(itemClass) {
if (
itemClass.includes('active', 0) &&
itemClass.includes('submenu__entry', 0) &&
!itemClass.includes('open', 0)
) {
return { color: 'white', fontWeight: 'inherit' }
}
return null
}
return (
<li
style={getStyle(itemClass)}
Expand All @@ -148,7 +163,7 @@ export class SidebarMenuItem extends React.Component {
href={this.props.href || null}
onToggle={this.toggleNode.bind(this)}
classBase={classBase}
textStyle={this.props.textStyle}
textStyle={getTextStyle(itemClass) || this.props.textStyle}
>
{this.props.icon &&
React.cloneElement(this.props.icon, {
Expand Down
1 change: 0 additions & 1 deletion app/routes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ export const RoutedContent = () => {
state.token ? state.token.scopes : state.authReducer.permissions,
)
const [pluginMenus, setPluginMenus] = useState([])
//console.log('==============' + JSON.stringify(scopes))
useEffect(() => {
setPluginMenus(processRoutes())
}, [])
Expand Down

0 comments on commit d121479

Please sign in to comment.