This repository has been archived by the owner on May 12, 2021. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create an added services view under /services.
The new view displays in the sidebar, along with the search widget.
- Loading branch information
Kyle Adams
committed
Oct 7, 2014
1 parent
ecad629
commit fb9202d
Showing
9 changed files
with
325 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<div class="search-widget"></div> | ||
<div class="services-list"> | ||
List added services here. | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/* | ||
This file is part of the Juju GUI, which lets users view and manage Juju | ||
environments within a graphical interface (https://launchpad.net/juju-gui). | ||
Copyright (C) 2012-2013 Canonical Ltd. | ||
This program is free software: you can redistribute it and/or modify it under | ||
the terms of the GNU Affero General Public License version 3, as published by | ||
the Free Software Foundation. | ||
This program is distributed in the hope that it will be useful, but WITHOUT | ||
ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, | ||
SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero | ||
General Public License for more details. | ||
You should have received a copy of the GNU Affero General Public License along | ||
with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
'use strict'; | ||
|
||
/* | ||
Sidebar added services view. | ||
@module juju.views | ||
*/ | ||
YUI.add('juju-addedservices', function(Y) { | ||
var ns = Y.namespace('juju.browser.views'), | ||
views = Y.namespace('juju.views'), | ||
Templates = views.Templates; | ||
|
||
ns.AddedServices = Y.Base.create('addedservices', Y.View, [ | ||
views.SearchWidgetMgmtExtension | ||
], { | ||
|
||
template: Templates.addedservices, | ||
|
||
/** | ||
Sets the default properties. | ||
@method initializer | ||
*/ | ||
initializer: function() { | ||
this.searchWidget = null; | ||
}, | ||
|
||
/** | ||
Renders the added services list. | ||
This method should always be idempotent. | ||
@method render | ||
*/ | ||
render: function() { | ||
var container = this.get('container'); | ||
container.setHTML(this.template()); | ||
// Provided by 'search-widget-mgmt-extension'. | ||
this._renderSearchWidget(); | ||
}, | ||
|
||
/** | ||
Destroys the rendered tokens. | ||
@method destructor | ||
*/ | ||
destructor: function() { | ||
this.get('container').remove(true); | ||
} | ||
}, | ||
{ | ||
ATTRS: { | ||
} | ||
}); | ||
|
||
}, '', { | ||
requires: [ | ||
'search-widget-mgmt-extension', | ||
'view' | ||
] | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
/* | ||
This file is part of the Juju GUI, which lets users view and manage Juju | ||
environments within a graphical interface (https://launchpad.net/juju-gui). | ||
Copyright (C) 2012-2013 Canonical Ltd. | ||
This program is free software: you can redistribute it and/or modify it under | ||
the terms of the GNU Affero General Public License version 3, as published by | ||
the Free Software Foundation. | ||
This program is distributed in the hope that it will be useful, but WITHOUT | ||
ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, | ||
SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero | ||
General Public License for more details. | ||
You should have received a copy of the GNU Affero General Public License along | ||
with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
'use strict'; | ||
|
||
describe('added services view', function() { | ||
var Y, view, View, utils; | ||
|
||
before(function(done) { | ||
Y = YUI(GlobalConfig).use( | ||
'juju-tests-utils', | ||
'juju-addedservices', | ||
function(Y) { | ||
utils = Y.namespace('juju-tests.utils'); | ||
View = Y.juju.browser.views.AddedServices; | ||
done(); | ||
}); | ||
}); | ||
|
||
beforeEach(function() { | ||
view = new View(); | ||
}); | ||
|
||
afterEach(function(done) { | ||
if (view) { | ||
view.after('destroy', function() { done(); }); | ||
view.destroy(); | ||
} | ||
}); | ||
|
||
it('is extended by the search widget', function() { | ||
assert.notEqual(view._renderSearchWidget, undefined); | ||
}); | ||
|
||
describe('render', function() { | ||
var renderSearch; | ||
|
||
beforeEach(function() { | ||
renderSearch = utils.makeStubMethod(view, '_renderSearchWidget'); | ||
this._cleanups.push(renderSearch.reset); | ||
}); | ||
|
||
it('appends the template to the container', function() { | ||
view.render(); | ||
var container = view.get('container'); | ||
assert.notEqual(container.one('.search-widget'), null); | ||
assert.notEqual(container.one('.services-list'), null); | ||
}); | ||
|
||
it('calls to render the search widget on render', function() { | ||
view.render(); | ||
assert.equal(renderSearch.calledOnce(), true); | ||
}); | ||
}); | ||
|
||
describe('destroy', function() { | ||
|
||
it('removes the container from the DOM', function() { | ||
view.render(); | ||
var container = view.get('container'); | ||
assert.notEqual(container.getDOMNode(), null, | ||
'Container is not present in DOM.'); | ||
assert.notEqual(container.one('.services-list'), null, | ||
'Template HTML is not present in DOM'); | ||
view.destroy(); | ||
assert.equal(container.getDOMNode(), null, | ||
'Container is still present in DOM'); | ||
assert.equal(container.one('.services-list'), null, | ||
'Template HTML is still present in DOM'); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.