diff --git a/frontend/src/js/component/wb-collection-listing.js b/frontend/src/js/component/wb-collection-listing.js index 663b11e..2e96671 100644 --- a/frontend/src/js/component/wb-collection-listing.js +++ b/frontend/src/js/component/wb-collection-listing.js @@ -22,7 +22,8 @@ class WBCollectionListing extends Component { prepareRows(items, ownerLookup) { let { app, renderRenameLink, renderDeleteButton, - renderSelectionCell, renderSharingButton } = this.props; + renderSelectionCell, renderSharingButton, + renderEditDescription } = this.props; return items.map(item => [ renderSelectionCell(item), @@ -34,7 +35,9 @@ class WBCollectionListing extends Component {
{ item['uuid'] }
), - item['description'], + (
+ { item['description'] } { renderEditDescription(item, () => this.fetchItems()) } +
), (
{ ownerLookup[item.owner_uuid] ? ( @@ -153,7 +156,9 @@ class WBCollectionListing extends Component { WBCollectionListing.defaultProps = { 'itemsPerPage': 100, - 'ownerUuid': null + 'ownerUuid': null, + 'renderSharingButton': () => null, + 'renderEditDescription': () => null }; export default WBCollectionListing; diff --git a/frontend/src/js/component/wb-process-listing.js b/frontend/src/js/component/wb-process-listing.js index 45e0e35..b4f9130 100644 --- a/frontend/src/js/component/wb-process-listing.js +++ b/frontend/src/js/component/wb-process-listing.js @@ -29,7 +29,9 @@ class WBProcessListing extends Component { prepareRows(requests, containerLookup, ownerLookup, outputLookup) { const { app, renderRenameLink, renderDeleteButton, - renderSelectionCell, renderSharingButton } = this.props; + renderSelectionCell, renderSharingButton, + renderEditDescription } = this.props; + return requests.map(item => { return ( [ renderSelectionCell(item), @@ -40,6 +42,9 @@ class WBProcessListing extends Component { { renderRenameLink(item, () => this.fetchItems()) }
{ item['uuid'] }
+
+ { item.description } { renderEditDescription(item, () => this.fetchItems()) } +
), ( ), ( ), @@ -121,7 +126,8 @@ WBProcessListing.defaultProps = { renderRenameLink: () => null, renderDeleteButton: () => null, renderSelectionCell: () => null, - renderSharingButton: () => null + renderSharingButton: () => null, + renderEditDescription: () => null }; export default WBProcessListing; diff --git a/frontend/src/js/component/wb-project-listing.js b/frontend/src/js/component/wb-project-listing.js index db05be9..e0bf9ee 100644 --- a/frontend/src/js/component/wb-project-listing.js +++ b/frontend/src/js/component/wb-project-listing.js @@ -18,7 +18,8 @@ class WBProjectListing extends Component { prepareRows(items) { const { app, renderRenameLink, renderDeleteButton, - renderSelectionCell, renderSharingButton } = this.props; + renderSelectionCell, renderSharingButton, + renderEditDescription } = this.props; return items.map(item => [ renderSelectionCell(item), @@ -30,7 +31,9 @@ class WBProjectListing extends Component {
{ item['uuid'] }
), - item['description'], + (
+ { item['description'] } { renderEditDescription(item, () => this.fetchItems()) } +
), item['owner_uuid'], (
{ renderDeleteButton(item, () => this.fetchItems()) } @@ -87,7 +90,8 @@ WBProjectListing.defaultProps = { 'ownerUuid': null, 'renderRenameLink': () => null, 'renderDeleteButton': () => null, - 'renderSelectionCell': () => null + 'renderSelectionCell': () => null, + 'renderEditDescription': () => null }; export default WBProjectListing; diff --git a/frontend/src/js/component/wb-workflow-listing.js b/frontend/src/js/component/wb-workflow-listing.js index bd2bf37..84f2d14 100644 --- a/frontend/src/js/component/wb-workflow-listing.js +++ b/frontend/src/js/component/wb-workflow-listing.js @@ -22,7 +22,9 @@ class WBWorkflowListing extends Component { prepareRows(items, ownerLookup) { const { renderRenameLink, renderDeleteButton, - renderSelectionCell, renderSharingButton } = this.props; + renderSelectionCell, renderSharingButton, + renderEditDescription } = this.props; + return items.map(item => [ renderSelectionCell(item), ( @@ -35,7 +37,9 @@ class WBWorkflowListing extends Component {
{ item.uuid }
), - item.description, + (
+ { item.description } { renderEditDescription(item, () => this.fetchItems()) } +
), ( ), wbFormatDate(item.created_at), (
@@ -97,7 +101,9 @@ class WBWorkflowListing extends Component { WBWorkflowListing.defaultProps = { 'itemsPerPage': 100, - 'ownerUuid': null + 'ownerUuid': null, + 'renderSharingButton': () => null, + 'renderEditDescription': () => null }; export default WBWorkflowListing; diff --git a/frontend/src/js/dialog/wb-edit-description-dialog.js b/frontend/src/js/dialog/wb-edit-description-dialog.js new file mode 100644 index 0000000..b2f920c --- /dev/null +++ b/frontend/src/js/dialog/wb-edit-description-dialog.js @@ -0,0 +1,52 @@ +import { h, Component, createRef } from 'preact'; +import WBDialog from 'wb-dialog'; +import linkState from 'linkstate'; +import makeArvadosRequest from 'make-arvados-request'; +import arvadosTypeName from 'arvados-type-name'; + +class WBEditDescriptionDialog extends Component { + constructor(...args) { + super(...args); + this.dialogRef = createRef(); + this.state.inputId = uuid.v4(); + } + + show(item, callback) { + const { inputId } = this.state; + this.setState({ + 'item': item, + 'newDescription': null, + 'callback': callback || (() => {}) + }); + this.dialogRef.current.show(); + $('#' + inputId).focus(); + } + + hide() { + this.dialogRef.current.hide(); + } + + render({ app }, { item, newDescription, callback, inputId }) { + const { arvHost, arvToken } = app.state; + return ( + + makeArvadosRequest(arvHost, arvToken, + '/arvados/v1/' + arvadosTypeName(item.uuid) + + 's/' + item.uuid, { + method: 'PUT', + data: JSON.stringify({ + description: newDescription || null + }) + }).then(callback) + }> +
+ +
+
+ ); + } +} + +export default WBEditDescriptionDialog; diff --git a/frontend/src/js/page/wb-browse.js b/frontend/src/js/page/wb-browse.js index d4c2dc5..da81311 100644 --- a/frontend/src/js/page/wb-browse.js +++ b/frontend/src/js/page/wb-browse.js @@ -11,6 +11,7 @@ import WBWorkflowListing from 'wb-workflow-listing'; import WBRenameDialog from 'wb-rename-dialog'; import WBDeleteDialog from 'wb-delete-dialog'; import WBNewProjectDialog from 'wb-new-project-dialog'; +import WBEditDescriptionDialog from 'wb-edit-description-dialog'; import wbMoveObject from 'wb-move-object'; import wbCopyCollection from 'wb-copy-collection'; import arvadosTypeName from 'arvados-type-name'; @@ -45,6 +46,7 @@ class WBBrowse extends Component { this.newProjectDialogRef = createRef(); this.projectListingRef = createRef(); this.projectTabsRef = createRef(); + this.editDescriptionDialogRef = createRef(); this.state.selected = {}; } @@ -85,6 +87,16 @@ class WBBrowse extends Component { ); } + renderEditDescription(item, callback) { + return ( + { e.preventDefault(); + this.editDescriptionDialogRef.current.show(item, callback); } }> + + + + ); + } + renderDeleteButton(item, callback) { return (