mirror of
https://github.com/ascribe/onion.git
synced 2024-12-23 01:39:36 +01:00
Fix app crashing warnings
This commit is contained in:
parent
fcaa85a0ed
commit
7e0068bec8
@ -43,7 +43,7 @@ let AclInformation = React.createClass({
|
|||||||
if(aim) {
|
if(aim) {
|
||||||
if(aim === 'form') {
|
if(aim === 'form') {
|
||||||
return (
|
return (
|
||||||
<p>
|
<p key={title}>
|
||||||
<span className="info">
|
<span className="info">
|
||||||
{replaceSubstringAtIndex(info.slice(2), 's ', ' ')}
|
{replaceSubstringAtIndex(info.slice(2), 's ', ' ')}
|
||||||
</span>
|
</span>
|
||||||
@ -55,7 +55,7 @@ let AclInformation = React.createClass({
|
|||||||
}
|
}
|
||||||
else if(aim === 'button') {
|
else if(aim === 'button') {
|
||||||
return (
|
return (
|
||||||
<p>
|
<p key={title}>
|
||||||
<span className="title">
|
<span className="title">
|
||||||
{title}
|
{title}
|
||||||
</span>
|
</span>
|
||||||
|
@ -34,11 +34,13 @@ let FileDragAndDropDialog = React.createClass({
|
|||||||
},
|
},
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { enableLocalHashing,
|
const {
|
||||||
|
enableLocalHashing,
|
||||||
fileClassToUpload,
|
fileClassToUpload,
|
||||||
multipleFiles,
|
multipleFiles,
|
||||||
onClick,
|
onClick,
|
||||||
uploadMethod } = this.props;
|
uploadMethod
|
||||||
|
} = this.props;
|
||||||
let dialogElement;
|
let dialogElement;
|
||||||
|
|
||||||
if (enableLocalHashing && !uploadMethod) {
|
if (enableLocalHashing && !uploadMethod) {
|
||||||
@ -66,9 +68,7 @@ let FileDragAndDropDialog = React.createClass({
|
|||||||
{getLangText('Hash your work')}
|
{getLangText('Hash your work')}
|
||||||
</span>
|
</span>
|
||||||
</Link>
|
</Link>
|
||||||
|
|
||||||
<span> {getLangText('or')} </span>
|
<span> {getLangText('or')} </span>
|
||||||
|
|
||||||
<Link
|
<Link
|
||||||
to={`/${window.location.pathname.split('/').pop()}`}
|
to={`/${window.location.pathname.split('/').pop()}`}
|
||||||
query={queryParamsUpload}>
|
query={queryParamsUpload}>
|
||||||
|
@ -3,11 +3,8 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { Link } from 'react-router';
|
import { Link } from 'react-router';
|
||||||
|
|
||||||
import history from '../history';
|
|
||||||
|
|
||||||
import Nav from 'react-bootstrap/lib/Nav';
|
import Nav from 'react-bootstrap/lib/Nav';
|
||||||
import Navbar from 'react-bootstrap/lib/Navbar';
|
import Navbar from 'react-bootstrap/lib/Navbar';
|
||||||
import CollapsibleNav from 'react-bootstrap/lib/CollapsibleNav';
|
|
||||||
import DropdownButton from 'react-bootstrap/lib/DropdownButton';
|
import DropdownButton from 'react-bootstrap/lib/DropdownButton';
|
||||||
import MenuItem from 'react-bootstrap/lib/MenuItem';
|
import MenuItem from 'react-bootstrap/lib/MenuItem';
|
||||||
import NavItem from 'react-bootstrap/lib/NavItem';
|
import NavItem from 'react-bootstrap/lib/NavItem';
|
||||||
@ -43,15 +40,10 @@ let Header = React.createClass({
|
|||||||
// conflicts with routes that may need to wait to load the piece list
|
// conflicts with routes that may need to wait to load the piece list
|
||||||
PieceListStore.listen(this.onChange);
|
PieceListStore.listen(this.onChange);
|
||||||
|
|
||||||
// react-bootstrap 0.25.1 has a bug in which it doesn't
|
|
||||||
// close the mobile expanded navigation after a click by itself.
|
|
||||||
// To get rid of this, we set the state of the component ourselves.
|
|
||||||
history.listen(this.onRouteChange);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
componentWillUnmount() {
|
componentWillUnmount() {
|
||||||
PieceListStore.unlisten(this.onChange);
|
PieceListStore.unlisten(this.onChange);
|
||||||
//history.unlisten(this.onRouteChange);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
onChange(state) {
|
onChange(state) {
|
||||||
@ -116,15 +108,6 @@ let Header = React.createClass({
|
|||||||
this.refs.dropdownbutton.setDropdownState(false);
|
this.refs.dropdownbutton.setDropdownState(false);
|
||||||
},
|
},
|
||||||
|
|
||||||
// On route change, close expanded navbar again since react-bootstrap doesn't close
|
|
||||||
// the collapsibleNav by itself on click. setState() isn't available on a ref so
|
|
||||||
// doing this explicitly is the only way for now.
|
|
||||||
onRouteChange() {
|
|
||||||
if (this.refs.navbar) {
|
|
||||||
this.refs.navbar.state.navExpanded = false;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { currentUser, routes, whitelabel } = this.props;
|
const { currentUser, routes, whitelabel } = this.props;
|
||||||
const { unfilteredPieceListCount } = this.state;
|
const { unfilteredPieceListCount } = this.state;
|
||||||
@ -175,7 +158,7 @@ let Header = React.createClass({
|
|||||||
navRoutesLinks = (
|
navRoutesLinks = (
|
||||||
<NavRoutesLinks
|
<NavRoutesLinks
|
||||||
navbar
|
navbar
|
||||||
right
|
pullRight
|
||||||
hasPieces={!!unfilteredPieceListCount}
|
hasPieces={!!unfilteredPieceListCount}
|
||||||
routes={routes}
|
routes={routes}
|
||||||
userAcl={currentUser.acl} />
|
userAcl={currentUser.acl} />
|
||||||
@ -201,26 +184,30 @@ let Header = React.createClass({
|
|||||||
<div>
|
<div>
|
||||||
<Navbar
|
<Navbar
|
||||||
ref="navbar"
|
ref="navbar"
|
||||||
brand={this.getLogo()}
|
|
||||||
toggleNavKey={0}
|
|
||||||
fixedTop={true}
|
fixedTop={true}
|
||||||
className="hidden-print">
|
className="hidden-print">
|
||||||
<CollapsibleNav eventKey={0}>
|
<Navbar.Header>
|
||||||
<Nav navbar left>
|
<Navbar.Brand>
|
||||||
|
{this.getLogo()}
|
||||||
|
</Navbar.Brand>
|
||||||
|
</Navbar.Header>
|
||||||
|
<Navbar.Collapse
|
||||||
|
eventKey={0}>
|
||||||
|
<Nav navbar pullLeft>
|
||||||
<AclProxy
|
<AclProxy
|
||||||
aclObject={whitelabel}
|
aclObject={whitelabel}
|
||||||
aclName="acl_view_powered_by">
|
aclName="acl_view_powered_by">
|
||||||
{this.getPoweredBy()}
|
{this.getPoweredBy()}
|
||||||
</AclProxy>
|
</AclProxy>
|
||||||
</Nav>
|
</Nav>
|
||||||
<Nav navbar right>
|
<Nav navbar pullRight>
|
||||||
<HeaderNotificationDebug show={false}/>
|
<HeaderNotificationDebug show={false}/>
|
||||||
{account}
|
{account}
|
||||||
{signup}
|
{signup}
|
||||||
</Nav>
|
</Nav>
|
||||||
<HeaderNotifications currentUser={currentUser} />
|
<HeaderNotifications currentUser={currentUser} />
|
||||||
{navRoutesLinks}
|
{navRoutesLinks}
|
||||||
</CollapsibleNav>
|
</Navbar.Collapse>
|
||||||
</Navbar>
|
</Navbar>
|
||||||
<p className="ascribe-print-header visible-print">
|
<p className="ascribe-print-header visible-print">
|
||||||
<span className="icon-ascribe-logo" />
|
<span className="icon-ascribe-logo" />
|
||||||
|
@ -45,31 +45,6 @@ let HeaderNotifications = React.createClass({
|
|||||||
this.setState(state);
|
this.setState(state);
|
||||||
},
|
},
|
||||||
|
|
||||||
onMenuItemClick() {
|
|
||||||
/*
|
|
||||||
This is a hack to make the dropdown close after clicking on an item
|
|
||||||
The function just need to be defined
|
|
||||||
|
|
||||||
from https://github.com/react-bootstrap/react-bootstrap/issues/368:
|
|
||||||
|
|
||||||
@jvillasante - Have you tried to use onSelect with the DropdownButton?
|
|
||||||
I don't have a working example that is exactly like yours,
|
|
||||||
but I just noticed that the Dropdown closes when I've attached an event handler to OnSelect:
|
|
||||||
|
|
||||||
<DropdownButton eventKey={3} title="Admin" onSelect={ this.OnSelected } >
|
|
||||||
|
|
||||||
onSelected: function(e) {
|
|
||||||
// doesn't need to have functionality (necessarily) ... just wired up
|
|
||||||
}
|
|
||||||
Internally, a call to DropdownButton.setDropDownState(false) is made which will hide the dropdown menu.
|
|
||||||
So, you should be able to call that directly on the DropdownButton instance as well if needed.
|
|
||||||
|
|
||||||
NOW, THAT DIDN'T WORK - the onSelect routine isnt triggered in all cases
|
|
||||||
Hence, we do this manually
|
|
||||||
*/
|
|
||||||
this.refs.dropdownbutton.setDropdownState(false);
|
|
||||||
},
|
|
||||||
|
|
||||||
refreshNotifications() {
|
refreshNotifications() {
|
||||||
NotificationActions.fetchPieceListNotifications();
|
NotificationActions.fetchPieceListNotifications();
|
||||||
NotificationActions.fetchEditionListNotifications();
|
NotificationActions.fetchEditionListNotifications();
|
||||||
@ -83,12 +58,18 @@ let HeaderNotifications = React.createClass({
|
|||||||
{`${(isPiece ? 'Artworks' : 'Editions')} (${notifications.length})`}
|
{`${(isPiece ? 'Artworks' : 'Editions')} (${notifications.length})`}
|
||||||
</div>
|
</div>
|
||||||
{notifications.map((notification, i) => {
|
{notifications.map((notification, i) => {
|
||||||
|
const pieceOrEdition = isPiece ? notification.piece : notification.edition;
|
||||||
|
const href = isPiece ? `/pieces/${pieceOrEdition.id}`
|
||||||
|
: `/editions/${pieceOrEdition.bitcoin_id}`;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<MenuItem eventKey={i + 2}>
|
<MenuItem
|
||||||
|
key={href}
|
||||||
|
eventKey={i + 2}
|
||||||
|
href={href}>
|
||||||
<NotificationListItem
|
<NotificationListItem
|
||||||
notification={notification.notification}
|
notification={notification.notification}
|
||||||
pieceOrEdition={isPiece ? notification.piece : notification.edition}
|
pieceOrEdition={pieceOrEdition} />
|
||||||
onClick={this.onMenuItemClick}/>
|
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
@ -112,7 +93,7 @@ let HeaderNotifications = React.createClass({
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Nav navbar right>
|
<Nav navbar pullRight>
|
||||||
<DropdownButton
|
<DropdownButton
|
||||||
ref='dropdownButton'
|
ref='dropdownButton'
|
||||||
id="header-notification-dropdown"
|
id="header-notification-dropdown"
|
||||||
@ -138,25 +119,6 @@ let NotificationListItem = React.createClass({
|
|||||||
propTypes: {
|
propTypes: {
|
||||||
notification: React.PropTypes.array,
|
notification: React.PropTypes.array,
|
||||||
pieceOrEdition: React.PropTypes.object,
|
pieceOrEdition: React.PropTypes.object,
|
||||||
onClick: React.PropTypes.func
|
|
||||||
},
|
|
||||||
|
|
||||||
isPiece() {
|
|
||||||
return !(this.props.pieceOrEdition && this.props.pieceOrEdition.parent);
|
|
||||||
},
|
|
||||||
|
|
||||||
getLinkData() {
|
|
||||||
let { pieceOrEdition } = this.props;
|
|
||||||
|
|
||||||
if (this.isPiece()) {
|
|
||||||
return `/pieces/${pieceOrEdition.id}`;
|
|
||||||
} else {
|
|
||||||
return `/editions/${pieceOrEdition.bitcoin_id}`;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
onClick(event){
|
|
||||||
this.props.onClick(event);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
getNotificationText(){
|
getNotificationText(){
|
||||||
@ -174,7 +136,6 @@ let NotificationListItem = React.createClass({
|
|||||||
render() {
|
render() {
|
||||||
if (this.props.pieceOrEdition) {
|
if (this.props.pieceOrEdition) {
|
||||||
return (
|
return (
|
||||||
<Link to={this.getLinkData()} onClick={this.onClick}>
|
|
||||||
<div className="row notification-wrapper">
|
<div className="row notification-wrapper">
|
||||||
<div className="col-xs-4 clear-paddings">
|
<div className="col-xs-4 clear-paddings">
|
||||||
<div className="thumbnail-wrapper">
|
<div className="thumbnail-wrapper">
|
||||||
@ -187,7 +148,7 @@ let NotificationListItem = React.createClass({
|
|||||||
{this.getNotificationText()}
|
{this.getNotificationText()}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</Link>);
|
);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user