Merge pull request #14389 from andrewthauer/explore-backend
feat: add explore-backend plugin
This commit is contained in:
@@ -25,6 +25,7 @@ import {
|
||||
Paper,
|
||||
useTheme,
|
||||
} from '@material-ui/core';
|
||||
import BuildIcon from '@material-ui/icons/Build';
|
||||
import LaunchIcon from '@material-ui/icons/Launch';
|
||||
import {
|
||||
CatalogIcon,
|
||||
@@ -38,6 +39,7 @@ import {
|
||||
catalogApiRef,
|
||||
CATALOG_FILTER_EXISTS,
|
||||
} from '@backstage/plugin-catalog-react';
|
||||
import { ToolSearchResultListItem } from '@backstage/plugin-explore';
|
||||
import { searchPlugin, SearchType } from '@backstage/plugin-search';
|
||||
import {
|
||||
DefaultResultListItem,
|
||||
@@ -110,6 +112,10 @@ export const SearchModal = ({ toggleModal }: { toggleModal: () => void }) => {
|
||||
value: 'techdocs',
|
||||
name: 'Documentation',
|
||||
},
|
||||
{
|
||||
value: 'tools',
|
||||
name: 'Tools',
|
||||
},
|
||||
]}
|
||||
/>
|
||||
</Grid>
|
||||
@@ -209,6 +215,17 @@ export const SearchModal = ({ toggleModal }: { toggleModal: () => void }) => {
|
||||
/>
|
||||
);
|
||||
break;
|
||||
case 'tools':
|
||||
resultItem = (
|
||||
<ToolSearchResultListItem
|
||||
icon={<BuildIcon />}
|
||||
key={document.location}
|
||||
result={document}
|
||||
highlight={highlight}
|
||||
rank={rank}
|
||||
/>
|
||||
);
|
||||
break;
|
||||
default:
|
||||
resultItem = (
|
||||
<DefaultResultListItem
|
||||
|
||||
@@ -41,6 +41,8 @@ import {
|
||||
import { TechDocsSearchResultListItem } from '@backstage/plugin-techdocs';
|
||||
import { Grid, List, makeStyles, Paper, Theme } from '@material-ui/core';
|
||||
import React from 'react';
|
||||
import { ToolSearchResultListItem } from '@backstage/plugin-explore';
|
||||
import BuildIcon from '@material-ui/icons/Build';
|
||||
|
||||
const useStyles = makeStyles((theme: Theme) => ({
|
||||
bar: {
|
||||
@@ -155,6 +157,16 @@ const SearchPage = () => {
|
||||
rank={rank}
|
||||
/>
|
||||
);
|
||||
case 'tools':
|
||||
return (
|
||||
<ToolSearchResultListItem
|
||||
icon={<BuildIcon />}
|
||||
key={document.location}
|
||||
result={document}
|
||||
highlight={highlight}
|
||||
rank={rank}
|
||||
/>
|
||||
);
|
||||
default:
|
||||
return (
|
||||
<DefaultResultListItem
|
||||
|
||||
@@ -43,6 +43,7 @@
|
||||
"@backstage/plugin-code-coverage-backend": "workspace:^",
|
||||
"@backstage/plugin-events-backend": "workspace:^",
|
||||
"@backstage/plugin-events-node": "workspace:^",
|
||||
"@backstage/plugin-explore-backend": "workspace:^",
|
||||
"@backstage/plugin-graphql-backend": "workspace:^",
|
||||
"@backstage/plugin-jenkins-backend": "workspace:^",
|
||||
"@backstage/plugin-kafka-backend": "workspace:^",
|
||||
|
||||
@@ -45,6 +45,7 @@ import catalog from './plugins/catalog';
|
||||
import catalogEventBasedProviders from './plugins/catalogEventBasedProviders';
|
||||
import codeCoverage from './plugins/codecoverage';
|
||||
import events from './plugins/events';
|
||||
import explore from './plugins/explore';
|
||||
import kubernetes from './plugins/kubernetes';
|
||||
import kafka from './plugins/kafka';
|
||||
import rollbar from './plugins/rollbar';
|
||||
@@ -144,6 +145,7 @@ async function main() {
|
||||
const permissionEnv = useHotMemoize(module, () => createEnv('permission'));
|
||||
const playlistEnv = useHotMemoize(module, () => createEnv('playlist'));
|
||||
const eventsEnv = useHotMemoize(module, () => createEnv('events'));
|
||||
const exploreEnv = useHotMemoize(module, () => createEnv('explore'));
|
||||
|
||||
const eventBasedEntityProviders = await catalogEventBasedProviders(
|
||||
catalogEnv,
|
||||
@@ -172,6 +174,7 @@ async function main() {
|
||||
apiRouter.use('/jenkins', await jenkins(jenkinsEnv));
|
||||
apiRouter.use('/permission', await permission(permissionEnv));
|
||||
apiRouter.use('/playlist', await playlist(playlistEnv));
|
||||
apiRouter.use('/explore', await explore(exploreEnv));
|
||||
apiRouter.use(notFoundHandler());
|
||||
|
||||
const service = createServiceBuilder(module)
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright 2020 The Backstage Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {
|
||||
createRouter,
|
||||
exampleTools,
|
||||
StaticExploreToolProvider,
|
||||
} from '@backstage/plugin-explore-backend';
|
||||
import { Router } from 'express';
|
||||
import { PluginEnvironment } from '../types';
|
||||
|
||||
export default async function createPlugin(
|
||||
env: PluginEnvironment,
|
||||
): Promise<Router> {
|
||||
return await createRouter({
|
||||
logger: env.logger,
|
||||
toolProvider: StaticExploreToolProvider.fromData(exampleTools),
|
||||
});
|
||||
}
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
import { useHotCleanup } from '@backstage/backend-common';
|
||||
import { DefaultCatalogCollatorFactory } from '@backstage/plugin-catalog-backend';
|
||||
import { ToolDocumentCollatorFactory } from '@backstage/plugin-explore-backend';
|
||||
import { createRouter } from '@backstage/plugin-search-backend';
|
||||
import { ElasticSearchSearchEngine } from '@backstage/plugin-search-backend-module-elasticsearch';
|
||||
import { PgSearchEngine } from '@backstage/plugin-search-backend-module-pg';
|
||||
@@ -84,6 +85,14 @@ export default async function createPlugin(
|
||||
}),
|
||||
});
|
||||
|
||||
indexBuilder.addCollator({
|
||||
schedule,
|
||||
factory: ToolDocumentCollatorFactory.fromConfig(env.config, {
|
||||
discovery: env.discovery,
|
||||
logger: env.logger,
|
||||
}),
|
||||
});
|
||||
|
||||
// The scheduler controls when documents are gathered from collators and sent
|
||||
// to the search engine for indexing.
|
||||
const { scheduler } = await indexBuilder.build();
|
||||
|
||||
Reference in New Issue
Block a user