aboutsummaryrefslogtreecommitdiffstats
path: root/ui-react/src
diff options
context:
space:
mode:
authorsebdet <sebastien.determe@intl.att.com>2020-02-23 09:31:04 -0800
committersebdet <sebastien.determe@intl.att.com>2020-02-25 06:49:46 -0800
commit7658007d67c5c2bc1d81bff4bf972b315cb5bea6 (patch)
treee44324c6dd8a1d653a59d3458a5c38116f25b86a /ui-react/src
parentaa486be66b1c29ad2e953cb44d105ca1bde40b1c (diff)
Simplify the user management
Simplify the user management and fix a bug in the server, crashing when no user are logged and an operation is requested, and also previous user still stored in the securitycontext when admin is logged (due to static variable) Issue-ID: CLAMP-651 Change-Id: I57523bc2c3afaf5ca5a3acf5c59823df06fd4cd9 Signed-off-by: sebdet <sebastien.determe@intl.att.com>
Diffstat (limited to 'ui-react/src')
-rw-r--r--ui-react/src/api/UserService.js6
-rw-r--r--ui-react/src/components/dialogs/UserInfoModal.js66
-rw-r--r--ui-react/src/components/dialogs/UserInfoModal.test.js18
-rw-r--r--ui-react/src/components/dialogs/__snapshots__/UserInfoModal.test.js.snap24
4 files changed, 23 insertions, 91 deletions
diff --git a/ui-react/src/api/UserService.js b/ui-react/src/api/UserService.js
index 8da6e3a7..5703fdcc 100644
--- a/ui-react/src/api/UserService.js
+++ b/ui-react/src/api/UserService.js
@@ -74,7 +74,7 @@ export default class UserService {
}
static getUserInfo() {
- return fetch('/restservices/clds/v1/clds/cldsInfo', {
+ return fetch('/restservices/clds/v2/clampInformation', {
method: 'GET',
credentials: 'same-origin'
})
@@ -82,6 +82,8 @@ export default class UserService {
console.debug("getUserInfo response received, status code:", response.status);
if (response.ok) {
return response.json();
+ } else {
+ return {}
}
})
.then(function (data) {
@@ -91,7 +93,7 @@ export default class UserService {
.catch(function(error) {
console.warn("getUserInfo error received, user set to: ",UserService.notLoggedUserName);
console.error("getUserInfo error:",error);
- return;
+ return {};
});
}
}
diff --git a/ui-react/src/components/dialogs/UserInfoModal.js b/ui-react/src/components/dialogs/UserInfoModal.js
index 1273d87c..4b779dec 100644
--- a/ui-react/src/components/dialogs/UserInfoModal.js
+++ b/ui-react/src/components/dialogs/UserInfoModal.js
@@ -39,12 +39,7 @@ export default class UserInfoModal extends React.Component {
super(props, context);
this.handleClose = this.handleClose.bind(this);
- this.renderReadTemplatePermission = this.renderReadTemplatePermission.bind(this);
- this.renderReadModelPermission = this.renderReadModelPermission.bind(this);
- this.renderReadToscaPermission = this.renderReadToscaPermission.bind(this);
- this.renderUpdateTemplatePermission = this.renderUpdateTemplatePermission.bind(this);
- this.renderUpdateModelPermission = this.renderUpdateModelPermission.bind(this);
- this.renderUpdateToscaPermission = this.renderUpdateToscaPermission.bind(this);
+ this.renderPermissions = this.renderPermissions.bind(this);
this.renderUserName = this.renderUserName.bind(this);
this.state = {
show: true,
@@ -60,48 +55,16 @@ export default class UserInfoModal extends React.Component {
handleClose() {
this.props.history.push('/');
}
- renderReadTemplatePermission() {
- if (this.state.userInfo["permissionReadTemplate"]) {
- return <Form.Control plaintext readOnly defaultValue="Read Template" />
- } else {
- return;
- }
- }
- renderReadModelPermission() {
- if (this.state.userInfo["permissionReadCl"]) {
- return <Form.Control plaintext readOnly defaultValue="Read Model" />
- } else {
- return;
- }
- }
- renderReadToscaPermission() {
- if (this.state.userInfo["permissionReadTosca"]) {
- return <Form.Control plaintext readOnly defaultValue="Read Tosca" />
- } else {
- return;
- }
- }
- renderUpdateTemplatePermission() {
- if (this.state.userInfo["permissionUpdateTemplate"]) {
- return <Form.Control plaintext readOnly defaultValue="Edit Template" />
- } else {
- return;
- }
- }
- renderUpdateModelPermission() {
- if (this.state.userInfo["permissionUpdateCl"]) {
- return <Form.Control plaintext readOnly defaultValue="Edit Model" />
- } else {
- return;
- }
- }
- renderUpdateToscaPermission() {
- if (this.state.userInfo["permissionUpdateTosca"]) {
- return <Form.Control plaintext readOnly defaultValue="Edit Tosca" />
- } else {
- return;
- }
- }
+ renderPermissions() {
+ if (this.state.userInfo["allPermissions"]) {
+ var listOfPermissions = this.state.userInfo["allPermissions"].map(function(perm) {
+ return <Form.Control plaintext readOnly defaultValue={perm} />;
+ })
+ return listOfPermissions;
+ } else {
+ return;
+ }
+ }
renderUserName() {
if (this.state.userInfo["userName"]) {
return <Form.Control plaintext readOnly defaultValue={this.state.userInfo["userName"]} />
@@ -134,12 +97,7 @@ export default class UserInfoModal extends React.Component {
<Form.Group as={Row} controlId="userPermissions">
<Form.Label column sm="3">User Permissions:</Form.Label>
<Col>
- {this.renderReadTemplatePermission()}
- {this.renderReadModelPermission()}
- {this.renderReadToscaPermission()}
- {this.renderUpdateTemplatePermission()}
- {this.renderUpdateModelPermission()}
- {this.renderUpdateToscaPermission()}
+ {this.renderPermissions()}
</Col>
</Form.Group>
</Modal.Body>
diff --git a/ui-react/src/components/dialogs/UserInfoModal.test.js b/ui-react/src/components/dialogs/UserInfoModal.test.js
index b5a2b272..f5ed0ae1 100644
--- a/ui-react/src/components/dialogs/UserInfoModal.test.js
+++ b/ui-react/src/components/dialogs/UserInfoModal.test.js
@@ -46,12 +46,7 @@ describe('Verify UserInfoModal', () => {
component.setState({ userInfo: {
"userName": "test",
"cldsVersion": "1.0.0",
- "permissionReadCl": true,
- "permissionReadTemplate" : true,
- "permissionReadTosca" : true,
- "permissionUpdateTemplate" : true,
- "permissionUpdateCl" : true,
- "permissionUpdateTosca": true
+ "allPermissions": ["permission1","permission2"]
}});
expect(component).toMatchSnapshot();
});
@@ -69,18 +64,15 @@ describe('Verify UserInfoModal', () => {
component.setState({ userInfo: {
"userName": "test",
"cldsVersion": "1.0.0",
- "permissionReadCl": true,
- "permissionReadTemplate" : true,
- "permissionReadTosca" : true
+ "allPermissions": ["permission1","permission2"]
}});
- expect(component.find('FormControl').length).toEqual(5);
+ expect(component.find('FormControl').length).toEqual(4);
const forms = component.find('FormControl');
expect(forms.get(0).props.defaultValue).toEqual("test");
expect(forms.get(1).props.defaultValue).toEqual("1.0.0");
- expect(forms.get(2).props.defaultValue).toEqual("Read Template");
- expect(forms.get(3).props.defaultValue).toEqual("Read Model");
- expect(forms.get(4).props.defaultValue).toEqual("Read Tosca");
+ expect(forms.get(2).props.defaultValue).toEqual("permission1");
+ expect(forms.get(3).props.defaultValue).toEqual("permission2");
});
});
diff --git a/ui-react/src/components/dialogs/__snapshots__/UserInfoModal.test.js.snap b/ui-react/src/components/dialogs/__snapshots__/UserInfoModal.test.js.snap
index fdb24a43..bd05e863 100644
--- a/ui-react/src/components/dialogs/__snapshots__/UserInfoModal.test.js.snap
+++ b/ui-react/src/components/dialogs/__snapshots__/UserInfoModal.test.js.snap
@@ -90,32 +90,12 @@ exports[`Verify UserInfoModal Test the render method full permission 1`] = `
</FormLabel>
<Col>
<FormControl
- defaultValue="Read Template"
+ defaultValue="permission1"
plaintext={true}
readOnly={true}
/>
<FormControl
- defaultValue="Read Model"
- plaintext={true}
- readOnly={true}
- />
- <FormControl
- defaultValue="Read Tosca"
- plaintext={true}
- readOnly={true}
- />
- <FormControl
- defaultValue="Edit Template"
- plaintext={true}
- readOnly={true}
- />
- <FormControl
- defaultValue="Edit Model"
- plaintext={true}
- readOnly={true}
- />
- <FormControl
- defaultValue="Edit Tosca"
+ defaultValue="permission2"
plaintext={true}
readOnly={true}
/>