Skip to content

Commit

Permalink
fix: org unit selector - only act on path if it exists (#276)
Browse files Browse the repository at this point in the history
Fixes include:

* call "Set" instead of "Add" since the returned list contains the complete selected list
* check that ou.path exists before acting on it. In the case of user org units, path does not exist, which resulted in the app crashing
  • Loading branch information
jenniferarnesen committed Apr 26, 2019
1 parent b520a65 commit 9299038
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export class DialogManager extends Component {
}, 1000);

onSelect = ({ dimensionId, items }) => {
this.props.addUiItems({
this.props.setUiItems({
dimensionId,
itemIds: items.map(item => item.id),
});
Expand All @@ -94,10 +94,12 @@ export class DialogManager extends Component {
displayName: ou.displayName,
};

const path = removeOrgUnitLastPathSegment(ou.path);
if (ou.path) {
const path = removeOrgUnitLastPathSegment(ou.path);

forParentGraphMap[ou.id] =
path === `/${ou.id}` ? '' : path.replace(/^\//, '');
forParentGraphMap[ou.id] =
path === `/${ou.id}` ? '' : path.replace(/^\//, '');
}
});

this.props.addMetadata(forMetadata);
Expand Down

0 comments on commit 9299038

Please sign in to comment.