Unverified Commit 18f59a97 authored by Robert Knight's avatar Robert Knight Committed by GitHub

Merge pull request #693 from hypothesis/remove-group-public-property

Move away from `public` property in application components
parents d3a567fa 7385c00a
......@@ -14,8 +14,8 @@ module.exports = {
return this.isShared ? this.group.name : this.privateLabel;
};
this.groupType = function () {
return this.group.public ? 'public' : 'group';
this.groupCategory = function () {
return this.group.type === 'private' ? 'group' : 'public';
};
this.setPrivacy = function (level) {
......
......@@ -91,8 +91,7 @@ describe('annotationShareDialog', function () {
{
group: {
name: 'Public',
type: 'public',
public: true,
type: 'open',
},
uri: 'fakeURI',
isPrivate: false,
......@@ -142,7 +141,7 @@ describe('annotationShareDialog', function () {
it('is available to a group', function () {
element = util.createDirective(document, 'annotationShareDialog', {
group: {
public: false,
type: 'private',
},
isPrivate: false,
});
......
......@@ -8,8 +8,9 @@ var util = require('../../directive/test/util');
describe('groupList', function () {
var $window;
var GROUP_LINK = 'https://hypothes.is/groups/hdevs';
var PUBLIC_GROUP_LINK = 'https://hypothes.is/groups/pub';
var PRIVATE_GROUP_LINK = 'https://hypothes.is/groups/hdevs';
var OPEN_GROUP_LINK = 'https://hypothes.is/groups/pub';
var RESTRICTED_GROUP_LINK = 'https://hypothes.is/groups/restricto';
var groups;
var fakeGroups;
......@@ -53,14 +54,19 @@ describe('groupList', function () {
groups = [{
id: 'public',
public: true,
name: 'Public Group',
type: 'open',
url: PUBLIC_GROUP_LINK,
url: OPEN_GROUP_LINK,
},{
id: 'h-devs',
name: 'Hypothesis Developers',
type: 'private',
url: GROUP_LINK,
url: PRIVATE_GROUP_LINK,
}, {
id: 'restricto',
name: 'Hello Restricted',
type: 'restricted',
url: RESTRICTED_GROUP_LINK,
}];
fakeGroups = {
......@@ -94,15 +100,27 @@ describe('groupList', function () {
assert.equal(groupItems.length, groups.length + 1);
});
it('should render appropriate group name link title per group type', function() {
var element = createGroupList();
var nameLinks = element.find('.group-name-link');
assert.equal(nameLinks.length, groups.length + 1);
assert.include(nameLinks[0].title, 'Show public annotations'); // Open
assert.include(nameLinks[1].title, 'Show and create annotations in'); // Private
assert.include(nameLinks[2].title, 'Show public annotations'); // Restricted
});
it('should render share links', function () {
var element = createGroupList();
var shareLinks = element.find('.share-link-container');
assert.equal(shareLinks.length, 2);
assert.equal(shareLinks.length, groups.length);
var link = element.find('.share-link');
assert.equal(link.length, 2);
assert.equal(link[0].href, PUBLIC_GROUP_LINK);
assert.equal(link[1].href, GROUP_LINK);
assert.equal(link.length, groups.length);
assert.equal(link[0].href, OPEN_GROUP_LINK);
assert.equal(link[1].href, PRIVATE_GROUP_LINK);
assert.equal(link[2].href, RESTRICTED_GROUP_LINK);
});
[{
......
......@@ -34,7 +34,6 @@ describe('publishAnnotationBtn', function () {
element = util.createDirective(document, 'publishAnnotationBtn', {
group: {
name: 'Public',
type: 'public',
},
canPost: true,
isShared: false,
......@@ -44,6 +43,31 @@ describe('publishAnnotationBtn', function () {
});
});
[
{
groupType: 'open',
expectedIcon: 'public',
},
{
groupType: 'restricted',
expectedIcon: 'public',
},
{
groupType: 'private',
expectedIcon: 'group',
},
].forEach(({ groupType, expectedIcon }) => {
it('should set the correct group-type icon class', function () {
element.ctrl.group = {
name: 'My Group',
type: groupType,
};
element.scope.$digest();
var iconElement = element.find('.group-icon-container > i');
assert.isTrue(iconElement.hasClass(`h-icon-${expectedIcon}`));
});
});
it('should display "Post to Only Me"', function () {
var buttons = element.find('button');
assert.equal(buttons.length, 3);
......@@ -53,7 +77,6 @@ describe('publishAnnotationBtn', function () {
it('should display "Post to Research Lab"', function () {
element.ctrl.group = {
name: 'Research Lab',
type: 'group',
};
element.ctrl.isShared = true;
element.scope.$digest();
......
......@@ -36,7 +36,7 @@
<i class="h-icon-clipboard btn-icon"></i>
</button>
</div>
<div class="annotation-share-dialog-msg" ng-if="vm.group && !vm.group.public && !vm.isPrivate">
<div class="annotation-share-dialog-msg" ng-if="vm.group && vm.group.type === 'private' && !vm.isPrivate">
<span class="annotation-share-dialog-msg__audience">
Group.
</span>
......
......@@ -39,7 +39,7 @@
<div class="group-name-container">
<a class="group-name-link"
href=""
title="{{ group.public ? 'Show public annotations' : 'Show and create annotations in ' + group.name }}">
title="{{ group.type === 'private' ? 'Show and create annotations in ' + group.name : 'Show public annotations' }}">
{{group.name}}
</a>
</div>
......
......@@ -12,7 +12,7 @@
<li class="dropdown-menu__row" ng-click="vm.setPrivacy('shared')">
<div class="group-item">
<div class="group-icon-container">
<i class="small" ng-class="'h-icon-' + vm.groupType()"></i>
<i class="small" ng-class="'h-icon-' + vm.groupCategory()"></i>
</div>
<div class="group-details">
<div class="group-name-container">
......
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