'use strict'; const {dialog} = require('electron').remote; const BaseComponent = require(__dirname + '/../../components/base.js'); const DomainUtil = require(__dirname + '/../../utils/domain-util.js'); class ServerInfoForm extends BaseComponent { constructor(props) { super(); this.props = props; } template() { return `
Name
Url
Icon
indeterminate_check_box Delete
`; } init() { this.initForm(); this.initActions(); } initForm() { this.$serverInfoForm = this.generateNodeFromTemplate(this.template()); this.$deleteServerButton = this.$serverInfoForm.getElementsByClassName('server-delete-action')[0]; this.props.$root.appendChild(this.$serverInfoForm); } initActions() { this.$deleteServerButton.addEventListener('click', () => { dialog.showMessageBox({ type: 'warning', buttons: ['YES', 'NO'], defaultId: 0, message: 'Are you sure you want to delete this server?' }, response => { if (response === 0) { DomainUtil.removeDomain(this.props.index); this.props.onChange(this.props.index); } }); }); } } module.exports = ServerInfoForm;