Merge "NOTICKET: Refactor with sessions. Now holds auth on server" into projects
diff --git a/skyquake/framework/core/modules/api/projectManagementAPI.js b/skyquake/framework/core/modules/api/projectManagementAPI.js
index 8eace6b..5ba3659 100644
--- a/skyquake/framework/core/modules/api/projectManagementAPI.js
+++ b/skyquake/framework/core/modules/api/projectManagementAPI.js
@@ -62,6 +62,7 @@
});
});
};
+
ProjectManagement.create = function(req) {
var self = this;
var api_server = req.query['api_server'];
@@ -175,4 +176,87 @@
});
})
}
+
+
+ProjectManagement.getPlatform = function(req) {
+ var self = this;
+ var api_server = req.query['api_server'];
+
+ return new Promise(function(resolve, reject) {
+ Promise.all([
+ rp({
+ uri: utils.confdPort(api_server) + '/api/operational/rbac-platform-config',
+ method: 'GET',
+ headers: _.extend({}, constants.HTTP_HEADERS.accept.data, {
+ 'Authorization': req.get('Authorization')
+ }),
+ forever: constants.FOREVER_ON,
+ rejectUnauthorized: false,
+ resolveWithFullResponse: true
+ })
+ ]).then(function(result) {
+ var response = {};
+ response['data'] = {};
+ if (result[0].body) {
+ response['data']['platform'] = JSON.parse(result[0].body)['rw-rbac-platform:rbac-platform-config'];
+ }
+ response.statusCode = constants.HTTP_RESPONSE_CODES.SUCCESS.OK
+
+ resolve(response);
+ }).catch(function(error) {
+ var response = {};
+ console.log('Problem with ProjectManagement.getPlatform', error);
+ response.statusCode = error.statusCode || 500;
+ response.errorMessage = {
+ error: 'Failed to get ProjectManagement.getPlatform' + error
+ };
+ reject(response);
+ });
+ });
+};
+
+ProjectManagement.updatePlatform = function(req) {
+ var self = this;
+ var api_server = req.query['api_server'];
+ var bodyData = req.body;
+ data = bodyData;
+ var updateTasks = [];
+
+ var updateUser = rp({
+ uri: utils.confdPort(api_server) + '/api/config/rbac-platform-config',
+ method: 'PUT',
+ headers: _.extend({}, constants.HTTP_HEADERS.accept.data, {
+ 'Authorization': req.get('Authorization')
+ }),
+ forever: constants.FOREVER_ON,
+ json: data,
+ rejectUnauthorized: false,
+ resolveWithFullResponse: true
+ });
+ updateTasks.push(updateUser)
+ return new Promise(function(resolve, reject) {
+ Promise.all([
+ updateTasks
+ ]).then(function(result) {
+ var response = {};
+ response['data'] = {};
+ if (result[0].body) {
+ response['data'] = result[0].body;
+ }
+ response.statusCode = constants.HTTP_RESPONSE_CODES.SUCCESS.OK
+
+ resolve(response);
+ }).catch(function(error) {
+ var response = {};
+ console.log('Problem with ProjectManagement.updatePlatform', error);
+ response.statusCode = error.statusCode || 500;
+ response.errorMessage = {
+ error: 'Failed to passwordChange user' + error
+ };
+ reject(response);
+ });
+ });
+};
+
+
module.exports = ProjectManagement;
diff --git a/skyquake/framework/core/modules/routes/projectManagement.js b/skyquake/framework/core/modules/routes/projectManagement.js
index a8f9a4d..ef52ba3 100644
--- a/skyquake/framework/core/modules/routes/projectManagement.js
+++ b/skyquake/framework/core/modules/routes/projectManagement.js
@@ -65,6 +65,21 @@
});
});
+Router.put('/platform', cors(), function(req, res) {
+ ProjectManagementAPI.updatePlatform(req).then(function(response) {
+ utils.sendSuccessResponse(response, res);
+ }, function(error) {
+ utils.sendErrorResponse(error, res);
+ });
+});
+
+Router.get('/platform', cors(), function(req, res) {
+ ProjectManagementAPI.getPlatform(req).then(function(response) {
+ utils.sendSuccessResponse(response, res);
+ }, function(error) {
+ utils.sendErrorResponse(error, res);
+ });
+});
module.exports = Router;
diff --git a/skyquake/framework/widgets/form_controls/input.jsx b/skyquake/framework/widgets/form_controls/input.jsx
index 370afcc..1563f29 100644
--- a/skyquake/framework/widgets/form_controls/input.jsx
+++ b/skyquake/framework/widgets/form_controls/input.jsx
@@ -17,7 +17,7 @@
*/
import './formControls.scss';
import SelectOption from 'widgets/form_controls/selectOption.jsx';
-
+import CircleSVG from '../../../node_modules/open-iconic/svg/media-record.svg'
import React, {Component} from 'react';
export default class Input extends Component {
@@ -71,6 +71,9 @@
} else {
displayedValue = value.toString();
}
+ if( props.readonly && props.type == "checkbox" && props.checked ) {
+ displayedValue = <img src={CircleSVG} />
+ }
let html = (
<label className={className} style={props.style}>
<span> { label } {isRequired}</span>
diff --git a/skyquake/framework/widgets/header/header.scss b/skyquake/framework/widgets/header/header.scss
index 5e1e717..6a2e56c 100644
--- a/skyquake/framework/widgets/header/header.scss
+++ b/skyquake/framework/widgets/header/header.scss
@@ -1,5 +1,5 @@
/*
- *
+ *
* Copyright 2016 RIFT.IO Inc
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -17,14 +17,20 @@
*/
header.header-app-component {
- padding: 20px 0px;
+ padding: 10px 0px;
+ display:-ms-flexbox;
display:flex;
- flex-direction:column;
+ -ms-flex-direction:column;
+ flex-direction:column;
.header-app-main {
+ display:-ms-flexbox;
display:flex;
- flex-direction:row;
- justify-content:space-between;
- align-items:center;
+ -ms-flex-direction:row;
+ flex-direction:row;
+ -ms-flex-pack:justify;
+ justify-content:space-between;
+ -ms-flex-align:center;
+ align-items:center;
}
h1 {
/*background: url('../../style/img/header-logo.png') no-repeat;*/
@@ -39,15 +45,19 @@
font-size: 1.625rem;
font-weight: 400;
position:relative;
- flex: 1 0 auto;
+ -ms-flex: 1 0 auto;
+ flex: 1 0 auto;
}
ul {
+ display:-ms-flexbox;
display:flex;
}
li {
+ display:-ms-flexbox;
display:flex;
- flex:1 1 auto;
+ -ms-flex:1 1 auto;
+ flex:1 1 auto;
border-right:1px solid #e5e5e5;
padding: 0 1rem;
&:last-child {
@@ -55,12 +65,13 @@
}
a {
cursor:pointer;
- // padding: 0.125rem;
- // border-bottom:1px solid black;
+ /* padding: 0.125rem;*/
+ /* border-bottom:1px solid black;*/
text-decoration:underline;
}
}
.header-app-nav {
+ display:-ms-flexbox;
display:flex;
margin-left: 0.25rem;
a,span {
@@ -81,8 +92,11 @@
}
}
nav {
+ display:-ms-flexbox;
display:flex;
- flex:0 1 auto;
- align-items:center;
+ -ms-flex:0 1 auto;
+ flex:0 1 auto;
+ -ms-flex-align:center;
+ align-items:center;
}
}
diff --git a/skyquake/framework/widgets/panel/panel.jsx b/skyquake/framework/widgets/panel/panel.jsx
index c078069..03877b0 100644
--- a/skyquake/framework/widgets/panel/panel.jsx
+++ b/skyquake/framework/widgets/panel/panel.jsx
@@ -60,17 +60,22 @@
export class PanelWrapper extends Component {
render() {
let wrapperClass = 'skyquakePanelWrapper';
- let {className, ...props} = this.props;
+ let {className, column, style, ...props} = this.props;
if(className) {
wrapperClass = `${wrapperClass} ${className}`
}
+ if(column) {
+ style.flexDirection = 'column';
+ }
return (
- <div className={wrapperClass} {...props}>
+ <div className={wrapperClass} style={style} {...props}>
{this.props.children}
</div>)
}
}
-
+PanelWrapper.defaultProps = {
+ style: {}
+}
export default Panel;
diff --git a/skyquake/framework/widgets/skyquake_container/skyquakeApp.scss b/skyquake/framework/widgets/skyquake_container/skyquakeApp.scss
index a01f154..77e72cf 100644
--- a/skyquake/framework/widgets/skyquake_container/skyquakeApp.scss
+++ b/skyquake/framework/widgets/skyquake_container/skyquakeApp.scss
@@ -1,4 +1,4 @@
-//import a reset
+/*import a reset*/
@import '../../style/_colors.scss';
html, body {
height:100%;
@@ -7,8 +7,10 @@
.skyquakeApp {
+ display: -ms-flexbox;
display: flex;
- flex-direction: column;
+ -ms-flex-direction: column;
+ flex-direction: column;
height: 100%;
background: $gray-lightest;
h1 {
@@ -20,6 +22,7 @@
color: #fff!important
}
.skyquakeNav {
+ display: -ms-flexbox;
display: flex;
color:white;
background:black;
@@ -27,17 +30,22 @@
z-index: 10;
font-size:0.75rem;
.secondaryNav {
- flex: 1 1 auto;
+ -ms-flex: 1 1 auto;
+ flex: 1 1 auto;
+ display: -ms-flexbox;
display: flex;
- justify-content: flex-end;
+ -ms-flex-pack: end;
+ justify-content: flex-end;
}
.app {
position:relative;
h2 {
font-size:0.75rem;
border-right: 1px solid black;
+ display: -ms-flexbox;
display: flex;
- align-items: center;
+ -ms-flex-align: center;
+ align-items: center;
.oi {
padding-right: 0.5rem;
}
@@ -102,18 +110,19 @@
.titleBar {
padding: 1rem 0 0;
h1 {
- // background: url('../../style/img/header-logo.png') no-repeat;
+ /* background: url('../../style/img/header-logo.png') no-repeat;*/
background-size:contain;
height: 51px;
line-height: 51px;
margin-left: 20px;
- // padding-left: 100px;
+ /* padding-left: 100px;*/
left: 0;
font-size: 1.625rem;
font-weight: 400;
text-align:left;
position:relative;
- flex: 1 0 auto;
+ -ms-flex: 1 0 auto;
+ flex: 1 0 auto;
}
}
.corner-accent {
diff --git a/skyquake/plugins/launchpad/src/recordViewer/recordView.jsx b/skyquake/plugins/launchpad/src/recordViewer/recordView.jsx
index 224bad5..05c6e5e 100644
--- a/skyquake/plugins/launchpad/src/recordViewer/recordView.jsx
+++ b/skyquake/plugins/launchpad/src/recordViewer/recordView.jsx
@@ -1,6 +1,6 @@
/*
- *
+ *
* Copyright 2016 RIFT.IO Inc
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -89,7 +89,7 @@
let nav = <AppHeader nav={navItems} />
if (this.state.showRecordDetails) {
- recordDetails = <RecordDetails isLoading={this.state.detailLoading} data={this.state.rawData} />
+ recordDetails = <RecordDetails isLoading={this.state.detailLoading} data={this.state.rawData} />
}
html = (
<div className="app-body recordView">
diff --git a/skyquake/plugins/project_management/src/dashboard/dashboard.jsx b/skyquake/plugins/project_management/src/dashboard/dashboard.jsx
index 4cbb1ef..6b613cc 100644
--- a/skyquake/plugins/project_management/src/dashboard/dashboard.jsx
+++ b/skyquake/plugins/project_management/src/dashboard/dashboard.jsx
@@ -259,10 +259,10 @@
platformRoles.push(<div>{`${role}: ${u.platformRoles[role]}`}</div>)
}
return (
- <div ref={(el) => this[`project-ref-${k}`] = el} className={`tableRow tableRow--data ${((self.state.activeIndex == k) && self.state.projectOpen) ? 'tableRow--data-active' : ''}`} key={k}>
+ <div onClick={self.viewProject.bind(null, u, k)} ref={(el) => this[`project-ref-${k}`] = el} className={`tableRow tableRow--data ${((self.state.activeIndex == k) && self.state.projectOpen) ? 'tableRow--data-active' : ''}`} key={k}>
<div
className={`projectName projectName-header ${((self.state.activeIndex == k) && self.state.projectOpen) ? 'activeProject' : ''}`}
- onClick={self.viewProject.bind(null, u, k)}>
+ >
{u['name']}
</div>
<div>
@@ -310,9 +310,9 @@
<tbody>
{
state.projectUsers.map((u,i)=> {
- let userRoles = u.role.map((r) => {
+ let userRoles = u.role && u.role.map((r) => {
return r.role;
- })
+ }) || [];
return (
<tr key={i}>
{!state.isReadOnly ? <td><span
@@ -327,7 +327,7 @@
</td>
{
state.roles.map((r,j) => {
- return <td key={j}><Input readonly={state.isReadOnly} type="checkbox" onChange={self.toggleUserRoleInProject.bind(self, i, j)} value={(userRoles.indexOf(r) > -1)} checked={(userRoles.indexOf(r) > -1)} /></td>
+ return <td key={j}><Input readonly={state.isReadOnly} type="checkbox" onChange={self.toggleUserRoleInProject.bind(self, i, j)} checked={(userRoles.indexOf(r) > -1)} /></td>
})
}
</tr>
diff --git a/skyquake/plugins/project_management/src/dashboard/projectMgmtSource.js b/skyquake/plugins/project_management/src/dashboard/projectMgmtSource.js
index 72fc2d3..ce0c984 100644
--- a/skyquake/plugins/project_management/src/dashboard/projectMgmtSource.js
+++ b/skyquake/plugins/project_management/src/dashboard/projectMgmtSource.js
@@ -13,9 +13,6 @@
}
-let Projects = mockProjects();
-let Users = mockUsers();
-
module.exports = function(Alt) {
return {
@@ -23,9 +20,6 @@
getUsers: {
remote: function() {
return new Promise(function(resolve, reject) {
- // setTimeout(function() {
- // resolve(Users);
- // }, 1000);
$.ajax({
url: `/user?api_server=${API_SERVER}`,
type: 'GET',
@@ -49,9 +43,6 @@
getProjects: {
remote: function() {
return new Promise(function(resolve, reject) {
- // setTimeout(function() {
- // resolve(Projects);
- // }, 1000)
$.ajax({
url: `/project?api_server=${API_SERVER}`,
type: 'GET',
@@ -99,9 +90,6 @@
deleteProject: {
remote: function(state, project) {
return new Promise(function(resolve, reject) {
- // setTimeout(function() {
- // resolve(true);
- // }, 1000)
$.ajax({
url: `/project/${project['name']}?api_server=${API_SERVER}`,
type: 'DELETE',
@@ -126,9 +114,6 @@
remote: function(state, project) {
return new Promise(function(resolve, reject) {
- // setTimeout(function() {
- // resolve(true);
- // }, 1000)
$.ajax({
url: `/project?api_server=${API_SERVER}`,
type: 'POST',
@@ -166,61 +151,3 @@
}
}
-function mockProjects() {
- let data = [];
- let count = 10;
- for(let i = 0; i < 3; i++) {
- data.push({
- name: `Test Project ${i}`,
- description: 'Some description',
- roles: ['Some-Role', 'Some-Other-Role'],
- users: [
- {
- 'user-name': 'Some-User',
- 'user-domain': 'system',
- role: [
- {
- 'role': 'Some-Role',
- 'key-set' : 'some key'
- },
- {
- 'role': 'Some-Other-Role',
- 'key-set' : 'some key'
- }
- ]
- },
- {
- 'user-name': 'Some-User',
- 'user-domain': 'system',
- role: [
- {
- 'role': 'Some-Role',
- 'key-set' : 'some key'
- }
- ]
- }
- ]
- })
- }
- return data;
-}
-function mockUsers() {
- let data = [];
- let count = 10;
- for(let i = 0; i < 10; i++) {
- data.push({
- 'user-name': `Tester ${i}`,
- 'user-domain': 'Some Domain',
- platformRoles: {
- super_admin: true,
- platform_admin: false,
- platform_oper: false
- },
- disabled: false,
- projectRoles: [
- 'Project:Role'
- ]
- })
- }
- return data;
-}
diff --git a/skyquake/plugins/project_management/src/dashboard/projectMgmtStore.js b/skyquake/plugins/project_management/src/dashboard/projectMgmtStore.js
index d7d76b8..1cb2088 100644
--- a/skyquake/plugins/project_management/src/dashboard/projectMgmtStore.js
+++ b/skyquake/plugins/project_management/src/dashboard/projectMgmtStore.js
@@ -170,6 +170,7 @@
let selectedRole = self.roles[roleIndex];
let keys = ',';
if(checked) {
+ if(!projectUsers[userIndex].role) projectUsers[userIndex].role = [];
projectUsers[userIndex].role.push({
role: self.roles[roleIndex],
keys: keys
diff --git a/skyquake/plugins/user_management/src/dashboard/dashboard.jsx b/skyquake/plugins/user_management/src/dashboard/dashboard.jsx
index c86d6b1..0275831 100644
--- a/skyquake/plugins/user_management/src/dashboard/dashboard.jsx
+++ b/skyquake/plugins/user_management/src/dashboard/dashboard.jsx
@@ -18,15 +18,15 @@
import SelectOption from 'widgets/form_controls/selectOption.jsx';
import 'widgets/form_controls/formControls.scss';
import imgAdd from '../../node_modules/open-iconic/svg/plus.svg'
-import imgRemove from '../../node_modules/open-iconic/svg/trash.svg'
+import imgRemove from '../../node_modules/open-iconic/svg/trash.svg';
class UserManagementDashboard extends React.Component {
constructor(props) {
super(props);
this.Store = this.props.flux.stores.hasOwnProperty('UserManagementStore') ? this.props.flux.stores.UserManagementStore : this.props.flux.createStore(UserManagementStore);
- this.Store.getUsers();
- this.state = this.Store.getState();
- this.actions = this.state.actions;
+ this.state = this.Store.getState();
+ this.actions = this.state.actions;
+
}
componentDidUpdate() {
let self = this;
@@ -38,6 +38,7 @@
}
componentWillMount() {
this.Store.listen(this.updateState);
+ this.Store.getUsers();
}
componentWillUnmount() {
this.Store.unlisten(this.updateState);
@@ -213,84 +214,86 @@
}
html = (
- <PanelWrapper className={`row userManagement ${!this.state.userOpen ? 'userList-open' : ''}`} style={{'flexDirection': 'row'}} >
- <PanelWrapper ref={(div) => { this.UserList = div}} className={`column userList expanded ${this.state.userOpen ? 'collapsed ' : ' '} ${this.state.hideColumns ? 'hideColumns ' : ' '}`}>
- <Panel title="User List" style={{marginBottom: 0}} no-corners>
- <div className="tableRow tableRow--header">
- <div className="userName">
- Username
- </div>
- <div>
- Domain
- </div>
- </div>
- {state.users && state.users.map((u, k) => {
- let platformRoles = [];
- for(let role in u.platformRoles) {
- platformRoles.push(<div>{`${role}: ${u.platformRoles[role]}`}</div>)
- }
- return (
- <div ref={(el) => this[`user-ref-${k}`] = el} className={`tableRow tableRow--data ${((self.state.activeIndex == k) && self.state.userOpen) ? 'tableRow--data-active' : ''}`} key={k}>
- <div
- className={`userName userName-header ${((self.state.activeIndex == k) && self.state.userOpen) ? 'activeUser' : ''}`}
- onClick={self.viewUser.bind(null, u, k)}>
- {u['user-name']}
- </div>
- <div>
- {u['user-domain']}
- </div>
-
-
+ <PanelWrapper column>
+ <AppHeader nav={[{name: 'PLATFORM ROLE MANAGEMENT', onClick: this.context.router.push.bind(this, {pathname: '/platform'})}]}/>
+ <PanelWrapper className={`row userManagement ${!this.state.userOpen ? 'userList-open' : ''}`} style={{'flexDirection': 'row'}} >
+ <PanelWrapper ref={(div) => { this.UserList = div}} className={`column userList expanded ${this.state.userOpen ? 'collapsed ' : ' '} ${this.state.hideColumns ? 'hideColumns ' : ' '}`}>
+ <Panel title="User List" style={{marginBottom: 0}} no-corners>
+ <div className="tableRow tableRow--header">
+ <div className="userName">
+ Username
</div>
- )
- })}
- </Panel>
- <ButtonGroup className="buttonGroup" style={{margin: '0 0.5rem 0.5rem', background: '#ddd', paddingBottom: '0.5rem'}}>
- <Button label="Add User" onClick={this.addUser} />
- </ButtonGroup>
+ <div>
+ Domain
+ </div>
+ </div>
+ {state.users && state.users.map((u, k) => {
+ let platformRoles = [];
+ for(let role in u.platformRoles) {
+ platformRoles.push(<div>{`${role}: ${u.platformRoles[role]}`}</div>)
+ }
+ return (
+ <div ref={(el) => this[`user-ref-${k}`] = el} className={`tableRow tableRow--data ${((self.state.activeIndex == k) && self.state.userOpen) ? 'tableRow--data-active' : ''}`}
+ key={k}
+ onClick={self.viewUser.bind(null, u, k)}>
+ <div
+ className={`userName userName-header ${((self.state.activeIndex == k) && self.state.userOpen) ? 'activeUser' : ''}`}
+ >
+ {u['user-name']}
+ </div>
+ <div>
+ {u['user-domain']}
+ </div>
+
+
+ </div>
+ )
+ })}
+ </Panel>
+ <ButtonGroup className="buttonGroup" style={{margin: '0 0.5rem 0.5rem', background: '#ddd', paddingBottom: '0.5rem'}}>
+ <Button label="Add User" onClick={this.addUser} />
+ </ButtonGroup>
+ </PanelWrapper>
+ <PanelWrapper onKeyUp={this.evaluateSubmit}
+ className={`userAdmin column`}>
+ <Panel
+ title={state.isEdit ? state['user-name'] : 'Create User'}
+ style={{marginBottom: 0}}
+ hasCloseButton={this.closePanel}
+ no-corners>
+ <FormSection title="USER INFO">
+ {
+ this.state.isEdit ?
+ null
+ : <Input readonly={state.isReadOnly} label="Username" value={state['user-name']} onChange={this.updateInput.bind(null, 'user-name')} />
+ }
+ <Input readonly={true} label="Domain" value={state['user-domain']} onChange={this.updateInput.bind(null, 'user-domain')}></Input>
+
+ <Input type="radiogroup" readonly={state.isReadOnly} label="Disabled" value={state.disabled} options={[{value: true, label: 'YES'}, {value: false, label: 'NO'}]} onChange={this.disableChange} />
+ </FormSection>
+ <FormSection title="PLATFORM ROLES" style={{display:'none'}}>
+ <Input label="Super Admin" onChange={this.platformChange.bind(null, 'super_admin')} checked={state.platformRoles.super_admin} type="checkbox" />
+ <Input label="Platform Admin" onChange={this.platformChange.bind(null, 'platform_admin')} checked={state.platformRoles.platform_admin} type="checkbox" />
+ <Input label="Platform Oper" onChange={this.platformChange.bind(null, 'platform_oper')} checked={state.platformRoles.platform_oper} type="checkbox" />
+ </FormSection>
+ <FormSection title="PROJECT ROLES" style={{display:'none'}}>
+ <InputCollection
+ inital={true}
+ type='select'
+ readonly={state.isReadOnly}
+ options={state.projectRolesOptions}
+ collection={state.projectRoles}
+ onChange={this.updateProjectRole}
+ AddItemFn={this.addProjectRole}
+ RemoveItemFn={this.removeProjectRole}
+ />
+ </FormSection>
+ {passwordSectionHTML}
+
+ </Panel>
+ {formButtonsHTML}
+ </PanelWrapper>
</PanelWrapper>
- <PanelWrapper onKeyUp={this.evaluateSubmit}
- className={`userAdmin column`}>
- <Panel
- title={state.isEdit ? state['user-name'] : 'Create User'}
- style={{marginBottom: 0}}
- hasCloseButton={this.closePanel}
- no-corners>
- <FormSection title="USER INFO">
- {
- this.state.isEdit ?
- null
- : <Input readonly={state.isReadOnly} label="Username" value={state['user-name']} onChange={this.updateInput.bind(null, 'user-name')} />
- }
- <Input readonly={true} label="Domain" value={state['user-domain']} onChange={this.updateInput.bind(null, 'user-domain')}></Input>
-
- <Input type="radiogroup" readonly={state.isReadOnly} label="Disabled" value={state.disabled} options={[{value: true, label: 'YES'}, {value: false, label: 'NO'}]} onChange={this.disableChange} />
- </FormSection>
- <FormSection title="PLATFORM ROLES" style={{display:'none'}}>
- <Input label="Super Admin" onChange={this.platformChange.bind(null, 'super_admin')} checked={state.platformRoles.super_admin} type="checkbox" />
- <Input label="Platform Admin" onChange={this.platformChange.bind(null, 'platform_admin')} checked={state.platformRoles.platform_admin} type="checkbox" />
- <Input label="Platform Oper" onChange={this.platformChange.bind(null, 'platform_oper')} checked={state.platformRoles.platform_oper} type="checkbox" />
- </FormSection>
- <FormSection title="PROJECT ROLES" style={{display:'none'}}>
- <InputCollection
- inital={true}
- type='select'
- readonly={state.isReadOnly}
- options={state.projectRolesOptions}
- collection={state.projectRoles}
- onChange={this.updateProjectRole}
- AddItemFn={this.addProjectRole}
- RemoveItemFn={this.removeProjectRole}
- />
- </FormSection>
- {passwordSectionHTML}
-
- </Panel>
- {formButtonsHTML}
-
- </PanelWrapper>
-
-
</PanelWrapper>
);
return html;
diff --git a/skyquake/plugins/user_management/src/dashboard/userMgmtSource.js b/skyquake/plugins/user_management/src/dashboard/userMgmtSource.js
index 2f922a9..a5c6242 100644
--- a/skyquake/plugins/user_management/src/dashboard/userMgmtSource.js
+++ b/skyquake/plugins/user_management/src/dashboard/userMgmtSource.js
@@ -13,7 +13,6 @@
}
-let Users = mockUsers();
module.exports = function(Alt) {
@@ -21,9 +20,6 @@
getUsers: {
remote: function() {
return new Promise(function(resolve, reject) {
- // setTimeout(function() {
- // resolve(Users);
- // }, 1000)
$.ajax({
url: `/user?api_server=${API_SERVER}`,
type: 'GET',
@@ -34,6 +30,11 @@
}).fail(function(xhr){
//Authentication and the handling of fail states should be wrapped up into a connection class.
Utils.checkAuthentication(xhr.status);
+ let msg = xhr.responseText;
+ if(xhr.errorMessage) {
+ msg = xhr.errorMessage
+ }
+ reject(msg);
});
});
},
@@ -58,6 +59,11 @@
}).fail(function(xhr){
//Authentication and the handling of fail states should be wrapped up into a connection class.
Utils.checkAuthentication(xhr.status);
+ let msg = xhr.responseText;
+ if(xhr.errorMessage) {
+ msg = xhr.errorMessage
+ }
+ reject(msg);
});
});
},
@@ -71,9 +77,6 @@
deleteUser: {
remote: function(state, user) {
return new Promise(function(resolve, reject) {
- // setTimeout(function() {
- // resolve(true);
- // }, 1000)
$.ajax({
url: `/user/${user['user-name']}/${user['user-domain']}?api_server=${API_SERVER}`,
type: 'DELETE',
@@ -85,6 +88,11 @@
}).fail(function(xhr){
//Authentication and the handling of fail states should be wrapped up into a connection class.
Utils.checkAuthentication(xhr.status);
+ let msg = xhr.responseText;
+ if(xhr.errorMessage) {
+ msg = xhr.errorMessage
+ }
+ reject(msg);
});
});
},
@@ -99,9 +107,6 @@
remote: function(state, user) {
return new Promise(function(resolve, reject) {
- // setTimeout(function() {
- // resolve(true);
- // }, 1000)
$.ajax({
url: `/user?api_server=${API_SERVER}`,
type: 'POST',
@@ -113,6 +118,11 @@
}).fail(function(xhr){
//Authentication and the handling of fail states should be wrapped up into a connection class.
Utils.checkAuthentication(xhr.status);
+ let msg = xhr.responseText;
+ if(xhr.errorMessage) {
+ msg = xhr.errorMessage
+ }
+ reject(msg);
});
});
},
@@ -139,23 +149,3 @@
}
}
-function mockUsers() {
- let data = [];
- let count = 10;
- for(let i = 0; i < 10; i++) {
- data.push({
- username: `Tester ${i}`,
- domain: 'Some Domain',
- platformRoles: {
- super_admin: true,
- platform_admin: false,
- platform_oper: false
- },
- disabled: false,
- projectRoles: [
- 'Project:Role'
- ]
- })
- }
- return data;
-}
diff --git a/skyquake/plugins/user_management/src/platformRoleManagement/platformRoleManagement.jsx b/skyquake/plugins/user_management/src/platformRoleManagement/platformRoleManagement.jsx
index 49efb82..761ce0d 100644
--- a/skyquake/plugins/user_management/src/platformRoleManagement/platformRoleManagement.jsx
+++ b/skyquake/plugins/user_management/src/platformRoleManagement/platformRoleManagement.jsx
@@ -5,7 +5,7 @@
import React from 'react';
import ReactDOM from 'react-dom';
import AppHeader from 'widgets/header/header.jsx';
-import ProjectManagementStore from './platformRoleManagementStore.js';
+import PlatformRoleManagementStore from './platformRoleManagementStore.js';
import SkyquakeComponent from 'widgets/skyquake_container/skyquakeComponent.jsx';
import 'style/layout.scss';
import './platformRoleManagement.scss';
@@ -23,15 +23,14 @@
class PlatformRoleManagement extends React.Component {
constructor(props) {
super(props);
- this.Store = this.props.flux.stores.hasOwnProperty('ProjectManagementStore') ? this.props.flux.stores.ProjectManagementStore : this.props.flux.createStore(ProjectManagementStore);
- this.Store.getProjects();
- this.Store.getUsers();
+ this.Store = this.props.flux.stores.hasOwnProperty('PlatformRoleManagementStore') ? this.props.flux.stores.PlatformRoleManagementStore : this.props.flux.createStore(PlatformRoleManagementStore);
this.state = this.Store.getState();
this.actions = this.state.actions;
+ this.Store.getPlatform();
+ this.Store.getUsers();
}
componentDidUpdate() {
- let self = this;
- ReactDOM.findDOMNode(this.projectList).addEventListener('transitionend', this.onTransitionEnd, false);
+
}
componentWillMount() {
this.Store.listen(this.updateState);
@@ -86,65 +85,41 @@
'name': this.state['name']
});
}
- createProject = (e) => {
+ updatePlatform = (e) => {
let self = this;
e.preventDefault();
e.stopPropagation();
- let projectUsers = self.state.projectUsers;
- let selectedUsers = [];
- //Remove null values from role
- projectUsers.map((u) => {
- u.role && u.role.map((r,i) => {
- let role = {};
- //you may add a user without a role or a keys, but if one is present then the other must be as well.
- if(!r || ((r.role || r['keys']) && (!r.role || !r['keys']))) {
- projectUsers.splice(i, 1);
- } else {
- return u;
+ let platformUsers = self.state.platformUsers;
+ let cleanUsers = this.cleanUsers(platformUsers);
+
+
+ this.Store.updatePlatform({
+ 'user': platformUsers
}
- })
- })
- this.Store.createProject({
- 'name': self.state['name'],
- 'description': self.state.description,
- 'project-config' : {
- 'user': projectUsers
- }
- });
+ );
}
- updateProject = (e) => {
- let self = this;
- e.preventDefault();
- e.stopPropagation();
- let projectUsers = self.state.projectUsers;
-
+ cleanUsers(projectUsers) {
+ let cleanUsers = [];
//Remove null values from role
projectUsers.map((u) => {
- u.role && u.role.map((r,i) => {
- let role = {};
- //you may add a user without a role or a keys, but if one is present then the other must be as well.
- if(!r || ((r.role || r['keys']) && (!r.role || !r['keys']))) {
- projectUsers.splice(i, 1);
- } else {
- return u;
- }
- })
- })
-
- this.Store.updateProject(_.merge({
- 'name': self.state['name'],
- 'description': self.state.description,
- 'project-config' : {
- 'user': projectUsers
- }
- }));
+ let cleanRoles = [];
+ u.role && u.role.map((r,i) => {
+ let role = {};
+ if(r.role){
+ //removing key for rbac-platform
+ delete r.keys;
+ cleanRoles.push(r)
+ }
+ });
+ u.role = cleanRoles;
+ cleanUsers.push(u);
+ });
+ return cleanUsers;
}
evaluateSubmit = (e) => {
if (e.keyCode == 13) {
if (this.props.isEdit) {
- this.updateProject(e);
- } else {
- this.createProject(e);
+ this.updatePlatform(e);
}
e.preventDefault();
e.stopPropagation();
@@ -209,9 +184,9 @@
<Button label="EDIT" type="submit" onClick={this.editProject} />
</ButtonGroup>
);
- let projectUsers = [];
- self.state.projectUsers.map((u) => {
- projectUsers.push(u['user-name']);
+ let platformUsers = [];
+ self.state.platformUsers.map((u) => {
+ platformUsers.push(u['user-name']);
});
if(!this.state.isReadOnly) {
@@ -219,176 +194,103 @@
state.isEdit ?
(
<ButtonGroup className="buttonGroup">
- <Button label="Update" type="submit" onClick={this.updateProject} />
+ <Button label="Update" type="submit" onClick={this.updatePlatform} />
<Button label="Delete" onClick={this.deleteProject} />
<Button label="Cancel" onClick={this.cancelEditProject} />
</ButtonGroup>
)
: (
<ButtonGroup className="buttonGroup">
- <Button label="Create" type="submit" onClick={this.createProject} />
+ <Button label="Edit" type="submit" onClick={this.updatePlatform} />
</ButtonGroup>
)
)
}
html = (
- <PanelWrapper className={`row projectManagement ${false ? 'projectList-open' : ''}`} style={{'alignContent': 'center', 'flexDirection': 'row'}} >
- <PanelWrapper onKeyUp={this.evaluateSubmit}
- className={`ProjectAdmin column`}>
- <Panel
- title={state.isEdit ? state['name'] : 'Create Project'}
- style={{marginBottom: 0}}
- hasCloseButton={this.closePanel}
- no-corners>
- <FormSection title="USER ROLES">
+ <PanelWrapper column>
+ <AppHeader nav={[{name: 'USER MANAGEMENT', onClick: this.context.router.push.bind(this, {pathname: '/'})}]}/>
+ <PanelWrapper className={`row projectManagement ${false ? 'projectList-open' : ''}`} style={{'alignContent': 'center', 'flexDirection': 'row'}} >
+ <PanelWrapper onKeyUp={this.evaluateSubmit}
+ className={`ProjectAdmin column`}>
+ <Panel
+ title="Manage Roles"
+ style={{marginBottom: 0}}
+ no-corners>
+ <FormSection title="USER ROLES">
- <table>
- <thead>
- <tr>
- {!state.isReadOnly ? <td></td> : null}
- <td>User Name</td>
- {
- state.roles.map((r,i) => {
- return <td key={i}>{r}</td>
- })
- }
- </tr>
- </thead>
- <tbody>
- {
- state.projectUsers.map((u,i)=> {
- let userRoles = u.role.map((r) => {
- return r.role;
- })
- return (
- <tr key={i}>
- {!state.isReadOnly ? <td><span
- className="removeInput"
- onClick={self.removeUserFromProject.bind(self, u)}
- >
- <img src={imgRemove} />
-
- </span></td> : null}
- <td>
- {u['user-name']}
- </td>
+ <table>
+ <thead>
+ <tr>
+ {!state.isReadOnly ? <td></td> : null}
+ <td>User Name</td>
{
- state.roles.map((r,j) => {
- return <td key={j}><Input type="checkbox" onChange={self.toggleUserRoleInProject.bind(self, i, j)} checked={(userRoles.indexOf(r) > -1)} /></td>
+ state.roles.map((r,i) => {
+ return <td key={i}>{r}</td>
})
}
</tr>
- )
- })
- }
- </tbody>
- </table>
-
-
- { false ?
- <div>
- <div className="tableRow tableRow--header">
- <div className="projectName">
- User Name
- </div>
- <div>
- Role
- </div>
- </div>
- {
- state.projectUsers && state.projectUsers.map((u, k) => {
- return (
- <div ref={(el) => this[`project-ref-${k}`] = el} className={`tableRow tableRow--data projectUsers`} key={k}>
- <div className="userName" style={state.isReadOnly ? {paddingTop: '0.25rem'} : {} }>{u['user-name']}</div>
- <div>
- {
- u.role && u.role.map((r, l) => {
- return (
- <div key={l}>
- <div style={{display: 'flex'}} className="selectRole">
- <SelectOption
- readonly={state.isReadOnly}
- defaultValue={r.role}
- options={state.roles}
- onChange={self.updateUserRoleInProject.bind(self, k, l)}
- />
- {!state.isReadOnly ?
- <span
- className="removeInput"
- onClick={self.removeRoleFromUserInProject.bind(self, k, l)}
- >
- <img src={imgRemove} />
- Remove Role
- </span>
- : null
- }
-
- </div>
- </div>
- )
- })
- }
- {!state.isReadOnly ?
- <div className="buttonGroup">
- <span className="addInput addRole" onClick={self.addRoleToUserInProject.bind(self, k)}><img src={imgAdd} />
- Add Role
- </span>
- {
- (!(u.role && u.role.length)) ?
- <span
+ </thead>
+ <tbody>
+ {
+ state.platformUsers.map((u,i)=> {
+ let userRoles = u.role && u.role.map((r) => {
+ return r.role;
+ }) || [];
+ return (
+ <tr key={i}>
+ {!state.isReadOnly ? <td><span
className="removeInput"
- onClick={self.removeUserFromProject.bind(self, k)}
+ onClick={self.removeUserFromProject.bind(self, u)}
>
<img src={imgRemove} />
- Remove User
- </span> : null
+
+ </span></td> : null}
+ <td>
+ {u['user-name']}
+ </td>
+ {
+ state.roles.map((r,j) => {
+ return <td key={j}><Input readonly={state.isReadOnly} type="checkbox" onChange={self.toggleUserRoleInProject.bind(self, i, j)} checked={(userRoles.indexOf(r) > -1)} /></td>
+ })
+ }
+ </tr>
+ )
+ })
+ }
+ </tbody>
+ </table>
+ {
+ !state.isReadOnly ?
+ <div className="tableRow tableRow--header">
+ <div>
+ <div className="addUser">
+ <SelectOption
+ onChange={this.actions.handleSelectedUser}
+ defaultValue={state.selectedUser}
+ initial={true}
+ options={state.users && state.users.filter((u) => {
+ return platformUsers.indexOf(u['user-name']) == -1
+ }).map((u) => {
+ return {
+ label: u['user-name'],
+ value: u
}
- </div>
- : null
- }
+ })}
+ />
+ <span className="addInput" onClick={this.addUserToProject}><img src={imgAdd} />
+ Add User
+ </span>
</div>
</div>
- )
- })
+ </div> : null
}
- </div>
- : null
- }
- {
- !state.isReadOnly ?
- <div className="tableRow tableRow--header">
- <div>
- <div className="addUser">
- <SelectOption
- onChange={this.actions.handleSelectedUser}
- defaultValue={state.selectedUser}
- initial={true}
- options={state.users && state.users.filter((u) => {
- return projectUsers.indexOf(u['user-name']) == -1
- }).map((u) => {
- return {
- label: u['user-name'],
- value: u
- }
- })}
- />
- <span className="addInput" onClick={this.addUserToProject}><img src={imgAdd} />
- Add User
- </span>
- </div>
- </div>
- </div> : null
- }
- </FormSection>
-
- </Panel>
+ </FormSection>
+ </Panel>
{formButtonsHTML}
-
+ </PanelWrapper>
</PanelWrapper>
-
-
</PanelWrapper>
);
return html;
diff --git a/skyquake/plugins/user_management/src/platformRoleManagement/platformRoleManagementActions.js b/skyquake/plugins/user_management/src/platformRoleManagement/platformRoleManagementActions.js
index 5f2b1ea..6ef5720 100644
--- a/skyquake/plugins/user_management/src/platformRoleManagement/platformRoleManagementActions.js
+++ b/skyquake/plugins/user_management/src/platformRoleManagement/platformRoleManagementActions.js
@@ -16,7 +16,8 @@
'handleAddUser',
'handleRemoveUserFromProject',
'getProjectsSuccess',
- 'getUsersSuccess',
+ 'getPlatformSuccess',
+ 'getPlatformRoleUsersSuccess',
'getProjectsNotification',
'handleDisabledChange',
'handlePlatformRoleUpdate',
diff --git a/skyquake/plugins/user_management/src/platformRoleManagement/platformRoleManagementSource.js b/skyquake/plugins/user_management/src/platformRoleManagement/platformRoleManagementSource.js
index 72fc2d3..ad6e818 100644
--- a/skyquake/plugins/user_management/src/platformRoleManagement/platformRoleManagementSource.js
+++ b/skyquake/plugins/user_management/src/platformRoleManagement/platformRoleManagementSource.js
@@ -13,9 +13,6 @@
}
-let Projects = mockProjects();
-let Users = mockUsers();
-
module.exports = function(Alt) {
return {
@@ -23,9 +20,6 @@
getUsers: {
remote: function() {
return new Promise(function(resolve, reject) {
- // setTimeout(function() {
- // resolve(Users);
- // }, 1000);
$.ajax({
url: `/user?api_server=${API_SERVER}`,
type: 'GET',
@@ -36,47 +30,54 @@
}).fail(function(xhr){
//Authentication and the handling of fail states should be wrapped up into a connection class.
Utils.checkAuthentication(xhr.status);
+ let msg = xhr.responseText;
+ if(xhr.errorMessage) {
+ msg = xhr.errorMessage
+ }
+ reject(msg);
});
});
},
interceptResponse: interceptResponse({
'error': 'There was an error retrieving the resource orchestrator information.'
}),
- success: Alt.actions.global.getUsersSuccess,
+ success: Alt.actions.global.getPlatformRoleUsersSuccess,
loading: Alt.actions.global.showScreenLoader,
error: Alt.actions.global.showNotification
},
- getProjects: {
+ getPlatform: {
remote: function() {
return new Promise(function(resolve, reject) {
- // setTimeout(function() {
- // resolve(Projects);
- // }, 1000)
$.ajax({
- url: `/project?api_server=${API_SERVER}`,
+ url: `/platform?api_server=${API_SERVER}`,
type: 'GET',
beforeSend: Utils.addAuthorizationStub,
success: function(data, textStatus, jqXHR) {
- resolve(data.project);
+ resolve(data.platform);
}
}).fail(function(xhr){
//Authentication and the handling of fail states should be wrapped up into a connection class.
Utils.checkAuthentication(xhr.status);
+ let msg = xhr.responseText;
+ if(xhr.errorMessage) {
+ msg = xhr.errorMessage
+ }
+ reject(msg);
});
});
},
interceptResponse: interceptResponse({
'error': 'There was an error retrieving the resource orchestrator information.'
}),
- success: Alt.actions.global.getProjectsSuccess,
+ success: Alt.actions.global.getPlatformSuccess,
loading: Alt.actions.global.showScreenLoader,
error: Alt.actions.global.showNotification
},
- updateProject: {
+ updatePlatform: {
remote: function(state, project) {
return new Promise(function(resolve, reject) {
$.ajax({
- url: `/project?api_server=${API_SERVER}`,
+ url: `/platform?api_server=${API_SERVER}`,
type: 'PUT',
data: project,
beforeSend: Utils.addAuthorizationStub,
@@ -86,6 +87,11 @@
}).fail(function(xhr){
//Authentication and the handling of fail states should be wrapped up into a connection class.
Utils.checkAuthentication(xhr.status);
+ let msg = xhr.responseText;
+ if(xhr.errorMessage) {
+ msg = xhr.errorMessage
+ }
+ reject(msg);
});
});
},
@@ -99,9 +105,6 @@
deleteProject: {
remote: function(state, project) {
return new Promise(function(resolve, reject) {
- // setTimeout(function() {
- // resolve(true);
- // }, 1000)
$.ajax({
url: `/project/${project['name']}?api_server=${API_SERVER}`,
type: 'DELETE',
@@ -112,6 +115,11 @@
}).fail(function(xhr){
//Authentication and the handling of fail states should be wrapped up into a connection class.
Utils.checkAuthentication(xhr.status);
+ let msg = xhr.responseText;
+ if(xhr.errorMessage) {
+ msg = xhr.errorMessage
+ }
+ reject(msg);
});
});
},
@@ -126,9 +134,6 @@
remote: function(state, project) {
return new Promise(function(resolve, reject) {
- // setTimeout(function() {
- // resolve(true);
- // }, 1000)
$.ajax({
url: `/project?api_server=${API_SERVER}`,
type: 'POST',
@@ -140,6 +145,11 @@
}).fail(function(xhr){
//Authentication and the handling of fail states should be wrapped up into a connection class.
Utils.checkAuthentication(xhr.status);
+ let msg = xhr.responseText;
+ if(xhr.errorMessage) {
+ msg = xhr.errorMessage
+ }
+ reject(msg);
});
});
},
@@ -166,61 +176,3 @@
}
}
-function mockProjects() {
- let data = [];
- let count = 10;
- for(let i = 0; i < 3; i++) {
- data.push({
- name: `Test Project ${i}`,
- description: 'Some description',
- roles: ['Some-Role', 'Some-Other-Role'],
- users: [
- {
- 'user-name': 'Some-User',
- 'user-domain': 'system',
- role: [
- {
- 'role': 'Some-Role',
- 'key-set' : 'some key'
- },
- {
- 'role': 'Some-Other-Role',
- 'key-set' : 'some key'
- }
- ]
- },
- {
- 'user-name': 'Some-User',
- 'user-domain': 'system',
- role: [
- {
- 'role': 'Some-Role',
- 'key-set' : 'some key'
- }
- ]
- }
- ]
- })
- }
- return data;
-}
-function mockUsers() {
- let data = [];
- let count = 10;
- for(let i = 0; i < 10; i++) {
- data.push({
- 'user-name': `Tester ${i}`,
- 'user-domain': 'Some Domain',
- platformRoles: {
- super_admin: true,
- platform_admin: false,
- platform_oper: false
- },
- disabled: false,
- projectRoles: [
- 'Project:Role'
- ]
- })
- }
- return data;
-}
diff --git a/skyquake/plugins/user_management/src/platformRoleManagement/platformRoleManagementStore.js b/skyquake/plugins/user_management/src/platformRoleManagement/platformRoleManagementStore.js
index 87eeb61..38dd1ce 100644
--- a/skyquake/plugins/user_management/src/platformRoleManagement/platformRoleManagementStore.js
+++ b/skyquake/plugins/user_management/src/platformRoleManagement/platformRoleManagementStore.js
@@ -12,10 +12,10 @@
this.projects = [];
this['name'] = '';
this['description'] = 'Some Description';
- this.projectUsers = [];
+ this.platformUsers = [];
this.selectedUser = null;
this.selectedRole = null;
- this.roles = ['super_admin', 'operator_role'
+ this.roles = ['rw-rbac-platform:platform-admin', 'rw-rbac-platform:platform-oper', 'rw-rbac-platform:super-admin'
// 'some_other_role', 'yet_another_role', 'operator_role', 'some_other_role', 'yet_another_role'
];
this.users = [];
@@ -63,7 +63,7 @@
let ProjectUser = {
'name': project['name'],
'description': project['description'],
- 'projectUsers': project['project-config'] && project['project-config']['user'] || []
+ 'platformUsers': project['project-config'] && project['project-config']['user'] || []
}
let state = _.merge({
activeIndex: projectIndex,
@@ -136,7 +136,7 @@
projectOpen: true,
activeIndex: null,
isReadOnly: false,
- projectUsers: []
+ platformUsers: []
}
))
}
@@ -149,78 +149,93 @@
handleAddUser() {
let u = JSON.parse(this.selectedUser);
let r = this.selectedRole;
- let projectUsers = this.projectUsers;
+ let platformUsers = this.platformUsers;
+ let keys = ","
console.log('adding user')
- projectUsers.push({
+ platformUsers.push({
'user-name': u['user-name'],
'user-domain': u['user-domain'],
"role":[{
"role": r,
- "keys": r
+ "keys": keys
}
]
})
- this.setState({projectUsers, selectedUser: null})
+ this.setState({platformUsers, selectedUser: null})
}
handleToggleUserRoleInProject(data) {
let self = this;
let {userIndex, roleIndex, checked} = data;
- let projectUsers = this.projectUsers;
+ let platformUsers = this.platformUsers;
let selectedRole = self.roles[roleIndex];
+ let keys = ","
if(checked) {
- projectUsers[userIndex].role.push({
- role: self.roles[roleIndex],
- keys: self.roles[roleIndex]
+ if(!platformUsers[userIndex].role) platformUsers[userIndex].role = [];
+ platformUsers[userIndex].role.push({
+ role: selectedRole,
+ keys: keys
})
} else {
- let role = projectUsers[userIndex].role;
- let roleIndex = _.findIndex(role, {role:selectedRole, keys: selectedRole})
- projectUsers[userIndex].role.splice(roleIndex, 1)
+ let role = platformUsers[userIndex].role;
+ let roleIndex = _.findIndex(role, {role:selectedRole, keys: keys})
+ platformUsers[userIndex].role.splice(roleIndex, 1)
}
- self.setState({projectUsers});
+ self.setState({platformUsers});
}
handleUpdateUserRoleInProject(data) {
let {userIndex, roleIndex, value} = data;
- let projectUsers = this.projectUsers;
- projectUsers[userIndex].role[roleIndex].role = value;
- projectUsers[userIndex].role[roleIndex]['keys'] = value;
+ let platformUsers = this.platformUsers;
+ platformUsers[userIndex].role[roleIndex].role = value;
+ platformUsers[userIndex].role[roleIndex]['keys'] = value;
}
addRoleToUserInProject(userIndex) {
- let projectUsers = this.projectUsers;
- if(!projectUsers[userIndex].role) {
- projectUsers[userIndex].role = [];
+ let platformUsers = this.platformUsers;
+ if(!platformUsers[userIndex].role) {
+ platformUsers[userIndex].role = [];
}
- projectUsers[userIndex].role.push({
+ platformUsers[userIndex].role.push({
'role': null,
//temp until we get actual keys
- 'keys' : 'some key'
+ 'keys' : ','
});
this.setState({
- projectUsers
+ platformUsers
})
}
handleRemoveRoleFromUserInProject (data) {
let {userIndex, roleIndex} = data;
- let projectUsers = this.projectUsers;
- projectUsers[userIndex].role.splice(roleIndex, 1);
+ let platformUsers = this.platformUsers;
+ platformUsers[userIndex].role.splice(roleIndex, 1);
this.setState({
- projectUsers
+ platformUsers
})
}
handleRemoveUserFromProject (userIndex) {
- let projectUsers = this.projectUsers;
- projectUsers.splice(userIndex, 1);
+ let platformUsers = this.platformUsers;
+ platformUsers.splice(userIndex, 1);
this.setState({
- projectUsers
+ platformUsers
})
}
getProjectsSuccess(projects) {
this.alt.actions.global.hideScreenLoader.defer();
this.setState({projects: projects});
}
- getUsersSuccess(users) {
+ getPlatformSuccess(platform) {
+ this.alt.actions.global.hideScreenLoader.defer();
+ let platformUsers = platform && platform.user || [];
+ let state = _.merge({
+ platform: platform,
+ projectOpen: true,
+ isEdit: true,
+ isReadOnly: true,
+ platformUsers: platformUsers
+ });
+ this.setState(state)
+ }
+ getPlatformRoleUsersSuccess(users) {
console.log(users)
this.alt.actions.global.hideScreenLoader.defer();
this.setState({users});