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

Merge pull request #823 from hypothesis/hide-share-in-tutorial

Hide non-applicable tutorial steps for third party users
parents c11835ec b3037373
'use strict'; 'use strict';
const sessionUtil = require('../util/session-util'); const sessionUtil = require('../util/session-util');
const isThirdPartyService = require('../util/is-third-party-service');
// @ngInject // @ngInject
function SidebarTutorialController(session, settings) { function SidebarTutorialController(session, settings) {
// Compute once since this doesn't change after the app starts.
const isThirdPartyService_ = isThirdPartyService(settings);
this.isThemeClean = settings.theme === 'clean'; this.isThemeClean = settings.theme === 'clean';
this.showSidebarTutorial = function () { this.showSidebarTutorial = function () {
...@@ -13,6 +17,20 @@ function SidebarTutorialController(session, settings) { ...@@ -13,6 +17,20 @@ function SidebarTutorialController(session, settings) {
this.dismiss = function () { this.dismiss = function () {
session.dismissSidebarTutorial(); session.dismissSidebarTutorial();
}; };
this.canCreatePrivateGroup = () => {
// Private group creation in the client is limited to first party users.
// In future we may extend this to third party users, but still disable
// private group creation in certain contexts (eg. the LMS app).
return !isThirdPartyService_;
};
this.canSharePage = () => {
// The "Share document" icon in the toolbar is limited to first party users.
// In future we may extend this to third party users, but still disable it
// in certain contexts (eg. the LMS app).
return !isThirdPartyService_;
};
} }
/** /**
......
...@@ -2,9 +2,17 @@ ...@@ -2,9 +2,17 @@
const Controller = require('../sidebar-tutorial').controller; const Controller = require('../sidebar-tutorial').controller;
describe('SidebarTutorialController', function () { describe('sidebar/components/sidebar-tutorial', function () {
const defaultSession = {state: {preferences: {}}};
const firstPartySettings = {};
const thirdPartySettings = {
services: [{
authority: 'publisher.org',
}],
};
describe('showSidebarTutorial', function () {
describe('#showSidebarTutorial', function () {
const settings = {}; const settings = {};
it('returns true if show_sidebar_tutorial is true', function () { it('returns true if show_sidebar_tutorial is true', function () {
...@@ -46,4 +54,28 @@ describe('SidebarTutorialController', function () { ...@@ -46,4 +54,28 @@ describe('SidebarTutorialController', function () {
assert.equal(result, false); assert.equal(result, false);
}); });
}); });
describe('#canSharePage', () => {
it('is true for first party users', () => {
const controller = new Controller(defaultSession, firstPartySettings);
assert.isTrue(controller.canSharePage());
});
it('is false for third party users', () => {
const controller = new Controller(defaultSession, thirdPartySettings);
assert.isFalse(controller.canSharePage());
});
});
describe('#canCreatePrivateGroup', () => {
it('is true for first party users', () => {
const controller = new Controller(defaultSession, firstPartySettings);
assert.isTrue(controller.canSharePage());
});
it('is false for third party users', () => {
const controller = new Controller(defaultSession, thirdPartySettings);
assert.isFalse(controller.canSharePage());
});
});
}); });
...@@ -27,13 +27,13 @@ ...@@ -27,13 +27,13 @@
<i class="h-icon-annotation-reply"></i>&nbsp;<strong>Reply</strong>&nbsp;link. <i class="h-icon-annotation-reply"></i>&nbsp;<strong>Reply</strong>&nbsp;link.
</p> </p>
</li> </li>
<li class="sidebar-tutorial__list-item"> <li class="sidebar-tutorial__list-item" ng-if="vm.canSharePage()">
<p class="sidebar-tutorial__list-item-content"> <p class="sidebar-tutorial__list-item-content">
To share an annotated page, click the To share an annotated page, click the
<i class="h-icon-annotation-share"></i>&nbsp;button at the top. <i class="h-icon-annotation-share"></i>&nbsp;button at the top.
</p> </p>
</li> </li>
<li class="sidebar-tutorial__list-item"> <li class="sidebar-tutorial__list-item" ng-if="vm.canCreatePrivateGroup()">
<p class="sidebar-tutorial__list-item-content"> <p class="sidebar-tutorial__list-item-content">
To create a private group, select <strong>Public</strong>, To create a private group, select <strong>Public</strong>,
open the dropdown, click&nbsp;<strong>+&nbsp;New&nbsp;group</strong>. open the dropdown, click&nbsp;<strong>+&nbsp;New&nbsp;group</strong>.
......
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