add serch filter blueprint extension
Signed-off-by: Mark Dunphy <markd@spotify.com>
This commit is contained in:
@@ -12,6 +12,7 @@ import { FrontendPlugin } from '@backstage/frontend-plugin-api';
|
||||
import { IconComponent } from '@backstage/core-plugin-api';
|
||||
import { default as React_2 } from 'react';
|
||||
import { RouteRef } from '@backstage/frontend-plugin-api';
|
||||
import { SearchFilterExtensionComponent } from '@backstage/plugin-search-react/alpha';
|
||||
import { SearchResultItemExtensionComponent } from '@backstage/plugin-search-react/alpha';
|
||||
import { SearchResultItemExtensionPredicate } from '@backstage/plugin-search-react/alpha';
|
||||
|
||||
@@ -92,6 +93,19 @@ const _default: FrontendPlugin<
|
||||
optional: false;
|
||||
}
|
||||
>;
|
||||
searchFilters: ExtensionInput<
|
||||
ConfigurableExtensionDataRef<
|
||||
{
|
||||
component: SearchFilterExtensionComponent;
|
||||
},
|
||||
'search.filters.filter',
|
||||
{}
|
||||
>,
|
||||
{
|
||||
singleton: false;
|
||||
optional: false;
|
||||
}
|
||||
>;
|
||||
};
|
||||
kind: 'page';
|
||||
name: undefined;
|
||||
@@ -214,6 +228,19 @@ export const searchPage: ExtensionDefinition<{
|
||||
optional: false;
|
||||
}
|
||||
>;
|
||||
searchFilters: ExtensionInput<
|
||||
ConfigurableExtensionDataRef<
|
||||
{
|
||||
component: SearchFilterExtensionComponent;
|
||||
},
|
||||
'search.filters.filter',
|
||||
{}
|
||||
>,
|
||||
{
|
||||
singleton: false;
|
||||
optional: false;
|
||||
}
|
||||
>;
|
||||
};
|
||||
kind: 'page';
|
||||
name: undefined;
|
||||
|
||||
@@ -64,6 +64,7 @@ import { searchApiRef } from '@backstage/plugin-search-react';
|
||||
import {
|
||||
SearchResultListItemBlueprint,
|
||||
SearchFilterResultTypeBlueprint,
|
||||
SearchFilterBlueprint,
|
||||
} from '@backstage/plugin-search-react/alpha';
|
||||
|
||||
import { rootRouteRef } from './plugin';
|
||||
@@ -112,6 +113,9 @@ export const searchPage = PageBlueprint.makeWithOverrides({
|
||||
resultTypes: createExtensionInput([
|
||||
SearchFilterResultTypeBlueprint.dataRefs.resultType,
|
||||
]),
|
||||
searchFilters: createExtensionInput([
|
||||
SearchFilterBlueprint.dataRefs.searchFilters,
|
||||
]),
|
||||
},
|
||||
factory(originalFactory, { config, inputs }) {
|
||||
return originalFactory({
|
||||
@@ -134,6 +138,11 @@ export const searchPage = PageBlueprint.makeWithOverrides({
|
||||
item.get(SearchFilterResultTypeBlueprint.dataRefs.resultType),
|
||||
);
|
||||
|
||||
const additionalSearchFilters = inputs.searchFilters.map(
|
||||
item =>
|
||||
item.get(SearchFilterBlueprint.dataRefs.searchFilters).component,
|
||||
);
|
||||
|
||||
const Component = () => {
|
||||
const classes = useSearchPageStyles();
|
||||
const { isMobile } = useSidebarPinState();
|
||||
@@ -203,6 +212,9 @@ export const searchPage = PageBlueprint.makeWithOverrides({
|
||||
name="lifecycle"
|
||||
values={['experimental', 'production']}
|
||||
/>
|
||||
{additionalSearchFilters.map(SearchFilterComponent => (
|
||||
<SearchFilterComponent className={classes.filter} />
|
||||
))}
|
||||
</Paper>
|
||||
</Grid>
|
||||
)}
|
||||
|
||||
Reference in New Issue
Block a user