summaryrefslogtreecommitdiffstats
path: root/polygerrit-ui/app/samples/some-screen.html
blob: de293157de79f8ae7d5a1b7d3210aa8c65d7605f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<dom-module id="some-screen">
  <script>
    Gerrit.install(plugin => {
      // Recommended approach for screen() API.
      plugin.screen('main', 'some-screen-main');

      const mainUrl = plugin.screenUrl('main');

      // Support for deprecated screen API.
      plugin.deprecated.screen('foo', ({token, body, show}) => {
        body.innerHTML = `This is a plugin screen at ${token}<br/>` +
            `<a href="${mainUrl}">Go to main plugin screen</a>`;
        show();
      });

      // Quick and dirty way to get something on screen.
      plugin.screen('bar').onAttached(el => {
        el.innerHTML = `This is a plugin screen at ${el.token}<br/>` +
            `<a href="${mainUrl}">Go to main plugin screen</a>`;
      });

      // Add a "Plugin screen" link to the change view screen.
      plugin.hook('change-metadata-item').onAttached(el => {
        el.innerHTML = `<a href="${mainUrl}">Plugin screen</a>`;
      });
    });
  </script>
</dom-module>

<dom-module id="some-screen-main">
  <template>
    This is the <b>main</b> plugin screen at [[token]]
    <ul>
      <li><a href$="[[rootUrl]]/foo">via deprecated</a></li>
      <li><a href$="[[rootUrl]]/bar">without component</a></li>
    </ul>
  </template>
  <script>
    Polymer({
      is: 'some-screen-main',
      properties: {
        rootUrl: String,
      },
      attached() {
        this.rootUrl = `${this.plugin.screenUrl()}`;
      },
    });
  </script>
</dom-module>