Convert to Polymer 3

Change-Id: I0e03fa6dc3727507045cb57596efa81aca5c2349
diff --git a/BUILD b/BUILD
index 7939099..b3d5777 100644
--- a/BUILD
+++ b/BUILD
@@ -1,3 +1,4 @@
+load("@npm//@bazel/rollup:index.bzl", "rollup_bundle")
 load("@rules_java//java:defs.bzl", "java_library")
 load(
     "//tools/bzl:plugin.bzl",
@@ -59,9 +60,18 @@
 
 polygerrit_plugin(
     name = "gr-verify-status",
-    srcs = [
-        "gr-verify-status/gr-verify-status-panel.html",
-        "gr-verify-status/gr-verify-status-panel.js",
+    app = "gr-verify-status-bundle.js",
+    plugin_name = "gr-verify-status",
+)
+
+rollup_bundle(
+    name = "gr-verify-status-bundle",
+    srcs = glob(["gr-verify-status/*.js"]),
+    entry_point = "gr-verify-status/plugin.js",
+    format = "iife",
+    rollup_bin = "//tools/node_tools:rollup-bin",
+    sourcemap = "hidden",
+    deps = [
+        "@tools_npm//rollup-plugin-node-resolve",
     ],
-    app = "plugin.html",
 )
diff --git a/gr-verify-status/gr-verify-status-panel.html b/gr-verify-status/gr-verify-status-panel.html
deleted file mode 100644
index e34af9c..0000000
--- a/gr-verify-status/gr-verify-status-panel.html
+++ /dev/null
@@ -1,45 +0,0 @@
-<!--
-Copyright (C) 2019 The Android Open Source Project
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-http://www.apache.org/licenses/LICENSE-2.0
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
--->
-
-<dom-module id="gr-verify-status-panel">
-  <template>
-    <style include="gr-form-styles"></style>
-    <style>
-        .u-green {
-            color: #388E3C;
-        }
-        .u-red {
-            color: #D32F2F;
-        }
-    </style>
-    <div id="gr-verify-status">
-        <span class="u-green">Passed: [[verifyStatus.summary.passed]]</span>,
-        <span class="u-red">Failed: [[verifyStatus.summary.failed]]</span>,
-        <span class="u-black">Not done: [[verifyStatus.summary.notdone]]</span>
-    </div>
-    <div class="separatedSection style-scope gr-change-metadata"
-        style="margin-top: 0; padding: 0">
-      <table class="test_result_table">
-        <tbody>
-            <template is="dom-repeat" items="{{verifyStatus.results}}">
-            <tr>
-                <td class="cell verifiedstatus"><a href$="[[item.url]]">[[item.name]]</a></td>
-                <td class="cell verifiedstatus verifiedstatus_value">[[item.value]]</td>
-            </tr>
-            </template>
-        </tbody>
-      </table>
-    </div>
-  </template>
-  <script src="gr-verify-status-panel.js"></script>
-</dom-module>
diff --git a/gr-verify-status/gr-verify-status-panel.js b/gr-verify-status/gr-verify-status-panel.js
index bdacdef..91b6f37 100644
--- a/gr-verify-status/gr-verify-status-panel.js
+++ b/gr-verify-status/gr-verify-status-panel.js
@@ -1,75 +1,90 @@
-// Copyright (C) 2019 The Android Open Source Project
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-(function() {
-  'use strict';
-  const Defs = {};
-  /**
-   * @typedef {{
-   *   summary: Object,
-   *   results: Array,
-   * }}
-   */
-  Defs.verifyStatus;
+/**
+ * @license
+ * Copyright (C) 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import {htmlTemplate} from './gr-verify-status-panel_html.js';
 
-  Polymer({
-    is: 'gr-verify-status-panel',
+const Defs = {};
+/**
+ * @typedef {{
+ *   summary: Object,
+ *   results: Array,
+ * }}
+ */
+Defs.verifyStatus;
 
-    properties: {
-        verifyStatus: {
-            /** @type {Defs.verifystatus} */
-            type: Object,
-        },
-        revision: {
-            type: Object,
-        },
-        change: {
-            type: Object,
-        }
-    },
+class GrVerifyStatusPanel extends Polymer.Element {
+  static get is() {
+    return 'gr-verify-status-panel';
+  }
 
-    attached() {
-        this._fetchData(this.revision);
-    },
+  static get template() {
+    return htmlTemplate;
+  }
 
-    _fetchData(revision) {
-      if (!revision) return;
-      const query ='/verify-status~verifications?sort=REPORTER&filter=CURRENT';
-      const endpoint = '/changes/' + this.change.id + '/revisions/' +
-                       revision._number + query;
+  static get properties() {
+    return {
+      verifyStatus: {
+          /** @type {Defs.verifystatus} */
+          type: Object,
+      },
+      revision: {
+          type: Object,
+      },
+      change: {
+          type: Object,
+      }
+    };
+  }
 
-      const errFn = response => {
-          this.fire('page-error', {response});
-      };
+  connectedCallback() {
+    super.connectedCallback();
 
-      this.plugin.restApi().get(endpoint, errFn).then(r => {
-          let summary = {failed:0, passed:0, notdone:0};
-          let results = [];
-          for (let checkid in r) {
-              let check= r[checkid];
-              if (check.value == '0') {
-                  summary.notdone +=1;}
-              else if (check.value == 1) {
-                  summary.passed +=1;
-              }
-              else {
-                  summary.failed +=1;
-              }
-              results.push(check);
-          };
+    this._fetchData(this.revision);
+  }
 
-          this.verifyStatus = {summary, results};
-      });
-    },
-  });
-}());
+  _fetchData(revision) {
+    if (!revision) return;
+
+    const query ='/verify-status~verifications?sort=REPORTER&filter=CURRENT';
+    const endpoint = '/changes/' + this.change.id + '/revisions/' +
+                     revision._number + query;
+
+    const errFn = response => {
+        this.fire('page-error', {response});
+    };
+
+    this.plugin.restApi().get(endpoint, errFn).then(r => {
+        let summary = {failed:0, passed:0, notdone:0};
+        let results = [];
+        for (let checkid in r) {
+            let check= r[checkid];
+            if (check.value == '0') {
+                summary.notdone +=1;}
+            else if (check.value == 1) {
+                summary.passed +=1;
+            }
+            else {
+                summary.failed +=1;
+            }
+            results.push(check);
+        };
+
+        this.verifyStatus = {summary, results};
+    });
+  }
+}
+
+customElements.define(GrVerifyStatusPanel.is, GrVerifyStatusPanel);
diff --git a/gr-verify-status/gr-verify-status-panel_html.js b/gr-verify-status/gr-verify-status-panel_html.js
new file mode 100644
index 0000000..247c564
--- /dev/null
+++ b/gr-verify-status/gr-verify-status-panel_html.js
@@ -0,0 +1,45 @@
+/**
+ * @license
+ * Copyright (C) 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+export const htmlTemplate = Polymer.html`
+<style include="gr-form-styles"></style>
+<style>
+    .u-green {
+        color: #388E3C;
+    }
+    .u-red {
+        color: #D32F2F;
+    }
+</style>
+<div id="gr-verify-status">
+    <span class="u-green">Passed: [[verifyStatus.summary.passed]]</span>,
+    <span class="u-red">Failed: [[verifyStatus.summary.failed]]</span>,
+    <span class="u-black">Not done: [[verifyStatus.summary.notdone]]</span>
+</div>
+<div class="separatedSection style-scope gr-change-metadata"
+    style="margin-top: 0; padding: 0">
+  <table class="test_result_table">
+    <tbody>
+        <template is="dom-repeat" items="{{verifyStatus.results}}">
+        <tr>
+            <td class="cell verifiedstatus"><a href$="[[item.url]]">[[item.name]]</a></td>
+            <td class="cell verifiedstatus verifiedstatus_value">[[item.value]]</td>
+        </tr>
+        </template>
+    </tbody>
+  </table>
+</div>`;
diff --git a/gr-verify-status/plugin.js b/gr-verify-status/plugin.js
new file mode 100644
index 0000000..5ea53a1
--- /dev/null
+++ b/gr-verify-status/plugin.js
@@ -0,0 +1,23 @@
+/**
+ * @license
+ * Copyright (C) 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import './gr-verify-status-panel.js';
+
+Gerrit.install(plugin => {
+  plugin.registerCustomComponent(
+      'change-metadata-item', 'gr-verify-status-panel');
+});
diff --git a/plugin.html b/plugin.html
deleted file mode 100644
index e1b3d61..0000000
--- a/plugin.html
+++ /dev/null
@@ -1,28 +0,0 @@
-<!--
-Copyright (C) 2019 The Android Open Source Project
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
-http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
--->
-
-<link rel="import" href="./gr-verify-status/gr-verify-status-panel.html">
-
-<dom-module id="verify-status">
-  <script>
-    if (window.Polymer) {
-      Gerrit.install(function(plugin) {
-          plugin.registerCustomComponent(
-              'change-metadata-item', 'gr-verify-status-panel');
-      });
-    }
-  </script>
-</dom-module>
diff --git a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/HttpModule.java b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/HttpModule.java
index d1f2fa5..9e4a33b 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/HttpModule.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/HttpModule.java
@@ -23,6 +23,6 @@
   @Override
   protected void configureServlets() {
     DynamicSet.bind(binder(), WebUiPlugin.class)
-        .toInstance(new JavaScriptPlugin("gr-verify-status.html"));
+        .toInstance(new JavaScriptPlugin("gr-verify-status.js"));
   }
 }