release-2021-06-01 packages/core-plugin-api/src/routing/RouteRef.ts:118,120,122
Signed-off-by: Colton Padden <colton.padden@fastmail.com>
This commit is contained in:
@@ -36,48 +36,10 @@ export class RouteRefImpl<Params extends AnyParams>
|
||||
constructor(
|
||||
private readonly id: string,
|
||||
readonly params: ParamKeys<Params>,
|
||||
private readonly config: {
|
||||
/** @deprecated */
|
||||
path?: string;
|
||||
/** @deprecated */
|
||||
icon?: OldIconComponent;
|
||||
/** @deprecated */
|
||||
title?: string;
|
||||
},
|
||||
) {
|
||||
if (config.path) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.warn(
|
||||
`DEPRECATION WARNING: Passing a path to createRouteRef is deprecated, please remove the path for ${this}.`,
|
||||
);
|
||||
}
|
||||
|
||||
if (config.icon) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.warn(
|
||||
`DEPRECATION WARNING: Passing an icon to createRouteRef is deprecated, please remove the icon for ${this}.`,
|
||||
);
|
||||
}
|
||||
|
||||
if (config.title) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.warn(
|
||||
`DEPRECATION WARNING: Passing a title to createRouteRef is deprecated, please remove the title for ${this}.`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/** @deprecated use `useRouteRef` instead */
|
||||
get path() {
|
||||
return this.config.path ?? '';
|
||||
}
|
||||
|
||||
get icon() {
|
||||
return this.config.icon;
|
||||
}
|
||||
) {}
|
||||
|
||||
get title() {
|
||||
return this.config.title ?? this.id;
|
||||
return this.id;
|
||||
}
|
||||
|
||||
toString() {
|
||||
@@ -104,20 +66,13 @@ export function createRouteRef<
|
||||
id?: string;
|
||||
/** A list of parameter names that the path that this route ref is bound to must contain */
|
||||
params?: ParamKey[];
|
||||
/** @deprecated Route refs no longer decide their own path */
|
||||
path?: string;
|
||||
/** @deprecated Route refs no longer decide their own icon */
|
||||
icon?: OldIconComponent;
|
||||
/** @deprecated Route refs no longer decide their own title */
|
||||
title?: string;
|
||||
}): RouteRef<OptionalParams<Params>> {
|
||||
const id = config.id || config.title;
|
||||
const id = config.id;
|
||||
if (!id) {
|
||||
throw new Error('RouteRef must be provided a non-empty id');
|
||||
}
|
||||
return new RouteRefImpl(
|
||||
id,
|
||||
(config.params ?? []) as ParamKeys<OptionalParams<Params>>,
|
||||
config,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { OldIconComponent } from '../icons/types';
|
||||
import { getOrCreateGlobalSingleton } from '@backstage/version-bridge';
|
||||
|
||||
/**
|
||||
@@ -85,14 +84,6 @@ export type RouteRef<Params extends AnyParams = any> = {
|
||||
$$routeRefType: 'absolute'; // See routeRefType above
|
||||
|
||||
params: ParamKeys<Params>;
|
||||
|
||||
// TODO(Rugvip): Remove all of these once plugins don't rely on the path
|
||||
/** @deprecated paths are no longer accessed directly from RouteRefs, use useRouteRef instead */
|
||||
path: string;
|
||||
/** @deprecated icons are no longer accessed via RouteRefs */
|
||||
icon?: OldIconComponent;
|
||||
/** @deprecated titles are no longer accessed via RouteRefs */
|
||||
title?: string;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -159,7 +159,7 @@ export class DevAppBuilder {
|
||||
* Build a DevApp component using the resources registered so far
|
||||
*/
|
||||
build(): ComponentType<{}> {
|
||||
const dummyRouteRef = createRouteRef({ title: 'Page of another plugin' });
|
||||
const dummyRouteRef = createRouteRef({ id: 'dummy' });
|
||||
const DummyPage = () => <Box p={3}>Page belonging to another plugin.</Box>;
|
||||
attachComponentData(DummyPage, 'core.mountPoint', dummyRouteRef);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user