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.

71 lines
2.1KB

  1. import { h, Component } from 'preact';
  2. import WBTable from 'wb-table';
  3. import makeArvadosRequest from 'make-arvados-request';
  4. import WBAccordion from 'wb-accordion';
  5. import WBJsonViewer from 'wb-json-viewer';
  6. import wbFormatSpecialValue from 'wb-format-special-value';
  7. import WBLazyInlineName from 'wb-lazy-inline-name';
  8. import wbFormatDate from 'wb-format-date';
  9. import wbUpdateField from 'wb-update-field';
  10. import WBJsonEditor from 'wb-json-editor';
  11. class WBProjectFields extends Component {
  12. componentDidMount() {
  13. this.fetchData();
  14. }
  15. componentWillReceiveProps(nextProps) {
  16. this.props = nextProps;
  17. this.fetchData();
  18. }
  19. prepareRows(item) {
  20. const { app } = this.props;
  21. const { arvHost, arvToken } = app.state;
  22. const rows = [
  23. [ 'Name', wbFormatSpecialValue(item.name) ],
  24. [ 'Description', wbFormatSpecialValue(item.description) ],
  25. [ 'Properties', (
  26. <WBJsonEditor name="Properties" app={ app } value={ item.properties }
  27. onChange={ value => wbUpdateField(arvHost, arvToken, item.uuid, 'properties', value)
  28. .then(() => { item.properties = value; this.prepareRows(item); }) } />
  29. ) ],
  30. [ 'Writable by', item.writable_by
  31. .map(a => (<WBLazyInlineName app={ app } identifier={ a } />))
  32. .reduce((a, b) => [].concat(a).concat(', ').concat(b))
  33. ],
  34. [ 'Trash At', wbFormatDate(item.trash_at) ],
  35. [ 'Delete At', wbFormatDate(item.delete_at) ],
  36. [ 'Is Trashed', wbFormatSpecialValue(item.is_trashed) ]
  37. ];
  38. this.setState({ rows });
  39. }
  40. fetchData() {
  41. let { uuid, app } = this.props;
  42. let { arvHost, arvToken } = app.state;
  43. let prom = makeArvadosRequest(arvHost, arvToken,
  44. '/arvados/v1/groups/' + uuid);
  45. prom = prom.then(xhr => this.prepareRows(xhr.response));
  46. }
  47. render({}, { rows }) {
  48. return (
  49. rows ? (
  50. <WBTable columns={ [ "Name", "Value" ] }
  51. headerClasses={ [ "col-sm-2", "col-sm-4" ] }
  52. rows={ rows }
  53. verticalHeader={ true } />
  54. ) : (
  55. <div>Loading...</div>
  56. )
  57. );
  58. }
  59. }
  60. export default WBProjectFields;