Commit a15b525a authored by Lyza Danger Gardner's avatar Lyza Danger Gardner

Refactor `group-list`’s checking of share links

parent 29b8534d
......@@ -35,6 +35,17 @@ function GroupListController($window, analytics, groups, settings, serviceUrl) {
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);
if (svc && svc.icon) {
this.thirdPartyGroupIcon = svc.icon;
......
......@@ -129,6 +129,22 @@ describe('groupList', function () {
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.
firstPartyAuthDomain: 'example.com',
......
......@@ -43,7 +43,7 @@
{{group.name}}
</a>
</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"
href="{{group.links.html}}"
target="_blank"
......
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