Skip to content
This repository has been archived by the owner on Mar 8, 2022. It is now read-only.

Commit

Permalink
Merge pull request #68 from newrelic/ru/patch-2
Browse files Browse the repository at this point in the history
fix: issue with html tag in catalog documentation
  • Loading branch information
rudouglas authored Nov 12, 2021
2 parents b066247 + 7dc818d commit 3eea7bc
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 31 deletions.
32 changes: 1 addition & 31 deletions catalog/documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,37 +72,7 @@ Renderers are simply React component classes with an additional static method, `
Documentation is a little lacking at the moment but you _could_ drop your own renderer in today! Here's one you can try out that will link account IDs on account objects to the account page in APM.
Add this file to the `nerdlets/notebook-nerdlet/renderers` directory.
```javascript
import React from 'react';

// Render account IDs as links to the account page in APM
export default class AccountIdRenderer extends React.Component {
static test(node) {
let parent = node.__meta.parent;

if (!parent) return false;

let isAccountTypeObject =
parent.__meta.typename == 'Account' ||
parent.__meta.typename == 'AccountOutline';

return isAccountTypeObject && node.__meta.fieldName == 'id';
}

render() {
let accountId = this.props.node.value;
return (
<a
target="_blank"
href={`https://rpm.newrelic.com/accounts/${accountId}`}
>
Visit Account {accountId}
</a>
);
}
}
```
- https://github.com/newrelic/nr1-graphiql-notebook/tree/main/nerdlets/notebook-nerdlet/context-render-example.txt
Next, import this class into `nerdlets/notebook-nerdlet/renderers/render.js` and add it to the `RENDERERS` array.
Expand Down
29 changes: 29 additions & 0 deletions nerdlets/notebook-nerdlet/context-render-example.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import React from 'react';

// Render account IDs as links to the account page in APM
export default class AccountIdRenderer extends React.Component {
static test(node) {
const parent = node.__meta.parent;

if (!parent) return false;

const isAccountTypeObject =
parent.__meta.typename === 'Account' ||
parent.__meta.typename === 'AccountOutline';

return isAccountTypeObject && node.__meta.fieldName === 'id';
}

render() {
const accountId = this.props.node.value;
return (
<a
target="_blank"
rel="noreferrer"
href={`https://rpm.newrelic.com/accounts/${accountId}`}
>
Visit Account {accountId}
</a>
);
}
}

0 comments on commit 3eea7bc

Please sign in to comment.