Commit 3008d356 authored by kushalpandya's avatar kushalpandya

Fix incorrect selection checks

parent 68c94194
...@@ -9,4 +9,10 @@ export const LEVEL_TYPES = { ...@@ -9,4 +9,10 @@ export const LEVEL_TYPES = {
GROUP: 'group', GROUP: 'group',
}; };
export const LEVEL_ID_PROP = {
ROLE: 'access_level',
USER: 'user_id',
GROUP: 'group_id',
};
export const ACCESS_LEVEL_NONE = 0; export const ACCESS_LEVEL_NONE = 0;
/* eslint-disable no-underscore-dangle, class-methods-use-this */ /* eslint-disable no-underscore-dangle, class-methods-use-this */
/* global Flash */ /* global Flash */
import { LEVEL_TYPES, ACCESS_LEVEL_NONE } from './constants'; import { LEVEL_TYPES, LEVEL_ID_PROP, ACCESS_LEVEL_NONE } from './constants';
export default class ProtectedBranchAccessDropdown { export default class ProtectedBranchAccessDropdown {
constructor(options) { constructor(options) {
...@@ -150,8 +150,24 @@ export default class ProtectedBranchAccessDropdown { ...@@ -150,8 +150,24 @@ export default class ProtectedBranchAccessDropdown {
let index = -1; let index = -1;
const selectedItems = this.getAllSelectedItems(); const selectedItems = this.getAllSelectedItems();
// Compare IDs based on selectedItem.type
selectedItems.forEach((item, i) => { selectedItems.forEach((item, i) => {
if (selectedItem.id === item.access_level) { let comparator;
switch (selectedItem.type) {
case LEVEL_TYPES.ROLE:
comparator = LEVEL_ID_PROP.ROLE;
break;
case LEVEL_TYPES.GROUP:
comparator = LEVEL_ID_PROP.GROUP;
break;
case LEVEL_TYPES.USER:
comparator = LEVEL_ID_PROP.USER;
break;
default:
break;
}
if (selectedItem.id === item[comparator]) {
index = i; index = i;
} }
}); });
......
...@@ -8,4 +8,10 @@ export const LEVEL_TYPES = { ...@@ -8,4 +8,10 @@ export const LEVEL_TYPES = {
GROUP: 'group', GROUP: 'group',
}; };
export const LEVEL_ID_PROP = {
ROLE: 'access_level',
USER: 'user_id',
GROUP: 'group_id',
};
export const ACCESS_LEVEL_NONE = 0; export const ACCESS_LEVEL_NONE = 0;
/* eslint-disable no-underscore-dangle, class-methods-use-this */ /* eslint-disable no-underscore-dangle, class-methods-use-this */
/* global Flash */ /* global Flash */
import { LEVEL_TYPES, ACCESS_LEVEL_NONE } from './constants'; import { LEVEL_TYPES, LEVEL_ID_PROP, ACCESS_LEVEL_NONE } from './constants';
export default class ProtectedTagAccessDropdown { export default class ProtectedTagAccessDropdown {
constructor(options) { constructor(options) {
...@@ -145,8 +145,24 @@ export default class ProtectedTagAccessDropdown { ...@@ -145,8 +145,24 @@ export default class ProtectedTagAccessDropdown {
let index = -1; let index = -1;
const selectedItems = this.getAllSelectedItems(); const selectedItems = this.getAllSelectedItems();
// Compare IDs based on selectedItem.type
selectedItems.forEach((item, i) => { selectedItems.forEach((item, i) => {
if (selectedItem.id === item.access_level) { let comparator;
switch (selectedItem.type) {
case LEVEL_TYPES.ROLE:
comparator = LEVEL_ID_PROP.ROLE;
break;
case LEVEL_TYPES.GROUP:
comparator = LEVEL_ID_PROP.GROUP;
break;
case LEVEL_TYPES.USER:
comparator = LEVEL_ID_PROP.USER;
break;
default:
break;
}
if (selectedItem.id === item[comparator]) {
index = i; index = i;
} }
}); });
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment