Skip to content

Commit

Permalink
fix(admin-ui): resolve all bugs displayed for admin-ui #308
Browse files Browse the repository at this point in the history
  • Loading branch information
syntrydy committed Nov 16, 2021
1 parent e7bc830 commit b35a6e1
Show file tree
Hide file tree
Showing 9 changed files with 61 additions and 100 deletions.
1 change: 0 additions & 1 deletion app/redux/api/FidoApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ export default class FidoApi {

// update fido Config
updateFidoConfig = (input) => {
// console.log('*********************** Fido2 API input = ' + input)
return new Promise((resolve, reject) => {
this.api.putPropertiesFido2(input, (error, data) => {
if (error) {
Expand Down
22 changes: 13 additions & 9 deletions app/utils/AppAuthProvider.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { Component } from 'react'
import ViewRedirect from './ViewRedirect'
import { withRouter } from 'react-router'
import { saveState, isValidState } from './TokenController'
import { saveState } from './TokenController'
import queryString from 'query-string'
import { uuidv4 } from './Util'
import { connect } from 'react-redux'
Expand Down Expand Up @@ -41,9 +41,8 @@ class AppAuthProvider extends Component {
console.warn('Parameters to process authz code flow are missing.')
return
}
const url = `${authzBaseUrl}?acr_values=${acrValues}&response_type=${responseType}
return `${authzBaseUrl}?acr_values=${acrValues}&response_type=${responseType}
&redirect_uri=${redirectUrl}&client_id=${clientId}&scope=${scope}&state=${state}&nonce=${nonce}`
return url
}
constructor() {
super()
Expand All @@ -55,7 +54,7 @@ class AppAuthProvider extends Component {
}

static getDerivedStateFromProps(props) {
if (window.location.href.indexOf('logout') > -1) {
if (window.location.href.indexOf('logout') > -1) {
return { showContent: true }
}
if (!props.isLicenseValid) {
Expand Down Expand Up @@ -106,14 +105,18 @@ class AppAuthProvider extends Component {
<React.Fragment>
<SessionTimeout isAuthenticated={showContent} />
{showContent && this.props.children}
{!showContent &&
<ViewRedirect backendIsUp={this.props.backendIsUp}
{!showContent && (
<ViewRedirect
backendIsUp={this.props.backendIsUp}
isLicenseValid={this.props.isLicenseValid}
activateLicense={this.props.activateLicense}
redirectUrl={this.props.config.redirectUrl}
islicenseCheckResultLoaded={this.props.islicenseCheckResultLoaded}
isLicenseActivationResultLoaded={this.props.isLicenseActivationResultLoaded}
/>}
isLicenseActivationResultLoaded={
this.props.isLicenseActivationResultLoaded
}
/>
)}
</React.Fragment>
)
}
Expand All @@ -127,7 +130,8 @@ const mapStateToProps = ({ authReducer, licenseReducer }) => {
const backendIsUp = authReducer.backendIsUp
const isLicenseValid = licenseReducer.isLicenseValid
const islicenseCheckResultLoaded = licenseReducer.islicenseCheckResultLoaded
const isLicenseActivationResultLoaded = licenseReducer.isLicenseActivationResultLoaded
const isLicenseActivationResultLoaded =
licenseReducer.isLicenseActivationResultLoaded

return {
config,
Expand Down
5 changes: 1 addition & 4 deletions app/utils/ViewRedirect.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
import React, { useState, useEffect } from 'react'
import React from 'react'
import { Container } from './../components'
import GluuNotification from './../routes/Apps/Gluu/GluuNotification'
import GluuCommitDialog from '../../app/routes/Apps/Gluu/GluuCommitDialog'
import { useTranslation } from 'react-i18next'

function ViewRedirect({ backendIsUp, isLicenseValid, activateLicense, redirectUrl, islicenseCheckResultLoaded, isLicenseActivationResultLoaded }) {
const { t } = useTranslation()
//const [licensePresent, setLicensePresent] = useState(isLicenseValid)
//const [isLoading, setIsLoading] = useState(false);

function submitForm(message) {
activateLicense(message.trim());
}
Expand Down
43 changes: 10 additions & 33 deletions plugins/PluginMenuResolver.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import plugins from '../plugins.config'

//get all metadata path

export function processMenus() {
let pluginMenus = []
plugins
Expand All @@ -10,7 +7,7 @@ export function processMenus() {
pluginMenus = pluginMenus.concat(require(`${path}`).default.menus)
})

pluginMenus= sortMenu(pluginMenus)
pluginMenus = sortMenu(pluginMenus)

return pluginMenus
}
Expand All @@ -24,42 +21,22 @@ export function processRoutes() {
return pluginRoutes
}

const sortMenu= (menu) => {
menu= sortParentMenu(menu)
//menu= sortChildMenu(menu)

const sortMenu = (menu) => {
menu = sortParentMenu(menu)
return menu
}

const sortParentMenu= (menu) => {

menu.sort( (a, b) => {
var titleA = a.title.toUpperCase();
var titleB = b.title.toUpperCase();
const sortParentMenu = (menu) => {
menu.sort((a, b) => {
var titleA = a.title.toUpperCase()
var titleB = b.title.toUpperCase()
if (titleA < titleB) {
return -1;
return -1
}
if (titleA > titleB) {
return 1;
return 1
}
return 0;
});

return menu

}

const sortChildMenu= (menu) => {

menu.map( item => {
if(item.children){
item.children= sortParentMenu(item.children)
}
item.children.map( subItem => {
if(subItem.children){
subItem.children= sortParentMenu(subItem.children)
}
})
return 0
})

return menu
Expand Down
4 changes: 2 additions & 2 deletions plugins/PluginReducersResolver.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import plugins from '../plugins.config'
import reducerRegistry from '../app/redux/reducers/ReducerRegistry'

async function process() {
const metadataFilePath = await plugins.map((item) => item.metadataFile)
const metadataFilePath = plugins.map((item) => item.metadataFile)
let pluginReducers = []
await metadataFilePath.forEach(async (path) => {
pluginReducers = await [
Expand All @@ -14,6 +14,6 @@ async function process() {
await reducerRegistry.register(element.name, element.reducer)
})
})
console.log(pluginReducers)

}
export default process
7 changes: 2 additions & 5 deletions plugins/admin/components/Configuration/ConfigPage.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
import React from 'react'
import { FormGroup, Card, CardBody } from '../../../../app/components'
import { Card, CardBody } from '../../../../app/components'
import GluuLoader from '../../../../app/routes/Apps/Gluu/GluuLoader'
import { connect } from 'react-redux'
import { useTranslation } from 'react-i18next'

function ConfigPage({ loading, dispatch }) {
const { t } = useTranslation()

function ConfigPage({ loading }) {
return (
<GluuLoader blocking={loading}>
<Card>
Expand Down
53 changes: 21 additions & 32 deletions plugins/admin/components/Configuration/LicenseDetailsPage.js
Original file line number Diff line number Diff line change
@@ -1,41 +1,27 @@
import React, { useEffect, useState } from 'react'
import { useTranslation } from "react-i18next";
import { connect } from 'react-redux'
import LicenseDetailsForm from './LicenseDetailsForm'
import LicenseDetailsForm from './LicenseDetailsForm'
import GluuLabel from '../../../../app/routes/Apps/Gluu/GluuLabel'
import GluuFormDetailRow from '../../../../app/routes/Apps/Gluu/GluuFormDetailRow'
import { LICENSE } from '../../../../app/utils/ApiResources'
import { getLicenseDetails, updateLicenseDetails } from '../../redux/actions/LicenseDetailsActions'
import { Container, Row, Col, Form, FormGroup, Input, Accordion } from '../../../../app/components'
import {
getLicenseDetails,
updateLicenseDetails,
} from '../../redux/actions/LicenseDetailsActions'
import { Container, Row, Col } from '../../../../app/components'
import GluuLoader from '../../../../app/routes/Apps/Gluu/GluuLoader'
import Alert from '@material-ui/lab/Alert';
import { Formik } from 'formik'
import Alert from '@material-ui/lab/Alert'

function LicenseDetailsPage({ item, loading, dispatch }) {
const { t } = useTranslation();
const [validityPeriod, setValidityPeriod] = useState(!!item.validityPeriod ? new Date(item.validityPeriod) : new Date())
const [init, setInit] = useState(false)
const [modal, setModal] = useState(false)
const [validityPeriod, setValidityPeriod] = useState(
!!item.validityPeriod ? new Date(item.validityPeriod) : new Date(),
)
useEffect(() => {
dispatch(getLicenseDetails())
}, []);
}, [])
useEffect(() => {
setValidityPeriod(new Date(item.validityPeriod))
}, [item.validityPeriod]);

function activate() {
if (!init) {
setInit(true)
}
}
function toggle() {
setModal(!modal)
}

function submitForm() {
toggle()
document.getElementsByClassName('UserActionSubmitButton')[0].click()
}
}, [item.validityPeriod])

function handleSubmit(data) {
if (data) {
Expand All @@ -48,8 +34,8 @@ function LicenseDetailsPage({ item, loading, dispatch }) {
{/* <Container> */}
<GluuLabel label="fields.licenseDetails" size={8} />
<GluuLoader blocking={loading}>
{item.licenseEnable ?
(<>
{item.licenseEnable ? (
<>
<Container style={{ backgroundColor: '#F5F5F5' }}>
<Row>
<Col sm={6}>
Expand All @@ -61,7 +47,6 @@ function LicenseDetailsPage({ item, loading, dispatch }) {
rsize={9}
doc_entry="productName"
doc_category={LICENSE}

/>
</Col>
<Col sm={6}>
Expand Down Expand Up @@ -115,7 +100,7 @@ function LicenseDetailsPage({ item, loading, dispatch }) {
<Col sm={6}>
<GluuFormDetailRow
label="fields.customerName"
value={item.customerFirstName + " " + item.customerLastName}
value={item.customerFirstName + ' ' + item.customerLastName}
isBadge={true}
lsize={3}
rsize={9}
Expand All @@ -140,8 +125,12 @@ function LicenseDetailsPage({ item, loading, dispatch }) {
</Container>
<hr></hr>
<LicenseDetailsForm item={item} handleSubmit={handleSubmit} />
</>) :
(<Alert severity="info">{!loading && 'The License Api is not enabled for this application.'}</Alert>)}
</>
) : (
<Alert severity="info">
{!loading && 'The License Api is not enabled for this application.'}
</Alert>
)}
</GluuLoader>
</React.Fragment>
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React from 'react'
import { Container, Row, Col } from '../../../../app/components'
import GluuFormDetailRow from '../../../../app/routes/Apps/Gluu/GluuFormDetailRow'
import GluuTooltip from '../../../../app/routes/Apps/Gluu/GluuTooltip'
import { SCRIPT } from '../../../../app/utils/ApiResources'
import { useTranslation } from 'react-i18next'

Expand Down
25 changes: 12 additions & 13 deletions plugins/admin/components/CustomScripts/CustomScriptForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ function CustomScriptForm({ item, scripts, handleSubmit }) {
document.getElementsByClassName('UserActionSubmitButton')[0].click()
}

function getPropertiesConfig(item) {
function getPropertiesConfig(entry) {
if (
item.configurationProperties &&
Array.isArray(item.configurationProperties)
entry.configurationProperties &&
Array.isArray(entry.configurationProperties)
) {
return item.configurationProperties.map((e) => ({
return entry.configurationProperties.map((e) => ({
key: e.value1,
value: e.value2,
}))
Expand Down Expand Up @@ -110,12 +110,13 @@ function CustomScriptForm({ item, scripts, handleSubmit }) {
}

if (
item.moduleProperties.filter((item) => item.value1 === 'location_type')
.length > 0
item.moduleProperties.filter(
(candidate) => candidate.value1 === 'location_type',
).length > 0
) {
item.moduleProperties.splice(
item.moduleProperties.findIndex(
(item) => item.value1 === 'location_type',
(el) => el.value1 === 'location_type',
),
1,
)
Expand All @@ -135,13 +136,11 @@ function CustomScriptForm({ item, scripts, handleSubmit }) {
}

if (
item.moduleProperties.filter((item) => item.value1 === 'usage_type')
item.moduleProperties.filter((ligne) => ligne.value1 === 'usage_type')
.length > 0
) {
item.moduleProperties.splice(
item.moduleProperties.findIndex(
(item) => item.value1 === 'usage_type',
),
item.moduleProperties.findIndex((row) => row.value1 === 'usage_type'),
1,
)
}
Expand Down Expand Up @@ -302,10 +301,10 @@ function CustomScriptForm({ item, scripts, handleSubmit }) {
defaultValue={
!!item.moduleProperties &&
item.moduleProperties.filter(
(item) => item.value1 === 'location_type',
(i) => i.value1 === 'location_type',
).length > 0
? item.moduleProperties.filter(
(item) => item.value1 === 'location_type',
(it) => it.value1 === 'location_type',
)[0].value2
: undefined
}
Expand Down

0 comments on commit b35a6e1

Please sign in to comment.