@@ -8,6 +8,14 @@ import wbFormatDate from 'wb-format-date'; | |||||
import WBNameAndUuid from 'wb-name-and-uuid'; | import WBNameAndUuid from 'wb-name-and-uuid'; | ||||
import WBAccordion from 'wb-accordion'; | import WBAccordion from 'wb-accordion'; | ||||
function formatSpecialValue(value) { | |||||
if (value === null) return (<i>null</i>); | |||||
if (value === undefined) return (<i>undefined</i>); | |||||
if (typeof(value) === 'boolean') return (<i>{ String(value) }</i>); | |||||
if (value === '') return '-'; | |||||
return String(value); | |||||
} | |||||
class WBCollectionFields extends Component { | class WBCollectionFields extends Component { | ||||
componentDidMount() { | componentDidMount() { | ||||
this.prepareRows(); | this.prepareRows(); | ||||
@@ -25,7 +33,7 @@ class WBCollectionFields extends Component { | |||||
const filters = [ | const filters = [ | ||||
['uuid', '=', uuid] | ['uuid', '=', uuid] | ||||
]; | ]; | ||||
let prom = makeArvadosRequest(arvHost, arvToken, | let prom = makeArvadosRequest(arvHost, arvToken, | ||||
'/arvados/v1/collections?filters=' + encodeURIComponent(JSON.stringify(filters))); | '/arvados/v1/collections?filters=' + encodeURIComponent(JSON.stringify(filters))); | ||||
@@ -35,7 +43,7 @@ class WBCollectionFields extends Component { | |||||
throw Error('Item not found'); | throw Error('Item not found'); | ||||
let rows = [ | let rows = [ | ||||
[ 'Name', item.name ], | [ 'Name', item.name ], | ||||
[ 'Description', item.description || (<i>{ String(item.description) }</i>) ], | |||||
[ 'Description', formatSpecialValue(item.description) ], | |||||
[ 'Properties', ( | [ 'Properties', ( | ||||
<WBAccordion names={ ['Properties'] } cardHeaderClass="card-header-sm"> | <WBAccordion names={ ['Properties'] } cardHeaderClass="card-header-sm"> | ||||
<pre class="word-wrap">{ JSON.stringify(item.properties, null, 2) }</pre> | <pre class="word-wrap">{ JSON.stringify(item.properties, null, 2) }</pre> | ||||
@@ -22,18 +22,14 @@ class WBCommonFields extends Component { | |||||
let { uuid, app } = this.props; | let { uuid, app } = this.props; | ||||
let { arvHost, arvToken } = app.state; | let { arvHost, arvToken } = app.state; | ||||
const filters = [ | |||||
['uuid', '=', uuid] | |||||
]; | |||||
const typeName = arvadosTypeName(uuid); | |||||
let prom = makeArvadosRequest(arvHost, arvToken, | let prom = makeArvadosRequest(arvHost, arvToken, | ||||
'/arvados/v1/' + arvadosTypeName(uuid) + | |||||
's?filters=' + encodeURIComponent(JSON.stringify(filters))); | |||||
'/arvados/v1/' + typeName + 's/' + | |||||
encodeURIComponent(uuid)); | |||||
prom = prom.then(xhr => { | prom = prom.then(xhr => { | ||||
const item = xhr.response.items[0]; | |||||
if (!item) | |||||
throw Error('Item not found'); | |||||
const item = xhr.response; | |||||
let rows = [ | let rows = [ | ||||
[ 'UUID', item.uuid ], | [ 'UUID', item.uuid ], | ||||
[ 'Kind', item.kind ], | [ 'Kind', item.kind ], | ||||
@@ -43,14 +39,14 @@ class WBCommonFields extends Component { | |||||
[ 'Created at', wbFormatDate(item.created_at) ], | [ 'Created at', wbFormatDate(item.created_at) ], | ||||
[ 'Modified at', wbFormatDate(item.modified_at) ], | [ 'Modified at', wbFormatDate(item.modified_at) ], | ||||
[ 'Modified by User', ( | [ 'Modified by User', ( | ||||
<WBNameAndUuid app={ app } uuid={ item.modified_by_user_uuid } /> | |||||
item.modified_by_user_uuid ? (<WBNameAndUuid app={ app } uuid={ item.modified_by_user_uuid } />) : '-' | |||||
) ], | ) ], | ||||
[ 'Modified by Client', ( | [ 'Modified by Client', ( | ||||
<WBNameAndUuid app={ app } uuid={ item.modified_by_client_uuid } /> | |||||
item.modified_by_client_uuid ? (<WBNameAndUuid app={ app } uuid={ item.modified_by_client_uuid } />) : '-' | |||||
) ], | ) ], | ||||
[ 'API Url', ( | [ 'API Url', ( | ||||
<a href={ 'https://' + app.state.arvHost + '/arvados/v1' + item.href }> | |||||
{ 'https://' + app.state.arvHost + '/arvados/v1' + item.href } | |||||
<a href={ 'https://' + app.state.arvHost + '/arvados/v1/' + typeName + 's/' + uuid }> | |||||
{ 'https://' + app.state.arvHost + '/arvados/v1/' + typeName + 's/' + uuid } | |||||
</a> | </a> | ||||
) ], | ) ], | ||||
[ 'ETag', item.etag ] | [ 'ETag', item.etag ] | ||||
@@ -87,7 +87,7 @@ class WBNameAndUuid extends Component { | |||||
return; | return; | ||||
if (nextProps.lazy) { | if (nextProps.lazy) { | ||||
this.setState({ item: { uuid: nextProps.uuid }}); | |||||
this.setState({ item: null }); | |||||
} else { | } else { | ||||
this.props = nextProps; | this.props = nextProps; | ||||
@@ -3,6 +3,7 @@ import { route } from 'preact-router'; | |||||
import makeArvadosRequest from 'make-arvados-request'; | import makeArvadosRequest from 'make-arvados-request'; | ||||
import WBTable from 'wb-table'; | import WBTable from 'wb-table'; | ||||
import WBPagination from 'wb-pagination'; | import WBPagination from 'wb-pagination'; | ||||
import WBNameAndUuid from 'wb-name-and-uuid'; | |||||
class WBProjectListing extends Component { | class WBProjectListing extends Component { | ||||
@@ -34,7 +35,7 @@ class WBProjectListing extends Component { | |||||
(<div> | (<div> | ||||
{ item['description'] } { renderEditDescription(item, () => this.fetchItems()) } | { item['description'] } { renderEditDescription(item, () => this.fetchItems()) } | ||||
</div>), | </div>), | ||||
item['owner_uuid'], | |||||
( <WBNameAndUuid app={ app } uuid={ item['owner_uuid'] } lazy={ true } /> ), | |||||
(<div> | (<div> | ||||
{ renderDeleteButton(item, () => this.fetchItems()) } | { renderDeleteButton(item, () => this.fetchItems()) } | ||||
{ renderSharingButton(item) } | { renderSharingButton(item) } | ||||
@@ -0,0 +1,9 @@ | |||||
function wbFormatSpecialValue(value) { | |||||
if (value === null) return (<i>null</i>); | |||||
if (value === undefined) return (<i>undefined</i>); | |||||
if (typeof(value) === 'boolean') return (<i>{ String(value) }</i>); | |||||
if (value === '') return '-'; | |||||
return String(value); | |||||
} | |||||
export default wbFormatSpecialValue; |