-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
143 additions
and
43 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 |
---|---|---|
@@ -1,59 +1,126 @@ | ||
import React from 'react'; | ||
import { get } from 'lodash'; | ||
import { BASE_NERDGRAPH_QUERY } from '../utils/queries'; | ||
import { NerdletStateContext, NerdGraphQuery, Spinner } from 'nr1'; | ||
import { | ||
Icon, | ||
nerdlet, | ||
NerdletStateContext, | ||
NerdGraphQuery, | ||
Spinner | ||
} from 'nr1'; | ||
|
||
import { NerdGraphError, EmptyState } from '@newrelic/nr1-community'; | ||
|
||
import { HelpModal } from 'nr-labs-components'; | ||
|
||
import NrqlFactory from '../nrql-factory'; | ||
import Breakdown from './breakdown'; | ||
|
||
export default class Wrapper extends React.PureComponent { | ||
state = { | ||
helpModalOpen: false | ||
}; | ||
|
||
componentDidMount() { | ||
nerdlet.setConfig({ | ||
actionControls: true, | ||
actionControlButtons: [ | ||
{ | ||
label: 'Help', | ||
hint: 'Quick links to get support', | ||
type: 'primary', | ||
iconType: Icon.TYPE.INTERFACE__INFO__HELP, | ||
onClick: () => this.setHelpModalOpen(true) | ||
} | ||
] | ||
}); | ||
} | ||
|
||
setHelpModalOpen = helpModalOpen => { | ||
this.setState({ helpModalOpen }); | ||
}; | ||
|
||
render() { | ||
const { helpModalOpen } = this.state; | ||
|
||
return ( | ||
<NerdletStateContext.Consumer> | ||
{nerdletUrlState => { | ||
return ( | ||
<NerdGraphQuery | ||
query={BASE_NERDGRAPH_QUERY} | ||
variables={{ entityGuid: nerdletUrlState.entityGuid }} | ||
fetchPolicyType={NerdGraphQuery.FETCH_POLICY_TYPE.NO_CACHE} | ||
> | ||
{({ data, loading, error }) => { | ||
if (loading) { | ||
return <Spinner fillContainer />; | ||
} | ||
<> | ||
<NerdletStateContext.Consumer> | ||
{nerdletUrlState => { | ||
return ( | ||
<NerdGraphQuery | ||
query={BASE_NERDGRAPH_QUERY} | ||
variables={{ entityGuid: nerdletUrlState.entityGuid }} | ||
fetchPolicyType={NerdGraphQuery.FETCH_POLICY_TYPE.NO_CACHE} | ||
> | ||
{({ data, loading, error }) => { | ||
if (loading) { | ||
return <Spinner fillContainer />; | ||
} | ||
|
||
if (error) { | ||
return <NerdGraphError error={error} />; | ||
} | ||
// console.debug(data); | ||
const entity = get(data, 'actor.entity'); | ||
if (entity) { | ||
const nrqlFactory = NrqlFactory.getFactory(data); | ||
return ( | ||
<Breakdown | ||
entity={entity} | ||
nrqlFactory={nrqlFactory} | ||
nerdletUrlState={nerdletUrlState} | ||
/> | ||
); | ||
} else { | ||
return ( | ||
<div className="empty-state-container"> | ||
<EmptyState | ||
heading="Site Analyzer is not available" | ||
description="You have access to this entity, but Site Analyzer is not | ||
enabled for Browser entities in this account. Please see | ||
your Nerdpack Manager with concerns." | ||
buttonText="" | ||
if (error) { | ||
return <NerdGraphError error={error} />; | ||
} | ||
// console.debug(data); | ||
const entity = get(data, 'actor.entity'); | ||
if (entity) { | ||
const nrqlFactory = NrqlFactory.getFactory(data); | ||
return ( | ||
<Breakdown | ||
entity={entity} | ||
nrqlFactory={nrqlFactory} | ||
nerdletUrlState={nerdletUrlState} | ||
/> | ||
</div> | ||
); | ||
); | ||
} else { | ||
return ( | ||
<div className="empty-state-container"> | ||
<EmptyState | ||
heading="Site Analyzer is not available" | ||
description="You have access to this entity, but Site Analyzer is not | ||
enabled for Browser entities in this account. Please see | ||
your Nerdpack Manager with concerns." | ||
buttonText="" | ||
/> | ||
</div> | ||
); | ||
} | ||
}} | ||
</NerdGraphQuery> | ||
); | ||
}} | ||
</NerdletStateContext.Consumer> | ||
{helpModalOpen && ( | ||
<HelpModal | ||
isModalOpen={helpModalOpen} | ||
setModalOpen={this.setHelpModalOpen} | ||
urls={{ | ||
docs: 'https://github.com/newrelic/nr1-status-pages#readme', | ||
createIssue: | ||
'https://github.com/newrelic/nr1-status-pages/issues/new?assignees=&labels=bug%2C+needs-triage&template=bug_report.md&title=', | ||
createFeature: | ||
'https://github.com/newrelic/nr1-status-pages/issues/new?assignees=&labels=enhancement%2C+needs-triage&template=enhancement.md&title=', | ||
createQuestion: | ||
'https://github.com/newrelic/nr1-status-pages/discussions/new/choose' | ||
}} | ||
ownerBadge={{ | ||
logo: { | ||
src: | ||
'https://drive.google.com/uc?id=1BdXVy2X34rufvG4_1BYb9czhLRlGlgsT', | ||
alt: 'New Relic Labs' | ||
}, | ||
blurb: { | ||
text: 'This is a New Relic Labs open source app.', | ||
link: { | ||
text: 'Take a look at our other repos', | ||
url: | ||
'https://github.com/newrelic?q=nrlabs-viz&type=all&language=&sort=' | ||
} | ||
}} | ||
</NerdGraphQuery> | ||
); | ||
}} | ||
</NerdletStateContext.Consumer> | ||
} | ||
}} | ||
/> | ||
)} | ||
</> | ||
); | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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