Revert "Add an option for checks to provide HTML results"
This reverts commit 19b02c792c7d645e2ef7c4c4e66aa4cd36a28d05.
Reason for revert: I did not manage to make this work with Google's internal BUILD system and the requirement for using SafeHtml type.
Change-Id: Id579bf22bd4c4a13898cbfafb4ae32a87b15e187
diff --git a/polygerrit-ui/app/elements/checks/gr-checks-results.ts b/polygerrit-ui/app/elements/checks/gr-checks-results.ts
index 26e23c6..f27c2ee 100644
--- a/polygerrit-ui/app/elements/checks/gr-checks-results.ts
+++ b/polygerrit-ui/app/elements/checks/gr-checks-results.ts
@@ -15,7 +15,6 @@
* limitations under the License.
*/
import {html} from 'lit-html';
-import {unsafeHTML} from 'lit-html/directives/unsafe-html';
import {css, customElement, property, PropertyValues} from 'lit-element';
import {GrLitElement} from '../lit/gr-lit-element';
import {
@@ -137,8 +136,7 @@
update(changedProperties: PropertyValues) {
if (changedProperties.has('result')) {
- this.isExpandable =
- !!this.result?.message || !!this.result?.messageSafeHtml;
+ this.isExpandable = !!this.result?.message;
}
super.update(changedProperties);
}
@@ -159,7 +157,9 @@
<!-- The is for being able to shrink a tiny amount without
the text itself getting shrunk with an ellipsis. -->
<div class="summary">${this.result.summary} </div>
- <div class="message">${this.renderMessageCollapsed()}</div>
+ <div class="message">
+ ${this.isExpanded ? '' : this.result.message}
+ </div>
<div class="tags">
${(this.result.tags ?? []).map(t => this.renderTag(t))}
</div>
@@ -199,11 +199,6 @@
this.isExpanded = !this.isExpanded;
}
- renderMessageCollapsed() {
- if (this.isExpanded || !this.result) return '';
- return html`${this.result.messageSafeHtml ?? this.result.message}`;
- }
-
renderLink(link: Link) {
return html`
<a href="${link.url}" target="_blank">
@@ -250,11 +245,11 @@
render() {
if (!this.result) return '';
- let msg = html`${this.result.message}`;
- if (this.result.messageSafeHtml) {
- msg = html`${unsafeHTML(this.result.messageSafeHtml)}`;
- }
- return html`<div class="message">${msg}</div>`;
+ return html`
+ <div class="message">
+ ${this.result.message}
+ </div>
+ `;
}
}
diff --git a/polygerrit-ui/app/elements/plugins/gr-checks-api/gr-checks-api-types.ts b/polygerrit-ui/app/elements/plugins/gr-checks-api/gr-checks-api-types.ts
index 0af612b..859d82d 100644
--- a/polygerrit-ui/app/elements/plugins/gr-checks-api/gr-checks-api-types.ts
+++ b/polygerrit-ui/app/elements/plugins/gr-checks-api/gr-checks-api-types.ts
@@ -287,16 +287,12 @@
* MB size. The UI is not limiting this. Data providing plugins are
* responsible for not killing the browser. :-)
*
- * `message` is just a plain unformatted string. Then the only
- * formatting applied is the one that Gerrit also applies to human comments.
- *
- * `messageSafeHtml` is a HTML string. Then Gerrit will just insert that as
- * is into the DOM. The plugin is responsible for the HTML being safe.
- *
- * If `messageSafeHtml` is set, then `message` will be ignored.
+ * For now this is just a plain unformatted string. The only formatting
+ * applied is the one that Gerrit also applies to human comments. TBD: Both
+ * human comments and check result messages should get richer formatting
+ * options.
*/
message?: string;
- messageSafeHtml?: string;
/**
* Tags allow a plugins to further categorize a result, e.g. making a list
diff --git a/polygerrit-ui/app/services/checks/checks-model.ts b/polygerrit-ui/app/services/checks/checks-model.ts
index b0424d9..eacd56a 100644
--- a/polygerrit-ui/app/services/checks/checks-model.ts
+++ b/polygerrit-ui/app/services/checks/checks-model.ts
@@ -119,13 +119,8 @@
{
category: Category.WARNING,
summary: 'We think that you could improve this.',
- messageSafeHtml: `There is a <b style="font-weight: bold">lot</b>
- to be said.<br/>A lot.
- <span style="color: red">I say, a lot.</span><br/>
- <span style="text-decoration: underline">
- So please keep reading.</span><br/>
- <span style="color: #444; background-color: lightblue; border-radius: 4px;">
- Approved Opinion </span>`,
+ message: `There is a lot to be said. A lot. I say, a lot.\n
+ So please keep reading.`,
tags: [{name: 'INTERRUPTED'}, {name: 'WINDOWS'}],
},
],