Merge branch 'application-mgt-new' into 'application-mgt-new'

Fix device type loading issue for custom apps

See merge request entgra/carbon-device-mgt!248
feature/appm-store/pbac
Dharmakeerthi Lasantha 5 years ago
commit 8ce3318645

@ -67,28 +67,7 @@
"text": "The final state of an application, where no transition of states will be allowed after this." "text": "The final state of an application, where no transition of states will be allowed after this."
} }
}, },
"installationTypes": { "deviceTypes": {
"ENTERPRISE": { "mobileTypes": ["android", "ios"]
"deviceTypes": [
"android",
"ios"
]
},
"PUBLIC": {
"deviceTypes": [
"android",
"ios"
]
},
"WEB_CLIP": {
"deviceTypes": [
"android",
"ios"
]
},
"CUSTOM": {
"deviceTypes": [
]
}
} }
} }

@ -414,6 +414,7 @@ class AppDetailsDrawer extends React.Component {
} }
}; };
render() { render() {
const config = this.props.context; const config = this.props.context;
const {app, visible, onClose} = this.props; const {app, visible, onClose} = this.props;
@ -459,12 +460,11 @@ class AppDetailsDrawer extends React.Component {
<div> <div>
<Drawer <Drawer
placement="right" placement="right"
width={this.state.drawerWidth} width={640}
closable={false} closable={false}
onClose={onClose} onClose={onClose}
visible={visible} visible={visible}
> >
<Spin spinning={loading} delay={500}> <Spin spinning={loading} delay={500}>
<div style={{textAlign: "center"}}> <div style={{textAlign: "center"}}>
{avatar} {avatar}
@ -555,7 +555,6 @@ class AppDetailsDrawer extends React.Component {
)} )}
<Divider dashed={true}/> <Divider dashed={true}/>
<Text strong={true}>Categories </Text> <Text strong={true}>Categories </Text>
{!isCategoriesEditEnabled && (<Text {!isCategoriesEditEnabled && (<Text
style={{color: config.theme.primaryColor, cursor: "pointer"}} style={{color: config.theme.primaryColor, cursor: "pointer"}}
@ -600,8 +599,8 @@ class AppDetailsDrawer extends React.Component {
}</span> }</span>
)} )}
<Divider dashed={true}/>
<Divider dashed={true}/>
<Text strong={true}>Tags </Text> <Text strong={true}>Tags </Text>
{!isTagsEditEnabled && (<Text {!isTagsEditEnabled && (<Text
style={{color: config.theme.primaryColor, cursor: "pointer"}} style={{color: config.theme.primaryColor, cursor: "pointer"}}

@ -148,21 +148,31 @@ class NewAppDetailsForm extends React.Component {
getDeviceTypes = () => { getDeviceTypes = () => {
const config = this.props.context; const config = this.props.context;
const {formConfig} = this.props; const {formConfig} = this.props;
console.log("test"); const {installationType} = formConfig;
axios.get( axios.get(
window.location.origin + config.serverConfig.invoker.uri + config.serverConfig.invoker.deviceMgt + "/device-types" window.location.origin + config.serverConfig.invoker.uri + config.serverConfig.invoker.deviceMgt + "/device-types"
).then(res => { ).then(res => {
if (res.status === 200) { if (res.status === 200) {
const allDeviceTypes = JSON.parse(res.data.data); const allDeviceTypes = JSON.parse(res.data.data);
const whitelistedDeviceTypes = config.installationTypes[formConfig.installationType].deviceTypes; const mobileDeviceTypes = config.deviceTypes.mobileTypes;
const allowedDeviceTypes = []; const allowedDeviceTypes = [];
// exclude mobile device types if installation type is custom
if(installationType==="CUSTOM"){
allDeviceTypes.forEach(deviceType=>{
if(!mobileDeviceTypes.includes(deviceType.name)){
allowedDeviceTypes.push(deviceType);
}
});
}else{
allDeviceTypes.forEach(deviceType=>{ allDeviceTypes.forEach(deviceType=>{
if(whitelistedDeviceTypes.includes(deviceType.name)){ if(mobileDeviceTypes.includes(deviceType.name)){
allowedDeviceTypes.push(deviceType); allowedDeviceTypes.push(deviceType);
} }
}); });
}
this.setState({ this.setState({
deviceTypes: allowedDeviceTypes, deviceTypes: allowedDeviceTypes,
loading: false, loading: false,

Loading…
Cancel
Save