Commit 1cde80cd authored by Hannah Stepanek's avatar Hannah Stepanek

Remove disableOosGroupSelection config option

Since the isScopedToUri is no longer dependent on scope enforcement
and scope enforcement is now taken into account as part of whether
a group is selectable or not, disableOosGroupSelection is no longer
necessary. Group selection can be determined purely from isScopedToUri
and scopes.enforced.
parent bef29a30
......@@ -4,7 +4,7 @@
function GroupListSectionController() {
this.isSelectable = function(groupId) {
const group = this.sectionGroups.find(g => g.id === groupId);
return !this.disableOosGroupSelection || group.isScopedToUri;
return !group.scopes.enforced || group.isScopedToUri;
};
}
......@@ -16,8 +16,6 @@ module.exports = {
sectionGroups: '<',
/* The string name of the group list section. */
heading: '<',
/* A boolean indicating whether out of scope group selection should be disabled. */
disableOosGroupSelection: '<',
},
template: require('../templates/group-list-section.html'),
};
......@@ -13,59 +13,50 @@ describe('groupListSection', () => {
angular.mock.module('app', {});
});
const createGroupListSection = (
fakeSectionGroups,
fakeDisableOosGroupSelection
) => {
const config = {
const createGroupListSection = fakeSectionGroups => {
return util.createDirective(document, 'groupListSection', {
sectionGroups: fakeSectionGroups,
};
if (fakeDisableOosGroupSelection !== undefined) {
config.disableOosGroupSelection = fakeDisableOosGroupSelection;
}
return util.createDirective(document, 'groupListSection', config);
});
};
describe('isSelectable', () => {
[
{
description: 'always returns true if disableOosGroupSelection is false',
fakeDisableOosGroupSelection: false,
expectedIsSelectable: [true, true],
},
{
description:
'always returns true if disableOosGroupSelection is undefined',
fakeDisableOosGroupSelection: undefined,
expectedIsSelectable: [true, true],
'returns false if group is out of scope and scope is enforced',
scopesEnforced: true,
expectedIsSelectable: [true, false],
},
{
description:
'returns false if disableOosGroupSelection is true and group is out of scope',
fakeDisableOosGroupSelection: true,
expectedIsSelectable: [true, false],
'returns true if group is out of scope but scope is not enforced',
scopesEnforced: false,
expectedIsSelectable: [true, true],
},
].forEach(
({ description, fakeDisableOosGroupSelection, expectedIsSelectable }) => {
it(description, () => {
const fakeSectionGroups = [
{ isScopedToUri: true, id: 0 },
{ isScopedToUri: false, id: 1 },
];
].forEach(({ description, scopesEnforced, expectedIsSelectable }) => {
it(description, () => {
const fakeSectionGroups = [
{
isScopedToUri: true,
scopes: { enforced: scopesEnforced },
id: 0,
},
{
isScopedToUri: false,
scopes: { enforced: scopesEnforced },
id: 1,
},
];
const element = createGroupListSection(
fakeSectionGroups,
fakeDisableOosGroupSelection
);
const element = createGroupListSection(fakeSectionGroups);
fakeSectionGroups.forEach(g =>
assert.equal(
element.ctrl.isSelectable(g.id),
expectedIsSelectable[g.id]
)
);
});
}
);
fakeSectionGroups.forEach(g =>
assert.equal(
element.ctrl.isSelectable(g.id),
expectedIsSelectable[g.id]
)
);
});
});
});
});
......@@ -162,7 +162,6 @@
class="group-list-section"
heading="'My Groups'"
section-groups="vm.myGroupOrganizations()"
disable-oos-group-selection="true"
ng-if="vm.myGroupOrganizations().length > 0"
>
</group-list-section>
......
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