added proptype checks to components

This commit is contained in:
bill bittner 2018-02-04 16:40:28 -08:00
parent 339f213482
commit 0a541b6dd9
7 changed files with 54 additions and 32 deletions
react
components
AssetDisplay
AssetInfo
AssetPreview
ShowAssetDetails
ShowAssetLite
containers
ChannelClaimsDisplay
ShowAsset

View file

@ -1,8 +1,8 @@
import React from 'react'; import React from 'react';
import PropTypes from 'prop-types';
import ProgressBar from 'components/ProgressBar'; import ProgressBar from 'components/ProgressBar';
import Request from 'utils/request'; import Request from 'utils/request';
import { LOCAL_CHECK, SEARCHING, UNAVAILABLE, AVAILABLE } from 'constants/asset_display_states'; import { LOCAL_CHECK, SEARCHING, UNAVAILABLE, AVAILABLE } from 'constants/asset_display_states';
import PropTypes from 'prop-types';
class AssetDisplay extends React.Component { class AssetDisplay extends React.Component {
constructor (props) { constructor (props) {
@ -128,7 +128,6 @@ AssetDisplay.propTypes = {
contentType: PropTypes.string.isRequired, contentType: PropTypes.string.isRequired,
fileExt : PropTypes.string.isRequired, fileExt : PropTypes.string.isRequired,
thumbnail : PropTypes.string, thumbnail : PropTypes.string,
// shortId : PropTypes.string.isRequired,
}; };
export default AssetDisplay; export default AssetDisplay;

View file

@ -1,11 +1,12 @@
import React from 'react'; import React from 'react';
import PropTypes from 'prop-types';
class AssetInfo extends React.Component { class AssetInfo extends React.Component {
constructor (props) { constructor (props) {
super(props); super(props);
this.state = { this.state = {
showDetails: false, showDetails: false,
} };
this.toggleDetails = this.toggleDetails.bind(this); this.toggleDetails = this.toggleDetails.bind(this);
this.copyToClipboard = this.copyToClipboard.bind(this); this.copyToClipboard = this.copyToClipboard.bind(this);
} }
@ -80,7 +81,7 @@ class AssetInfo extends React.Component {
{(this.props.contentType === 'video/mp4') ? ( {(this.props.contentType === 'video/mp4') ? (
<input type="text" id="embed-text" className="input-disabled input-text--full-width" readOnly <input type="text" id="embed-text" className="input-disabled input-text--full-width" readOnly
onClick={this.select} spellCheck="false" onClick={this.select} spellCheck="false"
value={`<video width="100%" controls poster="${this.props.thumbnail}" src="${this.props.host}/{claimInfo.claimId}/${this.props.name}.${this.props.fileExt}"/></video>`}/> value={`<video width="100%" controls poster="${this.props.thumbnail}" src="${this.props.host}/${this.props.claimId}/${this.props.name}.${this.props.fileExt}"/></video>`}/>
) : ( ) : (
<input type="text" id="embed-text" className="input-disabled input-text--full-width" readOnly <input type="text" id="embed-text" className="input-disabled input-text--full-width" readOnly
onClick={this.select} spellCheck="false" onClick={this.select} spellCheck="false"
@ -162,5 +163,17 @@ class AssetInfo extends React.Component {
// required props // required props
// {channelName, certificateId, description, shortClaimId, name, fileExt, claimId, contentType, thumbnail, host} // {channelName, certificateId, description, shortClaimId, name, fileExt, claimId, contentType, thumbnail, host}
AssetInfo.propTypes = {
channelName : PropTypes.string,
certificateId: PropTypes.string,
description : PropTypes.string,
// shortClaimId : PropsTypes.string.isRequired,
name : PropTypes.string.isRequired,
claimId : PropTypes.string.isRequired,
contentType : PropTypes.string.isRequired,
fileExt : PropTypes.string.isRequired,
thumbnail : PropTypes.string,
host : PropTypes.string.isRequired,
};
export default AssetInfo; export default AssetInfo;

View file

@ -5,12 +5,11 @@ const AssetPreview = ({ name, claimId, fileExt, contentType }) => {
const directSourceLink = `${claimId}/${name}.${fileExt}`; const directSourceLink = `${claimId}/${name}.${fileExt}`;
const showUrlLink = `${claimId}/${name}`; const showUrlLink = `${claimId}/${name}`;
const previewHolderStyle = { const previewHolderStyle = {
clear : 'both', clear : 'both',
display : 'inline-block', display: 'inline-block',
width : '31%', width : '31%',
padding : '0px', padding: '0px',
margin : '1%', margin : '1%',
backgroundColor: 'black',
}; };
const assetStyle = { const assetStyle = {
width : '100%', width : '100%',

View file

@ -1,4 +1,5 @@
import React from 'react'; import React from 'react';
import PropTypes from 'prop-types';
import NavBar from 'containers/NavBar'; import NavBar from 'containers/NavBar';
import AssetTitle from 'components/AssetTitle'; import AssetTitle from 'components/AssetTitle';
import AssetDisplay from 'components/AssetDisplay'; import AssetDisplay from 'components/AssetDisplay';
@ -39,10 +40,10 @@ class ShowAssetDetails extends React.Component {
channelName={this.props.claimData.channelName} channelName={this.props.claimData.channelName}
certificateId={this.props.claimData.certificateId} certificateId={this.props.claimData.certificateId}
description={this.props.claimData.description} description={this.props.claimData.description}
shortClaimId={this.props.claimData.shortClaimId}
name={this.props.claimData.name} name={this.props.claimData.name}
fileExt={this.props.claimData.fileExt}
claimId={this.props.claimData.claimId} claimId={this.props.claimData.claimId}
shortClaimId={this.props.claimData.shortClaimId}
fileExt={this.props.claimData.fileExt}
contentType={this.props.claimData.contentType} contentType={this.props.claimData.contentType}
thumbnail={this.props.claimData.thumbnail} thumbnail={this.props.claimData.thumbnail}
host={this.props.claimData.host} host={this.props.claimData.host}
@ -56,11 +57,10 @@ class ShowAssetDetails extends React.Component {
} }
}; };
// required props ShowAssetDetails.propTypes = {
// isChannel error : PropTypes.string,
// channelName claimData: PropTypes.object.isRequired,
// channelClaimId // shortUrl: PropTypes.string.isRequired,
// claimId };
// claimName
export default ShowAssetDetails; export default ShowAssetDetails;

View file

@ -1,4 +1,5 @@
import React from 'react'; import React from 'react';
import PropTypes from 'prop-types';
import { Link } from 'react-router-dom'; import { Link } from 'react-router-dom';
import AssetDisplay from 'components/AssetDisplay'; import AssetDisplay from 'components/AssetDisplay';
@ -27,4 +28,9 @@ class ShowLite extends React.Component {
} }
}; };
ShowLite.propTypes = {
error : PropTypes.string,
claimData: PropTypes.object.isRequired,
};
export default ShowLite; export default ShowLite;

View file

@ -82,8 +82,4 @@ class ChannelClaimsDisplay extends React.Component {
} }
}; };
// PropTypes
// name
// id
export default ChannelClaimsDisplay; export default ChannelClaimsDisplay;

View file

@ -82,21 +82,30 @@ class ShowAsset extends React.Component {
}); });
}); });
} }
componentWillUnmount () {
this.props.onAssetClaimDataClear();
}
render () { render () {
if (this.props.extension) { if (this.props.claimData) {
return ( return (
<ShowAssetLite <div>
error={this.state.error} { this.props.extension ? (
claimData={this.props.claimData} <ShowAssetLite
/> error={this.state.error}
claimData={this.props.claimData}
/>
) : (
<ShowAssetDetails
error={this.state.error}
claimData={this.props.claimData}
// shortUrl={this.props.shortUrl}
/>
)}
</div>
); );
} }
return ( return (
<ShowAssetDetails <div></div>
error={this.state.error}
claimData={this.props.claimData}
// shortUrl={this.props.shortUrl}
/>
); );
} }
}; };