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!
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

55 líneas
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. class WBNewProjectDialog extends Component {
  6. constructor(...args) {
  7. super(...args);
  8. this.dialogRef = createRef();
  9. this.state.inputId = uuid.v4();
  10. }
  11. show(ownerUuid, callback) {
  12. const { inputId } = this.state;
  13. this.setState({
  14. 'ownerUuid': ownerUuid,
  15. 'newName': null,
  16. 'placeholderName': 'New Project (' + (new Date()).toISOString() + ')',
  17. 'callback': callback || (() => {})
  18. });
  19. this.dialogRef.current.show();
  20. $('#' + inputId).focus();
  21. }
  22. hide() {
  23. this.dialogRef.current.hide();
  24. }
  25. render({ app }, { ownerUuid, newName, placeholderName, callback, inputId }) {
  26. const { arvHost, arvToken } = app.state;
  27. return (
  28. <WBDialog title="New Project" ref={ this.dialogRef } accept={ () => {
  29. const group = {
  30. 'group_class': 'project',
  31. 'name': newName || placeholderName,
  32. 'owner_uuid': ownerUuid
  33. };
  34. makeArvadosRequest(arvHost, arvToken,
  35. '/arvados/v1/groups', { 'method': 'POST',
  36. 'data': JSON.stringify(group),
  37. 'promiseOrdering': false }
  38. ).then(callback);
  39. } }>
  40. <div>
  41. <input type="text" class="form-control" id={ inputId }
  42. placeholder={ placeholderName }
  43. value={ newName } onChange={ linkState(this, 'newName') } />
  44. </div>
  45. </WBDialog>
  46. );
  47. }
  48. }
  49. export default WBNewProjectDialog;