blob: b3b08d2735918edd8abd5a3e56350f1de2759d74 [file] [log] [blame]
Adrià Vilanova Martínezf276ac72022-10-13 22:16:22 +02001import '@material/web/fab/fab.js';
Renovate botaa5fb8e2024-02-25 18:10:09 +00002import '@material/web/icon/icon.js';
Adrià Vilanova Martínezf276ac72022-10-13 22:16:22 +02003import './components/List.js';
4import './components/AddDialog.js';
Adrià Vilanova Martínez8803b6c2022-10-17 00:36:38 +02005import './components/WorkflowDialog.js';
Adrià Vilanova Martínezf276ac72022-10-13 22:16:22 +02006
7import {css, html, LitElement} from 'lit';
8import {createRef, ref} from 'lit/directives/ref.js';
9
10import {SHARED_MD3_STYLES} from '../../common/styles/md3.js';
Adrià Vilanova Martínez7f1e8ea2022-10-14 15:50:11 +020011import {default as WorkflowsStorage, kWorkflowsDataKey} from '../workflowsStorage.js';
Adrià Vilanova Martínezf276ac72022-10-13 22:16:22 +020012
13export default class WFApp extends LitElement {
14 static styles = [
15 SHARED_MD3_STYLES,
16 css`
17 :host {
18 font-family: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI',
19 Helvetica, Arial, sans-serif, 'Apple Color Emoji',
20 'Segoe UI Emoji', 'Segoe UI Symbol'!important;
21
22 display: block;
23 max-width: 1024px;
24 margin: auto;
25 position: relative;
26 }
27
28 md-fab {
29 position: fixed;
30 bottom: 2em;
31 right: 2em;
32 }
33 `,
34 ];
35
36 addFabRef = createRef();
Adrià Vilanova Martínez8803b6c2022-10-17 00:36:38 +020037 addDialog = createRef();
Adrià Vilanova Martínezf276ac72022-10-13 22:16:22 +020038
Adrià Vilanova Martínez7f1e8ea2022-10-14 15:50:11 +020039 constructor() {
40 super();
41 this._workflows = undefined;
Adrià Vilanova Martínez0caffdd2022-10-17 19:40:35 +020042 WorkflowsStorage.watch(workflows => {
43 this._workflows = workflows;
44 this.requestUpdate();
45 }, /* asProtobuf = */ true);
Adrià Vilanova Martínez7f1e8ea2022-10-14 15:50:11 +020046 }
47
Adrià Vilanova Martínezf276ac72022-10-13 22:16:22 +020048 render() {
49 return html`
50 <h1>Workflows</h1>
Adrià Vilanova Martínez7f1e8ea2022-10-14 15:50:11 +020051 <p>Workflows allow you to run a customized list of actions on a thread easily.</p>
52 <wf-list .workflows=${this._workflows}></wf-list>
Adrià Vilanova Martínezf276ac72022-10-13 22:16:22 +020053 <md-fab ${ref(this.addFabRef)}
Adrià Vilanova Martínezf276ac72022-10-13 22:16:22 +020054 @click=${this._showAddDialog}>
Renovate botaa5fb8e2024-02-25 18:10:09 +000055 <md-icon slot="icon">add</md-icon>
Adrià Vilanova Martínezf276ac72022-10-13 22:16:22 +020056 </md-fab>
Adrià Vilanova Martínez8803b6c2022-10-17 00:36:38 +020057 <wf-add-dialog ${ref(this.addDialog)}>
58 </wf-add-dialog>
Adrià Vilanova Martínezf276ac72022-10-13 22:16:22 +020059 `;
60 }
61
Adrià Vilanova Martínezf276ac72022-10-13 22:16:22 +020062 _showAddDialog() {
Adrià Vilanova Martínez8803b6c2022-10-17 00:36:38 +020063 this.addDialog.value.open = true;
Adrià Vilanova Martínezf276ac72022-10-13 22:16:22 +020064 }
65}
66window.customElements.define('wf-app', WFApp);