go.chromium.org/luci@v0.0.0-20240309015107-7cdc2e660f33/milo/ui/src/monitoring/components/luci_bisection_result/culprit_section.tsx (about)

     1  // Copyright 2024 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 Link from '@mui/material/Link';
    16  import List from '@mui/material/List';
    17  import ListItem from '@mui/material/ListItem';
    18  
    19  import { Culprit } from '@/monitoring/util/server_json';
    20  
    21  import { generateAnalysisUrl } from './util';
    22  
    23  interface CulpritSectionProps {
    24    culprits: Culprit[];
    25    failed_bbid: string;
    26  }
    27  
    28  export const CulpritSection = ({
    29    culprits,
    30    failed_bbid,
    31  }: CulpritSectionProps) => {
    32    return (
    33      <>
    34        <Link
    35          href={generateAnalysisUrl(failed_bbid)}
    36          target="_blank"
    37          rel="noopener"
    38        >
    39          LUCI Bisection
    40        </Link>
    41        &nbsp; has identified the following CL(s) as culprit(s) of the failure:
    42        <List>
    43          {culprits.map((c) => (
    44            <ListItem key={c.review_url}>
    45              <Link
    46                href={c.review_url}
    47                target="_blank"
    48                rel="noopener"
    49                onClick={() => {
    50                  ga('send', {
    51                    hitType: 'event',
    52                    eventCategory: 'LuciBisection',
    53                    eventAction: 'ClickCulpritLink',
    54                    eventLabel: c.review_url,
    55                    transport: 'beacon',
    56                  });
    57                }}
    58              >
    59                {getCulpritDisplayUrl(c)}
    60              </Link>
    61            </ListItem>
    62          ))}
    63        </List>
    64      </>
    65    );
    66  };
    67  
    68  function getCulpritDisplayUrl(c: Culprit) {
    69    if (c.review_title === '' || c.review_title === null) {
    70      return c.review_url;
    71    }
    72    return c.review_title;
    73  }