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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/persistence/PersistenceUtils.js

Issue 2594883002: DevTools: [Persistence] introduce badged icons instead of checkmarks (Closed)
Patch Set: missing jsdoc Created 4 years 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 Persistence.PersistenceUtils = class { 5 Persistence.PersistenceUtils = class {
6 /** 6 /**
7 * @param {!Workspace.UISourceCode} uiSourceCode 7 * @param {!Workspace.UISourceCode} uiSourceCode
8 * @return {string} 8 * @return {string}
9 */ 9 */
10 static tooltipForUISourceCode(uiSourceCode) { 10 static tooltipForUISourceCode(uiSourceCode) {
11 var binding = Persistence.persistence.binding(uiSourceCode); 11 var binding = Persistence.persistence.binding(uiSourceCode);
12 if (!binding) 12 if (!binding)
13 return ''; 13 return '';
14 if (uiSourceCode === binding.network) 14 if (uiSourceCode === binding.network)
15 return Common.UIString('Persisted to file system: %s', binding.fileSystem. url().trimMiddle(150)); 15 return Common.UIString('Persisted to file system: %s', binding.fileSystem. url().trimMiddle(150));
16 if (binding.network.contentType().isFromSourceMap()) 16 if (binding.network.contentType().isFromSourceMap())
17 return Common.UIString('Linked to source map: %s', binding.network.url().t rimMiddle(150)); 17 return Common.UIString('Linked to source map: %s', binding.network.url().t rimMiddle(150));
18 return Common.UIString('Linked to %s', binding.network.url().trimMiddle(150) ); 18 return Common.UIString('Linked to %s', binding.network.url().trimMiddle(150) );
19 } 19 }
20
21 /**
22 * @param {!Workspace.UISourceCode} uiSourceCode
23 * @return {?Element}
24 */
25 static iconForUISourceCode(uiSourceCode) {
26 if (!Runtime.experiments.isEnabled('persistence2'))
27 return null;
28 var binding = Persistence.persistence.binding(uiSourceCode);
29 if (binding) {
30 var icon = UI.Icon.create('smallicon-file-sync');
31 var badge = UI.Icon.create('smallicon-badge-sync');
32 var combined = UI.Icon.combine([icon, badge]);
33 combined.title = Persistence.PersistenceUtils.tooltipForUISourceCode(bindi ng.fileSystem);
34 return combined;
35 }
36 if (uiSourceCode.project().type() !== Workspace.projectTypes.FileSystem)
37 return null;
38 var icon = UI.Icon.create('smallicon-file');
39 icon.title = Persistence.PersistenceUtils.tooltipForUISourceCode(uiSourceCod e);
40 return icon;
41 }
20 }; 42 };
21 43
22 /** 44 /**
23 * @extends {Common.Object} 45 * @extends {Common.Object}
24 * @implements {Components.LinkDecorator} 46 * @implements {Components.LinkDecorator}
25 */ 47 */
26 Persistence.PersistenceUtils.LinkDecorator = class extends Common.Object { 48 Persistence.PersistenceUtils.LinkDecorator = class extends Common.Object {
27 /** 49 /**
28 * @param {!Persistence.Persistence} persistence 50 * @param {!Persistence.Persistence} persistence
29 */ 51 */
30 constructor(persistence) { 52 constructor(persistence) {
31 super(); 53 super();
32 persistence.addEventListener(Persistence.Persistence.Events.BindingCreated, this._bindingChanged, this); 54 persistence.addEventListener(Persistence.Persistence.Events.BindingCreated, this._bindingChanged, this);
33 persistence.addEventListener(Persistence.Persistence.Events.BindingRemoved, this._bindingChanged, this); 55 persistence.addEventListener(Persistence.Persistence.Events.BindingRemoved, this._bindingChanged, this);
34 } 56 }
35 57
36 /** 58 /**
37 * @param {!Common.Event} event 59 * @param {!Common.Event} event
38 */ 60 */
39 _bindingChanged(event) { 61 _bindingChanged(event) {
40 var binding = /** @type {!Persistence.PersistenceBinding} */ (event.data); 62 var binding = /** @type {!Persistence.PersistenceBinding} */ (event.data);
41 this.dispatchEventToListeners(Components.LinkDecorator.Events.LinkIconChange d, binding.network); 63 this.dispatchEventToListeners(Components.LinkDecorator.Events.LinkIconChange d, binding.network);
42 } 64 }
43 65
44 /** 66 /**
45 * @override 67 * @override
46 * @param {!Workspace.UISourceCode} uiSourceCode 68 * @param {!Workspace.UISourceCode} uiSourceCode
47 * @return {?UI.Icon} 69 * @return {?Element}
48 */ 70 */
49 linkIcon(uiSourceCode) { 71 linkIcon(uiSourceCode) {
50 var binding = Persistence.persistence.binding(uiSourceCode); 72 return Persistence.PersistenceUtils.iconForUISourceCode(uiSourceCode);
51 if (!binding)
52 return null;
53 var icon = UI.Icon.create('smallicon-green-checkmark');
54 icon.title = Persistence.PersistenceUtils.tooltipForUISourceCode(uiSourceCod e);
55 return icon;
56 } 73 }
57 }; 74 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698