Skip to content

Commit 1f1e945

Browse files
authored
Merge pull request #6855 from Countly/groups-update
Fix user permission update after updating user group permission
2 parents 476b665 + e4ed1a8 commit 1f1e945

File tree

2 files changed

+29
-3
lines changed

2 files changed

+29
-3
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
## Version 25.03.X
2-
Fixes:
2+
Enterprise Fixes:
33
- [ab-testing] Add script for fixing variant cohort
4+
- [groups] Fix user permission update after updating user group permission
45

56

67
## Version 25.03.24

frontend/express/public/core/user-management/javascripts/countly.views.js

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -866,6 +866,7 @@
866866
}
867867
},
868868
onOpen: function() {
869+
this.patchUserPermission();
869870
this.changePasswordFlag = false;
870871
// types
871872
var types = ['c', 'r', 'u', 'd'];
@@ -879,7 +880,7 @@
879880
// if it's in edit mode
880881
if (this.settings.editMode) {
881882
// is user member of a group?
882-
if (this.user.group_id && countlyGlobal.plugins.indexOf('groups') > -1) {
883+
if (this.user.group_id && this.user.group_id.length && countlyGlobal.plugins.indexOf('groups') > -1) {
883884
// set groups state
884885
if (Array.isArray(this.user.group_id)) {
885886
this.groups = this.user.group_id;
@@ -982,7 +983,31 @@
982983
},
983984
onRoleChange: function(role) {
984985
this.roles[role.name] = role;
985-
}
986+
},
987+
patchUserPermission: function() {
988+
if (this.user && this.user.permission && this.user.permission._ && this.user.permission._.u) {
989+
var appIdReducer = function(acc, curr) {
990+
if (curr.length > 0) {
991+
acc.push(curr);
992+
}
993+
return acc;
994+
};
995+
996+
var _u = this.user.permission._.u.reduce(function(acc, curr) {
997+
if (curr.length > 0) {
998+
var appIds = curr.reduce(appIdReducer, []);
999+
1000+
if (appIds.length > 0) {
1001+
acc.push(appIds);
1002+
}
1003+
}
1004+
return acc;
1005+
}, []);
1006+
1007+
this.user.permission._.u = _u;
1008+
this.$refs.userDrawer.editedObject.permission._.u = _u;
1009+
}
1010+
},
9861011
},
9871012
watch: {
9881013
'groups': function() {

0 commit comments

Comments
 (0)