blob: 38d342011f05bc232fcbb8629c0314c19e1596e6 [file] [log] [blame]
Adrià Vilanova Martínezca25b682022-10-24 00:11:03 +02001import '@material/mwc-dialog/mwc-dialog.js';
2import '@material/web/button/filled-button.js';
3import '@material/web/button/text-button.js';
4
5import {css, html, LitElement} from 'lit';
6import {createRef, ref} from 'lit/directives/ref.js';
7
Adrià Vilanova Martínez6f62c7d2022-11-05 20:48:52 +01008import {SHARED_MD3_STYLES} from '../../../../common/styles/md3.js';
9
Adrià Vilanova Martínezca25b682022-10-24 00:11:03 +020010export default class TwptConfirmDialog extends LitElement {
11 static properties = {
12 open: {type: Boolean},
13 workflow: {type: Object},
14 };
15
Adrià Vilanova Martínez6f62c7d2022-11-05 20:48:52 +010016 static styles = [
17 SHARED_MD3_STYLES,
18 css`
19 :host {
20 --mdc-dialog-content-ink-color: var(--mdc-theme-on-surface, #000);
21 --mdc-dialog-z-index: 200;
22 }
Adrià Vilanova Martínezca25b682022-10-24 00:11:03 +020023
Adrià Vilanova Martínez6f62c7d2022-11-05 20:48:52 +010024 .workflow {
25 font-weight: 500;
26 }
27 `,
28 ];
Adrià Vilanova Martínezca25b682022-10-24 00:11:03 +020029
30 constructor() {
31 super();
32 this.open = false;
33 }
34
35 render() {
36 return html`
37 <mwc-dialog
38 ?open=${this.open}
39 @opening=${this._openingDialog}
40 @closing=${this._closingDialog}>
41 <p>
42 Are you sure you want to run workflow
43 <span class="workflow">${this.workflow?.getName?.()}</span> for all
44 the selected threads?
45 </p>
46 <md-filled-button
47 slot="primaryAction"
48 label="Run workflow"
49 @click=${this._dispatchConfirmEvent}>
50 </md-filled-button>
51 <md-text-button
52 slot="secondaryAction"
53 dialogAction="cancel"
54 label="Cancel">
55 </md-text-button>
56 </mwc-dialog>
57 `;
58 }
59
60 _openingDialog() {
61 this.open = true;
62 }
63
64 _closingDialog() {
65 this.open = false;
66 }
67
68 _dispatchConfirmEvent() {
69 const e = new Event('confirm');
70 this.dispatchEvent(e);
71 this.open = false;
72 }
73}
74window.customElements.define('twpt-confirm-dialog', TwptConfirmDialog);