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.

67 lines
2.2KB

  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. projectDescription }) {
  27. const { arvHost, arvToken } = app.state;
  28. return (
  29. <WBDialog title="New Project" ref={ this.dialogRef } accept={ () => {
  30. const group = {
  31. 'group_class': 'project',
  32. 'name': newName || placeholderName,
  33. 'description': projectDescription || null,
  34. 'owner_uuid': ownerUuid
  35. };
  36. makeArvadosRequest(arvHost, arvToken,
  37. '/arvados/v1/groups', { 'method': 'POST',
  38. 'data': JSON.stringify(group),
  39. 'expectedStatus': [200, 202] }
  40. ).then(callback);
  41. } }>
  42. <div>
  43. <div class="form-group">
  44. <label for={ inputId }>Project Name</label>
  45. <input type="text" class="form-control" id={ inputId }
  46. placeholder={ placeholderName }
  47. value={ newName } onChange={ linkState(this, 'newName') } />
  48. </div>
  49. <div class="form-group">
  50. <label for="projectDescription">Project Description (optional)</label>
  51. <input type="text" class="form-control" id="projectDescription"
  52. placeholder="Project Description (optional)"
  53. value={ projectDescription } onChange={ linkState(this, 'projectDescription') } />
  54. </div>
  55. </div>
  56. </WBDialog>
  57. );
  58. }
  59. }
  60. export default WBNewProjectDialog;