@@ -22,6 +22,7 @@
|
||||
"postpack": "backstage-cli package postpack"
|
||||
},
|
||||
"dependencies": {
|
||||
"@backstage/catalog-model": "workspace:^",
|
||||
"@backstage/core-components": "workspace:^",
|
||||
"@backstage/core-plugin-api": "workspace:^",
|
||||
"@backstage/theme": "workspace:^",
|
||||
|
||||
+3
-3
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
import React from 'react';
|
||||
import { ExampleComponent } from './ExampleComponent';
|
||||
import { NomadComponent } from './NomadComponent';
|
||||
import { rest } from 'msw';
|
||||
import { setupServer } from 'msw/node';
|
||||
import { screen } from '@testing-library/react';
|
||||
@@ -23,7 +23,7 @@ import {
|
||||
renderInTestApp,
|
||||
} from '@backstage/test-utils';
|
||||
|
||||
describe('ExampleComponent', () => {
|
||||
describe('NomadComponent', () => {
|
||||
const server = setupServer();
|
||||
// Enable sane handlers for network requests
|
||||
setupRequestMockHandlers(server);
|
||||
@@ -36,7 +36,7 @@ describe('ExampleComponent', () => {
|
||||
});
|
||||
|
||||
it('should render', async () => {
|
||||
await renderInTestApp(<ExampleComponent />);
|
||||
await renderInTestApp(<NomadComponent />);
|
||||
expect(screen.getByText('Welcome to nomad!')).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
+3
-3
@@ -24,9 +24,9 @@ import {
|
||||
HeaderLabel,
|
||||
SupportButton,
|
||||
} from '@backstage/core-components';
|
||||
import { ExampleFetchComponent } from '../ExampleFetchComponent';
|
||||
import { NomadFetchComponent } from '../NomadFetchComponent';
|
||||
|
||||
export const ExampleComponent = () => (
|
||||
export const NomadComponent = () => (
|
||||
<Page themeId="tool">
|
||||
<Header title="Welcome to nomad!" subtitle="Optional subtitle">
|
||||
<HeaderLabel label="Owner" value="Team X" />
|
||||
@@ -45,7 +45,7 @@ export const ExampleComponent = () => (
|
||||
</InfoCard>
|
||||
</Grid>
|
||||
<Grid item>
|
||||
<ExampleFetchComponent />
|
||||
<NomadFetchComponent />
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Content>
|
||||
+1
-1
@@ -13,4 +13,4 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
export { ExampleComponent } from './ExampleComponent';
|
||||
export { NomadComponent } from './NomadComponent';
|
||||
+3
-3
@@ -15,12 +15,12 @@
|
||||
*/
|
||||
import React from 'react';
|
||||
import { render, screen } from '@testing-library/react';
|
||||
import { ExampleFetchComponent } from './ExampleFetchComponent';
|
||||
import { NomadFetchComponent } from './NomadFetchComponent';
|
||||
import { rest } from 'msw';
|
||||
import { setupServer } from 'msw/node';
|
||||
import { setupRequestMockHandlers } from '@backstage/test-utils';
|
||||
|
||||
describe('ExampleFetchComponent', () => {
|
||||
describe('NomadFetchComponent', () => {
|
||||
const server = setupServer();
|
||||
// Enable sane handlers for network requests
|
||||
setupRequestMockHandlers(server);
|
||||
@@ -34,7 +34,7 @@ describe('ExampleFetchComponent', () => {
|
||||
);
|
||||
});
|
||||
it('should render', async () => {
|
||||
await render(<ExampleFetchComponent />);
|
||||
await render(<NomadFetchComponent />);
|
||||
expect(await screen.findByTestId('progress')).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
+1
-1
@@ -93,7 +93,7 @@ export const DenseTable = ({ users }: DenseTableProps) => {
|
||||
);
|
||||
};
|
||||
|
||||
export const ExampleFetchComponent = () => {
|
||||
export const NomadFetchComponent = () => {
|
||||
const { fetch } = useApi(fetchApiRef);
|
||||
const { value, loading, error } = useAsync(async (): Promise<User[]> => {
|
||||
const response = await fetch('https://randomuser.me/api/?results=20');
|
||||
+1
-1
@@ -13,4 +13,4 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
export { ExampleFetchComponent } from './ExampleFetchComponent';
|
||||
export { NomadFetchComponent } from './NomadFetchComponent';
|
||||
@@ -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 { Entity } from '@backstage/catalog-model';
|
||||
|
||||
/** @public */
|
||||
export const NOMAD_JOB_ANNOTATION = 'nomad.io/job';
|
||||
|
||||
/** @public */
|
||||
export const NOMAD_GROUP_ANNOTATION = 'nomad.io/group';
|
||||
|
||||
/** @public */
|
||||
export const NOMAD_TASK_ANNOTATION = 'nomad.io/task';
|
||||
|
||||
/** @public */
|
||||
export const isNomadAvailable = (entity: Entity) =>
|
||||
Boolean(entity.metadata.annotations?.[NOMAD_JOB_ANNOTATION]) ||
|
||||
Boolean(entity.metadata.annotations?.[NOMAD_GROUP_ANNOTATION]) ||
|
||||
Boolean(entity.metadata.annotations?.[NOMAD_TASK_ANNOTATION]);
|
||||
@@ -31,7 +31,7 @@ export const NomadPage = nomadPlugin.provide(
|
||||
createRoutableExtension({
|
||||
name: 'NomadPage',
|
||||
component: () =>
|
||||
import('./components/ExampleComponent').then(m => m.ExampleComponent),
|
||||
import('./components/NomadComponent').then(m => m.NomadComponent),
|
||||
mountPoint: rootRouteRef,
|
||||
}),
|
||||
);
|
||||
|
||||
@@ -7930,6 +7930,7 @@ __metadata:
|
||||
version: 0.0.0-use.local
|
||||
resolution: "@backstage/plugin-nomad@workspace:plugins/nomad"
|
||||
dependencies:
|
||||
"@backstage/catalog-model": "workspace:^"
|
||||
"@backstage/cli": "workspace:^"
|
||||
"@backstage/core-app-api": "workspace:^"
|
||||
"@backstage/core-components": "workspace:^"
|
||||
|
||||
Reference in New Issue
Block a user