Skip to content

Commit

Permalink
Merge pull request #958 from GluuFederation/admin-ui-issue-745-extend
Browse files Browse the repository at this point in the history
feat(admin-ui): make admin-ui compatible with latest version node and npm
  • Loading branch information
mjatin-dev authored Apr 26, 2023
2 parents 642cfa7 + 4b8e7bd commit aa4da4b
Show file tree
Hide file tree
Showing 110 changed files with 6,406 additions and 366 deletions.
2 changes: 1 addition & 1 deletion admin-ui/app/common.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import * as CommonDashboardFuncs from '@miltonbo/dashboard-style-airframe'
import * as CommonDashboardFuncs from './components/dashboard-style-airframe'

export default CommonDashboardFuncs
2 changes: 1 addition & 1 deletion admin-ui/app/components/Avatar/AvatarAddonIcon.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import avatarColors from './../../colors.scss'
const AvatarAddonIcon = (props) => {
const addOnClass = classNames({
'avatar__icon__inner': props.small
}, avatarColors[`fg-color--${ props.color }`])
}, avatarColors[`fg-color--${ props.color || 'default' }`])

return (
<i className={ classNames(addOnClass, props.className) }></i>
Expand Down
174 changes: 174 additions & 0 deletions admin-ui/app/components/BlockUi/BlockUi.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
import React, { useState, useRef, useEffect } from "react";
import DefaultLoader from "./DefaultLoader";
import safeActiveElement from "./safeActiveElement";

export default function BlockUi(props) {
const {
tag: Tag = "div",
blocking,
className,
children,
message,
loader: Loader = DefaultLoader,
renderChildren = true,
keepInView,
ariaLabel = "loading",
...attributes
} = props;

const classes = blocking ? `block-ui ${className}` : className;
const renderChilds = !blocking || renderChildren;

const [top] = useState("50%");
const [focused, setFocused] = useState(null);

const helper = useRef(null);
const blocker = useRef(null);
const topFocus = useRef(null);
const container = useRef(null);
const messageContainer = useRef(null);

useEffect(() => {
if (blocking) {
if (
helper.current &&
helper.current.parentNode &&
helper.current.parentNode.contains &&
helper.current.parentNode.contains(safeActiveElement())
) {
setFocused(safeActiveElement());
if (focused && focused !== document.body) {
(window.setImmediate || setTimeout)(
() =>
focused && typeof focused.blur === "function" && focused.blur()
);
}
}
} else {
detachListeners();
const ae = safeActiveElement();
if (focused && (!ae || ae === document.body || ae === topFocus.current)) {
if (typeof focused.focus === "function") {
focused.focus();
}
setFocused(null);
}
}
if (
keepInView &&
(keepInView !== props.keepInView ||
(blocking && blocking !== props.blocking))
) {
attachListeners();
keepInViewFunc();
}
return () => {
detachListeners();
};
}, [blocking, keepInView, focused]);

const blockingTab = (e, withShift = false) => {
return (
blocking &&
(e.key === "Tab" || e.keyCode === 9) &&
e.shiftKey == withShift
);
};

const tabbedUpTop = (e) => {
if (blockingTab(e)) {
blocker.current.focus();
}
};

const tabbedDownTop = (e) => {
if (blockingTab(e)) {
e.preventDefault();
blocker.current.focus();
}
};

const tabbedUpBottom = (e) => {
if (blockingTab(e, true)) {
topFocus.current.focus();
}
};

const tabbedDownBottom = (e) => {
if (blockingTab(e, true)) {
e.preventDefault();
topFocus.current.focus();
}
};

const attachListeners = () => {
window.addEventListener("scroll", handleScroll);
};

const detachListeners = () => {
window.removeEventListener("scroll", handleScroll);
};

const keepInViewFunc = () => {
if (props.blocking && props.keepInView && container.current) {
const containerBounds = container.current.getBoundingClientRect();
const windowHeight = window.innerHeight;
if (containerBounds.top > windowHeight || containerBounds.bottom < 0)
return;
if (containerBounds.top >= 0 && containerBounds.bottom <= windowHeight)
return;
const topDelta = Math.min(containerBounds.top, 0);
const bottomDelta = Math.max(containerBounds.bottom - windowHeight, 0);
const scrollDelta = topDelta || bottomDelta;
window.scrollBy({
top: scrollDelta,
left: 0,
behavior: "smooth",
});
}
};

function handleScroll() {
keepInView();
}

return (
<Tag {...attributes} className={classes} aria-busy={blocking}>
{blocking && (
<div
tabIndex="0"
onKeyUp={tabbedUpTop}
onKeyDown={tabbedDownTop}
ref={topFocus}
>
<div className="sr-only">{message || ariaLabel}</div>
</div>
)}
{renderChilds && children}
{blocking && (
<div
className="block-ui-container"
tabIndex="0"
ref={blocker}
onKeyUp={tabbedUpBottom}
onKeyDown={tabbedDownBottom}
>
<div className="block-ui-overlay" ref={container} />
<div
className="block-ui-message-container"
ref={messageContainer}
style={{ top: keepInView ? top : undefined }}
>
<div className="block-ui-message">
{message || <span className="sr-only">{ariaLabel}</span>}
<div aria-hidden>
{React.isValidElement(Loader) ? Loader : <Loader />}
</div>
</div>
</div>
</div>
)}
<span ref={helper} />
</Tag>
);
}
13 changes: 13 additions & 0 deletions admin-ui/app/components/BlockUi/DefaultLoader.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import React from "react"

function Loader() {
return (
<div className="loading-indicator">
<span className="loading-bullet">&bull;</span>
<span className="loading-bullet">&bull;</span>
<span className="loading-bullet">&bull;</span>
</div>
);
}

export default Loader
20 changes: 20 additions & 0 deletions admin-ui/app/components/BlockUi/safeActiveElement.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// https://gist.github.com/Alex1990/046a6553dc83e22dd6f4
/**
* Get the current active element safely.
* Ref: https://github.com/jquery/jquery-ui/blob/2b84531ae9331f60e4d739fabca6d78abde89ae1/ui/safe-active-element.js
*/
export default function safeActiveElement(doc) {
doc = doc || document;
let activeElement;

try {
activeElement = document.activeElement;
if (!activeElement || !activeElement.nodeName) {
activeElement = doc.body;
}
} catch (error) {
activeElement = doc.body;
}

return activeElement;
}
14 changes: 1 addition & 13 deletions admin-ui/app/components/Layout/Layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react'
import ReactDOM from 'react-dom'
import PropTypes from 'prop-types'
import classNames from 'classnames'
import { Helmet } from 'react-helmet'
// import { Helmet } from 'react-helmet'
import { useWithRouter as withRouter } from 'Utils/WithRouter'
import {
filter,
Expand Down Expand Up @@ -239,18 +239,6 @@ class Layout extends React.Component {
changeMeta: (metaData) => { this.setState(metaData) }
}}
>
<Helmet>
<meta charSet="utf-8" />
<title>{ config.siteTitle + (this.state.pageTitle ? ` - ${this.state.pageTitle}` : '') }</title>
<link rel="canonical" href={ config.siteCannonicalUrl } />
<meta name="description" content={ this.state.pageDescription } />
{
map(favIcons, (favIcon, index) => (
<link { ...favIcon } key={ index } />
))
}

</Helmet>
<ThemeClass>
{(themeClass) => (
<div className={ classNames(layoutClass, themeClass) } ref={ this.containerRef }>
Expand Down
10 changes: 5 additions & 5 deletions admin-ui/app/components/NavSearch/search.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import React from 'react'
import Paper from '@material-ui/core/Paper'
import InputBase from '@material-ui/core/InputBase'
import IconButton from '@material-ui/core/IconButton'
import SearchIcon from '@material-ui/icons/Search'
import Paper from '@mui/material/Paper'
import InputBase from '@mui/material/InputBase'
import IconButton from '@mui/material/IconButton'
import SearchIcon from '@mui/icons-material/Search'
import styles from './styles'

export default function Search({ isTabletOrMobile }) {
const classes = styles()
const { classes } = styles()

return (
<Paper component="form" className={`${classes.root} ${isTabletOrMobile ? classes.mobile : ''}`}>
Expand Down
4 changes: 2 additions & 2 deletions admin-ui/app/components/NavSearch/styles.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { makeStyles } from '@material-ui/core/styles'
import { makeStyles } from "tss-react/mui";

const styles = makeStyles((theme) => ({
const styles = makeStyles()((theme) => ({
root: {
padding: '1px 10px 1px 10px',
display: 'flex',
Expand Down
22 changes: 11 additions & 11 deletions admin-ui/app/components/Notifications/index.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import React from 'react'
import Button from '@material-ui/core/Button'
import ClickAwayListener from '@material-ui/core/ClickAwayListener'
import Grow from '@material-ui/core/Grow'
import Paper from '@material-ui/core/Paper'
import Popper from '@material-ui/core/Popper'
import List from '@material-ui/core/List'
import ListItem from '@material-ui/core/ListItem'
import ListItemText from '@material-ui/core/ListItemText'
import NotificationsIcon from '@material-ui/icons/Notifications'
import Button from '@mui/material/Button'
import ClickAwayListener from '@mui/base/ClickAwayListener'
import Grow from '@mui/material/Grow'
import Paper from '@mui/material/Paper'
import Popper from '@mui/material/Popper'
import List from '@mui/material/List'
import ListItem from '@mui/material/ListItem'
import ListItemText from '@mui/material/ListItemText'
import NotificationsIcon from '@mui/icons-material/Notifications'
import styles from './styles'

export default function Lang() {
const classes = styles()
const { classes } = styles()
const [open, setOpen] = React.useState(false)
const anchorRef = React.useRef(null)

Expand Down Expand Up @@ -47,7 +47,7 @@ export default function Lang() {
className={classes.btnContainer}
onClick={handleToggle}
>
<NotificationsIcon />
<NotificationsIcon style={{color: "white"}}/>
</Button>
<Popper open={open} anchorEl={anchorRef.current} role={undefined} transition disablePortal className={classes.topElm}>
{({ TransitionProps, placement }) => (
Expand Down
5 changes: 3 additions & 2 deletions admin-ui/app/components/Notifications/styles.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { makeStyles } from '@material-ui/core/styles'
import { makeStyles } from "tss-react/mui";
// import { useTheme } from '@mui/material/styles';

const styles = makeStyles((theme) => ({
const styles = makeStyles()((theme) => ({
root: {
display: 'flex',
},
Expand Down
12 changes: 6 additions & 6 deletions admin-ui/app/components/ThemeSetting/ThemeSettings.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React, { useContext } from 'react'
import clsx from 'clsx'
import Drawer from '@material-ui/core/Drawer'
import Button from '@material-ui/core/Button'
import Box from '@material-ui/core/Box'
import SettingsIcon from '@material-ui/icons/Settings'
import Drawer from '@mui/material/Drawer'
import Button from '@mui/material/Button'
import Box from '@mui/material/Box'
import SettingsIcon from '@mui/icons-material/Settings'
import { ThemeContext } from "Context/theme/themeContext"
import darkBlackThumbnail from 'Images/theme-thumbnail/darkBlack.jpg'
import darkBlueThumbnail from 'Images/theme-thumbnail/darkBlue.jpg'
Expand All @@ -12,7 +12,7 @@ import lightGreenThumbnail from 'Images/theme-thumbnail/lightGreen.jpg'
import styles from './styles'

export function ThemeSettings({ userInfo }) {
const classes = styles()
const { classes } = styles()
const [open, setOpen] = React.useState(false)
const themeContext = useContext(ThemeContext)

Expand Down Expand Up @@ -78,7 +78,7 @@ export function ThemeSettings({ userInfo }) {
return (
<React.Fragment>
<Button onClick={toggleDrawer(true)} className={classes.whiteColor}>
<SettingsIcon />
<SettingsIcon style={{color: "white"}}/>
</Button>
<Drawer className={classes.drawerContainer} anchor={'right'} open={open} onClose={toggleDrawer(false)}>
{list('right')}
Expand Down
4 changes: 2 additions & 2 deletions admin-ui/app/components/ThemeSetting/styles.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { makeStyles } from '@material-ui/core/styles'
import { makeStyles } from "tss-react/mui";

const styles = makeStyles({
const styles = makeStyles()({
list: {
width: 250,
},
Expand Down
4 changes: 2 additions & 2 deletions admin-ui/app/components/Widgets/GroupedButtons/Counter.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react'
import Button from '@material-ui/core/Button'
import ButtonGroup from '@material-ui/core/ButtonGroup'
import Button from '@mui/material/Button'
import ButtonGroup from '@mui/material/ButtonGroup'

class Counter extends React.Component {
state = {
Expand Down
11 changes: 11 additions & 0 deletions admin-ui/app/components/dashboard-style-airframe/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import SideMenuAnimate from './side-menu-animate'
import SidebarEntryAnimate from './sidebar-entry-animate'
import SlimSidebarAnimate from './slim-sidebar-animate'
import SlimMenuAnimate from './slim-menu-animate'

export {
SideMenuAnimate,
SidebarEntryAnimate,
SlimSidebarAnimate,
SlimMenuAnimate,
};
Loading

0 comments on commit aa4da4b

Please sign in to comment.