// // Copyright (C) Stanislaw Adaszewski, 2020 // Contact: s.adaszewski@gmail.com // Website: https://adared.ch/wba // License: GNU Affero General Public License, Version 3 // import { h, Component, createRef } from 'preact'; import WBDialog from 'wb-dialog'; import linkState from 'linkstate'; import wbRenameObject from 'wb-rename-object'; class WBRenameDialog extends Component { constructor(...args) { super(...args); this.dialogRef = createRef(); this.state.inputId = uuid.v4(); } show(item, callback) { const { inputId } = this.state; this.setState({ 'item': item, 'newName': null, 'callback': callback || (() => {}) }); this.dialogRef.current.show(); $('#' + inputId).focus(); } hide() { this.dialogRef.current.hide(); } render({ app }, { item, newName, callback, inputId }) { const { arvHost, arvToken } = app.state; return ( { if (newName) wbRenameObject(arvHost, arvToken, item.uuid, newName).then(callback); } }>
); } } export default WBRenameDialog;