You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ab...@apache.org on 2015/01/23 13:06:15 UTC
ambari git commit: AMBARI-9293 Versions: Filtering on stack versions
should remove "Installed" option. (ababiichuk)
Repository: ambari
Updated Branches:
refs/heads/trunk 474cfcd3d -> 69bc4f02a
AMBARI-9293 Versions: Filtering on stack versions should remove "Installed" option. (ababiichuk)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/69bc4f02
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/69bc4f02
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/69bc4f02
Branch: refs/heads/trunk
Commit: 69bc4f02af367c8fe0299c61be54d66bd3bba6ee
Parents: 474cfcd
Author: aBabiichuk <ab...@cybervisiontech.com>
Authored: Fri Jan 23 13:43:17 2015 +0200
Committer: aBabiichuk <ab...@cybervisiontech.com>
Committed: Fri Jan 23 13:43:37 2015 +0200
----------------------------------------------------------------------
ambari-web/app/assets/test/tests.js | 1 +
.../main/admin/stack_upgrade/versions_view.js | 27 ++--
.../admin/stack_upgrade/version_view_test.js | 149 +++++++++++++++++++
3 files changed, 159 insertions(+), 18 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/69bc4f02/ambari-web/app/assets/test/tests.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/assets/test/tests.js b/ambari-web/app/assets/test/tests.js
index 674f676..5d21495 100644
--- a/ambari-web/app/assets/test/tests.js
+++ b/ambari-web/app/assets/test/tests.js
@@ -170,6 +170,7 @@ var files = ['test/init_model_test',
'test/views/main/admin/stack_upgrade/upgrade_group_view_test',
'test/views/main/admin/stack_upgrade/upgrade_task_view_test',
'test/views/main/admin/stack_upgrade/upgrade_wizard_view_test',
+ 'test/views/main/admin/stack_upgrade/version_view_test',
'test/views/main/dashboard/config_history_view_test',
'test/views/main/dashboard/widget_test',
'test/views/main/dashboard/widgets_test',
http://git-wip-us.apache.org/repos/asf/ambari/blob/69bc4f02/ambari-web/app/views/main/admin/stack_upgrade/versions_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/admin/stack_upgrade/versions_view.js b/ambari-web/app/views/main/admin/stack_upgrade/versions_view.js
index a5cd7ee..4a987f3 100644
--- a/ambari-web/app/views/main/admin/stack_upgrade/versions_view.js
+++ b/ambari-web/app/views/main/admin/stack_upgrade/versions_view.js
@@ -36,28 +36,22 @@ App.MainAdminStackVersionsView = Em.View.extend({
categories: [
Em.Object.create({
labelKey: 'admin.stackVersions.filter.all',
- value: '',
isSelected: true
}),
Em.Object.create({
labelKey: 'admin.stackVersions.filter.notInstalled',
- value: 'NOT_INSTALLED',
- isSelected: false
- }),
- Em.Object.create({
- labelKey: 'admin.stackVersions.filter.installed',
- value: 'INSTALLED',
- isSelected: false
+ isSelected: false,
+ statuses: ["INIT", "INSTALLING", "INSTALL_FAILED", "OUT_OF_SYNC"]
}),
Em.Object.create({
labelKey: 'admin.stackVersions.filter.upgradeReady',
- value: 'UPGRADE_READY',
- isSelected: false
+ isSelected: false,
+ statuses: ["INSTALLED"]
}),
Em.Object.create({
labelKey: 'admin.stackVersions.filter.current',
- value: 'CURRENT',
- isSelected: false
+ isSelected: false,
+ statuses: ["CURRENT"]
})
],
@@ -121,15 +115,12 @@ App.MainAdminStackVersionsView = Em.View.extend({
*/
filterBy: function (versions, filter) {
var currentVersion = this.get('controller.currentVersion');
- if (filter && filter.get('value')) {
+ if (filter && filter.get('statuses')) {
return versions.filter(function (version) {
- var status = version.get('stackVersion.state');
- if (status === 'INSTALLED' && filter.get('value') === 'UPGRADE_READY') {
+ if (version.get('status') === 'INSTALLED' && filter.get('statuses').contains("INSTALLED")) {
return stringUtils.compareVersions(version.get('repositoryVersion'), Em.get(currentVersion, 'repository_version')) === 1;
- } else if (filter.get('value') === 'NOT_INSTALLED') {
- return ['INIT', 'INSTALL_FAILED', 'INSTALLING', 'OUT_OF_SYNC'].contains(status);
} else {
- return status === filter.get('value');
+ return filter.get('statuses').contains(version.get('status'));
}
}, this);
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/69bc4f02/ambari-web/test/views/main/admin/stack_upgrade/version_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/main/admin/stack_upgrade/version_view_test.js b/ambari-web/test/views/main/admin/stack_upgrade/version_view_test.js
new file mode 100644
index 0000000..6542816
--- /dev/null
+++ b/ambari-web/test/views/main/admin/stack_upgrade/version_view_test.js
@@ -0,0 +1,149 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+var App = require('app');
+require('views/main/admin/stack_upgrade/upgrade_wizard_view');
+
+describe('App.mainAdminStackVersionsView', function () {
+ var view = App.MainAdminStackVersionsView.create({
+ controller: {
+ currentVersion: {
+ repository_version: "2.2.1.0"
+ }
+ }
+ });
+
+ describe("#filterBy()", function () {
+ var versions = [
+ Em.Object.create({
+ status: "INIT"
+ }),
+ Em.Object.create({
+ status: "INSTALLING"
+ }),
+ Em.Object.create({
+ status: "INSTALLED",
+ repositoryVersion: "2.2.0.1"
+ }),
+ Em.Object.create({
+ status: "INSTALLED",
+ repositoryVersion: "2.2.2.1"
+ }),
+ Em.Object.create({
+ status: "INSTALL_FAILED"
+ }),
+ Em.Object.create({
+ status: "OUT_OF_SYNC"
+ }),
+ Em.Object.create({
+ status: "UPGRADING"
+ }),
+ Em.Object.create({
+ status: "UPGRADE_FAILED"
+ }),
+ Em.Object.create({
+ status: "CURRENT"
+ })
+ ];
+
+ var tets = [
+ {
+ filter: Em.Object.create({}),
+ filteredVersions: [
+ Em.Object.create({
+ status: "INIT"
+ }),
+ Em.Object.create({
+ status: "INSTALLING"
+ }),
+ Em.Object.create({
+ status: "INSTALLED",
+ repositoryVersion: "2.2.0.1"
+ }),
+ Em.Object.create({
+ status: "INSTALLED",
+ repositoryVersion: "2.2.2.1"
+ }),
+ Em.Object.create({
+ status: "INSTALL_FAILED"
+ }),
+ Em.Object.create({
+ status: "OUT_OF_SYNC"
+ }),
+ Em.Object.create({
+ status: "UPGRADING"
+ }),
+ Em.Object.create({
+ status: "UPGRADE_FAILED"
+ }),
+ Em.Object.create({
+ status: "CURRENT"
+ })
+ ]
+ },
+ {
+ filter: Em.Object.create({
+ statuses: ["INIT", "INSTALLING", "INSTALL_FAILED", "OUT_OF_SYNC"]
+ }),
+ filteredVersions: [
+ Em.Object.create({
+ status: "INIT"
+ }),
+ Em.Object.create({
+ status: "INSTALLING"
+ }),
+ Em.Object.create({
+ status: "INSTALL_FAILED"
+ }),
+ Em.Object.create({
+ status: "OUT_OF_SYNC"
+ })
+ ]
+ },
+ {
+ filter: Em.Object.create({
+ statuses: ["INSTALLED"]
+ }),
+ filteredVersions: [
+ Em.Object.create({
+ status: "INSTALLED",
+ repositoryVersion: "2.2.2.1"
+ })
+ ]
+ },
+ {
+ filter: Em.Object.create({
+ statuses: ["CURRENT"]
+ }),
+ filteredVersions: [
+ Em.Object.create({
+ status: "CURRENT"
+ })
+ ]
+ }
+ ].forEach(function(t) {
+ var msg = t.filter.get('statuses') ? t.filter.get('statuses').toString() : "All";
+ it("filter By " + msg, function () {
+ expect(view.filterBy(versions, t.filter)).to.eql(t.filteredVersions);
+ });
+ });
+
+ });
+
+});