blob: ece9a757cb0a0c56c890f19122f3e1b71dde411a [file] [log] [blame]
Adrià Vilanova Martínezc6e1ce32024-02-26 03:34:13 +01001import '@material/web/dialog/dialog.js';
Adrià Vilanova Martínezca25b682022-10-24 00:11:03 +02002import '@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`
Adrià Vilanova Martínezc6e1ce32024-02-26 03:34:13 +010037 <md-dialog
Adrià Vilanova Martínezca25b682022-10-24 00:11:03 +020038 ?open=${this.open}
Adrià Vilanova Martínezc6e1ce32024-02-26 03:34:13 +010039 @open=${this._openingDialog}
40 @close=${this._closingDialog}>
41 <div slot="content">
Adrià Vilanova Martínezca25b682022-10-24 00:11:03 +020042 Are you sure you want to run workflow
43 <span class="workflow">${this.workflow?.getName?.()}</span> for all
44 the selected threads?
Adrià Vilanova Martínezc6e1ce32024-02-26 03:34:13 +010045 </div>
46 <div slot="actions">
47 <md-filled-button
48 @click=${this._dispatchConfirmEvent}>
49 Run workflow
50 </md-filled-button>
51 <md-text-button
52 @click=${() => this.open = false}>
53 Cancel
54 </md-text-button>
55 </div>
56 </md-dialog>
Adrià Vilanova Martínezca25b682022-10-24 00:11:03 +020057 `;
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);