rename header action to plugin header action
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
@@ -1424,39 +1424,6 @@ export const googleAuthApiRef: ApiRef<
|
||||
SessionApi
|
||||
>;
|
||||
|
||||
// @public
|
||||
export const HeaderActionBlueprint: ExtensionBlueprint_2<{
|
||||
kind: 'header-action';
|
||||
params: (params: {
|
||||
loader: () => Promise<JSX.Element>;
|
||||
}) => ExtensionBlueprintParams_2<{
|
||||
loader: () => Promise<JSX.Element>;
|
||||
}>;
|
||||
output: ExtensionDataRef_2<
|
||||
() => Promise<JSX.Element>,
|
||||
'core.header-action.loader',
|
||||
{}
|
||||
>;
|
||||
inputs: {};
|
||||
config: {};
|
||||
configInput: {};
|
||||
dataRefs: {
|
||||
action: ConfigurableExtensionDataRef_2<
|
||||
() => Promise<JSX.Element>,
|
||||
'core.header-action.loader',
|
||||
{}
|
||||
>;
|
||||
};
|
||||
}>;
|
||||
|
||||
// @public
|
||||
export type HeaderActionsApi = {
|
||||
getHeaderActions(pluginId: string): ReactNode[];
|
||||
};
|
||||
|
||||
// @public
|
||||
export const headerActionsApiRef: ApiRef_2<HeaderActionsApi>;
|
||||
|
||||
// @public @deprecated
|
||||
export type IconComponent = ComponentType<{
|
||||
fontSize?: 'medium' | 'large' | 'small' | 'inherit';
|
||||
@@ -1869,6 +1836,29 @@ export type PendingOAuthRequest = {
|
||||
trigger(): Promise<void>;
|
||||
};
|
||||
|
||||
// @public
|
||||
export const PluginHeaderActionBlueprint: ExtensionBlueprint_2<{
|
||||
kind: 'plugin-header-action';
|
||||
params: (params: {
|
||||
loader: () => Promise<JSX.Element>;
|
||||
}) => ExtensionBlueprintParams_2<{
|
||||
loader: () => Promise<JSX.Element>;
|
||||
}>;
|
||||
output: ExtensionDataRef_2<JSX_2, 'core.reactElement', {}>;
|
||||
inputs: {};
|
||||
config: {};
|
||||
configInput: {};
|
||||
dataRefs: never;
|
||||
}>;
|
||||
|
||||
// @public
|
||||
export type PluginHeaderActionsApi = {
|
||||
getPluginHeaderActions(pluginId: string): ReactNode[];
|
||||
};
|
||||
|
||||
// @public
|
||||
export const pluginHeaderActionsApiRef: ApiRef_2<PluginHeaderActionsApi>;
|
||||
|
||||
// @public (undocumented)
|
||||
export interface PluginOptions<
|
||||
TId extends string,
|
||||
|
||||
+6
-6
@@ -23,23 +23,23 @@ import { createApiRef } from '../system';
|
||||
* @remarks
|
||||
*
|
||||
* Header actions are provided via
|
||||
* {@link @backstage/frontend-plugin-api#HeaderActionBlueprint}
|
||||
* {@link @backstage/frontend-plugin-api#PluginHeaderActionBlueprint}
|
||||
* and automatically scoped to the providing plugin.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export type HeaderActionsApi = {
|
||||
export type PluginHeaderActionsApi = {
|
||||
/**
|
||||
* Returns the header actions for a given plugin.
|
||||
*/
|
||||
getHeaderActions(pluginId: string): ReactNode[];
|
||||
getPluginHeaderActions(pluginId: string): ReactNode[];
|
||||
};
|
||||
|
||||
/**
|
||||
* The `ApiRef` of {@link HeaderActionsApi}.
|
||||
* The `ApiRef` of {@link PluginHeaderActionsApi}.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export const headerActionsApiRef = createApiRef<HeaderActionsApi>({
|
||||
id: 'core.header-actions',
|
||||
export const pluginHeaderActionsApiRef = createApiRef<PluginHeaderActionsApi>({
|
||||
id: 'core.plugin-header-actions',
|
||||
});
|
||||
@@ -49,4 +49,4 @@ export * from './RouteResolutionApi';
|
||||
export * from './StorageApi';
|
||||
export * from './AnalyticsApi';
|
||||
export * from './TranslationApi';
|
||||
export * from './HeaderActionsApi';
|
||||
export * from './PluginHeaderActionsApi';
|
||||
|
||||
@@ -25,11 +25,11 @@ import {
|
||||
} from '../wiring';
|
||||
import { ExtensionBoundary, PageLayout, PageTab } from '../components';
|
||||
import { useApi } from '../apis/system';
|
||||
import { headerActionsApiRef } from '../apis/definitions/HeaderActionsApi';
|
||||
import { pluginHeaderActionsApiRef } from '../apis/definitions/PluginHeaderActionsApi';
|
||||
|
||||
function useHeaderActions(pluginId: string): ReactNode {
|
||||
const headerActionsApi = useApi(headerActionsApiRef);
|
||||
const actions = headerActionsApi.getHeaderActions(pluginId);
|
||||
function usePluginHeaderActions(pluginId: string): ReactNode {
|
||||
const pluginHeaderActionsApi = useApi(pluginHeaderActionsApiRef);
|
||||
const actions = pluginHeaderActionsApi.getPluginHeaderActions(pluginId);
|
||||
if (actions.length === 0) {
|
||||
return undefined;
|
||||
}
|
||||
@@ -97,7 +97,7 @@ export const PageBlueprint = createExtensionBlueprint({
|
||||
if (params.loader) {
|
||||
const loader = params.loader;
|
||||
const PageContent = () => {
|
||||
const headerActions = useHeaderActions(pluginId);
|
||||
const headerActions = usePluginHeaderActions(pluginId);
|
||||
return (
|
||||
<PageLayout
|
||||
title={title}
|
||||
@@ -127,7 +127,7 @@ export const PageBlueprint = createExtensionBlueprint({
|
||||
|
||||
const PageContent = () => {
|
||||
const firstPagePath = inputs.pages[0]?.get(coreExtensionData.routePath);
|
||||
const headerActions = useHeaderActions(pluginId);
|
||||
const headerActions = usePluginHeaderActions(pluginId);
|
||||
|
||||
return (
|
||||
<PageLayout
|
||||
@@ -158,7 +158,7 @@ export const PageBlueprint = createExtensionBlueprint({
|
||||
yield coreExtensionData.reactElement(<PageContent />);
|
||||
} else {
|
||||
const PageContent = () => {
|
||||
const headerActions = useHeaderActions(pluginId);
|
||||
const headerActions = usePluginHeaderActions(pluginId);
|
||||
return (
|
||||
<PageLayout title={title} icon={icon} headerActions={headerActions} />
|
||||
);
|
||||
|
||||
+3
-3
@@ -32,9 +32,9 @@ import {
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export const HeaderActionBlueprint = createExtensionBlueprint({
|
||||
kind: 'header-action',
|
||||
attachTo: { id: 'api:app/header-actions', input: 'actions' },
|
||||
export const PluginHeaderActionBlueprint = createExtensionBlueprint({
|
||||
kind: 'plugin-header-action',
|
||||
attachTo: { id: 'api:app/plugin-header-actions', input: 'actions' },
|
||||
output: [coreExtensionData.reactElement],
|
||||
defineParams(params: { loader: () => Promise<JSX.Element> }) {
|
||||
return createExtensionBlueprintParams(params);
|
||||
@@ -23,4 +23,4 @@ export { AppRootElementBlueprint } from './AppRootElementBlueprint';
|
||||
export { NavItemBlueprint } from './NavItemBlueprint';
|
||||
export { PageBlueprint } from './PageBlueprint';
|
||||
export { SubPageBlueprint } from './SubPageBlueprint';
|
||||
export { HeaderActionBlueprint } from './HeaderActionBlueprint';
|
||||
export { PluginHeaderActionBlueprint } from './PluginHeaderActionBlueprint';
|
||||
|
||||
Reference in New Issue
Block a user