Skip to content

Commit

Permalink
Fix #2110
Browse files Browse the repository at this point in the history
By using a dropwhile instead of filtering the full array
  • Loading branch information
greenape committed Mar 13, 2020
1 parent 0cccbf5 commit 7e9bff0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
### Changed

### Fixed
- Fixed the display of deeply nested permissions for flows in FlowAuth. [#2110](https://github.com/Flowminder/FlowKit/issues/2110)

### Removed

Expand Down
12 changes: 11 additions & 1 deletion flowauth/frontend/src/util/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

function dropWhile(func) {
let arr = this;
while (arr.length > 0 && !func(arr[0])) {
arr = arr.slice(1);
}
return arr;
}

Array.prototype.dropWhile = dropWhile;

function zip() {
/* https://stackoverflow.com/a/10284006 */
var args = [].slice.call(arguments);
Expand All @@ -26,7 +36,7 @@ export function scopesGraph(array) {
obj["parent"] = parents.join("&");
let split = sub_scope.split(".");
split = zip(last_split, split)
.filter(x => x[0] !== x[1])
.dropWhile(x => x[0] !== x[1])
.map(x => x[1])
.filter(x => x !== undefined);
split.forEach((k, ix) => {
Expand Down

0 comments on commit 7e9bff0

Please sign in to comment.