Skip to content

Commit

Permalink
Add JSDoc comments for props in EnvironmentBanner
Browse files Browse the repository at this point in the history
  • Loading branch information
Mr0grog committed Feb 3, 2018
1 parent 6fa9ee2 commit c4b981d
Showing 1 changed file with 12 additions and 16 deletions.
28 changes: 12 additions & 16 deletions src/components/environment-banner.jsx
Original file line number Diff line number Diff line change
@@ -1,31 +1,29 @@
import React from 'react';

/**
* A banner to conditionally display warnings to users about the environment.
* @typedef EnvironmentBannerProps
* @property {string} apiUrl
*/

import React from 'react';

/**
* A banner to conditionally display warnings to users about the environment.
*
* @class EnvironmentBanner
* @extends {React.Component}
* @param {EnvironmentBannerProps} props
*/
export default class EnvironmentBanner extends React.Component {

constructor(props) {
super(props);
this.state = {
apiEnvironment: 'production',
dismissed: false,
};

// Would be preferable to use WebMonitoringDb rather than parse environment
// info from the API URL.

// webMonitoringConfig is a global, unimported external dependency
// We expect it to be in the 'window' namepace.
// this.dbapi = new WebMonitoringDb({
// url: webMonitoringConfig.WEB_MONITORING_DB_URL
// });
}

componentDidMount() {
// This is not a good method, but a proof of concept.
// A better method would result from querying the data via this.dbapi
// TODO: see about querying the data via this.context.api
const environment = (this.props.apiUrl.match(/api-([^.]+)/i) || [])[1];
if (environment) {
this.setState({apiEnvironment: environment});
Expand Down Expand Up @@ -53,5 +51,3 @@ export default class EnvironmentBanner extends React.Component {
) : null;
}
}


0 comments on commit c4b981d

Please sign in to comment.