Fix registration of component

Signed-off-by: josh <josh.timmons@hashicorp.com>
This commit is contained in:
josh
2023-06-04 15:30:32 -04:00
parent 285de62914
commit 523af24224
6 changed files with 65 additions and 12 deletions
@@ -113,8 +113,10 @@ import {
EntityUserProfileCard,
} from '@backstage/plugin-org';
import {
EntityNomadContent,
EntityNomadAllocationListTable,
EntityNomadJobVersionListCard,
isNomadAllocationsAvailable,
isNomadJobIDAvailable,
} from '@backstage/plugin-nomad';
import {
EntityPagerDutyCard,
@@ -176,7 +178,6 @@ import {
isLinguistAvailable,
EntityLinguistCard,
} from '@backstage/plugin-linguist';
import { isNomadJobIDAvailable } from '@backstage/plugin-nomad';
const customEntityFilterKind = ['Component', 'API', 'System'];
@@ -450,7 +451,7 @@ const overviewContent = (
<EntitySwitch>
<EntitySwitch.Case if={isNomadJobIDAvailable}>
<Grid item sm={4}>
<Grid item md={6} xs={12}>
<EntityNomadJobVersionListCard />
</Grid>
</EntitySwitch.Case>
@@ -514,8 +515,12 @@ const serviceEntityPage = (
<EntityKubernetesContent />
</EntityLayout.Route>
<EntityLayout.Route path="/nomad" title="Nomad">
<EntityNomadContent />
<EntityLayout.Route
if={isNomadAllocationsAvailable}
path="/nomad"
title="Nomad"
>
<EntityNomadAllocationListTable />
</EntityLayout.Route>
<EntityLayout.Route path="/pull-requests" title="Pull Requests">
+3 -1
View File
@@ -16,12 +16,14 @@
import { getRootLogger } from '@backstage/backend-common';
import yn from 'yn';
import { startStandaloneServer } from './service/standaloneServer';
import { ConfigReader } from '@backstage/config';
const config = new ConfigReader({});
const port = process.env.PLUGIN_PORT ? Number(process.env.PLUGIN_PORT) : 7007;
const enableCors = yn(process.env.PLUGIN_CORS, { default: false });
const logger = getRootLogger();
startStandaloneServer({ port, enableCors, logger }).catch(err => {
startStandaloneServer({ config, port, enableCors, logger }).catch(err => {
logger.error(err);
process.exit(1);
});
@@ -110,6 +110,8 @@ export const EntityNomadJobVersionListCard = () => {
return <ResponseErrorPanel error={err} />;
}
if (!entity) return <></>;
// Check that job ID is set
if (!isNomadJobIDAvailable(entity)) {
return (
@@ -121,11 +123,11 @@ export const EntityNomadJobVersionListCard = () => {
return (
<Table<rowType>
title="Job Versions"
title="Job versions"
actions={[
{
icon: () => <OpenInNewIcon />,
tooltip: 'Open Job Versions Tab in Nomad',
tooltip: 'Open in Nomad UI',
isFreeAction: true,
onClick: () => window.open(`${nomadAddr}/ui/jobs/${jobID}/versions`),
},
+2 -1
View File
@@ -14,5 +14,6 @@
* limitations under the License.
*/
import { EntityNomadJobVersionListCard } from './EntityNomadJobVersionListCard/EntityNomadJobVersionListCard';
import { EntityNomadAllocationListTable } from './EntityNomadAllocationListTable/EntityNomadAllocationListTable';
export { EntityNomadJobVersionListCard };
export { EntityNomadJobVersionListCard, EntityNomadAllocationListTable };
+5 -2
View File
@@ -13,10 +13,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export { nomadPlugin } from './plugin';
export {
nomadPlugin,
EntityNomadJobVersionListCard,
EntityNomadAllocationListTable,
} from './plugin';
export {
isNomadAllocationsAvailable,
isNomadJobIDAvailable,
EmbeddedRouter,
} from './Router';
export { EntityNomadJobVersionListCard } from './components';
+41 -1
View File
@@ -18,8 +18,9 @@ import {
fetchApiRef,
createApiFactory,
createPlugin,
createRoutableExtension,
createRouteRef,
createRoutableExtension,
createComponentExtension,
} from '@backstage/core-plugin-api';
import { rootRouteRef } from './routes';
@@ -44,3 +45,42 @@ export const nomadPlugin = createPlugin({
entityContent: entityContentRouteRef,
},
});
/** @public */
export const EntityNomadContent = nomadPlugin.provide(
createRoutableExtension({
name: 'EntityNomadContent',
component: () => import('./Router').then(m => m.EmbeddedRouter),
mountPoint: entityContentRouteRef,
}),
);
/**
* Card used to show the list of Nomad job versions.
*
* @public
*/
export const EntityNomadJobVersionListCard = nomadPlugin.provide(
createComponentExtension({
name: 'EntityNomadJobVersionListCard',
component: {
lazy: () =>
import('./components').then(m => m.EntityNomadJobVersionListCard),
},
}),
);
/**
* Table used to show the list of Nomad allocations for a job and/or task-group.
*
* @public
*/
export const EntityNomadAllocationListTable = nomadPlugin.provide(
createComponentExtension({
name: 'EntityNomadAllocationListTable',
component: {
lazy: () =>
import('./components').then(m => m.EntityNomadAllocationListTable),
},
}),
);