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.

61 lines
1.7KB

  1. //
  2. // Copyright (C) Stanislaw Adaszewski, 2020
  3. // Contact: s.adaszewski@gmail.com
  4. // Website: https://adared.ch/wba
  5. // License: GNU Affero General Public License, Version 3
  6. //
  7. import { h, Component, createRef } from 'preact';
  8. import WBDialog from 'wb-dialog';
  9. import WBArvadosCrumbs from 'wb-arvados-crumbs';
  10. import linkState from 'linkstate';
  11. import wbDeleteObject from 'wb-delete-object';
  12. import arvadosTypeName from 'arvados-type-name';
  13. class WBDeleteDialog extends Component {
  14. constructor(...args) {
  15. super(...args);
  16. this.dialogRef = createRef();
  17. }
  18. show(item, callback) {
  19. this.setState({
  20. 'item': item,
  21. 'callback': callback || (() => {})
  22. });
  23. this.dialogRef.current.show();
  24. }
  25. hide() {
  26. this.dialogRef.current.hide();
  27. }
  28. render({ app }, { item, callback }) {
  29. const { arvHost, arvToken } = app.state;
  30. return (
  31. <WBDialog title="Delete" ref={ this.dialogRef }>
  32. <div>
  33. <div class="mb-3">
  34. Are you sure you want to delete the following { item ? arvadosTypeName(item.uuid) : null }:
  35. </div>
  36. { item ? <WBArvadosCrumbs app={ app } uuid={ item.uuid } /> : null }
  37. <div>???</div>
  38. </div>
  39. <div>
  40. <input type="submit" class="btn btn-danger mr-2" value="Delete"
  41. onclick={ e => { e.preventDefault(); this.hide();
  42. wbDeleteObject(arvHost, arvToken, item.uuid).then(callback); } } />
  43. <button class="btn btn-secondary mr-2" onclick={ e => { e.preventDefault();
  44. this.hide(); } }>
  45. Cancel
  46. </button>
  47. </div>
  48. </WBDialog>
  49. );
  50. }
  51. }
  52. export default WBDeleteDialog;