-
-
Notifications
You must be signed in to change notification settings - Fork 671
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(acls): add Cluster and TransactionalID (#1103)
close #1084
- Loading branch information
Showing
6 changed files
with
225 additions
and
3 deletions.
There are no files selected for viewing
96 changes: 96 additions & 0 deletions
96
client/src/containers/Acl/AclDetail/AclClusters/AclClusters.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
import React from 'react'; | ||
import Table from '../../../../components/Table/Table'; | ||
import { uriAclsByPrincipal } from '../../../../utils/endpoints'; | ||
import Root from "../../../../components/Root"; | ||
|
||
class AclClusters extends Root { | ||
state = { | ||
selectedCluster: this.props.clusterId, | ||
principalEncoded: this.props.principalEncoded, | ||
tableData: [], | ||
loading: true | ||
}; | ||
|
||
componentDidMount() { | ||
this.getAcls(); | ||
} | ||
|
||
async getAcls() { | ||
const { selectedCluster, principalEncoded } = this.state; | ||
|
||
const response = await this.getApi(uriAclsByPrincipal(selectedCluster, principalEncoded, 'CLUSTER')); | ||
if (response.data.acls) { | ||
const acls = response.data || []; | ||
this.handleAcls(acls); | ||
} else { | ||
this.setState({ tableData: [], loading: false }); | ||
} | ||
} | ||
|
||
handleAcls = data => { | ||
const tableData = data.acls.map(acl => { | ||
return { | ||
topic: acl.resource.name, | ||
host: acl.host, | ||
permission: acl.operation | ||
}; | ||
}); | ||
|
||
this.setState({ tableData, loading: false }); | ||
}; | ||
|
||
handlePermission = permission => { | ||
return ( | ||
<React.Fragment> | ||
<span className="badge badge-secondary">{permission.permissionType}</span>{' '} | ||
{permission.operation} | ||
</React.Fragment> | ||
); | ||
}; | ||
|
||
render() { | ||
const { loading } = this.state; | ||
return ( | ||
<Table | ||
loading={loading} | ||
history={this.props.history} | ||
columns={[ | ||
{ | ||
id: 'topic', | ||
accessor: 'topic', | ||
colName: 'Topic', | ||
type: 'text', | ||
sortable: true | ||
}, | ||
{ | ||
id: 'host', | ||
accessor: 'host', | ||
colName: 'Host', | ||
type: 'text', | ||
sortable: true | ||
}, | ||
{ | ||
id: 'permission', | ||
accessor: 'permission', | ||
colName: 'Permission', | ||
type: 'text', | ||
cell: obj => { | ||
if (obj.permission) { | ||
return <div>{this.handlePermission(obj.permission)}</div>; | ||
} | ||
} | ||
} | ||
]} | ||
data={this.state.tableData} | ||
updateData={data => { | ||
this.setState({ tableData: data }); | ||
}} | ||
noContent={ | ||
'No ACLS found, or the "authorizer.class.name" parameter is not configured on the cluster.' | ||
} | ||
/> | ||
); | ||
} | ||
} | ||
|
||
export default AclClusters; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import AclClusters from './AclClusters'; | ||
|
||
export default AclClusters; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
96 changes: 96 additions & 0 deletions
96
client/src/containers/Acl/AclDetail/AclTransactionalIds/AclTransactionalIds.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
import React from 'react'; | ||
import Table from '../../../../components/Table/Table'; | ||
import { uriAclsByPrincipal } from '../../../../utils/endpoints'; | ||
import Root from "../../../../components/Root"; | ||
|
||
class AclTransactionalIds extends Root { | ||
state = { | ||
selectedCluster: this.props.clusterId, | ||
principalEncoded: this.props.principalEncoded, | ||
tableData: [], | ||
loading: true | ||
}; | ||
|
||
componentDidMount() { | ||
this.getAcls(); | ||
} | ||
|
||
async getAcls() { | ||
const { selectedCluster, principalEncoded } = this.state; | ||
|
||
const response = await this.getApi(uriAclsByPrincipal(selectedCluster, principalEncoded, 'TRANSACTIONAL_ID')); | ||
if (response.data.acls) { | ||
const acls = response.data || []; | ||
this.handleAcls(acls); | ||
} else { | ||
this.setState({ tableData: [], loading: false }); | ||
} | ||
} | ||
|
||
handleAcls = data => { | ||
const tableData = data.acls.map(acl => { | ||
return { | ||
topic: acl.resource.name, | ||
host: acl.host, | ||
permission: acl.operation | ||
}; | ||
}); | ||
|
||
this.setState({ tableData, loading: false }); | ||
}; | ||
|
||
handlePermission = permission => { | ||
return ( | ||
<React.Fragment> | ||
<span className="badge badge-secondary">{permission.permissionType}</span>{' '} | ||
{permission.operation} | ||
</React.Fragment> | ||
); | ||
}; | ||
|
||
render() { | ||
const { loading } = this.state; | ||
return ( | ||
<Table | ||
loading={loading} | ||
history={this.props.history} | ||
columns={[ | ||
{ | ||
id: 'topic', | ||
accessor: 'topic', | ||
colName: 'Topic', | ||
type: 'text', | ||
sortable: true | ||
}, | ||
{ | ||
id: 'host', | ||
accessor: 'host', | ||
colName: 'Host', | ||
type: 'text', | ||
sortable: true | ||
}, | ||
{ | ||
id: 'permission', | ||
accessor: 'permission', | ||
colName: 'Permission', | ||
type: 'text', | ||
cell: obj => { | ||
if (obj.permission) { | ||
return <div>{this.handlePermission(obj.permission)}</div>; | ||
} | ||
} | ||
} | ||
]} | ||
data={this.state.tableData} | ||
updateData={data => { | ||
this.setState({ tableData: data }); | ||
}} | ||
noContent={ | ||
'No ACLS found, or the "authorizer.class.name" parameter is not configured on the cluster.' | ||
} | ||
/> | ||
); | ||
} | ||
} | ||
|
||
export default AclTransactionalIds; |
3 changes: 3 additions & 0 deletions
3
client/src/containers/Acl/AclDetail/AclTransactionalIds/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import AclTransactionalIds from './AclTransactionalIds'; | ||
|
||
export default AclTransactionalIds; |