Commit 7f9126c7 authored by Sigurdur Asgeirsson's avatar Sigurdur Asgeirsson Committed by Commit Bot

Add simple path navigation to chrome://discards.

While I'm in there add a style to make the swimlane dividers impossible
to select, which was a persistent nuisance.

Bug: 1068233
Change-Id: Ie4b1b10fe39823102e9ec36d6396865b49e5de32
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2144261
Commit-Queue: Sigurður Ásgeirsson <siggi@chromium.org>
Reviewed-by: default avatardpapad <dpapad@chromium.org>
Cr-Commit-Position: refs/heads/master@{#758021}
parent 3ad62d42
......@@ -22,6 +22,7 @@
overflow: hidden;
}
</style>
<iron-location path="{{path}}"></iron-location>
<cr-tabs selected="{{selected}}" tab-names="[[tabs]]"></cr-tabs>
<iron-pages selected="[[selected]]">
......
......@@ -4,6 +4,7 @@
import 'chrome://resources/cr_elements/hidden_style_css.m.js';
import 'chrome://resources/cr_elements/cr_tabs/cr_tabs.m.js';
import 'chrome://resources/polymer/v3_0/iron-location/iron-location.js';
import 'chrome://resources/polymer/v3_0/iron-pages/iron-pages.js';
import './database_tab.js';
import './discards_tab.js';
......@@ -21,6 +22,13 @@ Polymer({
selected: {
type: Number,
value: 0,
observer: 'selectedChanged_',
},
path: {
type: String,
value: '',
observer: 'pathChanged_',
},
tabs: {
......@@ -28,4 +36,38 @@ Polymer({
value: () => ['Discards', 'Database', 'Graph'],
},
},
/**
* Updates the location hash on selection change.
* @param {number} newValue
* @param {number|undefined} oldValue
* @private
*/
selectedChanged_(newValue, oldValue) {
if (oldValue != undefined) {
this.path = '/' + this.tabs[newValue].toLowerCase();
}
},
/**
* Returns the index of the currently selected tab corresponding to the
* path or zero if no match.
* @param {string} path
* @return {number}
* @private
*/
selectedFromPath_(path) {
const index = this.tabs.findIndex(tab => path === tab.toLowerCase());
return Math.max(index, 0);
},
/**
* Updates the selection property on path change.
* @param {string} newValue
* @param {string|undefined} oldValue
* @private
*/
pathChanged_(newValue, oldValue) {
this.selected = this.selectedFromPath_(newValue.substr(1));
},
});
......@@ -34,6 +34,7 @@ URL. As result, this document needs to be self-contained, hence inline scripts.
.separator {
font: italic 13px sans-serif;
user-select: none;
}
</style>
<script src="https://ajax.googleapis.com/ajax/libs/d3js/5.7.0/d3.min.js"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment