Skip to content

Commit b35a6e1

Browse files
committed
fix(admin-ui): resolve all bugs displayed for admin-ui #308
1 parent e7bc830 commit b35a6e1

File tree

9 files changed

+61
-100
lines changed

9 files changed

+61
-100
lines changed

app/redux/api/FidoApi.js

-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ export default class FidoApi {
1717

1818
// update fido Config
1919
updateFidoConfig = (input) => {
20-
// console.log('*********************** Fido2 API input = ' + input)
2120
return new Promise((resolve, reject) => {
2221
this.api.putPropertiesFido2(input, (error, data) => {
2322
if (error) {

app/utils/AppAuthProvider.js

+13-9
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, { Component } from 'react'
22
import ViewRedirect from './ViewRedirect'
33
import { withRouter } from 'react-router'
4-
import { saveState, isValidState } from './TokenController'
4+
import { saveState } from './TokenController'
55
import queryString from 'query-string'
66
import { uuidv4 } from './Util'
77
import { connect } from 'react-redux'
@@ -41,9 +41,8 @@ class AppAuthProvider extends Component {
4141
console.warn('Parameters to process authz code flow are missing.')
4242
return
4343
}
44-
const url = `${authzBaseUrl}?acr_values=${acrValues}&response_type=${responseType}
44+
return `${authzBaseUrl}?acr_values=${acrValues}&response_type=${responseType}
4545
&redirect_uri=${redirectUrl}&client_id=${clientId}&scope=${scope}&state=${state}&nonce=${nonce}`
46-
return url
4746
}
4847
constructor() {
4948
super()
@@ -55,7 +54,7 @@ class AppAuthProvider extends Component {
5554
}
5655

5756
static getDerivedStateFromProps(props) {
58-
if (window.location.href.indexOf('logout') > -1) {
57+
if (window.location.href.indexOf('logout') > -1) {
5958
return { showContent: true }
6059
}
6160
if (!props.isLicenseValid) {
@@ -106,14 +105,18 @@ class AppAuthProvider extends Component {
106105
<React.Fragment>
107106
<SessionTimeout isAuthenticated={showContent} />
108107
{showContent && this.props.children}
109-
{!showContent &&
110-
<ViewRedirect backendIsUp={this.props.backendIsUp}
108+
{!showContent && (
109+
<ViewRedirect
110+
backendIsUp={this.props.backendIsUp}
111111
isLicenseValid={this.props.isLicenseValid}
112112
activateLicense={this.props.activateLicense}
113113
redirectUrl={this.props.config.redirectUrl}
114114
islicenseCheckResultLoaded={this.props.islicenseCheckResultLoaded}
115-
isLicenseActivationResultLoaded={this.props.isLicenseActivationResultLoaded}
116-
/>}
115+
isLicenseActivationResultLoaded={
116+
this.props.isLicenseActivationResultLoaded
117+
}
118+
/>
119+
)}
117120
</React.Fragment>
118121
)
119122
}
@@ -127,7 +130,8 @@ const mapStateToProps = ({ authReducer, licenseReducer }) => {
127130
const backendIsUp = authReducer.backendIsUp
128131
const isLicenseValid = licenseReducer.isLicenseValid
129132
const islicenseCheckResultLoaded = licenseReducer.islicenseCheckResultLoaded
130-
const isLicenseActivationResultLoaded = licenseReducer.isLicenseActivationResultLoaded
133+
const isLicenseActivationResultLoaded =
134+
licenseReducer.isLicenseActivationResultLoaded
131135

132136
return {
133137
config,

app/utils/ViewRedirect.js

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
1-
import React, { useState, useEffect } from 'react'
1+
import React from 'react'
22
import { Container } from './../components'
33
import GluuNotification from './../routes/Apps/Gluu/GluuNotification'
44
import GluuCommitDialog from '../../app/routes/Apps/Gluu/GluuCommitDialog'
55
import { useTranslation } from 'react-i18next'
66

77
function ViewRedirect({ backendIsUp, isLicenseValid, activateLicense, redirectUrl, islicenseCheckResultLoaded, isLicenseActivationResultLoaded }) {
88
const { t } = useTranslation()
9-
//const [licensePresent, setLicensePresent] = useState(isLicenseValid)
10-
//const [isLoading, setIsLoading] = useState(false);
11-
129
function submitForm(message) {
1310
activateLicense(message.trim());
1411
}

plugins/PluginMenuResolver.js

+10-33
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
import plugins from '../plugins.config'
2-
3-
//get all metadata path
4-
52
export function processMenus() {
63
let pluginMenus = []
74
plugins
@@ -10,7 +7,7 @@ export function processMenus() {
107
pluginMenus = pluginMenus.concat(require(`${path}`).default.menus)
118
})
129

13-
pluginMenus= sortMenu(pluginMenus)
10+
pluginMenus = sortMenu(pluginMenus)
1411

1512
return pluginMenus
1613
}
@@ -24,42 +21,22 @@ export function processRoutes() {
2421
return pluginRoutes
2522
}
2623

27-
const sortMenu= (menu) => {
28-
menu= sortParentMenu(menu)
29-
//menu= sortChildMenu(menu)
30-
24+
const sortMenu = (menu) => {
25+
menu = sortParentMenu(menu)
3126
return menu
3227
}
3328

34-
const sortParentMenu= (menu) => {
35-
36-
menu.sort( (a, b) => {
37-
var titleA = a.title.toUpperCase();
38-
var titleB = b.title.toUpperCase();
29+
const sortParentMenu = (menu) => {
30+
menu.sort((a, b) => {
31+
var titleA = a.title.toUpperCase()
32+
var titleB = b.title.toUpperCase()
3933
if (titleA < titleB) {
40-
return -1;
34+
return -1
4135
}
4236
if (titleA > titleB) {
43-
return 1;
37+
return 1
4438
}
45-
return 0;
46-
});
47-
48-
return menu
49-
50-
}
51-
52-
const sortChildMenu= (menu) => {
53-
54-
menu.map( item => {
55-
if(item.children){
56-
item.children= sortParentMenu(item.children)
57-
}
58-
item.children.map( subItem => {
59-
if(subItem.children){
60-
subItem.children= sortParentMenu(subItem.children)
61-
}
62-
})
39+
return 0
6340
})
6441

6542
return menu

plugins/PluginReducersResolver.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import plugins from '../plugins.config'
22
import reducerRegistry from '../app/redux/reducers/ReducerRegistry'
33

44
async function process() {
5-
const metadataFilePath = await plugins.map((item) => item.metadataFile)
5+
const metadataFilePath = plugins.map((item) => item.metadataFile)
66
let pluginReducers = []
77
await metadataFilePath.forEach(async (path) => {
88
pluginReducers = await [
@@ -14,6 +14,6 @@ async function process() {
1414
await reducerRegistry.register(element.name, element.reducer)
1515
})
1616
})
17-
console.log(pluginReducers)
17+
1818
}
1919
export default process

plugins/admin/components/Configuration/ConfigPage.js

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
import React from 'react'
2-
import { FormGroup, Card, CardBody } from '../../../../app/components'
2+
import { Card, CardBody } from '../../../../app/components'
33
import GluuLoader from '../../../../app/routes/Apps/Gluu/GluuLoader'
44
import { connect } from 'react-redux'
5-
import { useTranslation } from 'react-i18next'
6-
7-
function ConfigPage({ loading, dispatch }) {
8-
const { t } = useTranslation()
95

6+
function ConfigPage({ loading }) {
107
return (
118
<GluuLoader blocking={loading}>
129
<Card>

plugins/admin/components/Configuration/LicenseDetailsPage.js

+21-32
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,27 @@
11
import React, { useEffect, useState } from 'react'
2-
import { useTranslation } from "react-i18next";
32
import { connect } from 'react-redux'
4-
import LicenseDetailsForm from './LicenseDetailsForm'
3+
import LicenseDetailsForm from './LicenseDetailsForm'
54
import GluuLabel from '../../../../app/routes/Apps/Gluu/GluuLabel'
65
import GluuFormDetailRow from '../../../../app/routes/Apps/Gluu/GluuFormDetailRow'
76
import { LICENSE } from '../../../../app/utils/ApiResources'
8-
import { getLicenseDetails, updateLicenseDetails } from '../../redux/actions/LicenseDetailsActions'
9-
import { Container, Row, Col, Form, FormGroup, Input, Accordion } from '../../../../app/components'
7+
import {
8+
getLicenseDetails,
9+
updateLicenseDetails,
10+
} from '../../redux/actions/LicenseDetailsActions'
11+
import { Container, Row, Col } from '../../../../app/components'
1012
import GluuLoader from '../../../../app/routes/Apps/Gluu/GluuLoader'
11-
import Alert from '@material-ui/lab/Alert';
12-
import { Formik } from 'formik'
13+
import Alert from '@material-ui/lab/Alert'
1314

1415
function LicenseDetailsPage({ item, loading, dispatch }) {
15-
const { t } = useTranslation();
16-
const [validityPeriod, setValidityPeriod] = useState(!!item.validityPeriod ? new Date(item.validityPeriod) : new Date())
17-
const [init, setInit] = useState(false)
18-
const [modal, setModal] = useState(false)
16+
const [validityPeriod, setValidityPeriod] = useState(
17+
!!item.validityPeriod ? new Date(item.validityPeriod) : new Date(),
18+
)
1919
useEffect(() => {
2020
dispatch(getLicenseDetails())
21-
}, []);
21+
}, [])
2222
useEffect(() => {
2323
setValidityPeriod(new Date(item.validityPeriod))
24-
}, [item.validityPeriod]);
25-
26-
function activate() {
27-
if (!init) {
28-
setInit(true)
29-
}
30-
}
31-
function toggle() {
32-
setModal(!modal)
33-
}
34-
35-
function submitForm() {
36-
toggle()
37-
document.getElementsByClassName('UserActionSubmitButton')[0].click()
38-
}
24+
}, [item.validityPeriod])
3925

4026
function handleSubmit(data) {
4127
if (data) {
@@ -48,8 +34,8 @@ function LicenseDetailsPage({ item, loading, dispatch }) {
4834
{/* <Container> */}
4935
<GluuLabel label="fields.licenseDetails" size={8} />
5036
<GluuLoader blocking={loading}>
51-
{item.licenseEnable ?
52-
(<>
37+
{item.licenseEnable ? (
38+
<>
5339
<Container style={{ backgroundColor: '#F5F5F5' }}>
5440
<Row>
5541
<Col sm={6}>
@@ -61,7 +47,6 @@ function LicenseDetailsPage({ item, loading, dispatch }) {
6147
rsize={9}
6248
doc_entry="productName"
6349
doc_category={LICENSE}
64-
6550
/>
6651
</Col>
6752
<Col sm={6}>
@@ -115,7 +100,7 @@ function LicenseDetailsPage({ item, loading, dispatch }) {
115100
<Col sm={6}>
116101
<GluuFormDetailRow
117102
label="fields.customerName"
118-
value={item.customerFirstName + " " + item.customerLastName}
103+
value={item.customerFirstName + ' ' + item.customerLastName}
119104
isBadge={true}
120105
lsize={3}
121106
rsize={9}
@@ -140,8 +125,12 @@ function LicenseDetailsPage({ item, loading, dispatch }) {
140125
</Container>
141126
<hr></hr>
142127
<LicenseDetailsForm item={item} handleSubmit={handleSubmit} />
143-
</>) :
144-
(<Alert severity="info">{!loading && 'The License Api is not enabled for this application.'}</Alert>)}
128+
</>
129+
) : (
130+
<Alert severity="info">
131+
{!loading && 'The License Api is not enabled for this application.'}
132+
</Alert>
133+
)}
145134
</GluuLoader>
146135
</React.Fragment>
147136
)

plugins/admin/components/CustomScripts/CustomScriptDetailPage.js

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import React from 'react'
22
import { Container, Row, Col } from '../../../../app/components'
33
import GluuFormDetailRow from '../../../../app/routes/Apps/Gluu/GluuFormDetailRow'
4-
import GluuTooltip from '../../../../app/routes/Apps/Gluu/GluuTooltip'
54
import { SCRIPT } from '../../../../app/utils/ApiResources'
65
import { useTranslation } from 'react-i18next'
76

plugins/admin/components/CustomScripts/CustomScriptForm.js

+12-13
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,12 @@ function CustomScriptForm({ item, scripts, handleSubmit }) {
3939
document.getElementsByClassName('UserActionSubmitButton')[0].click()
4040
}
4141

42-
function getPropertiesConfig(item) {
42+
function getPropertiesConfig(entry) {
4343
if (
44-
item.configurationProperties &&
45-
Array.isArray(item.configurationProperties)
44+
entry.configurationProperties &&
45+
Array.isArray(entry.configurationProperties)
4646
) {
47-
return item.configurationProperties.map((e) => ({
47+
return entry.configurationProperties.map((e) => ({
4848
key: e.value1,
4949
value: e.value2,
5050
}))
@@ -110,12 +110,13 @@ function CustomScriptForm({ item, scripts, handleSubmit }) {
110110
}
111111

112112
if (
113-
item.moduleProperties.filter((item) => item.value1 === 'location_type')
114-
.length > 0
113+
item.moduleProperties.filter(
114+
(candidate) => candidate.value1 === 'location_type',
115+
).length > 0
115116
) {
116117
item.moduleProperties.splice(
117118
item.moduleProperties.findIndex(
118-
(item) => item.value1 === 'location_type',
119+
(el) => el.value1 === 'location_type',
119120
),
120121
1,
121122
)
@@ -135,13 +136,11 @@ function CustomScriptForm({ item, scripts, handleSubmit }) {
135136
}
136137

137138
if (
138-
item.moduleProperties.filter((item) => item.value1 === 'usage_type')
139+
item.moduleProperties.filter((ligne) => ligne.value1 === 'usage_type')
139140
.length > 0
140141
) {
141142
item.moduleProperties.splice(
142-
item.moduleProperties.findIndex(
143-
(item) => item.value1 === 'usage_type',
144-
),
143+
item.moduleProperties.findIndex((row) => row.value1 === 'usage_type'),
145144
1,
146145
)
147146
}
@@ -302,10 +301,10 @@ function CustomScriptForm({ item, scripts, handleSubmit }) {
302301
defaultValue={
303302
!!item.moduleProperties &&
304303
item.moduleProperties.filter(
305-
(item) => item.value1 === 'location_type',
304+
(i) => i.value1 === 'location_type',
306305
).length > 0
307306
? item.moduleProperties.filter(
308-
(item) => item.value1 === 'location_type',
307+
(it) => it.value1 === 'location_type',
309308
)[0].value2
310309
: undefined
311310
}

0 commit comments

Comments
 (0)