core-app-api: use createVersionedContext
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
@@ -14,19 +14,13 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import React, {
|
||||
createContext,
|
||||
useContext,
|
||||
ReactNode,
|
||||
PropsWithChildren,
|
||||
} from 'react';
|
||||
import React, { useContext, ReactNode, PropsWithChildren } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { ApiHolder } from '@backstage/core-plugin-api';
|
||||
import { ApiAggregator } from './ApiAggregator';
|
||||
import {
|
||||
VersionedValue,
|
||||
createVersionedValueMap,
|
||||
getOrCreateGlobalSingleton,
|
||||
createVersionedContext,
|
||||
} from '@backstage/version-bridge';
|
||||
|
||||
type ApiProviderProps = {
|
||||
@@ -34,10 +28,7 @@ type ApiProviderProps = {
|
||||
children: ReactNode;
|
||||
};
|
||||
|
||||
type ApiContextType = VersionedValue<{ 1: ApiHolder }> | undefined;
|
||||
const ApiContext = getOrCreateGlobalSingleton('api-context', () =>
|
||||
createContext<ApiContextType>(undefined),
|
||||
);
|
||||
const ApiContext = createVersionedContext<{ 1: ApiHolder }>('api-context');
|
||||
|
||||
export const ApiProvider = ({
|
||||
apis,
|
||||
|
||||
@@ -14,18 +14,14 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import React, { createContext, PropsWithChildren } from 'react';
|
||||
import React, { PropsWithChildren } from 'react';
|
||||
import {
|
||||
VersionedValue,
|
||||
createVersionedValueMap,
|
||||
getOrCreateGlobalSingleton,
|
||||
createVersionedContext,
|
||||
} from '@backstage/version-bridge';
|
||||
import { AppContext as AppContextV1 } from './types';
|
||||
|
||||
type AppContextType = VersionedValue<{ 1: AppContextV1 }> | undefined;
|
||||
const AppContext = getOrCreateGlobalSingleton('app-context', () =>
|
||||
createContext<AppContextType | undefined>(undefined),
|
||||
);
|
||||
const AppContext = createVersionedContext<{ 1: AppContextV1 }>('app-context');
|
||||
|
||||
type Props = {
|
||||
appContext: AppContextV1;
|
||||
|
||||
@@ -14,24 +14,21 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import React, { createContext, ReactNode } from 'react';
|
||||
import React, { ReactNode } from 'react';
|
||||
import {
|
||||
ExternalRouteRef,
|
||||
RouteRef,
|
||||
SubRouteRef,
|
||||
} from '@backstage/core-plugin-api';
|
||||
import {
|
||||
VersionedValue,
|
||||
createVersionedValueMap,
|
||||
getOrCreateGlobalSingleton,
|
||||
createVersionedContext,
|
||||
} from '@backstage/version-bridge';
|
||||
import { RouteResolver } from './RouteResolver';
|
||||
import { BackstageRouteObject } from './types';
|
||||
|
||||
type RoutingContextType = VersionedValue<{ 1: RouteResolver }> | undefined;
|
||||
const RoutingContext = getOrCreateGlobalSingleton('routing-context', () =>
|
||||
createContext<RoutingContextType>(undefined),
|
||||
);
|
||||
const RoutingContext =
|
||||
createVersionedContext<{ 1: RouteResolver }>('routing-context');
|
||||
|
||||
type ProviderProps = {
|
||||
routePaths: Map<RouteRef, string>;
|
||||
|
||||
Reference in New Issue
Block a user