go.chromium.org/luci@v0.0.0-20240309015107-7cdc2e660f33/milo/ui/src/common/components/associated_bugs_tooltip.ts (about)

     1  // Copyright 2022 The LUCI Authors.
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //      http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  import '@material/mwc-menu';
    16  import { MobxLitElement } from '@adobe/lit-mobx';
    17  import { css, html } from 'lit';
    18  import { customElement } from 'lit/decorators.js';
    19  import { makeObservable, observable } from 'mobx';
    20  
    21  import { Cluster, makeRuleLink } from '@/common/services/luci_analysis';
    22  import { commonStyles } from '@/common/styles/stylesheets';
    23  
    24  @customElement('milo-associated-bugs-tooltip')
    25  export class AssociatedBugsTooltipElement extends MobxLitElement {
    26    @observable.ref project!: string;
    27    @observable.ref clusters!: readonly Cluster[];
    28  
    29    constructor() {
    30      super();
    31      makeObservable(this);
    32    }
    33  
    34    protected render() {
    35      const bugClusters = this.clusters.filter((c) => c.bug);
    36  
    37      return html`
    38        <table style="padding: 5px;">
    39          <tbody>
    40            <tr>
    41              <td colspan="2">
    42                This failure is associated with the following bug(s):
    43              </td>
    44            </tr>
    45            ${bugClusters.map(
    46              (c) => html`
    47                <tr class="row">
    48                  <td><a href=${c.bug!.url}>${c.bug!.linkText}</a></td>
    49                  <td>
    50                    <a
    51                      href=${makeRuleLink(this.project, c.clusterId.id)}
    52                      target="_blank"
    53                    >
    54                      Failures
    55                    </a>
    56                  </td>
    57                </tr>
    58              `,
    59            )}
    60          </tbody>
    61        </table>
    62      `;
    63    }
    64  
    65    static styles = [
    66      commonStyles,
    67      css`
    68        :host {
    69          display: block;
    70          width: 300px;
    71        }
    72  
    73        table {
    74          width: 100%;
    75        }
    76  
    77        tr > td:first-child {
    78          width: 100%;
    79        }
    80      `,
    81    ];
    82  }