Commit d5a04537 authored by Nick Stenning's avatar Nick Stenning

Replace "firstRun" config option with "openSidebar" and "openLoginForm"

This commit deprecates the confusingly-named "firstRun" embed script
option with two which actually describe the relevant actions triggered.

Unfortunately, at the moment this requires a fairly horrific check that
the string value of a config option is not the literal 'false', due to
the way that the Host code passes configuration from the page frame to
the sidebar frame (using URL query string parameters).
parent c928e4fe
......@@ -24,7 +24,7 @@ module.exports = class Sidebar extends Host
super
this.hide()
if options.firstRun || options.annotations
if options.openSidebar || options.annotations
this.on 'panelReady', => this.show()
if @plugins.BucketBar?
......
......@@ -55,12 +55,12 @@ describe('annotator configuration', function () {
it('merges the config from hypothesisConfig()', function () {
var fakeWindow = Object.assign({}, fakeWindowBase, {
hypothesisConfig: function () {
return {firstRun: true};
return {foo: true};
},
});
assert.deepEqual(config(fakeWindow), {
app: 'app.html',
firstRun: true,
foo: true,
});
});
......
......@@ -79,7 +79,11 @@ module.exports = function AppController(
// update the auth info in the top bar and show the login form
// after first install of the extension.
$scope.auth = authStateFromUserID(state.userid);
if (!state.userid && settings.firstRun) {
// FIXME: Fix this horrendous !== 'false' conditional. Unfortunately, we
// currently pass settings from the hosting page into the sidebar via the
// URL query string, so type information is lost. Ugh.
if (!state.userid && settings.openLoginForm && settings.openLoginForm !== 'false') {
$scope.login();
}
});
......
......@@ -94,7 +94,6 @@ describe('AppController', function () {
};
fakeSettings = {
firstRun: false,
serviceUrl: 'http://fake.service.com/',
};
......
......@@ -45,7 +45,7 @@ function LiveReloadServer(port, appServer) {
liveReloadServer: 'ws://' + appHost + ':${port}',
// Open the sidebar when the page loads
firstRun: true,
openSidebar: true,
};
};
......
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