-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds PrivatePage container to wrap internal components
* PrivatePage wraps components that are only accessible when logged in * PrivatePage contains the toolbar * It does a cookie-check and redirects to login when no cookie Fixes #702 Fixes #679
- Loading branch information
Showing
6 changed files
with
98 additions
and
140 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import React from 'react'; | ||
|
||
import { getInstance } from '../common/api'; | ||
import { trackException } from '../common/tracking'; | ||
import Toolbar from './toolbar'; | ||
|
||
export default class PrivatePage extends React.Component { | ||
|
||
constructor() { | ||
super(); | ||
this.state = { | ||
instance: null | ||
}; | ||
|
||
this.handleInstanceSuccess = this.handleInstanceSuccess.bind(this); | ||
this.handleInstanceError = this.handleInstanceError.bind(this); | ||
} | ||
|
||
handleInstanceSuccess(instance) { | ||
this.setState({ instance }); | ||
} | ||
|
||
handleInstanceError(res) { | ||
trackException(res); | ||
} | ||
|
||
componentDidMount() { | ||
if (this.props.orgId) { | ||
// includes a cookie check | ||
getInstance(this.props.orgId) | ||
.then(this.handleInstanceSuccess) | ||
.catch(this.handleInstanceError); | ||
} | ||
} | ||
|
||
render() { | ||
const styles = { | ||
backgroundContainer: { | ||
height: '100%', | ||
position: 'relative' | ||
} | ||
}; | ||
|
||
return ( | ||
<div style={styles.backgroundContainer}> | ||
<Toolbar | ||
page={this.props.page} | ||
instance={this.state.instance} | ||
orgId={this.props.orgId} /> | ||
{this.props.children} | ||
</div> | ||
); | ||
} | ||
} |
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
Oops, something went wrong.