Add a discovery API
Signed-off-by: Karan Shah <karan.shah@simplybusiness.co.uk>
This commit is contained in:
@@ -71,12 +71,6 @@ export const ApiBar = () => {
|
||||
value.setProjectId?.(parseInt(e.target.value, 10) || undefined)
|
||||
}
|
||||
/>
|
||||
<TextField
|
||||
label="API Key"
|
||||
variant="outlined"
|
||||
defaultValue={value.apiKey}
|
||||
onChange={e => value.setApiKey?.(e.target.value)}
|
||||
/>
|
||||
</MuiThemeProvider>
|
||||
</div>
|
||||
)}
|
||||
|
||||
@@ -23,23 +23,18 @@ import React, {
|
||||
interface ContextInterface {
|
||||
projectId?: number;
|
||||
setProjectId?: Dispatch<SetStateAction<number | undefined>>;
|
||||
apiKey?: string;
|
||||
setApiKey?: Dispatch<SetStateAction<string>>;
|
||||
}
|
||||
|
||||
export const Context = React.createContext<ContextInterface>({});
|
||||
|
||||
export const ContextProvider = ({ children }: PropsWithChildren<{}>) => {
|
||||
const [projectId, setProjectId] = useState<number>();
|
||||
const [apiKey, setApiKey] = useState<string>('');
|
||||
|
||||
return (
|
||||
<Context.Provider
|
||||
value={{
|
||||
projectId,
|
||||
setProjectId,
|
||||
apiKey,
|
||||
setApiKey,
|
||||
}}
|
||||
>
|
||||
{children}
|
||||
|
||||
@@ -19,13 +19,14 @@ import { TestApiProvider } from '@backstage/test-utils';
|
||||
import { airbrakePlugin, EntityAirbrakeContent } from '../src';
|
||||
import {
|
||||
airbrakeApiRef,
|
||||
localDiscoveryApi,
|
||||
MockAirbrakeApi,
|
||||
ProductionAirbrakeApi,
|
||||
} from '../src/api';
|
||||
import { ApiBar } from './components/ApiBar';
|
||||
import { Content, Header, Page } from '@backstage/core-components';
|
||||
import { EntityProvider } from '@backstage/plugin-catalog-react';
|
||||
import { createEntity } from '../src/api/mock/MockEntity';
|
||||
import { createEntity } from '../src/api';
|
||||
import CloudOffIcon from '@material-ui/icons/CloudOff';
|
||||
import CloudIcon from '@material-ui/icons/Cloud';
|
||||
import { Context, ContextProvider } from './components/ContextProvider';
|
||||
@@ -61,7 +62,10 @@ createDevApp()
|
||||
{value => (
|
||||
<TestApiProvider
|
||||
apis={[
|
||||
[airbrakeApiRef, new ProductionAirbrakeApi(value.apiKey)],
|
||||
[
|
||||
airbrakeApiRef,
|
||||
new ProductionAirbrakeApi(localDiscoveryApi),
|
||||
],
|
||||
]}
|
||||
>
|
||||
<EntityProvider entity={createEntity(value.projectId)}>
|
||||
|
||||
Reference in New Issue
Block a user