Skip to content

Commit

Permalink
feat: toggle between old/new
Browse files Browse the repository at this point in the history
  • Loading branch information
Kav91 committed Dec 17, 2023
1 parent fa98743 commit 6ee2c5c
Show file tree
Hide file tree
Showing 9 changed files with 8,171 additions and 3,202 deletions.
33 changes: 31 additions & 2 deletions nerdlets/maturity-nerdlet/ViewList/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,31 @@ export default function ViewList() {

const headers = [
{ key: 'View', value: ({ item }) => item.document?.name },
{ key: 'Description', value: ({ item }) => item.document?.description },
{
key: 'Description',
value: ({ item }) => item.document?.description,
onClick: ({ item }) => {
const previousResult = item?.history?.[0];
let onClickHandler = undefined;

if (previousResult) {
onClickHandler = () => loadHistoricalResult(item, previousResult);
} else {
onClickHandler = () =>
runView(
{
name: item.document.name,
account: selectedAccountId,
},
{ ...item },
false,
true
);
}

return onClickHandler;
},
},
{
key: 'Last run',
value: ({ item }) => {
Expand Down Expand Up @@ -172,7 +196,12 @@ export default function ViewList() {
}

return (
<TableRowCell key={header}>
<TableRowCell
key={header}
onClick={
header.onClick ? header.onClick({ item }) : undefined
}
>
{header.value({ item })}
</TableRowCell>
);
Expand Down
23 changes: 22 additions & 1 deletion nerdlets/maturity-nerdlet/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import React, { useContext, useEffect } from 'react';
import { PlatformStateContext, nerdlet, AutoSizer } from 'nr1';
import {
PlatformStateContext,
nerdlet,
navigation,
AutoSizer,
SectionMessage,
} from 'nr1';
import { ProvideData } from '../../src/context/data';
import AccountMaturity from './AccountMaturity';

Expand All @@ -15,6 +21,21 @@ export default function AccountMaturityRoot() {

return (
<div>
<SectionMessage
title="Welcome to the new version of Account Maturity"
description="If there are any bugs or features missing please raise an issue"
actions={[
{
label: 'Raise issue or feature request',
to: 'https://github.com/newrelic/nr1-account-maturity/issues/new/choose',
},
{
label: 'Launch the old version',
onClick: () =>
navigation.openNerdlet({ id: 'old-maturity-nerdlet' }),
},
]}
/>
<ProvideData platformContext={platformContext}>
<AutoSizer>
{({ width, height }) => (
Expand Down
107 changes: 107 additions & 0 deletions nerdlets/old-maturity-nerdlet/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
import React from 'react';
import { navigation, NerdGraphQuery, SectionMessage } from 'nr1';

import { Tab, Tabs, TabList, TabPanel } from 'react-tabs';
import {
OverviewPanel,
APMPanel,
BrowserPanel,
SynthPanel,
InfraPanel,
KubernetesPanel,
InsightsPanel,
LogPanel,
ProgramPanel,
MobilePanel,
WorkloadPanel,
SLMPanel,
NPMPanel,
} from 'maturity-products/dist/entities';
import {
ApplicationCtxProvider,
MaturityScoreCtxProvider,
} from 'maturity-products/dist/contexts';

export default class MaturityApplication extends React.Component {
constructor(props) {
super(props);
}

render() {
return (
<>
<SectionMessage
type={SectionMessage.TYPE.WARNING}
title="You are on the old version of account maturity"
description="No further support will be provided on this version."
actions={[
{
label: 'Launch the new version',
onClick: () => navigation.openNerdlet({ id: 'maturity-nerdlet' }),
},
]}
/>
<Tabs forceRenderTabPanel>
<TabList>
<Tab>Overview</Tab>
<Tab>APM</Tab>
<Tab>Browser</Tab>
<Tab>Synthetics</Tab>
<Tab>Infrastructure</Tab>
<Tab>Kubernetes</Tab>
<Tab>Insights</Tab>
<Tab>Log</Tab>
<Tab>Programmability</Tab>
<Tab>Mobile</Tab>
<Tab>Workloads</Tab>
<Tab>SLM</Tab>
<Tab>NPM</Tab>
</TabList>
<ApplicationCtxProvider nr1graph={NerdGraphQuery}>
<MaturityScoreCtxProvider>
<TabPanel>
<OverviewPanel />
</TabPanel>
<TabPanel>
<APMPanel />
</TabPanel>
<TabPanel>
<BrowserPanel />
</TabPanel>
<TabPanel>
<SynthPanel />
</TabPanel>
<TabPanel>
<InfraPanel />
</TabPanel>
<TabPanel>
<KubernetesPanel />
</TabPanel>
<TabPanel>
<InsightsPanel />
</TabPanel>
<TabPanel>
<LogPanel />
</TabPanel>
<TabPanel>
<ProgramPanel />
</TabPanel>
<TabPanel>
<MobilePanel />
</TabPanel>
<TabPanel>
<WorkloadPanel />
</TabPanel>
<TabPanel>
<SLMPanel />
</TabPanel>
<TabPanel>
<NPMPanel />
</TabPanel>
</MaturityScoreCtxProvider>
</ApplicationCtxProvider>
</Tabs>
</>
);
}
}
6 changes: 6 additions & 0 deletions nerdlets/old-maturity-nerdlet/nr1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"schemaType": "NERDLET",
"id": "old-maturity-nerdlet",
"description": "Evaluates maturity score for New Relic Products",
"displayName": "Account Maturity"
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions nerdlets/old-maturity-nerdlet/styles.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@import url('https://unpkg.com/react-table-v6@latest/react-table.css');
@import '~react-tabs/style/react-tabs.css';


Loading

0 comments on commit 6ee2c5c

Please sign in to comment.