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