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