Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2916)

Unified Diff: dashboard/dashboard/elements/test-picker.html

Issue 2767433002: Start using /list_tests to populate subtest menus in test-picker (Closed)
Patch Set: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dashboard/dashboard/elements/test-picker.html
diff --git a/dashboard/dashboard/elements/test-picker.html b/dashboard/dashboard/elements/test-picker.html
index 770e073a41ac9a369c9659ca24f0feec0c604d5e..3bc2be648afe08fc3904610a71d54a01603f47a1 100644
--- a/dashboard/dashboard/elements/test-picker.html
+++ b/dashboard/dashboard/elements/test-picker.html
@@ -253,8 +253,6 @@ found in the LICENSE file.
} else if (boxIndex == 0) {
this.updateTestSuiteDescription();
this.updateBotMenu();
- } else if (boxIndex == 1) {
- this.sendSubtestRequest();
} else {
// Update all the next dropdown menus for subtests.
this.updateSubtestMenus(boxIndex + 1);
@@ -289,9 +287,9 @@ found in the LICENSE file.
menu.set('items', botItems);
menu.set('disabled', botItems.length === 0);
this.subtestDict = null;
- // If there's a selection, send a subtest request.
+ // If there's a selection, update the subtest menus.
if (menu.selectedItem) {
- this.sendSubtestRequest();
+ this.updateSubtestMenus(2);
} else {
// Clear all subtest menus.
this.splice('selectionModels', 2);
@@ -300,86 +298,46 @@ found in the LICENSE file.
},
/**
- * Sends a request for subtestDict base on selected test suite and bot.
+ * Updates all subtest menus starting at 'startIndex'.
*/
- sendSubtestRequest: function() {
- if (this.subtestXhr) {
- this.subtestXhr.abort();
- this.subtestXhr = null;
- }
- var bot = this.getCheckedBot();
- // If no bot is selected, just leave the current subtests.
- if (bot === null) {
- return;
- }
- var suite = this.getCheckedSuite();
- if (!suite) {
- return;
- }
+ updateSubtestMenus: async function(startIndex) {
shatch 2017/03/22 17:10:13 Just for record-keeping since we spoke offline, si
+ // If there's no selection model at this level yet, we must make one.
+ if (startIndex >= this.selectionModels.length) {
+ this.loading = true;
- this.loading = true;
+ const children = await this.getChildren(
+ this.getCurrentPreselectedPath());
+ this.loading = false;
- var params = {
- type: 'sub_tests',
- suite: suite,
- bots: bot,
- xsrf_token: this.xsrfToken
- };
- this.subtestXhr = simple_xhr.send(
- '/list_tests',
- params,
- function(response) {
- this.loading = false;
- this.subtestDict = response;
- // Start at first subtest menu.
- this.updateSubtestMenus(2);
- }.bind(this),
- function(error) {
- // TODO: Display error.
- this.loading = false;
- }.bind(this)
- );
- },
+ this.push('selectionModels', {
+ placeholder: this.SUBTEST_LABEL,
+ datalist: children,
+ disabled: false,
+ });
- /**
- * Updates all subtest menus starting at 'startIndex'.
- */
- updateSubtestMenus: function(startIndex) {
- var subtestDict = this.getSubtestAtIndex(startIndex);
+ Polymer.dom.flush();
+ }
- // Update existing subtest menu.
for (var i = startIndex; i < this.selectionModels.length; i++) {
- // Remove the rest of the menu if no subtestDict.
- if (!subtestDict || Object.keys(subtestDict).length == 0) {
+ const children = await this.getChildren(
+ this.getCurrentPreselectedPath());
sullivan 2017/03/21 13:24:23 This is pretty confusing. It seems like either: *
shatch 2017/03/21 17:48:02 Yeah this could use some clarification, had to pas
+ // Remove the rest of the menu if no children.
+ if (children.length === 0) {
this.splice('selectionModels', i);
this.updateAddButtonState();
return;
}
- var subtestItems = this.getSubtestItems(subtestDict);
- var menu = this.getSelectionMenu(i);
- menu.set('items', subtestItems);
+ const menu = this.getSelectionMenu(i);
+ menu.set('items', children);
// If there are selected item, update next menu.
if (menu.selectedItem) {
- subtestDict = subtestDict[menu.selectedName]['sub_tests'];
+ continue;
} else {
- subtestDict = null;
+ break;
}
}
- // Check if we still need to add a subtest menu.
- if (subtestDict && Object.keys(subtestDict).length > 0) {
- var subtestItems = this.getSubtestItems(subtestDict);
- this.push('selectionModels', {
- placeholder: this.SUBTEST_LABEL,
- datalist: subtestItems,
- disabled: false,
- });
- Polymer.dom.flush();
- var menu = this.getSelectionMenu(this.selectionModels.length - 1);
- menu.set('items', subtestItems);
- }
-
this.updateAddButtonState();
},
@@ -387,30 +345,16 @@ found in the LICENSE file.
this.enableAddSeries = this.getCurrentSelection() instanceof Array;
},
- getSubtestAtIndex: function(index) {
- var subtestDict = this.subtestDict;
- for (var i = 2; i < index; i++) {
- var test = this.getSelectionMenu(i).selectedName;
- if (test in subtestDict) {
- subtestDict = subtestDict[test]['sub_tests'];
- } else {
- return null;
- }
- }
- return subtestDict;
- },
+ getChildren: function(path) {
+ const testPathDict = {};
+ testPathDict[path] = 'all';
+ const params = {
+ type: 'test_path_dict',
+ return_selected: '1',
+ test_path_dict: JSON.stringify(testPathDict)
+ };
- getSubtestItems: function(subtestDict) {
- var subtestItems = [];
- var subtestNames = Object.keys(subtestDict).sort();
- for (var i = 0; i < subtestNames.length; i++) {
- var name = subtestNames[i];
- subtestItems.push({
- name: name,
- tag: (subtestDict[name]['deprecated'] ? this.DEPRECATED_TAG : '')
- });
- }
- return subtestItems;
+ return simple_xhr.asPromise('/list_tests', params);
},
getCheckedBot: function() {
@@ -458,6 +402,16 @@ found in the LICENSE file.
* is a valid selection.
*/
getCurrentSelection: function() {
+ const path = this.getCurrentPreselectedPath(true);
+ if (this.currentSelectedPath_ === path) {
+ return this.currentSelectedTests_;
+ }
+ this.currentSelectedPath_ = path;
+ this.sendListTestsRequest(path);
+ return null;
+ },
+
+ getCurrentPreselectedPath: function(onlyValid) {
var level = 0;
var parts = [];
while (true) {
@@ -465,7 +419,7 @@ found in the LICENSE file.
if (!menu || !menu.selectedItem) {
// A selection is only valid if it specifies at least one subtest
// component, which is the third level.
- if (level <= 2) return null;
+ if (onlyValid && level <= 2) return null;
break;
} else {
// We want to collect all the subtest components so we can form
@@ -480,12 +434,7 @@ found in the LICENSE file.
parts.unshift(suite);
parts.unshift(bot);
- var path = parts.join('/');
-
- if (this.currentSelectedPath_ === path)
- return this.currentSelectedTests_;
- this.sendListTestsRequest(path);
- return null;
+ return parts.join('/');
},
getCurrentSelectedPath: function() {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698