IF YOU WOULD LIKE TO GET AN ACCOUNT, please write an email to s dot adaszewski at gmail dot com. User accounts are meant only to report issues and/or generate pull requests. This is a purpose-specific Git hosting for ADARED projects. Thank you for your understanding!
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
1.6KB

  1. import { h, Component, createRef } from 'preact';
  2. import WBDialog from 'wb-dialog';
  3. import linkState from 'linkstate';
  4. import makeArvadosRequest from 'make-arvados-request';
  5. import arvadosTypeName from 'arvados-type-name';
  6. class WBEditDescriptionDialog extends Component {
  7. constructor(...args) {
  8. super(...args);
  9. this.dialogRef = createRef();
  10. this.state.inputId = uuid.v4();
  11. }
  12. show(item, callback) {
  13. const { inputId } = this.state;
  14. this.setState({
  15. 'item': item,
  16. 'newDescription': null,
  17. 'callback': callback || (() => {})
  18. });
  19. this.dialogRef.current.show();
  20. $('#' + inputId).focus();
  21. }
  22. hide() {
  23. this.dialogRef.current.hide();
  24. }
  25. render({ app }, { item, newDescription, callback, inputId }) {
  26. const { arvHost, arvToken } = app.state;
  27. return (
  28. <WBDialog title="Edit Description" ref={ this.dialogRef } accept={ () =>
  29. makeArvadosRequest(arvHost, arvToken,
  30. '/arvados/v1/' + arvadosTypeName(item.uuid) +
  31. 's/' + item.uuid, {
  32. method: 'PUT',
  33. data: JSON.stringify({
  34. description: newDescription || null
  35. })
  36. }).then(callback)
  37. }>
  38. <div>
  39. <input type="text" class="form-control" id={ inputId }
  40. placeholder={ (item && item.description) ? item.description : 'Type new description here' }
  41. value={ newDescription } onChange={ linkState(this, 'newDescription') } />
  42. </div>
  43. </WBDialog>
  44. );
  45. }
  46. }
  47. export default WBEditDescriptionDialog;