+79
-82
@@ -4,85 +4,82 @@
|
||||
# The last matching pattern takes precedence.
|
||||
# https://help.github.com/articles/about-codeowners/
|
||||
|
||||
* @backstage/maintainers
|
||||
yarn.lock @backstage/maintainers @backstage-service
|
||||
*/yarn.lock @backstage/maintainers @backstage-service
|
||||
/.changeset/*.md
|
||||
/cypress/src/integration/plugins/techdocs.spec.ts @backstage/techdocs-maintainers
|
||||
/docs/assets/search @backstage/discoverability-maintainers
|
||||
/docs/features/search @backstage/discoverability-maintainers
|
||||
/docs/features/techdocs @backstage/techdocs-maintainers
|
||||
/docs/plugins/integrating-search-into-plugins.md @backstage/discoverability-maintainers
|
||||
/packages/cli/src/commands/onboard @backstage/sharks
|
||||
/packages/techdocs-cli @backstage/techdocs-maintainers
|
||||
/packages/techdocs-cli-embedded-app @backstage/techdocs-maintainers
|
||||
/plugins/adr @backstage/maintainers @kuangp
|
||||
/plugins/adr-* @backstage/maintainers @kuangp
|
||||
/plugins/allure @backstage/maintainers @deepak-bhardwaj-ps
|
||||
/plugins/apache-airflow @backstage/maintainers @cmpadden
|
||||
/plugins/api-docs @backstage/maintainers @backstage/sda-se-reviewers
|
||||
/plugins/azure-devops @backstage/maintainers @marleypowell @awanlin
|
||||
/plugins/azure-devops-backend @backstage/maintainers @marleypowell @awanlin
|
||||
/plugins/azure-devops-common @backstage/maintainers @marleypowell @awanlin
|
||||
/plugins/bitbucket-cloud-common @backstage/maintainers @pjungermann
|
||||
/plugins/bitrise @backstage/maintainers @backstage/sda-se-reviewers
|
||||
/plugins/catalog @backstage/maintainers @backstage/catalog-maintainers
|
||||
/plugins/catalog-* @backstage/maintainers @backstage/catalog-maintainers
|
||||
/plugins/catalog-backend-module-aws @backstage/maintainers @backstage/catalog-maintainers @pjungermann
|
||||
/plugins/catalog-backend-module-bitbucket-cloud @backstage/maintainers @backstage/catalog-maintainers @pjungermann
|
||||
/plugins/catalog-backend-module-msgraph @backstage/maintainers @backstage/catalog-maintainers @pjungermann
|
||||
/plugins/catalog-backend-module-puppetdb @backstage/maintainers @backstage/catalog-maintainers @tdabasinskas
|
||||
/plugins/catalog-graph @backstage/maintainers @backstage/catalog-maintainers @backstage/sda-se-reviewers
|
||||
/plugins/circleci @backstage/maintainers @adamdmharvey
|
||||
/plugins/cloudbuild @backstage/maintainers @trivago/ebarrios
|
||||
/plugins/code-coverage @backstage/maintainers @alde @nissayeva
|
||||
/plugins/code-coverage-backend @backstage/maintainers @alde @nissayeva
|
||||
/plugins/cost-insights @backstage/maintainers @backstage/silver-lining
|
||||
/plugins/cost-insights-* @backstage/maintainers @backstage/silver-lining
|
||||
/plugins/entity-feedback @backstage/maintainers @kuangp
|
||||
/plugins/entity-feedback-* @backstage/maintainers @kuangp
|
||||
/plugins/events-backend @backstage/maintainers @pjungermann
|
||||
/plugins/events-backend-module-aws-sqs @backstage/maintainers @pjungermann
|
||||
/plugins/events-backend-module-azure @backstage/maintainers @pjungermann
|
||||
/plugins/events-backend-module-bitbucket-cloud @backstage/maintainers @pjungermann
|
||||
/plugins/events-backend-module-gerrit @backstage/maintainers @pjungermann
|
||||
/plugins/events-backend-module-github @backstage/maintainers @pjungermann
|
||||
/plugins/events-backend-module-gitlab @backstage/maintainers @pjungermann
|
||||
/plugins/events-backend-test-utils @backstage/maintainers @pjungermann
|
||||
/plugins/events-node @backstage/maintainers @pjungermann
|
||||
/plugins/explore @backstage/maintainers @backstage/sda-se-reviewers
|
||||
/plugins/explore-react @backstage/maintainers @backstage/sda-se-reviewers
|
||||
/plugins/fossa @backstage/maintainers @backstage/sda-se-reviewers
|
||||
/plugins/gcalendar @backstage/maintainers @szubster @ptychu @kielosz @alexrybch
|
||||
/plugins/git-release-manager @backstage/maintainers @erikengervall
|
||||
/plugins/home @backstage/discoverability-maintainers
|
||||
/plugins/home-* @backstage/discoverability-maintainers
|
||||
/plugins/ilert @backstage/maintainers @yacut
|
||||
/plugins/jenkins @backstage/maintainers @timja
|
||||
/plugins/jenkins-backend @backstage/maintainers @timja
|
||||
/plugins/kafka @backstage/maintainers @nirga @andrewthauer
|
||||
/plugins/kafka-backend @backstage/maintainers @nirga @andrewthauer
|
||||
/plugins/kubernetes @backstage/maintainers @backstage/kubernetes-maintainers
|
||||
/plugins/kubernetes-* @backstage/maintainers @backstage/kubernetes-maintainers
|
||||
/plugins/microsoft-calendar @backstage/maintainers @abhay-soni-developer @NishkarshRaj
|
||||
/plugins/newrelic-dashboard @backstage/maintainers @mufaddal7
|
||||
/plugins/permission-* @backstage/permission-maintainers
|
||||
/plugins/playlist @backstage/maintainers @kuangp
|
||||
/plugins/playlist-* @backstage/maintainers @kuangp
|
||||
/plugins/puppetdb @backstage/maintainers @tdabasinskas
|
||||
/plugins/rollbar @backstage/maintainers @andrewthauer
|
||||
/plugins/rollbar-backend @backstage/maintainers @andrewthauer
|
||||
/plugins/scaffolder-backend-module-rails @backstage/maintainers @angeliski
|
||||
/plugins/scaffolder-backend-module-yeoman @backstage/maintainers @pawelmitka
|
||||
/plugins/search @backstage/discoverability-maintainers
|
||||
/plugins/search-* @backstage/discoverability-maintainers
|
||||
/plugins/sonarqube @backstage/maintainers @backstage/sda-se-reviewers
|
||||
/plugins/stack-overflow @backstage/discoverability-maintainers
|
||||
/plugins/stack-overflow-backend @backstage/discoverability-maintainers
|
||||
/plugins/techdocs @backstage/techdocs-maintainers
|
||||
/plugins/techdocs-* @backstage/techdocs-maintainers
|
||||
/plugins/user-settings-backend @backstage/maintainers @backstage/sda-se-reviewers
|
||||
/tech-insights-backend @backstage/maintainers @xantier @iain-b
|
||||
/tech-insights-backend-module-jsonfc @backstage/maintainers @xantier @iain-b
|
||||
/tech-insights-tech-insights-common @backstage/maintainers @xantier @iain-b
|
||||
/tech-insights-tech-insights-node @backstage/maintainers @xantier @iain-b
|
||||
* @backstage/maintainers
|
||||
*/yarn.lock @backstage/maintainers @backstage-service
|
||||
/cypress/src/integration/plugins/techdocs.spec.ts @backstage/techdocs-maintainers
|
||||
/docs/assets/search @backstage/discoverability-maintainers
|
||||
/docs/features/search @backstage/discoverability-maintainers
|
||||
/docs/features/techdocs @backstage/techdocs-maintainers
|
||||
/docs/plugins/integrating-search-into-plugins.md @backstage/discoverability-maintainers
|
||||
/packages/cli/src/commands/onboard @backstage/sharks
|
||||
/packages/techdocs-cli @backstage/techdocs-maintainers
|
||||
/packages/techdocs-cli-embedded-app @backstage/techdocs-maintainers
|
||||
/plugins/adr @backstage/maintainers @kuangp
|
||||
/plugins/adr-* @backstage/maintainers @kuangp
|
||||
/plugins/allure @backstage/maintainers @deepak-bhardwaj-ps
|
||||
/plugins/apache-airflow @backstage/maintainers @cmpadden
|
||||
/plugins/api-docs @backstage/maintainers @backstage/sda-se-reviewers
|
||||
/plugins/azure-devops @backstage/maintainers @marleypowell @awanlin
|
||||
/plugins/azure-devops-backend @backstage/maintainers @marleypowell @awanlin
|
||||
/plugins/azure-devops-common @backstage/maintainers @marleypowell @awanlin
|
||||
/plugins/bitbucket-cloud-common @backstage/maintainers @pjungermann
|
||||
/plugins/bitrise @backstage/maintainers @backstage/sda-se-reviewers
|
||||
/plugins/catalog @backstage/maintainers @backstage/catalog-maintainers
|
||||
/plugins/catalog-* @backstage/maintainers @backstage/catalog-maintainers
|
||||
/plugins/catalog-backend-module-aws @backstage/maintainers @backstage/catalog-maintainers @pjungermann
|
||||
/plugins/catalog-backend-module-bitbucket-cloud @backstage/maintainers @backstage/catalog-maintainers @pjungermann
|
||||
/plugins/catalog-backend-module-msgraph @backstage/maintainers @backstage/catalog-maintainers @pjungermann
|
||||
/plugins/catalog-backend-module-puppetdb @backstage/maintainers @backstage/catalog-maintainers @tdabasinskas
|
||||
/plugins/catalog-graph @backstage/maintainers @backstage/catalog-maintainers @backstage/sda-se-reviewers
|
||||
/plugins/circleci @backstage/maintainers @adamdmharvey
|
||||
/plugins/cloudbuild @backstage/maintainers @trivago/ebarrios
|
||||
/plugins/code-coverage @backstage/maintainers @alde @nissayeva
|
||||
/plugins/code-coverage-backend @backstage/maintainers @alde @nissayeva
|
||||
/plugins/cost-insights @backstage/maintainers @backstage/silver-lining
|
||||
/plugins/cost-insights-* @backstage/maintainers @backstage/silver-lining
|
||||
/plugins/entity-feedback @backstage/maintainers @kuangp
|
||||
/plugins/entity-feedback-* @backstage/maintainers @kuangp
|
||||
/plugins/events-backend @backstage/maintainers @pjungermann
|
||||
/plugins/events-backend-module-aws-sqs @backstage/maintainers @pjungermann
|
||||
/plugins/events-backend-module-azure @backstage/maintainers @pjungermann
|
||||
/plugins/events-backend-module-bitbucket-cloud @backstage/maintainers @pjungermann
|
||||
/plugins/events-backend-module-gerrit @backstage/maintainers @pjungermann
|
||||
/plugins/events-backend-module-github @backstage/maintainers @pjungermann
|
||||
/plugins/events-backend-module-gitlab @backstage/maintainers @pjungermann
|
||||
/plugins/events-backend-test-utils @backstage/maintainers @pjungermann
|
||||
/plugins/events-node @backstage/maintainers @pjungermann
|
||||
/plugins/explore @backstage/maintainers @backstage/sda-se-reviewers
|
||||
/plugins/explore-react @backstage/maintainers @backstage/sda-se-reviewers
|
||||
/plugins/fossa @backstage/maintainers @backstage/sda-se-reviewers
|
||||
/plugins/gcalendar @backstage/maintainers @szubster @ptychu @kielosz @alexrybch
|
||||
/plugins/git-release-manager @backstage/maintainers @erikengervall
|
||||
/plugins/home @backstage/discoverability-maintainers
|
||||
/plugins/ilert @backstage/maintainers @yacut
|
||||
/plugins/jenkins @backstage/maintainers @timja
|
||||
/plugins/jenkins-backend @backstage/maintainers @timja
|
||||
/plugins/kafka @backstage/maintainers @nirga @andrewthauer
|
||||
/plugins/kafka-backend @backstage/maintainers @nirga @andrewthauer
|
||||
/plugins/kubernetes @backstage/maintainers @backstage/kubernetes-maintainers
|
||||
/plugins/kubernetes-* @backstage/maintainers @backstage/kubernetes-maintainers
|
||||
/plugins/microsoft-calendar @backstage/maintainers @abhay-soni-developer @NishkarshRaj
|
||||
/plugins/newrelic-dashboard @backstage/maintainers @mufaddal7
|
||||
/plugins/playlist @backstage/maintainers @kuangp
|
||||
/plugins/playlist-* @backstage/maintainers @kuangp
|
||||
/plugins/puppetdb @backstage/maintainers @tdabasinskas
|
||||
/plugins/rollbar @backstage/maintainers @andrewthauer
|
||||
/plugins/rollbar-backend @backstage/maintainers @andrewthauer
|
||||
/plugins/scaffolder-backend-module-rails @backstage/maintainers @angeliski
|
||||
/plugins/scaffolder-backend-module-yeoman @backstage/maintainers @pawelmitka
|
||||
/plugins/search @backstage/discoverability-maintainers
|
||||
/plugins/search-* @backstage/discoverability-maintainers
|
||||
/plugins/sonarqube @backstage/maintainers @backstage/sda-se-reviewers
|
||||
/plugins/stack-overflow @backstage/discoverability-maintainers
|
||||
/plugins/stack-overflow-backend @backstage/discoverability-maintainers
|
||||
/plugins/techdocs @backstage/techdocs-maintainers
|
||||
/plugins/techdocs-* @backstage/techdocs-maintainers
|
||||
/plugins/user-settings-backend @backstage/maintainers @backstage/sda-se-reviewers
|
||||
/tech-insights-backend @backstage/maintainers @xantier @iain-b
|
||||
/tech-insights-backend-module-jsonfc @backstage/maintainers @xantier @iain-b
|
||||
/tech-insights-tech-insights-common @backstage/maintainers @xantier @iain-b
|
||||
/tech-insights-tech-insights-node @backstage/maintainers @xantier @iain-b
|
||||
yarn.lock @backstage/maintainers @backstage-service
|
||||
|
||||
@@ -50,6 +50,7 @@
|
||||
"@backstage/plugin-microsoft-calendar": "workspace:^",
|
||||
"@backstage/plugin-newrelic": "workspace:^",
|
||||
"@backstage/plugin-newrelic-dashboard": "workspace:^",
|
||||
"@backstage/plugin-nomad": "^0.0.0",
|
||||
"@backstage/plugin-octopus-deploy": "workspace:^",
|
||||
"@backstage/plugin-org": "workspace:^",
|
||||
"@backstage/plugin-pagerduty": "workspace:^",
|
||||
|
||||
@@ -110,6 +110,7 @@ import { ScoreBoardPage } from '@oriflame/backstage-plugin-score-card';
|
||||
import { StackstormPage } from '@backstage/plugin-stackstorm';
|
||||
import { PuppetDbPage } from '@backstage/plugin-puppetdb';
|
||||
import { DevToolsPage } from '@backstage/plugin-devtools';
|
||||
import { NomadPage } from '@backstage/plugin-nomad';
|
||||
import { customDevToolsPage } from './components/devtools/CustomDevToolsPage';
|
||||
import { CatalogUnprocessedEntitiesPage } from '@backstage/plugin-catalog-unprocessed-entities';
|
||||
|
||||
@@ -302,6 +303,7 @@ const routes = (
|
||||
<Route path="/devtools" element={<DevToolsPage />}>
|
||||
{customDevToolsPage}
|
||||
</Route>
|
||||
<Route path="/nomad" element={<NomadPage />} />
|
||||
</FlatRoutes>
|
||||
);
|
||||
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
module.exports = require('@backstage/cli/config/eslint-factory')(__dirname);
|
||||
@@ -0,0 +1,13 @@
|
||||
# nomad
|
||||
|
||||
Welcome to the nomad plugin!
|
||||
|
||||
_This plugin was created through the Backstage CLI_
|
||||
|
||||
## Getting started
|
||||
|
||||
Your plugin has been added to the example app in this repository, meaning you'll be able to access it by running `yarn start` in the root directory, and then navigating to [/nomad](http://localhost:3000/nomad).
|
||||
|
||||
You can also serve the plugin in isolation by running `yarn start` in the plugin directory.
|
||||
This method of serving the plugin provides quicker iteration speed and a faster startup and hot reloads.
|
||||
It is only meant for local development, and the setup for it can be found inside the [/dev](./dev) directory.
|
||||
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright 2023 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 React from 'react';
|
||||
import { createDevApp } from '@backstage/dev-utils';
|
||||
import { nomadPlugin, NomadPage } from '../src/plugin';
|
||||
|
||||
createDevApp()
|
||||
.registerPlugin(nomadPlugin)
|
||||
.addPage({
|
||||
element: <NomadPage />,
|
||||
title: 'Root Page',
|
||||
path: '/nomad',
|
||||
})
|
||||
.render();
|
||||
@@ -0,0 +1,51 @@
|
||||
{
|
||||
"name": "@backstage/plugin-nomad",
|
||||
"version": "0.0.0",
|
||||
"main": "src/index.ts",
|
||||
"types": "src/index.ts",
|
||||
"license": "Apache-2.0",
|
||||
"publishConfig": {
|
||||
"access": "public",
|
||||
"main": "dist/index.esm.js",
|
||||
"types": "dist/index.d.ts"
|
||||
},
|
||||
"backstage": {
|
||||
"role": "frontend-plugin"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "backstage-cli package start",
|
||||
"build": "backstage-cli package build",
|
||||
"lint": "backstage-cli package lint",
|
||||
"test": "backstage-cli package test",
|
||||
"clean": "backstage-cli package clean",
|
||||
"prepack": "backstage-cli package prepack",
|
||||
"postpack": "backstage-cli package postpack"
|
||||
},
|
||||
"dependencies": {
|
||||
"@backstage/core-components": "workspace:^",
|
||||
"@backstage/core-plugin-api": "workspace:^",
|
||||
"@backstage/theme": "workspace:^",
|
||||
"@material-ui/core": "^4.9.13",
|
||||
"@material-ui/icons": "^4.9.1",
|
||||
"@material-ui/lab": "^4.0.0-alpha.60",
|
||||
"react-use": "^17.2.4"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"react": "^16.13.1 || ^17.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@backstage/cli": "workspace:^",
|
||||
"@backstage/core-app-api": "workspace:^",
|
||||
"@backstage/dev-utils": "workspace:^",
|
||||
"@backstage/test-utils": "workspace:^",
|
||||
"@testing-library/jest-dom": "^5.10.1",
|
||||
"@testing-library/react": "^12.1.3",
|
||||
"@testing-library/user-event": "^14.0.0",
|
||||
"@types/node": "*",
|
||||
"cross-fetch": "^3.1.5",
|
||||
"msw": "^1.0.0"
|
||||
},
|
||||
"files": [
|
||||
"dist"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright 2023 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 React from 'react';
|
||||
import { ExampleComponent } from './ExampleComponent';
|
||||
import { rest } from 'msw';
|
||||
import { setupServer } from 'msw/node';
|
||||
import { screen } from '@testing-library/react';
|
||||
import {
|
||||
setupRequestMockHandlers,
|
||||
renderInTestApp,
|
||||
} from '@backstage/test-utils';
|
||||
|
||||
describe('ExampleComponent', () => {
|
||||
const server = setupServer();
|
||||
// Enable sane handlers for network requests
|
||||
setupRequestMockHandlers(server);
|
||||
|
||||
// setup mock response
|
||||
beforeEach(() => {
|
||||
server.use(
|
||||
rest.get('/*', (_, res, ctx) => res(ctx.status(200), ctx.json({}))),
|
||||
);
|
||||
});
|
||||
|
||||
it('should render', async () => {
|
||||
await renderInTestApp(<ExampleComponent />);
|
||||
expect(screen.getByText('Welcome to nomad!')).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright 2023 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 React from 'react';
|
||||
import { Typography, Grid } from '@material-ui/core';
|
||||
import {
|
||||
InfoCard,
|
||||
Header,
|
||||
Page,
|
||||
Content,
|
||||
ContentHeader,
|
||||
HeaderLabel,
|
||||
SupportButton,
|
||||
} from '@backstage/core-components';
|
||||
import { ExampleFetchComponent } from '../ExampleFetchComponent';
|
||||
|
||||
export const ExampleComponent = () => (
|
||||
<Page themeId="tool">
|
||||
<Header title="Welcome to nomad!" subtitle="Optional subtitle">
|
||||
<HeaderLabel label="Owner" value="Team X" />
|
||||
<HeaderLabel label="Lifecycle" value="Alpha" />
|
||||
</Header>
|
||||
<Content>
|
||||
<ContentHeader title="Plugin title">
|
||||
<SupportButton>A description of your plugin goes here.</SupportButton>
|
||||
</ContentHeader>
|
||||
<Grid container spacing={3} direction="column">
|
||||
<Grid item>
|
||||
<InfoCard title="Information card">
|
||||
<Typography variant="body1">
|
||||
All content should be wrapped in a card like this.
|
||||
</Typography>
|
||||
</InfoCard>
|
||||
</Grid>
|
||||
<Grid item>
|
||||
<ExampleFetchComponent />
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Content>
|
||||
</Page>
|
||||
);
|
||||
@@ -0,0 +1,16 @@
|
||||
/*
|
||||
* Copyright 2023 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.
|
||||
*/
|
||||
export { ExampleComponent } from './ExampleComponent';
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright 2023 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 React from 'react';
|
||||
import { render, screen } from '@testing-library/react';
|
||||
import { ExampleFetchComponent } from './ExampleFetchComponent';
|
||||
import { rest } from 'msw';
|
||||
import { setupServer } from 'msw/node';
|
||||
import { setupRequestMockHandlers } from '@backstage/test-utils';
|
||||
|
||||
describe('ExampleFetchComponent', () => {
|
||||
const server = setupServer();
|
||||
// Enable sane handlers for network requests
|
||||
setupRequestMockHandlers(server);
|
||||
|
||||
// setup mock response
|
||||
beforeEach(() => {
|
||||
server.use(
|
||||
rest.get('https://randomuser.me/*', (_, res, ctx) =>
|
||||
res(ctx.status(200), ctx.delay(2000), ctx.json({})),
|
||||
),
|
||||
);
|
||||
});
|
||||
it('should render', async () => {
|
||||
await render(<ExampleFetchComponent />);
|
||||
expect(await screen.findByTestId('progress')).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,111 @@
|
||||
/*
|
||||
* Copyright 2023 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 React from 'react';
|
||||
import { makeStyles } from '@material-ui/core/styles';
|
||||
import {
|
||||
Table,
|
||||
TableColumn,
|
||||
Progress,
|
||||
ResponseErrorPanel,
|
||||
} from '@backstage/core-components';
|
||||
import { fetchApiRef, useApi } from '@backstage/core-plugin-api';
|
||||
import useAsync from 'react-use/lib/useAsync';
|
||||
|
||||
const useStyles = makeStyles({
|
||||
avatar: {
|
||||
height: 32,
|
||||
width: 32,
|
||||
borderRadius: '50%',
|
||||
},
|
||||
});
|
||||
|
||||
type User = {
|
||||
gender: string; // "male"
|
||||
name: {
|
||||
title: string; // "Mr",
|
||||
first: string; // "Duane",
|
||||
last: string; // "Reed"
|
||||
};
|
||||
location: object; // {street: {number: 5060, name: "Hickory Creek Dr"}, city: "Albany", state: "New South Wales",…}
|
||||
email: string; // "duane.reed@example.com"
|
||||
login: object; // {uuid: "4b785022-9a23-4ab9-8a23-cb3fb43969a9", username: "blackdog796", password: "patch",…}
|
||||
dob: object; // {date: "1983-06-22T12:30:23.016Z", age: 37}
|
||||
registered: object; // {date: "2006-06-13T18:48:28.037Z", age: 14}
|
||||
phone: string; // "07-2154-5651"
|
||||
cell: string; // "0405-592-879"
|
||||
id: {
|
||||
name: string; // "TFN",
|
||||
value: string; // "796260432"
|
||||
};
|
||||
picture: { medium: string }; // {medium: "https://randomuser.me/api/portraits/men/95.jpg",…}
|
||||
nat: string; // "AU"
|
||||
};
|
||||
|
||||
type DenseTableProps = {
|
||||
users: User[];
|
||||
};
|
||||
|
||||
export const DenseTable = ({ users }: DenseTableProps) => {
|
||||
const classes = useStyles();
|
||||
|
||||
const columns: TableColumn[] = [
|
||||
{ title: 'Avatar', field: 'avatar' },
|
||||
{ title: 'Name', field: 'name' },
|
||||
{ title: 'Email', field: 'email' },
|
||||
{ title: 'Nationality', field: 'nationality' },
|
||||
];
|
||||
|
||||
const data = users.map(user => {
|
||||
return {
|
||||
avatar: (
|
||||
<img
|
||||
src={user.picture.medium}
|
||||
className={classes.avatar}
|
||||
alt={user.name.first}
|
||||
/>
|
||||
),
|
||||
name: `${user.name.first} ${user.name.last}`,
|
||||
email: user.email,
|
||||
nationality: user.nat,
|
||||
};
|
||||
});
|
||||
|
||||
return (
|
||||
<Table
|
||||
title="Example User List (fetching data from randomuser.me)"
|
||||
options={{ search: false, paging: false }}
|
||||
columns={columns}
|
||||
data={data}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
export const ExampleFetchComponent = () => {
|
||||
const { fetch } = useApi(fetchApiRef);
|
||||
const { value, loading, error } = useAsync(async (): Promise<User[]> => {
|
||||
const response = await fetch('https://randomuser.me/api/?results=20');
|
||||
const data = await response.json();
|
||||
return data.results;
|
||||
}, []);
|
||||
|
||||
if (loading) {
|
||||
return <Progress />;
|
||||
} else if (error) {
|
||||
return <ResponseErrorPanel error={error} />;
|
||||
}
|
||||
|
||||
return <DenseTable users={value || []} />;
|
||||
};
|
||||
@@ -0,0 +1,16 @@
|
||||
/*
|
||||
* Copyright 2023 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.
|
||||
*/
|
||||
export { ExampleFetchComponent } from './ExampleFetchComponent';
|
||||
@@ -0,0 +1,16 @@
|
||||
/*
|
||||
* Copyright 2023 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.
|
||||
*/
|
||||
export { nomadPlugin, NomadPage } from './plugin';
|
||||
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* Copyright 2023 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 { nomadPlugin } from './plugin';
|
||||
|
||||
describe('nomad', () => {
|
||||
it('should export plugin', () => {
|
||||
expect(nomadPlugin).toBeDefined();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright 2023 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 {
|
||||
createPlugin,
|
||||
createRoutableExtension,
|
||||
} from '@backstage/core-plugin-api';
|
||||
|
||||
import { rootRouteRef } from './routes';
|
||||
|
||||
export const nomadPlugin = createPlugin({
|
||||
id: 'nomad',
|
||||
routes: {
|
||||
root: rootRouteRef,
|
||||
},
|
||||
});
|
||||
|
||||
export const NomadPage = nomadPlugin.provide(
|
||||
createRoutableExtension({
|
||||
name: 'NomadPage',
|
||||
component: () =>
|
||||
import('./components/ExampleComponent').then(m => m.ExampleComponent),
|
||||
mountPoint: rootRouteRef,
|
||||
}),
|
||||
);
|
||||
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* Copyright 2023 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 { createRouteRef } from '@backstage/core-plugin-api';
|
||||
|
||||
export const rootRouteRef = createRouteRef({
|
||||
id: 'nomad',
|
||||
});
|
||||
@@ -0,0 +1,17 @@
|
||||
/*
|
||||
* Copyright 2023 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 '@testing-library/jest-dom';
|
||||
import 'cross-fetch/polyfill';
|
||||
@@ -7926,6 +7926,32 @@ __metadata:
|
||||
languageName: unknown
|
||||
linkType: soft
|
||||
|
||||
"@backstage/plugin-nomad@^0.0.0, @backstage/plugin-nomad@workspace:plugins/nomad":
|
||||
version: 0.0.0-use.local
|
||||
resolution: "@backstage/plugin-nomad@workspace:plugins/nomad"
|
||||
dependencies:
|
||||
"@backstage/cli": "workspace:^"
|
||||
"@backstage/core-app-api": "workspace:^"
|
||||
"@backstage/core-components": "workspace:^"
|
||||
"@backstage/core-plugin-api": "workspace:^"
|
||||
"@backstage/dev-utils": "workspace:^"
|
||||
"@backstage/test-utils": "workspace:^"
|
||||
"@backstage/theme": "workspace:^"
|
||||
"@material-ui/core": ^4.9.13
|
||||
"@material-ui/icons": ^4.9.1
|
||||
"@material-ui/lab": ^4.0.0-alpha.60
|
||||
"@testing-library/jest-dom": ^5.10.1
|
||||
"@testing-library/react": ^12.1.3
|
||||
"@testing-library/user-event": ^14.0.0
|
||||
"@types/node": "*"
|
||||
cross-fetch: ^3.1.5
|
||||
msw: ^1.0.0
|
||||
react-use: ^17.2.4
|
||||
peerDependencies:
|
||||
react: ^16.13.1 || ^17.0.0
|
||||
languageName: unknown
|
||||
linkType: soft
|
||||
|
||||
"@backstage/plugin-octopus-deploy@workspace:^, @backstage/plugin-octopus-deploy@workspace:plugins/octopus-deploy":
|
||||
version: 0.0.0-use.local
|
||||
resolution: "@backstage/plugin-octopus-deploy@workspace:plugins/octopus-deploy"
|
||||
@@ -24521,6 +24547,7 @@ __metadata:
|
||||
"@backstage/plugin-microsoft-calendar": "workspace:^"
|
||||
"@backstage/plugin-newrelic": "workspace:^"
|
||||
"@backstage/plugin-newrelic-dashboard": "workspace:^"
|
||||
"@backstage/plugin-nomad": ^0.0.0
|
||||
"@backstage/plugin-octopus-deploy": "workspace:^"
|
||||
"@backstage/plugin-org": "workspace:^"
|
||||
"@backstage/plugin-pagerduty": "workspace:^"
|
||||
|
||||
Reference in New Issue
Block a user