Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

Render deployer bar and environment switcher by default #587

Merged
merged 2 commits into from Sep 29, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
37 changes: 2 additions & 35 deletions app/app.js
Expand Up @@ -565,10 +565,8 @@ YUI.add('juju-gui', function(Y) {
this.dispatch();
}
this._renderHelpDropdownView();
if (window.flags.mv) {
this._renderDeployerBarView();
this._renderEnvironmentHeaderView();
}
this._renderDeployerBarView();
this._renderEnvironmentHeaderView();
}, this);

this.zoomMessageHandler = Y.one(Y.config.win).on('resize', function(e) {
Expand All @@ -594,37 +592,6 @@ YUI.add('juju-gui', function(Y) {
}
}, this);

if (!window.flags.mv) {
var exportNode = Y.one('#export-trigger');
// Tests won't have this node.
if (exportNode) {
exportNode.on('click', function(e) {
e.halt();
importHelpers.exportYAML(this.db);
}, this);
}

var importNode = Y.one('#import-trigger');
var importFileInput = Y.one('.import-export input[type=file]');

// Tests won't have this node.
if (importNode && importFileInput) {
importNode.on('click', function(e) {
e.halt();
e.currentTarget.siblings('input[type=file]')
.item(0).getDOMNode().click();
});

importFileInput.on('change', function(e) {
importHelpers.deployBundleFiles(
e.currentTarget.get('files')._nodes,
this.env,
this.db
);
}, this);
}
}

// Attach SubApplications. The subapps should share the same db.
cfg.db = this.db;

Expand Down
76 changes: 54 additions & 22 deletions test/test_app.js
Expand Up @@ -55,13 +55,18 @@ function injectData(app, data) {
var Y, app, container, utils, juju, env, conn;

before(function(done) {
Y = YUI(GlobalConfig).use(
['juju-gui', 'juju-tests-utils', 'juju-view-utils', 'juju-views'],
function(Y) {
utils = Y.namespace('juju-tests.utils');
juju = Y.namespace('juju');
done();
});
Y = YUI(GlobalConfig).use([
'juju-gui',
'juju-tests-utils',
'juju-view-utils',
'juju-views',
'environment-change-set'
],
function(Y) {
utils = Y.namespace('juju-tests.utils');
juju = Y.namespace('juju');
done();
});
});

beforeEach(function() {
Expand All @@ -87,14 +92,18 @@ function injectData(app, data) {
app.destroy();
});

function constructAppInstance(config) {
function constructAppInstance(config, context) {
config = config || {};
if (config.env && config.env.connect) {
config.env.connect();
}
config.container = container;
config.viewContainer = container;

if (context) {
var _renderDeployerBarView = utils.makeStubMethod(
Y.juju.App.prototype, '_renderDeployerBarView');
context._cleanups.push(_renderDeployerBarView.reset);
}
app = new Y.juju.App(config);
app.navigate = function() {};
app.showView(new Y.View());
Expand All @@ -106,7 +115,7 @@ function injectData(app, data) {
function() {
constructAppInstance({
env: juju.newEnvironment({ conn: new utils.SocketStub() })
});
}, this);
assert.equal(app.env.get('user'), undefined);
assert.equal(app.env.get('password'), undefined);
});
Expand All @@ -127,6 +136,9 @@ function injectData(app, data) {
function(done) {
var the_username = 'nehi';
var the_password = 'moonpie';
var _renderDeployerBarView = utils.makeStubMethod(
Y.juju.App.prototype, '_renderDeployerBarView');
this._cleanups.push(_renderDeployerBarView.reset);
app = new Y.juju.App(
{ container: container,
user: the_username,
Expand All @@ -142,6 +154,9 @@ function injectData(app, data) {
});

it('propagates the readOnly option from the configuration', function() {
var _renderDeployerBarView = utils.makeStubMethod(
Y.juju.App.prototype, '_renderDeployerBarView');
this._cleanups.push(_renderDeployerBarView.reset);
app = new Y.juju.App({
container: container,
readOnly: true,
Expand All @@ -154,7 +169,7 @@ function injectData(app, data) {
it('should produce a valid index', function() {
constructAppInstance({
env: juju.newEnvironment({ conn: new utils.SocketStub() })
});
}, this);
var container = app.get('container');
container.getAttribute('id').should.equal('test-container');
container.getAttribute('class').should.include('container');
Expand All @@ -170,7 +185,7 @@ function injectData(app, data) {
}
}),
environment_name: environment_name
});
}, this);
assert.equal(
container.one('#environment-name').get('text'),
environment_name);
Expand Down Expand Up @@ -199,7 +214,7 @@ function injectData(app, data) {
close: function() {}
}
})
});
}, this);
var name = 'Sandbox';
assert.equal(
'Environment',
Expand All @@ -216,7 +231,7 @@ function injectData(app, data) {
close: function() {}
}
})
});
}, this);

// XXX bug:1217383
// Force an app._controlEvents so that we don't try to bind viewmode
Expand Down Expand Up @@ -244,7 +259,10 @@ function injectData(app, data) {

it('should display a zoom message on small browsers', function() {
constructAppInstance({
env: juju.newEnvironment({ conn: new utils.SocketStub() })
env: juju.newEnvironment({
conn: new utils.SocketStub(),
ecs: new juju.EnvironmentChangeSet()
})
});
app._displayZoomMessage(1024, 'linux');
assert.equal(app.db.notifications.item(0).get('title'),
Expand All @@ -253,7 +271,10 @@ function injectData(app, data) {

it('should not display the zoom message more than once', function() {
constructAppInstance({
env: juju.newEnvironment({ conn: new utils.SocketStub() })
env: juju.newEnvironment({
conn: new utils.SocketStub(),
ecs: new juju.EnvironmentChangeSet()
})
});
assert.equal(app.db.notifications.size(), 0);
app._displayZoomMessage(1024, 'linux');
Expand All @@ -265,7 +286,10 @@ function injectData(app, data) {

it('should show the correct message on a mac', function() {
constructAppInstance({
env: juju.newEnvironment({ conn: new utils.SocketStub() })
env: juju.newEnvironment({
conn: new utils.SocketStub(),
ecs: new juju.EnvironmentChangeSet()
})
});
app._displayZoomMessage(1024, 'macintosh');
assert.isTrue(app.db.notifications.item(0).get(
Expand All @@ -274,7 +298,10 @@ function injectData(app, data) {

it('should show the correct message for non mac', function() {
constructAppInstance({
env: juju.newEnvironment({ conn: new utils.SocketStub() })
env: juju.newEnvironment({
conn: new utils.SocketStub(),
ecs: new juju.EnvironmentChangeSet()
})
});
app._displayZoomMessage(1024, 'linux');
assert.isTrue(app.db.notifications.item(0).get(
Expand Down Expand Up @@ -324,6 +351,9 @@ describe('File drag over notification system', function() {
.append(Y.Node.create('<span/>')
.set('id', 'environment-name'))
.hide();
var _renderDeployerBarView = testUtils.makeStubMethod(
Y.juju.App.prototype, '_renderDeployerBarView');
this._cleanups.push(_renderDeployerBarView.reset);
});

afterEach(function(done) {
Expand Down Expand Up @@ -545,8 +575,9 @@ describe('File drag over notification system', function() {

describe('Application authentication', function() {
var FAKE_VIEW_NAME, LOGIN_VIEW_NAME;
var conn, container, destroyMe, env, juju, utils, Y;
var requirements = ['juju-gui', 'juju-tests-utils', 'juju-views'];
var conn, container, destroyMe, ecs, env, juju, utils, Y;
var requirements = [
'juju-gui', 'juju-tests-utils', 'juju-views', 'environment-change-set'];

before(function(done) {
Y = YUI(GlobalConfig).use(requirements, function(Y) {
Expand All @@ -561,9 +592,10 @@ describe('File drag over notification system', function() {
beforeEach(function(done) {
container = utils.makeContainer(this, 'container');
conn = new utils.SocketStub();
env = juju.newEnvironment({conn: conn});
ecs = new juju.EnvironmentChangeSet();
env = juju.newEnvironment({conn: conn, ecs: ecs});
env.setCredentials({user: 'user', password: 'password'});
destroyMe = [env];
destroyMe = [env, ecs];
done();
});

Expand Down
3 changes: 3 additions & 0 deletions test/test_app_hotkeys.js
Expand Up @@ -38,6 +38,9 @@ describe('application hotkeys', function() {

beforeEach(function() {
container = Y.namespace('juju-tests.utils').makeContainer(this);
var _renderDeployerBarView = Y.namespace('juju-tests.utils').makeStubMethod(
Y.juju.App.prototype, '_renderDeployerBarView');
this._cleanups.push(_renderDeployerBarView.reset);
app = new Y.juju.App({
env: env,
container: container,
Expand Down
21 changes: 15 additions & 6 deletions test/test_endpoints.js
Expand Up @@ -22,7 +22,7 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
// the addition of puppet subordinate relations.

describe('Relation endpoints logic', function() {
var Y, juju, utils, db, app, models, sample_endpoints, sample_env, env;
var Y, juju, utils, db, app, models, sample_endpoints, sample_env, env, ecs;

before(function(done) {
Y = YUI(GlobalConfig).use([
Expand All @@ -40,12 +40,14 @@ describe('Relation endpoints logic', function() {
'juju-models',
'juju-gui',
'juju-tests-utils',
'juju-controllers'],
'juju-controllers',
'environment-change-set'],
function(Y) {
juju = Y.namespace('juju');
models = Y.namespace('juju.models');
var conn = new utils.SocketStub();
env = juju.newEnvironment({conn: conn});
ecs = new juju.EnvironmentChangeSet();
env = juju.newEnvironment({conn: conn, ecs: ecs});
env.connect();
app = new Y.juju.App({env: env});
app.navigate = function() { return true; };
Expand Down Expand Up @@ -309,7 +311,8 @@ describe('Endpoints map', function() {
});

describe('Endpoints map handlers', function() {
var app, conn, controller, destroyMe, env, factory, juju, models, utils, Y;
var app, conn, controller, destroyMe, ecs, _renderDeployerBarView,
env, factory, juju, models, utils, Y;

before(function(done) {
Y = YUI(GlobalConfig).use(['juju-gui',
Expand All @@ -333,8 +336,12 @@ describe('Endpoints map handlers', function() {
destroyMe = [];
conn = new utils.SocketStub();
env = juju.newEnvironment({conn: conn});
env.setCredentials({user: 'user', password: 'password'});
env.connect();
destroyMe.push(env);
var _renderDeployerBarView = utils.makeStubMethod(
Y.juju.App.prototype, '_renderDeployerBarView');
this._cleanups.push(_renderDeployerBarView.reset);
app = new Y.juju.App({
env: env,
consoleEnabled: true,
Expand Down Expand Up @@ -506,7 +513,8 @@ describe('Service config handlers', function() {
'juju-endpoints-controller',
'juju-controllers',
'juju-charm-store',
'datasource-local'],
'datasource-local',
'environment-change-set'],
function(Y) {
juju = Y.namespace('juju');
utils = Y.namespace('juju-tests.utils');
Expand All @@ -518,7 +526,8 @@ describe('Service config handlers', function() {
beforeEach(function() {
destroyMe = [];
conn = new utils.SocketStub();
env = juju.newEnvironment({conn: conn});
var ecs = new juju.EnvironmentChangeSet();
env = juju.newEnvironment({conn: conn, ecs: ecs});
env.connect();
app = new Y.juju.App({env: env, consoleEnabled: true });
destroyMe.push(app);
Expand Down
9 changes: 6 additions & 3 deletions test/test_notifications.js
Expand Up @@ -84,7 +84,8 @@ describe('notifications', function() {
'juju-env',
'node-event-simulate',
'juju-tests-utils',
'ns-routing-app-extension'],
'ns-routing-app-extension',
'environment-change-set'],

function(Y) {
juju = Y.namespace('juju');
Expand Down Expand Up @@ -216,7 +217,8 @@ describe('notifications', function() {
var container = Y.Node.create(
'<div id="test" class="container"></div>'),
conn = new(Y.namespace('juju-tests.utils')).SocketStub(),
env = juju.newEnvironment({conn: conn}, 'python');
ecs = new juju.EnvironmentChangeSet(),
env = juju.newEnvironment({conn: conn, ecs: ecs}, 'python');
app = new Y.juju.App({
env: env,
container: container,
Expand Down Expand Up @@ -260,7 +262,8 @@ describe('notifications', function() {
var container = Y.Node.create(
'<div id="test" class="container"></div>');
var conn = new(Y.namespace('juju-tests.utils')).SocketStub();
var env = juju.newEnvironment({conn: conn}, 'python');
var ecs = new juju.EnvironmentChangeSet();
var env = juju.newEnvironment({conn: conn, ecs: ecs}, 'python');
env.connect();
app = new Y.juju.App({
env: env,
Expand Down