Commit 885ffcc4 authored by Sheetal Umesh Kumar's avatar Sheetal Umesh Kumar

Disable the link to activity pages from user profile, if the user is a 3rd party account user.

parent 14bcd38b
......@@ -49,7 +49,7 @@ function updateModel(annotation, changes, permissions) {
function AnnotationController(
$document, $q, $rootScope, $scope, $timeout, $window, analytics, annotationUI,
annotationMapper, drafts, flash, features, groups, permissions, serviceUrl,
session, store, streamer) {
session, settings, store, streamer) {
var vm = this;
var newlyCreatedByHighlightButton;
......@@ -477,6 +477,10 @@ function AnnotationController(
return vm.annotation.user;
};
vm.isThirdPartyUser = function () {
return persona.isThirdPartyUser(vm.annotation.user, settings.authDomain);
};
vm.username = function() {
return persona.username(vm.annotation.user);
};
......
'use strict';
var persona = require('../filter/persona');
// @ngInject
function GroupListController($scope, $window, groups) {
function GroupListController($scope, $window, groups, settings) {
$scope.isThirdPartyUser = function () {
return persona.isThirdPartyUser($scope.auth.userid, settings.authDomain);
};
$scope.leaveGroup = function (groupId) {
var groupName = groups.get(groupId).name;
var message = 'Are you sure you want to leave the group "' +
......
'use strict';
var persona = require('../filter/persona');
module.exports = function () {
return {
bindToController: true,
controllerAs: 'vm',
//@ngInject
controller: function (serviceUrl) {
controller: function (serviceUrl, settings) {
this.serviceUrl = serviceUrl;
this.isThirdPartyUser = function() {
return persona.isThirdPartyUser(this.auth.userid, settings.authDomain);
};
},
restrict: 'E',
scope: {
......
......@@ -90,6 +90,7 @@ describe('annotation', function() {
var fakePermissions;
var fakeServiceUrl;
var fakeSession;
var fakeSettings;
var fakeStore;
var fakeStreamer;
var sandbox;
......@@ -186,6 +187,10 @@ describe('annotation', function() {
get: function() {},
};
fakeSettings = {
authDomain: 'example.com',
};
fakeStore = {
annotation: {
create: sinon.spy(function (annot) {
......@@ -211,6 +216,7 @@ describe('annotation', function() {
$provide.value('permissions', fakePermissions);
$provide.value('session', fakeSession);
$provide.value('serviceUrl', fakeServiceUrl);
$provide.value('settings', fakeSettings);
$provide.value('store', fakeStore);
$provide.value('streamer', fakeStreamer);
}));
......
......@@ -13,6 +13,7 @@ describe('groupList', function () {
var groups;
var fakeGroups;
var fakeServiceUrl;
var fakeSettings;
before(function() {
angular.module('app', [])
......@@ -24,8 +25,13 @@ describe('groupList', function () {
beforeEach(function () {
fakeServiceUrl = sinon.stub();
fakeSettings = {
authDomain: 'example.com',
};
angular.mock.module('app', {
serviceUrl: fakeServiceUrl,
settings: fakeSettings,
});
});
......@@ -61,6 +67,7 @@ describe('groupList', function () {
return util.createDirective(document, 'groupList', {
auth: {
status: 'logged-in',
userid: 'acct:person@example.com',
},
});
}
......
......@@ -30,7 +30,21 @@ function username(user) {
return account.username;
}
/**
* Returns true if the authority is of a 3rd party user.
*/
function isThirdPartyUser(user, authDomain) {
var account = parseAccountID(user);
if (!account) {
return false;
}
return account.provider !== authDomain;
}
module.exports = {
isThirdPartyUser: isThirdPartyUser,
parseAccountID: parseAccountID,
username: username,
};
......@@ -27,4 +27,18 @@ describe('persona', function () {
assert.equal(persona.username('bogus'), '');
});
});
describe('isThirdPartyUser', function () {
it('should return true if user is a third party user', function () {
assert.isTrue(persona.isThirdPartyUser('acct:someone@example.com', 'ex.com'));
});
it('should return false if user is not a third party user', function () {
assert.isFalse(persona.isThirdPartyUser('acct:someone@example.com', 'example.com'));
});
it('should return false if the user is invalid', function () {
assert.isFalse(persona.isThirdPartyUser('bogus', 'example.com'));
});
});
});
......@@ -8,8 +8,13 @@
<span ng-if="vm.user()">
<a class="annotation-header__user"
target="_blank"
ng-if="!vm.isThirdPartyUser()"
ng-href="{{vm.serviceUrl('user',{user:vm.user()})}}"
>{{vm.username()}}</a>
<span class="annotation-header__user"
target="_blank"
ng-if="vm.isThirdPartyUser()"
>{{vm.username()}}</span>
<span class="annotation-collapsed-replies">
<a class="annotation-link" href=""
ng-click="vm.onReplyCountClick()"
......
......@@ -55,7 +55,7 @@
</div>
</div>
</li>
<li class="dropdown-menu__row dropdown-menu__row--unpadded new-group-btn">
<li ng-if="!isThirdPartyUser()" class="dropdown-menu__row dropdown-menu__row--unpadded new-group-btn">
<div class="group-item" ng-click="createNewGroup()">
<div class="group-icon-container"><i class="h-icon-add"></i></div>
<div class="group-details">
......
......@@ -20,7 +20,11 @@
</a>
<ul class="dropdown-menu pull-right" role="menu">
<li class="dropdown-menu__row" ng-if="vm.auth.status === 'logged-in'">
<a href="{{vm.serviceUrl('user',{user: vm.auth.username})}}"
<span ng-if="vm.isThirdPartyUser()"
class="dropdown-menu__link dropdown-menu__link--disabled"
target="_blank">{{vm.auth.username}}</span>
<a ng-if="!vm.isThirdPartyUser()"
href="{{vm.serviceUrl('user',{user: vm.auth.username})}}"
class="dropdown-menu__link"
title="View all your annotations"
target="_blank">{{vm.auth.username}}</a>
......
......@@ -107,7 +107,16 @@ html {
}
&__link--subtle {
color: $color-gray;
&:hover {
color: $color-gray;
}
}
&__link--disabled {
&:hover {
cursor: default;
color: inherit;
}
}
// These psuedo-elements add the speech bubble tail / triangle.
......
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