go.chromium.org/luci@v0.0.0-20240309015107-7cdc2e660f33/milo/ui/src/common/components/result_entry/image_diff_artifact.ts (about) 1 // Copyright 2020 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-icon'; 16 import { MobxLitElement } from '@adobe/lit-mobx'; 17 import { html } from 'lit'; 18 import { customElement } from 'lit/decorators.js'; 19 import { computed, makeObservable, observable } from 'mobx'; 20 21 import '@/generic_libs/components/expandable_entry'; 22 import '@/common/components/image_diff_viewer'; 23 import { Artifact } from '@/common/services/resultdb'; 24 import { getImageDiffArtifactURLPath } from '@/common/tools/url_utils'; 25 26 /** 27 * Renders an image diff artifact entry. 28 */ 29 @customElement('milo-image-diff-artifact') 30 export class TextDiffArtifactElement extends MobxLitElement { 31 @observable.ref expected!: Artifact; 32 @observable.ref actual!: Artifact; 33 @observable.ref diff!: Artifact; 34 35 @computed private get artifactPageUrl() { 36 return getImageDiffArtifactURLPath( 37 this.diff.name, 38 this.actual.artifactId, 39 this.expected.artifactId, 40 ); 41 } 42 43 constructor() { 44 super(); 45 makeObservable(this); 46 } 47 48 protected render() { 49 return html` 50 <milo-expandable-entry .expanded=${true} .contentRuler="invisible"> 51 <span id="header" slot="header"> 52 Unexpected image output from 53 <a href=${this.artifactPageUrl} target="_blank" 54 >${this.diff.artifactId}</a 55 > 56 </span> 57 <milo-image-diff-viewer 58 slot="content" 59 .expected=${this.expected} 60 .actual=${this.actual} 61 .diff=${this.diff} 62 > 63 </milo-image-diff-viewer> 64 </milo-expandable-entry> 65 `; 66 } 67 }