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

Unified Diff: tracing/tracing/value/ui/generic_set_span.html

Issue 3008203002: Format traceUrls in generic-set-span. (Closed)
Patch Set: Created 3 years, 3 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
Index: tracing/tracing/value/ui/generic_set_span.html
diff --git a/tracing/tracing/value/ui/generic_set_span.html b/tracing/tracing/value/ui/generic_set_span.html
index 5a92b8ebcc5684a35957af08f8b4514e7a0ca947..2ce30c7316b329be09d7ef5c6193e68aed397412 100644
--- a/tracing/tracing/value/ui/generic_set_span.html
+++ b/tracing/tracing/value/ui/generic_set_span.html
@@ -19,15 +19,7 @@ found in the LICENSE file.
<tr-ui-a-generic-object-view id="generic"></tr-ui-a-generic-object-view>
- <template is="dom-repeat" items="{{strings_}}">
- <template is="dom-if" if="[[isUrl_(item)]]">
- <a href="[[item]]">[[item]]</a>
- </template>
-
- <template is="dom-if" if="[[!isUrl_(item)]]">
- <div>[[item]]</div>
- </template>
- </template>
+ <div id="links"></div>
</template>
</dom-module>
@@ -38,21 +30,10 @@ tr.exportTo('tr.v.ui', function() {
is: 'tr-v-ui-generic-set-span',
behaviors: [tr.v.ui.DIAGNOSTIC_SPAN_BEHAVIOR],
- properties: {
- strings_: {
- type: Array,
- },
- },
-
- isUrl_(s) {
- return tr.b.isUrl(s);
- },
-
updateContents_() {
- if (this.diagnostic === undefined) {
- this.$.generic.object = undefined;
- return;
- }
+ this.$.generic.style.display = 'none';
+ this.$.links.textContent = '';
+ if (this.diagnostic === undefined) return;
const values = Array.from(this.diagnostic);
let areAllStrings = true;
@@ -67,15 +48,33 @@ tr.exportTo('tr.v.ui', function() {
}
}
- if (areAllStrings) {
- if (areAllNumbers) {
- values.sort((x, y) => x - y);
- } else {
- values.sort();
- }
- this.set('strings_', values);
- } else {
+ if (!areAllStrings) {
+ this.$.generic.style.display = '';
this.$.generic.object = values;
+ return;
+ }
+
+ if (areAllNumbers) {
+ values.sort((x, y) => x - y);
+ } else {
+ values.sort();
+ }
+
+ for (const value of values) {
+ const link = {textContent: '' + value};
+ if (tr.b.isUrl(value)) link.href = value;
+ if (this.name_ === tr.v.d.RESERVED_NAMES.TRACE_URLS) {
+ link.textContent = value.substr(1 + value.lastIndexOf('/'));
+ }
+ const linkEl = tr.ui.b.createLink(link);
+ if (link.href) {
+ linkEl.target = '_blank';
+ // In case there's a listener in the hierarchy that calls
+ // preventDefault(), stop the event from propagating to it so that
+ // clicking the link always opens it in a new tab.
+ linkEl.addEventListener('click', e => e.stopPropagation());
+ }
+ this.$.links.appendChild(linkEl);
}
}
});
« no previous file with comments | « tracing/tracing/value/ui/diagnostic_map_table.html ('k') | tracing/tracing/value/ui/generic_set_span_test.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698