mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
Fix android enterprise view crashing by permission rendering
This commit is contained in:
parent
4d491d1997
commit
7df02c5db5
@ -49,8 +49,8 @@ class Pages extends React.Component {
|
|||||||
homePageId: null,
|
homePageId: null,
|
||||||
};
|
};
|
||||||
this.hasPermissionToManage = isAuthorized(
|
this.hasPermissionToManage = isAuthorized(
|
||||||
this.props.config.user,
|
this.props.context.user,
|
||||||
'/device-mgt/enterprise/user/view',
|
'/permission/admin/device-mgt/enterprise/user/modify',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,7 +63,9 @@ class Pages extends React.Component {
|
|||||||
};
|
};
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
this.setHomePage();
|
if (this.hasPermissionToView) {
|
||||||
|
this.setHomePage();
|
||||||
|
}
|
||||||
this.fetch();
|
this.fetch();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -273,7 +275,7 @@ class Pages extends React.Component {
|
|||||||
return (
|
return (
|
||||||
<div className="layout-pages">
|
<div className="layout-pages">
|
||||||
<Title level={4}>Pages</Title>
|
<Title level={4}>Pages</Title>
|
||||||
<AddNewPage />
|
{this.hasPermissionToManage && <AddNewPage />}
|
||||||
<div style={{ backgroundColor: '#ffffff', borderRadius: 5 }}>
|
<div style={{ backgroundColor: '#ffffff', borderRadius: 5 }}>
|
||||||
<Table
|
<Table
|
||||||
columns={this.columns}
|
columns={this.columns}
|
||||||
|
|||||||
@ -295,8 +295,8 @@ class Cluster extends React.Component {
|
|||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<div className="product">
|
<div className="product">
|
||||||
{this.props.hasPermissionToManage && (
|
<div className="arrow">
|
||||||
<div className="arrow">
|
{this.props.hasPermissionToManage && (
|
||||||
<button
|
<button
|
||||||
disabled={index === 0}
|
disabled={index === 0}
|
||||||
className="btn"
|
className="btn"
|
||||||
@ -306,8 +306,8 @@ class Cluster extends React.Component {
|
|||||||
>
|
>
|
||||||
<Icon type="caret-left" theme="filled" />
|
<Icon type="caret-left" theme="filled" />
|
||||||
</button>
|
</button>
|
||||||
</div>
|
)}
|
||||||
)}
|
</div>
|
||||||
<div className="product-icon">
|
<div className="product-icon">
|
||||||
<img src={imageSrc} />
|
<img src={imageSrc} />
|
||||||
<Tooltip title={packageId}>
|
<Tooltip title={packageId}>
|
||||||
@ -348,9 +348,14 @@ class Cluster extends React.Component {
|
|||||||
<Spin spinning={loading}>
|
<Spin spinning={loading}>
|
||||||
<Row>
|
<Row>
|
||||||
<Col span={16}>
|
<Col span={16}>
|
||||||
<Title editable={{ onChange: this.handleNameChange }} level={4}>
|
{this.props.hasPermissionToManage && (
|
||||||
{name}
|
<Title editable={{ onChange: this.handleNameChange }} level={4}>
|
||||||
</Title>
|
{name}
|
||||||
|
</Title>
|
||||||
|
)}
|
||||||
|
{!this.props.hasPermissionToManage && (
|
||||||
|
<Title level={4}>{name}</Title>
|
||||||
|
)}
|
||||||
</Col>
|
</Col>
|
||||||
<Col span={8}>
|
<Col span={8}>
|
||||||
{!isTemporary && this.props.hasPermissionToManage && (
|
{!isTemporary && this.props.hasPermissionToManage && (
|
||||||
@ -413,51 +418,55 @@ class Cluster extends React.Component {
|
|||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
</div>
|
</div>
|
||||||
<Row>
|
{this.props.hasPermissionToManage && (
|
||||||
<Col>
|
<Row>
|
||||||
{isTemporary && (
|
<Col>
|
||||||
<div>
|
{isTemporary && (
|
||||||
<Button onClick={this.cancelAddingNewCluster}>Cancel</Button>
|
<div>
|
||||||
<Divider type="vertical" />
|
<Button onClick={this.cancelAddingNewCluster}>
|
||||||
<Tooltip
|
Cancel
|
||||||
title={
|
</Button>
|
||||||
products.length === 0
|
<Divider type="vertical" />
|
||||||
? 'You must add applications to the cluster before saving'
|
<Tooltip
|
||||||
: ''
|
title={
|
||||||
}
|
products.length === 0
|
||||||
>
|
? 'You must add applications to the cluster before saving'
|
||||||
|
: ''
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<Button
|
||||||
|
disabled={products.length === 0}
|
||||||
|
onClick={this.saveNewCluster}
|
||||||
|
htmlType="button"
|
||||||
|
type="primary"
|
||||||
|
>
|
||||||
|
Save
|
||||||
|
</Button>
|
||||||
|
</Tooltip>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
{!isTemporary && (
|
||||||
|
<div>
|
||||||
<Button
|
<Button
|
||||||
disabled={products.length === 0}
|
onClick={this.resetChanges}
|
||||||
onClick={this.saveNewCluster}
|
disabled={!this.state.isSaveable}
|
||||||
|
>
|
||||||
|
Cancel
|
||||||
|
</Button>
|
||||||
|
<Divider type="vertical" />
|
||||||
|
<Button
|
||||||
|
onClick={this.updateCluster}
|
||||||
htmlType="button"
|
htmlType="button"
|
||||||
type="primary"
|
type="primary"
|
||||||
|
disabled={!this.state.isSaveable}
|
||||||
>
|
>
|
||||||
Save
|
Save
|
||||||
</Button>
|
</Button>
|
||||||
</Tooltip>
|
</div>
|
||||||
</div>
|
)}
|
||||||
)}
|
</Col>
|
||||||
{!isTemporary && (
|
</Row>
|
||||||
<div>
|
)}
|
||||||
<Button
|
|
||||||
onClick={this.resetChanges}
|
|
||||||
disabled={!this.state.isSaveable}
|
|
||||||
>
|
|
||||||
Cancel
|
|
||||||
</Button>
|
|
||||||
<Divider type="vertical" />
|
|
||||||
<Button
|
|
||||||
onClick={this.updateCluster}
|
|
||||||
htmlType="button"
|
|
||||||
type="primary"
|
|
||||||
disabled={!this.state.isSaveable}
|
|
||||||
>
|
|
||||||
Save
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</Col>
|
|
||||||
</Row>
|
|
||||||
</Spin>
|
</Spin>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@ -63,15 +63,22 @@ class Page extends React.Component {
|
|||||||
links: [],
|
links: [],
|
||||||
};
|
};
|
||||||
this.hasPermissionToManage = isAuthorized(
|
this.hasPermissionToManage = isAuthorized(
|
||||||
this.props.config.user,
|
this.props.context.user,
|
||||||
'/device-mgt/enterprise/user/view',
|
'/permission/admin/device-mgt/enterprise/user/modify',
|
||||||
|
);
|
||||||
|
|
||||||
|
this.hasPermissionToView = isAuthorized(
|
||||||
|
this.props.context.user,
|
||||||
|
'/permission/admin/device-mgt/enterprise/user/view',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
this.fetchClusters();
|
if (this.hasPermissionToView) {
|
||||||
this.fetchApplications();
|
this.fetchClusters();
|
||||||
this.fetchPages();
|
this.fetchApplications();
|
||||||
|
this.fetchPages();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
removeLoadedCluster = clusterId => {
|
removeLoadedCluster = clusterId => {
|
||||||
@ -344,12 +351,17 @@ class Page extends React.Component {
|
|||||||
>
|
>
|
||||||
<Row>
|
<Row>
|
||||||
<Col md={8} sm={18} xs={24}>
|
<Col md={8} sm={18} xs={24}>
|
||||||
<Title
|
{this.hasPermissionToManage && (
|
||||||
editable={{ onChange: this.updatePageName }}
|
<Title
|
||||||
level={2}
|
editable={{ onChange: this.updatePageName }}
|
||||||
>
|
level={2}
|
||||||
{pageName}
|
>
|
||||||
</Title>
|
{pageName}
|
||||||
|
</Title>
|
||||||
|
)}
|
||||||
|
{!this.hasPermissionToManage && (
|
||||||
|
<Title level={2}>{pageName}</Title>
|
||||||
|
)}
|
||||||
</Col>
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
<Row>
|
<Row>
|
||||||
@ -412,6 +424,7 @@ class Page extends React.Component {
|
|||||||
name: 'New Cluster',
|
name: 'New Cluster',
|
||||||
products: [],
|
products: [],
|
||||||
}}
|
}}
|
||||||
|
hasPermissionToManage={true}
|
||||||
orderInPage={clusters.length}
|
orderInPage={clusters.length}
|
||||||
isTemporary={true}
|
isTemporary={true}
|
||||||
pageId={this.pageId}
|
pageId={this.pageId}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user