mirror of
https://github.com/yldio/copilot.git
synced 2024-11-14 15:20:06 +02:00
adding in functionality to determin current organisation when changing member role
This commit is contained in:
parent
f1cf0c4011
commit
1d2c322082
@ -13,7 +13,8 @@ const PeopleTable = (props) => {
|
|||||||
handleRoleUpdate,
|
handleRoleUpdate,
|
||||||
handleStatusTooltip,
|
handleStatusTooltip,
|
||||||
people = [],
|
people = [],
|
||||||
orgUI = {}
|
orgUI = {},
|
||||||
|
orgIndex
|
||||||
} = props;
|
} = props;
|
||||||
|
|
||||||
const columns = [{
|
const columns = [{
|
||||||
@ -49,6 +50,7 @@ const PeopleTable = (props) => {
|
|||||||
handleRoleTooltip={handleRoleTooltip}
|
handleRoleTooltip={handleRoleTooltip}
|
||||||
handleRoleUpdate={handleRoleUpdate}
|
handleRoleUpdate={handleRoleUpdate}
|
||||||
membersRolesOptions={orgUI.members_roles}
|
membersRolesOptions={orgUI.members_roles}
|
||||||
|
orgIndex={orgIndex}
|
||||||
person={person}
|
person={person}
|
||||||
personIndex={index}
|
personIndex={index}
|
||||||
toggledID={orgUI.member_role_tooltip}
|
toggledID={orgUI.member_role_tooltip}
|
||||||
@ -76,6 +78,7 @@ PeopleTable.propTypes = {
|
|||||||
handleRoleTooltip: React.PropTypes.func,
|
handleRoleTooltip: React.PropTypes.func,
|
||||||
handleRoleUpdate: React.PropTypes.func,
|
handleRoleUpdate: React.PropTypes.func,
|
||||||
handleStatusTooltip: React.PropTypes.func,
|
handleStatusTooltip: React.PropTypes.func,
|
||||||
|
orgIndex: React.PropTypes.number,
|
||||||
orgUI: React.PropTypes.object,
|
orgUI: React.PropTypes.object,
|
||||||
people: React.PropTypes.array,
|
people: React.PropTypes.array,
|
||||||
};
|
};
|
||||||
|
@ -54,7 +54,8 @@ const PersonRole = (props) => {
|
|||||||
person,
|
person,
|
||||||
personIndex,
|
personIndex,
|
||||||
handleRoleTooltip,
|
handleRoleTooltip,
|
||||||
handleRoleUpdate
|
handleRoleUpdate,
|
||||||
|
orgIndex
|
||||||
} = props;
|
} = props;
|
||||||
|
|
||||||
const toggled = toggledID;
|
const toggled = toggledID;
|
||||||
@ -78,6 +79,7 @@ const PersonRole = (props) => {
|
|||||||
? <Tooltip
|
? <Tooltip
|
||||||
handleSelect={handleOptionSelect}
|
handleSelect={handleOptionSelect}
|
||||||
options={membersRolesOptions}
|
options={membersRolesOptions}
|
||||||
|
orgIndex={orgIndex}
|
||||||
person={_person}
|
person={_person}
|
||||||
personIndex={personIndex}
|
personIndex={personIndex}
|
||||||
/>
|
/>
|
||||||
@ -90,6 +92,7 @@ PersonRole.propTypes = {
|
|||||||
handleRoleTooltip: React.PropTypes.func,
|
handleRoleTooltip: React.PropTypes.func,
|
||||||
handleRoleUpdate: React.PropTypes.func,
|
handleRoleUpdate: React.PropTypes.func,
|
||||||
membersRolesOptions: React.PropTypes.array,
|
membersRolesOptions: React.PropTypes.array,
|
||||||
|
orgIndex: React.PropTypes.number,
|
||||||
person: React.PropTypes.object,
|
person: React.PropTypes.object,
|
||||||
personIndex: React.PropTypes.number,
|
personIndex: React.PropTypes.number,
|
||||||
toggledID: React.PropTypes.oneOfType([
|
toggledID: React.PropTypes.oneOfType([
|
||||||
|
@ -18,6 +18,7 @@ module.exports = ({
|
|||||||
person = {},
|
person = {},
|
||||||
personIndex,
|
personIndex,
|
||||||
options = [],
|
options = [],
|
||||||
|
orgIndex,
|
||||||
}) => {
|
}) => {
|
||||||
|
|
||||||
const _options = options.map( (option, i) => {
|
const _options = options.map( (option, i) => {
|
||||||
@ -28,7 +29,8 @@ module.exports = ({
|
|||||||
status: person.status,
|
status: person.status,
|
||||||
role: option
|
role: option
|
||||||
},
|
},
|
||||||
personIndex
|
personIndex,
|
||||||
|
orgIndex,
|
||||||
};
|
};
|
||||||
|
|
||||||
const _onClick = () => handleSelect(payload);
|
const _onClick = () => handleSelect(payload);
|
||||||
@ -59,6 +61,7 @@ module.exports = ({
|
|||||||
module.exports.propTypes = {
|
module.exports.propTypes = {
|
||||||
handleSelect: React.PropTypes.func,
|
handleSelect: React.PropTypes.func,
|
||||||
options: React.PropTypes.array,
|
options: React.PropTypes.array,
|
||||||
|
orgIndex: React.PropTypes.number,
|
||||||
person: React.PropTypes.object,
|
person: React.PropTypes.object,
|
||||||
personIndex: React.PropTypes.number,
|
personIndex: React.PropTypes.number,
|
||||||
};
|
};
|
@ -12,7 +12,8 @@ const {
|
|||||||
const {
|
const {
|
||||||
peopleByOrgIdSelector,
|
peopleByOrgIdSelector,
|
||||||
orgUISelector,
|
orgUISelector,
|
||||||
membersSelector
|
orgIndexSelector,
|
||||||
|
membersSelector,
|
||||||
} = selectors;
|
} = selectors;
|
||||||
|
|
||||||
const {
|
const {
|
||||||
@ -36,6 +37,7 @@ const mapStateToProps = (state, {
|
|||||||
}) => ({
|
}) => ({
|
||||||
people: peopleByOrgIdSelector(params.org)(state),
|
people: peopleByOrgIdSelector(params.org)(state),
|
||||||
orgUI: orgUISelector(state),
|
orgUI: orgUISelector(state),
|
||||||
|
orgIndex: orgIndexSelector(params.org)(state),
|
||||||
platformMembers: membersSelector(state)
|
platformMembers: membersSelector(state)
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -48,9 +48,11 @@ module.exports = handleActions({
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
[handleRoleUpdate.toString()]: (state, action) => {
|
[handleRoleUpdate.toString()]: (state, action) => {
|
||||||
// TODO:
|
const {
|
||||||
// Change "1" to org index. At the moment only updates
|
orgIndex,
|
||||||
// "biz-tech"
|
person,
|
||||||
|
personIndex,
|
||||||
|
} = action.payload;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
@ -59,18 +61,18 @@ module.exports = handleActions({
|
|||||||
member_role_tooltip: false
|
member_role_tooltip: false
|
||||||
},
|
},
|
||||||
data: [
|
data: [
|
||||||
...state.data.slice(0, 1),
|
...state.data.slice(0, orgIndex),
|
||||||
{
|
{
|
||||||
...state.data[1],
|
...state.data[orgIndex],
|
||||||
members: [
|
members: [
|
||||||
...state.data[1].members.slice(0, action.payload.personIndex),
|
...state.data[orgIndex].members.slice(0, personIndex),
|
||||||
{
|
{
|
||||||
...action.payload.person
|
...person,
|
||||||
},
|
},
|
||||||
...state.data[1].members.slice(action.payload.personIndex + 1)
|
...state.data[orgIndex].members.slice(personIndex + 1)
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
...state.data.slice(1+1),
|
...state.data.slice(orgIndex + 1),
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -35,6 +35,11 @@ const orgById = (orgId) => createSelector(
|
|||||||
(orgs) => find(orgs, ['id', orgId])
|
(orgs) => find(orgs, ['id', orgId])
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const orgIndexById = (orgId) => createSelector(
|
||||||
|
orgs,
|
||||||
|
(orgs) => orgs.map((o) => o.id).indexOf(orgId)
|
||||||
|
);
|
||||||
|
|
||||||
const serviceById = (serviceId) => createSelector(
|
const serviceById = (serviceId) => createSelector(
|
||||||
[services],
|
[services],
|
||||||
(services) => find(services, ['id', serviceId])
|
(services) => find(services, ['id', serviceId])
|
||||||
@ -140,6 +145,7 @@ module.exports = {
|
|||||||
orgByIdSelector: orgById,
|
orgByIdSelector: orgById,
|
||||||
orgsSelector: orgs,
|
orgsSelector: orgs,
|
||||||
orgUISelector: orgUI,
|
orgUISelector: orgUI,
|
||||||
|
orgIndexSelector: orgIndexById,
|
||||||
servicesSelector: services,
|
servicesSelector: services,
|
||||||
serviceByIdSelector: serviceById,
|
serviceByIdSelector: serviceById,
|
||||||
orgSectionsSelector: orgSections,
|
orgSectionsSelector: orgSections,
|
||||||
|
@ -19,7 +19,8 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"husky": "^0.11.9",
|
"husky": "^0.11.9",
|
||||||
"license-to-fail": "^2.2.0"
|
"license-to-fail": "^2.2.0",
|
||||||
|
"lodash.findindex": "^4.6.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"tap-xunit": "^1.4.0"
|
"tap-xunit": "^1.4.0"
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
||||||
# yarn lockfile v1
|
# yarn lockfile v1
|
||||||
|
|
||||||
|
|
||||||
abbrev@1:
|
abbrev@1:
|
||||||
version "1.0.9"
|
version "1.0.9"
|
||||||
resolved "https://registry.yarnpkg.com/abbrev/-/abbrev-1.0.9.tgz#91b4792588a7738c25f35dd6f63752a2f8776135"
|
resolved "https://registry.yarnpkg.com/abbrev/-/abbrev-1.0.9.tgz#91b4792588a7738c25f35dd6f63752a2f8776135"
|
||||||
@ -136,7 +134,7 @@ inflight@^1.0.4:
|
|||||||
once "^1.3.0"
|
once "^1.3.0"
|
||||||
wrappy "1"
|
wrappy "1"
|
||||||
|
|
||||||
inherits@2, inherits@~2.0.1:
|
inherits@~2.0.1, inherits@2:
|
||||||
version "2.0.3"
|
version "2.0.3"
|
||||||
resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de"
|
resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de"
|
||||||
|
|
||||||
@ -190,6 +188,10 @@ license-to-fail@^2.2.0:
|
|||||||
dependencies:
|
dependencies:
|
||||||
license-checker "^7.1.0"
|
license-checker "^7.1.0"
|
||||||
|
|
||||||
|
lodash.findindex:
|
||||||
|
version "4.6.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/lodash.findindex/-/lodash.findindex-4.6.0.tgz#a3245dee61fb9b6e0624b535125624bb69c11106"
|
||||||
|
|
||||||
lodash@^3.5.0:
|
lodash@^3.5.0:
|
||||||
version "3.10.1"
|
version "3.10.1"
|
||||||
resolved "https://registry.yarnpkg.com/lodash/-/lodash-3.10.1.tgz#5bf45e8e49ba4189e17d482789dfd15bd140b7b6"
|
resolved "https://registry.yarnpkg.com/lodash/-/lodash-3.10.1.tgz#5bf45e8e49ba4189e17d482789dfd15bd140b7b6"
|
||||||
@ -389,3 +391,4 @@ xmlbuilder@~4.1.0:
|
|||||||
xtend@~4.0.0, xtend@~4.0.1:
|
xtend@~4.0.0, xtend@~4.0.1:
|
||||||
version "4.0.1"
|
version "4.0.1"
|
||||||
resolved "https://registry.yarnpkg.com/xtend/-/xtend-4.0.1.tgz#a5c6d532be656e23db820efb943a1f04998d63af"
|
resolved "https://registry.yarnpkg.com/xtend/-/xtend-4.0.1.tgz#a5c6d532be656e23db820efb943a1f04998d63af"
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user