Unverified Commit bcb8d9bc authored by Robert Knight's avatar Robert Knight Committed by GitHub

Merge pull request #698 from hypothesis/group-use-links-not-url

Remove reference to `group.url`
parents bd831601 a15b525a
...@@ -35,6 +35,17 @@ function GroupListController($window, analytics, groups, settings, serviceUrl) { ...@@ -35,6 +35,17 @@ function GroupListController($window, analytics, groups, settings, serviceUrl) {
groups.focus(groupId); groups.focus(groupId);
}; };
/**
* Show the share link for the group if it is not a third-party group
* AND if the URL needed is present in the group object. We should be able
* to simplify this once the API is adjusted only to return the link
* when applicable.
*/
this.shouldShowActivityLink = function (groupId) {
const group = groups.get(groupId);
return group.links && group.links.html && !this.isThirdPartyService;
};
var svc = serviceConfig(settings); var svc = serviceConfig(settings);
if (svc && svc.icon) { if (svc && svc.icon) {
this.thirdPartyGroupIcon = svc.icon; this.thirdPartyGroupIcon = svc.icon;
......
...@@ -54,19 +54,25 @@ describe('groupList', function () { ...@@ -54,19 +54,25 @@ describe('groupList', function () {
groups = [{ groups = [{
id: 'public', id: 'public',
links: {
html: OPEN_GROUP_LINK,
},
name: 'Public Group', name: 'Public Group',
type: 'open', type: 'open',
url: OPEN_GROUP_LINK,
},{ },{
id: 'h-devs', id: 'h-devs',
links: {
html: PRIVATE_GROUP_LINK,
},
name: 'Hypothesis Developers', name: 'Hypothesis Developers',
type: 'private', type: 'private',
url: PRIVATE_GROUP_LINK,
}, { }, {
id: 'restricto', id: 'restricto',
links: {
html: RESTRICTED_GROUP_LINK,
},
name: 'Hello Restricted', name: 'Hello Restricted',
type: 'restricted', type: 'restricted',
url: RESTRICTED_GROUP_LINK,
}]; }];
fakeGroups = { fakeGroups = {
...@@ -123,6 +129,22 @@ describe('groupList', function () { ...@@ -123,6 +129,22 @@ describe('groupList', function () {
assert.equal(link[2].href, RESTRICTED_GROUP_LINK); assert.equal(link[2].href, RESTRICTED_GROUP_LINK);
}); });
it('should not render share links if they are not present', function () {
groups = [
{
type: 'private',
},
{
id: 'anOpenGroup',
type: 'open',
links: {},
},
];
var element = createGroupList();
var links = element.find('.share-link-container');
assert.equal(links.length, 0);
});
[{ [{
// Logged-in third party user. // Logged-in third party user.
firstPartyAuthDomain: 'example.com', firstPartyAuthDomain: 'example.com',
......
...@@ -43,9 +43,9 @@ ...@@ -43,9 +43,9 @@
{{group.name}} {{group.name}}
</a> </a>
</div> </div>
<div class="share-link-container" ng-click="$event.stopPropagation()" ng-if="!vm.isThirdPartyService"> <div class="share-link-container" ng-click="$event.stopPropagation()" ng-if="vm.shouldShowActivityLink(group.id)">
<a class="share-link" <a class="share-link"
href="{{group.url}}" href="{{group.links.html}}"
target="_blank" target="_blank"
ng-click="vm.viewGroupActivity()"> ng-click="vm.viewGroupActivity()">
View group activity View group activity
......
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