diff --git a/portals/admin/src/main/webapp/site/public/locales/en.json b/portals/admin/src/main/webapp/site/public/locales/en.json
index fe6a5d05857..501d52cdb34 100644
--- a/portals/admin/src/main/webapp/site/public/locales/en.json
+++ b/portals/admin/src/main/webapp/site/public/locales/en.json
@@ -78,6 +78,7 @@
"AdminPages.Gateways.List.title": "Gateway Environments",
"AdminPages.Gateways.table.header.description": "Description",
"AdminPages.Gateways.table.header.displayName": "Name",
+ "AdminPages.Gateways.table.header.type": "Type",
"AdminPages.Gateways.table.header.gatewayType": "Gateway Type",
"AdminPages.Gateways.table.header.vhosts": "Virtual Host(s)",
"AdminPages.KeyManager.Delete.form.delete.confirmation.message": "Are you sure you want to delete this KeyManager ?",
diff --git a/portals/admin/src/main/webapp/site/public/locales/fr.json b/portals/admin/src/main/webapp/site/public/locales/fr.json
index d578c63c268..dea613a915a 100644
--- a/portals/admin/src/main/webapp/site/public/locales/fr.json
+++ b/portals/admin/src/main/webapp/site/public/locales/fr.json
@@ -79,6 +79,7 @@
"AdminPages.Gateways.table.header.description": "",
"AdminPages.Gateways.table.header.displayName": "",
"AdminPages.Gateways.table.header.gatewayType": "",
+ "AdminPages.Gateways.table.header.type": "",
"AdminPages.Gateways.table.header.vhosts": "",
"AdminPages.KeyManager.Delete.form.delete.confirmation.message": "",
"AdminPages.KeyManagers.Delete.form.delete.successful": "",
diff --git a/portals/admin/src/main/webapp/source/src/app/components/GatewayEnvironments/AddEditGWEnvironment.jsx b/portals/admin/src/main/webapp/source/src/app/components/GatewayEnvironments/AddEditGWEnvironment.jsx
index 82e410ee80b..ad48e2774b9 100644
--- a/portals/admin/src/main/webapp/source/src/app/components/GatewayEnvironments/AddEditGWEnvironment.jsx
+++ b/portals/admin/src/main/webapp/source/src/app/components/GatewayEnvironments/AddEditGWEnvironment.jsx
@@ -24,12 +24,16 @@ import { useAppContext } from 'AppComponents/Shared/AppContext';
import { FormattedMessage, useIntl } from 'react-intl';
import FormControl from '@material-ui/core/FormControl';
import { makeStyles } from '@material-ui/core/styles';
+import MenuItem from '@material-ui/core/MenuItem';
+import Select from '@material-ui/core/Select';
+import InputLabel from '@material-ui/core/InputLabel';
import FormDialogBase from 'AppComponents/AdminPages/Addons/FormDialogBase';
import Alert from 'AppComponents/Shared/Alert';
import Radio from '@material-ui/core/Radio';
import RadioGroup from '@material-ui/core/RadioGroup';
import Typography from '@material-ui/core/Typography';
import FormControlLabel from '@material-ui/core/FormControlLabel';
+import FormHelperText from '@material-ui/core/FormHelperText';
import FormLabel from '@material-ui/core/FormLabel';
import AddEditVhost from 'AppComponents/GatewayEnvironments/AddEditVhost';
@@ -94,6 +98,7 @@ function reducer(state, { field, value }) {
case 'displayName':
case 'gatewayType':
case 'description':
+ case 'type':
case 'vhosts':
return { ...state, [field]: value };
case 'editDetails':
@@ -117,45 +122,40 @@ function AddEditGWEnvironment(props) {
const defaultVhost = {
host: '', httpContext: '', httpsPort: 8243, httpPort: 8280, wssPort: 8099, wsPort: 9099, isNew: true,
};
+ const { settings } = useAppContext();
+ const { gatewayTypes } = settings;
const [initialState, setInitialState] = useState({
displayName: '',
description: '',
+ gatewayType: gatewayTypes && gatewayTypes.length > 1 ? 'Regular' : gatewayTypes[0],
+ type: 'hybrid',
vhosts: [defaultVhost],
});
const [editMode, setIsEditMode] = useState(false);
const [state, dispatch] = useReducer(reducer, initialState);
const {
- name, displayName, description, vhosts,
+ name, displayName, description, vhosts, type, gatewayType,
} = state;
const onChange = (e) => {
dispatch({ field: e.target.name, value: e.target.value });
};
- const [selectedGatewayType, setValue] = React.useState('');
- const { settings } = useAppContext();
- const { gatewayTypes } = settings;
- const getBorderColor = (gatewayType) => {
- return selectedGatewayType === gatewayType
+ const getBorderColor = (gatewayTypeNew) => {
+ return gatewayType === gatewayTypeNew
? '2px solid #1976D2'
: '2px solid gray';
};
- const handleChange = (event) => {
- setValue(event.target.value);
- };
-
useEffect(() => {
setInitialState({
displayName: '',
description: '',
- selectedGatewayType: '',
+ gatewayType: '',
+ type: 'hybrid',
vhosts: [defaultVhost],
});
- if (gatewayTypes.length === 1) {
- setValue(gatewayTypes[0]);
- }
}, []);
const handleHostValidation = (vhost) => {
@@ -309,7 +309,7 @@ function AddEditGWEnvironment(props) {
return false;
}
const vhostDto = [];
- if (selectedGatewayType === 'Regular') {
+ if (gatewayType === 'Regular') {
vhosts.forEach((vhost) => {
vhostDto.push({
host: vhost.host,
@@ -320,7 +320,7 @@ function AddEditGWEnvironment(props) {
wssPort: vhost.wssPort,
});
});
- } else if (selectedGatewayType === 'APK') {
+ } else if (gatewayType === 'APK') {
vhosts.forEach((vhost) => {
vhostDto.push({
host: vhost.host,
@@ -336,12 +336,12 @@ function AddEditGWEnvironment(props) {
if (dataRow) {
// assign the update promise to the promiseAPICall
promiseAPICall = restApi.updateGatewayEnvironment(
- dataRow.id, name.trim(), displayName, description, selectedGatewayType, vhostDto,
+ dataRow.id, name.trim(), displayName, type, description, gatewayType, vhostDto,
);
} else {
// assign the create promise to the promiseAPICall
- promiseAPICall = restApi.addGatewayEnvironment(name.trim(), displayName, description,
- selectedGatewayType, vhostDto);
+ promiseAPICall = restApi.addGatewayEnvironment(name.trim(), displayName, type, description,
+ gatewayType, vhostDto);
}
return promiseAPICall.then(() => {
@@ -377,7 +377,9 @@ function AddEditGWEnvironment(props) {
name: originalName,
displayName: originalDisplayName,
description: originalDescription,
+ type: originalType,
vhosts: originalVhosts,
+ gatewayType: originalGatewayType,
} = dataRow;
setIsEditMode(true);
dispatch({
@@ -385,6 +387,8 @@ function AddEditGWEnvironment(props) {
value: {
name: originalName,
displayName: originalDisplayName,
+ type: originalType,
+ gatewayType: originalGatewayType,
description: originalDescription,
vhosts: originalVhosts,
},
@@ -475,14 +479,15 @@ function AddEditGWEnvironment(props) {
row
aria-label='gateway-type'
name='gateway-type'
- value={selectedGatewayType}
- onChange={handleChange}
+ value={gatewayType}
+ onChange={onChange}
>