-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix error message * add bundle store cli commands * added store view * fix text * fix test * Update codalab/lib/bundle_cli.py Co-authored-by: Ashwin Ramaswami <[email protected]> * Remove replicate for now * Revert "fix error message" This reverts commit eeaccd7. * Fix endpoints to use bulk, add "cl store add" impl * refresh * more impl for bundle store commands * update * fix * Add deletion, support deletion logic * Fix delete * Support "cl upload --store" * Update references * finishing up * Add name field * Update bundles.py Co-authored-by: Ashwin Ramaswami <[email protected]>
- Loading branch information
Showing
8 changed files
with
383 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
// @flow | ||
import * as React from 'react'; | ||
import SubHeader from '../SubHeader'; | ||
import ContentWrapper from '../ContentWrapper'; | ||
import { renderFormat } from '../../util/worksheet_utils'; | ||
import './Store.scss'; | ||
import ErrorMessage from '../worksheets/ErrorMessage'; | ||
import { fetchStores } from '../../util/apiWrapper'; | ||
|
||
class Store extends React.Component { | ||
state = { | ||
errorMessages: [], | ||
storeInfo: null, | ||
}; | ||
/** | ||
* Fetch store data and update the state of this component. | ||
*/ | ||
refreshStore = () => { | ||
const { uuid } = this.props; | ||
fetchStores(uuid) | ||
.then((response) => { | ||
const { | ||
data: { attributes: storeInfo }, | ||
} = response; | ||
console.log('storeInfo', storeInfo); | ||
|
||
this.setState({ | ||
storeInfo, | ||
}); | ||
}) | ||
.catch((err) => { | ||
this.setState({ errorMessages: [err.toString()] }); | ||
}); | ||
}; | ||
|
||
componentDidMount = () => { | ||
this.refreshStore(); | ||
}; | ||
|
||
/** Renderer. */ | ||
render = () => { | ||
const storeInfo = this.state.storeInfo; | ||
console.log('storeInfo', storeInfo); | ||
if (!storeInfo) { | ||
// Error | ||
if (this.state.errorMessages.length > 0) { | ||
return <ErrorMessage message={"Not found: '/stores/" + this.props.uuid + "'"} />; | ||
} | ||
|
||
// Still loading | ||
return ( | ||
<div id='store-message' className='store-detail'> | ||
<img alt='Loading' src={`${process.env.PUBLIC_URL}/img/Preloader_Small.gif`} />{' '} | ||
Loading store info... | ||
</div> | ||
); | ||
} | ||
|
||
const storeMetadataChanged = this.refreshStore; | ||
|
||
const content = ( | ||
<div id='panel_content'> | ||
{renderErrorMessages(this.state.errorMessages)} | ||
{renderHeader(storeInfo, storeMetadataChanged)} | ||
</div> | ||
); | ||
return ( | ||
<div id='store-content'> | ||
<React.Fragment> | ||
<SubHeader title='Store View' /> | ||
<ContentWrapper>{content}</ContentWrapper> | ||
</React.Fragment> | ||
</div> | ||
); | ||
}; | ||
} | ||
|
||
function renderErrorMessages(messages) { | ||
return ( | ||
<div id='store-error-messages'> | ||
{messages.map((message) => { | ||
return <div className='alert alert-danger alert-dismissable'>{message}</div>; | ||
})} | ||
</div> | ||
); | ||
} | ||
|
||
function createRow(key, value) { | ||
return ( | ||
<tr key={key}> | ||
<th> | ||
<span>{key}</span> | ||
</th> | ||
<td> | ||
<span>{value}</span> | ||
</td> | ||
</tr> | ||
); | ||
} | ||
|
||
function renderHeader(storeInfo) { | ||
// Display basic information. | ||
let rows = []; | ||
rows.push(createRow('name', storeInfo.name)); | ||
rows.push(createRow('uuid', storeInfo.uuid)); | ||
rows.push(createRow('bundle store type', storeInfo.storage_type)); | ||
rows.push(createRow('owner', storeInfo.owner === null ? '<anonymous>' : storeInfo.owner)); | ||
rows.push(createRow('location', storeInfo.url)); | ||
|
||
return ( | ||
<div> | ||
<table className='store-meta table'> | ||
<tbody>{rows.map((elem) => elem)}</tbody> | ||
</table> | ||
</div> | ||
); | ||
} | ||
|
||
export default Store; |
Oops, something went wrong.