You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by on...@apache.org on 2017/03/15 11:37:06 UTC
ambari git commit: AMBARI-20456. Few breadcrumbs are missing
(onechiporenko)
Repository: ambari
Updated Branches:
refs/heads/trunk 5d20ccd23 -> e34f41ab5
AMBARI-20456. Few breadcrumbs are missing (onechiporenko)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/e34f41ab
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/e34f41ab
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/e34f41ab
Branch: refs/heads/trunk
Commit: e34f41ab5054f480de3fd2610441ebc0dbb92142
Parents: 5d20ccd
Author: Oleg Nechiporenko <on...@apache.org>
Authored: Wed Mar 15 12:51:44 2017 +0200
Committer: Oleg Nechiporenko <on...@apache.org>
Committed: Wed Mar 15 13:28:42 2017 +0200
----------------------------------------------------------------------
.../main/admin/stack_and_upgrade_controller.js | 10 +++
.../app/routes/activate_hawq_standby_routes.js | 4 ++
.../app/routes/add_hawq_standby_routes.js | 4 ++
ambari-web/app/routes/add_kerberos_routes.js | 1 +
.../app/routes/high_availability_routes.js | 4 ++
ambari-web/app/routes/main.js | 46 +++++++-----
.../app/routes/manage_journalnode_routes.js | 4 ++
.../app/routes/ra_high_availability_routes.js | 4 ++
ambari-web/app/routes/reassign_master_routes.js | 8 +++
.../app/routes/remove_hawq_standby_routes.js | 4 ++
.../app/routes/rm_high_availability_routes.js | 4 ++
ambari-web/app/routes/stack_upgrade_routes.js | 13 ++--
ambari-web/app/routes/view.js | 1 +
ambari-web/app/routes/views.js | 10 +--
ambari-web/app/views/common/breadcrumbs_view.js | 37 +++++++++-
.../test/views/common/breadcrumbs_view_test.js | 75 ++++++++++++++++++++
16 files changed, 196 insertions(+), 33 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/e34f41ab/ambari-web/app/controllers/main/admin/stack_and_upgrade_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/admin/stack_and_upgrade_controller.js b/ambari-web/app/controllers/main/admin/stack_and_upgrade_controller.js
index a760f0c..270c5c5 100644
--- a/ambari-web/app/controllers/main/admin/stack_and_upgrade_controller.js
+++ b/ambari-web/app/controllers/main/admin/stack_and_upgrade_controller.js
@@ -143,6 +143,16 @@ App.MainAdminStackAndUpgradeController = Em.Controller.extend(App.LocalStorage,
isWizardRestricted: false,
/**
+ * @type {string}
+ */
+ wizardModalTitle: function () {
+ if (this.get('isDowngrade')) {
+ return Em.I18n.t('admin.stackUpgrade.dialog.downgrade.header').format(this.get('upgradeVersion'));
+ }
+ return Em.I18n.t('admin.stackUpgrade.dialog.header').format(this.get('upgradeTypeDisplayName'), this.get('upgradeVersion'));
+ }.property('upgradeTypeDisplayName', 'upgradeVersion', 'isDowngrade'),
+
+ /**
* methods through which cluster could be upgraded, "allowed" indicated if the method is allowed
* by stack upgrade path
* @type {Array}
http://git-wip-us.apache.org/repos/asf/ambari/blob/e34f41ab/ambari-web/app/routes/activate_hawq_standby_routes.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/routes/activate_hawq_standby_routes.js b/ambari-web/app/routes/activate_hawq_standby_routes.js
index 9ba6073..fae281b 100644
--- a/ambari-web/app/routes/activate_hawq_standby_routes.js
+++ b/ambari-web/app/routes/activate_hawq_standby_routes.js
@@ -21,6 +21,10 @@ var App = require('app');
module.exports = App.WizardRoute.extend({
route: '/highAvailability/Hawq/activate',
+ breadcrumbs: {
+ label: Em.I18n.t('admin.activateHawqStandby.wizard.header')
+ },
+
enter: function (router, transition) {
var activateHawqStandbyWizardController = router.get('activateHawqStandbyWizardController');
activateHawqStandbyWizardController.dataLoading().done(function () {
http://git-wip-us.apache.org/repos/asf/ambari/blob/e34f41ab/ambari-web/app/routes/add_hawq_standby_routes.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/routes/add_hawq_standby_routes.js b/ambari-web/app/routes/add_hawq_standby_routes.js
index 346f506..dde7009 100644
--- a/ambari-web/app/routes/add_hawq_standby_routes.js
+++ b/ambari-web/app/routes/add_hawq_standby_routes.js
@@ -21,6 +21,10 @@ var App = require('app');
module.exports = App.WizardRoute.extend({
route: '/highAvailability/Hawq/add',
+ breadcrumbs: {
+ label: Em.I18n.t('admin.addHawqStandby.wizard.header')
+ },
+
enter: function (router, transition) {
var addHawqStandbyWizardController = router.get('addHawqStandbyWizardController');
addHawqStandbyWizardController.dataLoading().done(function () {
http://git-wip-us.apache.org/repos/asf/ambari/blob/e34f41ab/ambari-web/app/routes/add_kerberos_routes.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/routes/add_kerberos_routes.js b/ambari-web/app/routes/add_kerberos_routes.js
index 462ce44..f556acb 100644
--- a/ambari-web/app/routes/add_kerberos_routes.js
+++ b/ambari-web/app/routes/add_kerberos_routes.js
@@ -19,6 +19,7 @@ var App = require('app');
module.exports = App.WizardRoute.extend({
route: '/enable',
+ breadcrumbs: null,
enter: function (router) {
router.get('mainController').dataLoading().done(function() {
return App.clusterStatus.updateFromServer();
http://git-wip-us.apache.org/repos/asf/ambari/blob/e34f41ab/ambari-web/app/routes/high_availability_routes.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/routes/high_availability_routes.js b/ambari-web/app/routes/high_availability_routes.js
index 8f5fb13..f088c9f 100644
--- a/ambari-web/app/routes/high_availability_routes.js
+++ b/ambari-web/app/routes/high_availability_routes.js
@@ -21,6 +21,10 @@ var App = require('app');
module.exports = App.WizardRoute.extend({
route: '/highAvailability/NameNode/enable',
+ breadcrumbs: {
+ label: Em.I18n.t('admin.highAvailability.wizard.header')
+ },
+
enter: function (router) {
var highAvailabilityWizardController = router.get('highAvailabilityWizardController');
highAvailabilityWizardController.dataLoading().done(function () {
http://git-wip-us.apache.org/repos/asf/ambari/blob/e34f41ab/ambari-web/app/routes/main.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/routes/main.js b/ambari-web/app/routes/main.js
index aace4a2..88776b3 100644
--- a/ambari-web/app/routes/main.js
+++ b/ambari-web/app/routes/main.js
@@ -18,12 +18,6 @@
var App = require('app');
-function getPostFormatLabel(parent) {
- return function (label) {
- return `${parent} - ${label}`;
- }
-}
-
module.exports = Em.Route.extend(App.RouterRedirections, {
breadcrumbs: {
@@ -148,6 +142,9 @@ module.exports = Em.Route.extend(App.RouterRedirections, {
},
widgets: Em.Route.extend({
route: '/metrics',
+ breadcrumbs: {
+ label: Em.I18n.t('common.metrics')
+ },
connectOutlets: function (router, context) {
App.loadTimer.start('Dashboard Metrics Page');
router.set('mainDashboardController.selectedCategory', 'widgets');
@@ -156,6 +153,7 @@ module.exports = Em.Route.extend(App.RouterRedirections, {
}),
charts: Em.Route.extend({
route: '/charts',
+ breadcrumbs: null,
connectOutlets: function (router, context) {
App.loadTimer.start('Heatmaps Page');
router.set('mainDashboardController.selectedCategory', 'charts');
@@ -233,8 +231,7 @@ module.exports = Em.Route.extend(App.RouterRedirections, {
hostDetails: Em.Route.extend({
breadcrumbs: {
- labelBindingPath: 'App.router.mainHostDetailsController.content.hostName',
- disabled: true
+ labelBindingPath: 'App.router.mainHostDetailsController.content.hostName'
},
route: '/:host_id',
@@ -308,6 +305,9 @@ module.exports = Em.Route.extend(App.RouterRedirections, {
}),
stackVersions: Em.Route.extend({
+ breadcrumbs: {
+ label: Em.I18n.t('common.versions')
+ },
route: '/stackVersions',
connectOutlets: function (router, context) {
if (App.get('stackVersionsAvailable')) {
@@ -414,6 +414,9 @@ module.exports = Em.Route.extend(App.RouterRedirections, {
admin: Em.Route.extend({
route: '/admin',
+ breadcrumbs: {
+ disabled: true
+ },
enter: function (router, transition) {
if (router.get('loggedIn') && !App.isAuthorized('CLUSTER.TOGGLE_KERBEROS, SERVICE.SET_SERVICE_USERS_GROUPS, CLUSTER.UPGRADE_DOWNGRADE_STACK, CLUSTER.VIEW_STACK_DETAILS')
&& !(App.get('upgradeInProgress') || App.get('upgradeHolding'))) {
@@ -452,8 +455,7 @@ module.exports = Em.Route.extend(App.RouterRedirections, {
adminKerberos: Em.Route.extend({
breadcrumbs: {
- label: Em.I18n.t('common.kerberos'),
- labelPostFormat: getPostFormatLabel('Admin')
+ label: Em.I18n.t('common.kerberos')
},
route: '/kerberos',
@@ -562,6 +564,7 @@ module.exports = Em.Route.extend(App.RouterRedirections, {
stackAndUpgrade: Em.Route.extend({
route: '/stack',
+ breadcrumbs: null,
connectOutlets: function (router) {
router.set('mainAdminController.category', "stackAndUpgrade");
router.set('mainAdminController.categoryLabel', Em.I18n.t('admin.stackUpgrade.title'));
@@ -576,8 +579,7 @@ module.exports = Em.Route.extend(App.RouterRedirections, {
services: Em.Route.extend({
breadcrumbs: {
- label: Em.I18n.t('admin.stackUpgrade.title'),
- labelPostFormat: getPostFormatLabel('Admin')
+ label: Em.I18n.t('common.stack')
},
route: '/services',
@@ -587,6 +589,9 @@ module.exports = Em.Route.extend(App.RouterRedirections, {
}),
versions: Em.Route.extend({
+ breadcrumbs: {
+ label: Em.I18n.t('common.versions')
+ },
route: '/versions',
connectOutlets: function (router, context) {
router.get('mainAdminStackAndUpgradeController').connectOutlet('MainAdminStackVersions');
@@ -594,6 +599,11 @@ module.exports = Em.Route.extend(App.RouterRedirections, {
}),
upgradeHistory: Em.Route.extend({
+
+ breadcrumbs: {
+ label: Em.I18n.t('common.upgrade.history')
+ },
+
route: '/history',
connectOutlets: function (router, context) {
router.get('mainAdminStackAndUpgradeController').connectOutlet('mainAdminStackUpgradeHistory');
@@ -619,8 +629,7 @@ module.exports = Em.Route.extend(App.RouterRedirections, {
adminServiceAccounts: Em.Route.extend({
breadcrumbs: {
- label: Em.I18n.t('common.serviceAccounts'),
- labelPostFormat: getPostFormatLabel('Admin')
+ label: Em.I18n.t('common.serviceAccounts')
},
route: '/serviceAccounts',
@@ -639,8 +648,7 @@ module.exports = Em.Route.extend(App.RouterRedirections, {
adminServiceAutoStart: Em.Route.extend({
breadcrumbs: {
- label: Em.I18n.t('admin.serviceAutoStart.title'),
- labelPostFormat: getPostFormatLabel('Admin')
+ label: Em.I18n.t('admin.serviceAutoStart.title')
},
route: '/serviceAutoStart',
@@ -728,8 +736,6 @@ module.exports = Em.Route.extend(App.RouterRedirections, {
services: Em.Route.extend({
breadcrumbs: {
- labelBindingPath: 'App.router.mainServiceItemController.content.displayName',
- labelPostFormat: getPostFormatLabel('Service'),
disabled: true
},
@@ -762,6 +768,10 @@ module.exports = Em.Route.extend(App.RouterRedirections, {
},
service: Em.Route.extend({
route: '/:service_id',
+ breadcrumbs: {
+ labelBindingPath: 'App.router.mainServiceItemController.content.displayName',
+ disabled: true
+ },
connectOutlets: function (router, service) {
router.get('mainServiceController').connectOutlet('mainServiceItem', service);
if (service.get('isLoaded')) {
http://git-wip-us.apache.org/repos/asf/ambari/blob/e34f41ab/ambari-web/app/routes/manage_journalnode_routes.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/routes/manage_journalnode_routes.js b/ambari-web/app/routes/manage_journalnode_routes.js
index 90b45b0..16e019a 100644
--- a/ambari-web/app/routes/manage_journalnode_routes.js
+++ b/ambari-web/app/routes/manage_journalnode_routes.js
@@ -21,6 +21,10 @@ var App = require('app');
module.exports = App.WizardRoute.extend({
route: '/highAvailability/JournalNode/manage',
+ breadcrumbs: {
+ label: Em.I18n.t('admin.manageJournalNode.wizard.header')
+ },
+
enter: function (router) {
var manageJournalNodeWizardController = router.get('manageJournalNodeWizardController');
manageJournalNodeWizardController.dataLoading().done(function () {
http://git-wip-us.apache.org/repos/asf/ambari/blob/e34f41ab/ambari-web/app/routes/ra_high_availability_routes.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/routes/ra_high_availability_routes.js b/ambari-web/app/routes/ra_high_availability_routes.js
index 5be6c44..d2bea4e 100644
--- a/ambari-web/app/routes/ra_high_availability_routes.js
+++ b/ambari-web/app/routes/ra_high_availability_routes.js
@@ -21,6 +21,10 @@ var App = require('app');
module.exports = App.WizardRoute.extend({
route: '/highAvailability/RangerAdmin/enable',
+ breadcrumbs: {
+ label: Em.I18n.t('admin.ra_highAvailability.wizard.header')
+ },
+
enter: function (router) {
var rAHighAvailabilityWizardController = router.get('rAHighAvailabilityWizardController');
rAHighAvailabilityWizardController.dataLoading().done(function () {
http://git-wip-us.apache.org/repos/asf/ambari/blob/e34f41ab/ambari-web/app/routes/reassign_master_routes.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/routes/reassign_master_routes.js b/ambari-web/app/routes/reassign_master_routes.js
index 341172b..374bd53 100644
--- a/ambari-web/app/routes/reassign_master_routes.js
+++ b/ambari-web/app/routes/reassign_master_routes.js
@@ -26,6 +26,14 @@ module.exports = App.WizardRoute.extend({
reassignMasterController.resetOnClose(reassignMasterController, 'main.index');
},
+ breadcrumbs: {
+ labelBindingPath: 'App.router.reassignMasterController.content.reassign.display_name',
+ labelPostFormat(label) {
+ let msg = Em.I18n.t('services.reassign.header');
+ return label ? `${msg} (${label})` : msg;
+ }
+ },
+
enter: function (router) {
var context = this;
var reassignMasterController = router.get('reassignMasterController');
http://git-wip-us.apache.org/repos/asf/ambari/blob/e34f41ab/ambari-web/app/routes/remove_hawq_standby_routes.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/routes/remove_hawq_standby_routes.js b/ambari-web/app/routes/remove_hawq_standby_routes.js
index 64250ee..608274a 100644
--- a/ambari-web/app/routes/remove_hawq_standby_routes.js
+++ b/ambari-web/app/routes/remove_hawq_standby_routes.js
@@ -21,6 +21,10 @@ var App = require('app');
module.exports = App.WizardRoute.extend({
route: '/highAvailability/Hawq/remove',
+ breadcrumbs: {
+ label: Em.I18n.t('admin.removeHawqStandby.wizard.header')
+ },
+
enter: function (router, transition) {
var removeHawqStandbyWizardController = router.get('removeHawqStandbyWizardController');
removeHawqStandbyWizardController.dataLoading().done(function () {
http://git-wip-us.apache.org/repos/asf/ambari/blob/e34f41ab/ambari-web/app/routes/rm_high_availability_routes.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/routes/rm_high_availability_routes.js b/ambari-web/app/routes/rm_high_availability_routes.js
index d8aa8b3..7b0cf99 100644
--- a/ambari-web/app/routes/rm_high_availability_routes.js
+++ b/ambari-web/app/routes/rm_high_availability_routes.js
@@ -21,6 +21,10 @@ var App = require('app');
module.exports = App.WizardRoute.extend({
route: '/highAvailability/ResourceManager/enable',
+ breadcrumbs: {
+ label: Em.I18n.t('admin.rm_highAvailability.wizard.header')
+ },
+
enter: function (router, transition) {
var rMHighAvailabilityWizardController = router.get('rMHighAvailabilityWizardController');
rMHighAvailabilityWizardController.dataLoading().done(function () {
http://git-wip-us.apache.org/repos/asf/ambari/blob/e34f41ab/ambari-web/app/routes/stack_upgrade_routes.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/routes/stack_upgrade_routes.js b/ambari-web/app/routes/stack_upgrade_routes.js
index f95dd6e..ea40a1b 100644
--- a/ambari-web/app/routes/stack_upgrade_routes.js
+++ b/ambari-web/app/routes/stack_upgrade_routes.js
@@ -21,6 +21,10 @@ var App = require('app');
module.exports = App.WizardRoute.extend({
route: 'stack/upgrade',
+ breadcrumbs: {
+ label: 'App.router.mainAdminStackAndUpgradeController.wizardModalTitle'
+ },
+
enter: function (router) {
if (App.isAuthorized('CLUSTER.UPGRADE_DOWNGRADE_STACK')) {
router.get('mainController').dataLoading().done(function () {
@@ -36,14 +40,7 @@ module.exports = App.WizardRoute.extend({
return App.ModalPopup.show({
classNames: ['upgrade-wizard-modal'],
modalDialogClasses: ['modal-xlg'],
- header: function () {
- var controller = App.router.get('mainAdminStackAndUpgradeController');
- if (controller.get('isDowngrade')) {
- return Em.I18n.t('admin.stackUpgrade.dialog.downgrade.header').format(controller.get('upgradeVersion'));
- } else {
- return Em.I18n.t('admin.stackUpgrade.dialog.header').format(controller.get('upgradeTypeDisplayName'), controller.get('upgradeVersion'));
- }
- }.property('App.router.mainAdminStackAndUpgradeController.upgradeVersion', 'App.router.mainAdminStackAndUpgradeController.isDowngrade'),
+ header: Em.computed.alias('App.router.mainAdminStackAndUpgradeController.wizardModalTitle'),
bodyClass: App.upgradeWizardView,
primary: Em.I18n.t('common.dismiss'),
secondary: null,
http://git-wip-us.apache.org/repos/asf/ambari/blob/e34f41ab/ambari-web/app/routes/view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/routes/view.js b/ambari-web/app/routes/view.js
index 22a4057..54e7cb5 100644
--- a/ambari-web/app/routes/view.js
+++ b/ambari-web/app/routes/view.js
@@ -46,6 +46,7 @@ module.exports = Em.Route.extend({
shortViewDetails: Em.Route.extend({
route: '/:viewName/:shortName',
+ breadcrumbs: null,
connectOutlets: function (router, params) {
var viewPath = this.parseViewPath(window.location.href.slice(window.location.href.indexOf('?')));
var slicedShortName = params.shortName;
http://git-wip-us.apache.org/repos/asf/ambari/blob/e34f41ab/ambari-web/app/routes/views.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/routes/views.js b/ambari-web/app/routes/views.js
index 073507c..0300ee9 100644
--- a/ambari-web/app/routes/views.js
+++ b/ambari-web/app/routes/views.js
@@ -20,11 +20,7 @@ var App = require('app');
module.exports = Em.Route.extend({
- breadcrumbs: {
- transition() {
- App.router.route('views');
- }
- },
+ breadcrumbs: null,
route: '/views',
enter: function (router) {
@@ -48,6 +44,10 @@ module.exports = Em.Route.extend({
Em.$('body').addClass('contribview');
},
+ breadcrumbs: {
+ labelBindingPath: 'App.router.mainViewsDetailsController.content.label'
+ },
+
exit:function (router) {
this._super();
Em.$('body').removeClass('contribview');
http://git-wip-us.apache.org/repos/asf/ambari/blob/e34f41ab/ambari-web/app/views/common/breadcrumbs_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/common/breadcrumbs_view.js b/ambari-web/app/views/common/breadcrumbs_view.js
index f9073ba..e35a196 100644
--- a/ambari-web/app/views/common/breadcrumbs_view.js
+++ b/ambari-web/app/views/common/breadcrumbs_view.js
@@ -18,11 +18,25 @@
var App = require('app');
+/**
+ * @param {string} labelBindingPath
+ * @returns {string}
+ * @private
+ */
function _getLabelPathWithoutApp(labelBindingPath) {
return labelBindingPath.startsWith('App.') ? labelBindingPath.replace('App.', '') : labelBindingPath;
}
/**
+ * @param {string} stateName
+ * @returns {string}
+ * @private
+ */
+function _formatLabel(stateName) {
+ return stateName.capitalize().replace(/([a-z])([A-Z])/g, '$1 $2');
+}
+
+/**
* Don't create instances directly
* Only <code>App.BreadcrumbsView</code>-instance will create them
*
@@ -155,8 +169,26 @@ App.BreadcrumbsView = Em.View.extend({
let currentState = App.get('router.currentState');
let items = [];
while (currentState) {
- if (currentState.breadcrumbs) {
- items.pushObject(currentState.breadcrumbs);
+ if (currentState.breadcrumbs !== undefined) {
+ // breadcrumbs should be defined and be not null or any other falsie-value
+ if (currentState.breadcrumbs) {
+ const {label, labelBindingPath, route, disabled} = currentState.breadcrumbs;
+ // generate label if it isn't provided
+ if (!label && !labelBindingPath) {
+ currentState.breadcrumbs.label = _formatLabel(currentState.name);
+ }
+ // generate route if it isn't provided and breadcrumb is not disabled
+ if (!route && !disabled) {
+ currentState.breadcrumbs.route = currentState.absoluteRoute(App.router).replace('/main/', '');
+ }
+ items.pushObject(currentState.breadcrumbs);
+ }
+ }
+ else {
+ // generate breadcrumb if it is not defined
+ if (currentState.name && !['root', 'index'].contains(currentState.name)) {
+ items.pushObject({label: _formatLabel(currentState.name)});
+ }
}
currentState = currentState.get('parentState');
}
@@ -173,6 +205,7 @@ App.BreadcrumbsView = Em.View.extend({
/**
* Move user to the route described in the breadcrumb item
* <code>beforeTransition</code> hook is executed
+ * <code>afterTransition</code> hook is executed
*
* @param {{context: App.BreadcrumbItem}} event
* @returns {*}
http://git-wip-us.apache.org/repos/asf/ambari/blob/e34f41ab/ambari-web/test/views/common/breadcrumbs_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/common/breadcrumbs_view_test.js b/ambari-web/test/views/common/breadcrumbs_view_test.js
index 751811c..eff19f6 100644
--- a/ambari-web/test/views/common/breadcrumbs_view_test.js
+++ b/ambari-web/test/views/common/breadcrumbs_view_test.js
@@ -34,4 +34,79 @@ describe('App.BreadcrumbItem', function () {
});
+});
+
+function getCurrentState(parentStateProps, currentStateProps) {
+ var parentState = Em.Route.create(parentStateProps);
+ var currentState = Em.Route.create(currentStateProps);
+ currentState.set('parentState', parentState);
+ currentState.set('parentState.parentState', null);
+ return currentState;
+}
+
+var view;
+describe('App.BreadcrumbsView', function () {
+
+ beforeEach(function () {
+ view = App.BreadcrumbsView.create();
+ });
+
+ describe('#items', function () {
+ var currentState;
+
+ beforeEach(function () {
+ sinon.stub(App, 'get', function (key) {
+ if (key === 'router.currentState') {
+ return currentState;
+ }
+ return Em.get(App, key);
+ });
+ });
+
+ afterEach(function () {
+ App.get.restore();
+ });
+
+ it('predefined label', function () {
+ currentState = getCurrentState({}, {name: '', breadcrumbs: {label: 'abc'}});
+ expect(view.get('items.firstObject.formattedLabel')).to.be.equal('abc');
+ });
+
+ it('`name` as label', function () {
+ currentState = getCurrentState({}, {name: 'abc abc', breadcrumbs: {}});
+ expect(view.get('items.firstObject.formattedLabel')).to.be.equal('Abc abc');
+ });
+
+ it('label binding', function () {
+ App.set('somePath', 'abc');
+ currentState = getCurrentState({}, {name: '', breadcrumbs: {labelBindingPath: 'App.somePath'}});
+ expect(view.get('items.firstObject.formattedLabel')).to.be.equal('abc');
+ App.set('somePath', 'cba');
+ expect(view.get('items.firstObject.formattedLabel')).to.be.equal('cba');
+ });
+
+ it('`index` route is ignored', function () {
+ currentState = getCurrentState({}, {name: 'index'});
+ expect(view.get('items')).to.be.empty;
+ });
+
+ it('`root` route is ignored', function () {
+ currentState = getCurrentState({}, {name: 'root'});
+ expect(view.get('items')).to.be.empty;
+ });
+
+ it('last item is disabled by default', function () {
+ currentState = getCurrentState({breadcrumbs: {label: 'parent'}}, {breadcrumbs: {label: 'child'}});
+ expect(view.get('items.length')).to.be.equal(2);
+ expect(view.get('items.lastObject.disabled')).to.be.true;
+ });
+
+ it('last item `isLast` is true', function () {
+ currentState = getCurrentState({breadcrumbs: {label: 'parent'}}, {breadcrumbs: {label: 'child'}});
+ expect(view.get('items.length')).to.be.equal(2);
+ expect(view.get('items.lastObject.isLast')).to.be.true;
+ });
+
+ });
+
});
\ No newline at end of file