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