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

Unified Diff: third_party/WebKit/Source/devtools/front_end/sources/UIList.js

Issue 2431223003: [DevTools]: Require explicit connection (Closed)
Patch Set: Addressed one last comment Created 4 years, 1 month 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
Index: third_party/WebKit/Source/devtools/front_end/sources/UIList.js
diff --git a/third_party/WebKit/Source/devtools/front_end/sources/UIList.js b/third_party/WebKit/Source/devtools/front_end/sources/UIList.js
index 34f5957d6bd7bfeb571856609f53e3681ee860cd..a62787e9db74f3eb44b1298ce4765127c5d2b2f8 100644
--- a/third_party/WebKit/Source/devtools/front_end/sources/UIList.js
+++ b/third_party/WebKit/Source/devtools/front_end/sources/UIList.js
@@ -84,7 +84,8 @@ WebInspector.UIList.Item = class {
this.titleElement = this.element.createChild('div', 'title');
this.subtitleElement = this.element.createChild('div', 'subtitle');
-
+ /** @type {?Element} */
+ this._actionElement = null;
this._hidden = false;
this._isLabel = !!isLabel;
this.setTitle(title);
@@ -199,7 +200,7 @@ WebInspector.UIList.Item = class {
* @param {boolean} x
*/
setDimmed(x) {
- this.element.classList.toggle('dimmed', x);
+ this.element.classList.toggle('dimmed-item', x);
}
discard() {
@@ -211,4 +212,23 @@ WebInspector.UIList.Item = class {
setHoverable(hoverable) {
this.element.classList.toggle('ignore-hover', !hoverable);
}
+
+ /**
+ * @param {?string} title
+ * @param {?function(!Event):!Promise} handler
+ */
+ setAction(title, handler) {
+ if (this._actionElement)
+ this._actionElement.remove();
+ if (!title || !handler)
+ return;
+ this._actionElement = this.element.createChild('div', 'action');
+ var link = this._actionElement.createChild('a', 'action-link');
+ link.textContent = title;
+ link.addEventListener('click', (event) => {
+ link.disabled = true;
+ handler(event).then(() => link.disabled = false);
+ event.stopPropagation();
+ });
+ }
};

Powered by Google App Engine
This is Rietveld 408576698