blob: e27a5fe09f7a03b03fcc4f8c103884e1004195fc [file] [log] [blame]
Adrià Vilanova Martínezde942802022-07-15 14:06:55 +02001// Copyright 2019 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5import {LitElement, html, css} from 'lit-element';
6
7import {connectStore} from 'reducers/base.js';
8import * as issueV0 from 'reducers/issueV0.js';
9import {SHARED_STYLES} from 'shared/shared-styles.js';
10
11
12/**
13 * `<mr-migrated-banner>`
14 *
15 * Display for showing whether an issue is restricted.
16 *
17 */
18export class MrMigratedBanner extends connectStore(LitElement) {
19 /** @override */
20 static get styles() {
21 return [
22 SHARED_STYLES,
23 css`
24 :host {
25 width: 100%;
26 margin-top: 0;
27 background-color: var(--chops-orange-50);
28 border-bottom: var(--chops-normal-border);
29 font-size: var(--chops-main-font-size);
30 padding: 0.25em 8px;
31 box-sizing: border-box;
32 display: flex;
33 flex-direction: row;
34 justify-content: flex-start;
35 align-items: center;
36 }
37 :host([hidden]) {
38 display: none;
39 }
40 i.material-icons {
41 color: var(--chops-primary-icon-color);
42 font-size: var(--chops-icon-font-size);
43 }
44 .warning-icon {
45 margin-right: 4px;
46 }
47 `,
48 ];
49 }
50
51 /** @override */
52 render() {
53 return html`
54 <link href="https://fonts.googleapis.com/icon?family=Material+Icons"
55 rel="stylesheet">
56 <i
57 class="warning-icon material-icons"
58 icon="warning"
59 >warning</i>
60 <p>
61 This issue has been migrated to ${this._link}. Please see
62 ${this._link} for the latest version of this discussion.
63 </p>
64 `;
65 }
66
67 /** @override */
68 static get properties() {
69 return {
70 migratedId: {type: String},
71 hidden: {
72 type: Boolean,
73 reflect: true,
74 },
75 };
76 }
77
78 /** @override */
79 constructor() {
80 super();
81
82 this.hidden = true;
83 }
84
85 /** @override */
86 stateChanged(state) {
87 this.migratedId = issueV0.migratedId(state);
88 }
89
90 /** @override */
91 update(changedProperties) {
92 if (changedProperties.has('migratedId')) {
93 this.hidden = !this.migratedId || this.migratedId === '';
94 }
95
96 super.update(changedProperties);
97 }
98
99 /**
100 * @return {string} the link of the issue in Issue Tracker.
101 */
102 get _link() {
103 return html`<a href="https://issuetracker.google.com/issues/${this.migratedId}">b/${this.migratedId}</a>`;
104 }
105}
106
107customElements.define('mr-migrated-banner', MrMigratedBanner);