Skip to content

Commit

Permalink
Merge branch 'main' into multipleProjectKeys
Browse files Browse the repository at this point in the history
  • Loading branch information
SaachiNayyer committed Jan 13, 2025
2 parents 0301338 + 63bad8e commit e2bf385
Show file tree
Hide file tree
Showing 19 changed files with 247 additions and 56 deletions.
1 change: 1 addition & 0 deletions app-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ techdocs:
auth:
# see https://backstage.io/docs/auth/ to learn about auth providers
providers:
guest: {}
microsoft:
development:
clientId: ${AUTH_MICROSOFT_CLIENT_ID}
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"node": "18 || 20 || 22"
},
"scripts": {
"dev": "concurrently \"yarn start\" \"yarn start-backend\"",
"dev": "yarn workspaces foreach -A --include backend --include app --parallel -v -i run start",
"start": "yarn workspace app start",
"start-backend": "yarn workspace backend start",
"build:backend": "yarn workspace backend build",
Expand Down Expand Up @@ -45,7 +45,6 @@
"@changesets/cli": "^2.26.2",
"@playwright/test": "^1.32.3",
"@spotify/prettier-config": "^12.0.0",
"concurrently": "^8.0.0",
"lerna": "^7.3.0",
"node-gyp": "^9.0.0",
"prettier": "^2.3.2",
Expand Down
8 changes: 8 additions & 0 deletions packages/app/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# app

## 0.10.9

### Patch Changes

- 82161b3: Fixed so JiraDashboard content can read config value from app-config file.
- Updated dependencies [82161b3]
- @axis-backstage/plugin-jira-dashboard@1.14.1

## 0.10.8

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "app",
"version": "0.10.8",
"version": "0.10.9",
"private": true,
"bundled": true,
"backstage": {
Expand Down
8 changes: 8 additions & 0 deletions packages/backend/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# backend

## 0.7.16

### Patch Changes

- Updated dependencies [82161b3]
- [email protected]
- @axis-backstage/plugin-jira-dashboard-backend@4.1.1

## 0.7.15

### Patch Changes
Expand Down
3 changes: 2 additions & 1 deletion packages/backend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "backend",
"version": "0.7.15",
"version": "0.7.16",
"main": "dist/index.cjs.js",
"types": "src/index.ts",
"private": true,
Expand Down Expand Up @@ -28,6 +28,7 @@
"@backstage/config": "^1.2.0",
"@backstage/plugin-app-backend": "^0.3.72",
"@backstage/plugin-auth-backend": "^0.22.10",
"@backstage/plugin-auth-backend-module-guest-provider": "^0.2.3",
"@backstage/plugin-auth-backend-module-microsoft-provider": "^0.1.18",
"@backstage/plugin-auth-node": "^0.5.0",
"@backstage/plugin-catalog-backend": "^1.25.0",
Expand Down
1 change: 1 addition & 0 deletions packages/backend/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const backend = createBackend();
backend.add(import('@backstage/plugin-catalog-backend/alpha'));
backend.add(import('@backstage/plugin-scaffolder-backend/alpha'));
backend.add(import('@backstage/plugin-auth-backend'));
backend.add(import('@backstage/plugin-auth-backend-module-guest-provider'));
backend.add(import('@backstage/plugin-auth-backend-module-microsoft-provider'));
backend.add(import('@backstage/plugin-proxy-backend/alpha'));
backend.add(import('@backstage/plugin-techdocs-backend/alpha'));
Expand Down
6 changes: 6 additions & 0 deletions plugins/jira-dashboard-backend/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @axis-backstage/plugin-jira-dashboard-backend

## 4.1.1

### Patch Changes

- 82161b3: Fixed so JiraDashboard content can read config value from app-config file.

## 4.1.0

### Minor Changes
Expand Down
6 changes: 5 additions & 1 deletion plugins/jira-dashboard-backend/config.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
export interface Config {
/** Configuration options for the Jira Dashboard plugin */
/**
* Configuration options for the Jira Dashboard plugin
*/
jiraDashboard:
| {
/**
Expand Down Expand Up @@ -28,6 +30,7 @@ export interface Config {

/**
* Optional annotation prefix for retrieving a custom annotation. Defaut value is jira.com
* @visibility frontend
*/
annotationPrefix?: string;

Expand All @@ -46,6 +49,7 @@ export interface Config {
| {
/**
* Optional annotation prefix for retrieving a custom annotation. Defaut value is jira.com
* @visibility frontend
*/
annotationPrefix?: string;

Expand Down
2 changes: 1 addition & 1 deletion plugins/jira-dashboard-backend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@axis-backstage/plugin-jira-dashboard-backend",
"version": "4.1.0",
"version": "4.1.1",
"main": "src/index.ts",
"types": "src/index.ts",
"license": "Apache-2.0",
Expand Down
6 changes: 6 additions & 0 deletions plugins/jira-dashboard/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @axis-backstage/plugin-jira-dashboard

## 1.14.1

### Patch Changes

- 82161b3: Fixed so JiraDashboard content can read config value from app-config file.

## 1.14.0

### Minor Changes
Expand Down
6 changes: 4 additions & 2 deletions plugins/jira-dashboard/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,9 @@ kind: Component
metadata:
# ...
annotations:
jira.com/project-key: value # The key of the Jira project to track for this entity
jira.com/project-key: value # Single Jira project key
# Or if your component is part of multiple Jira projects, you can specify multiple project keys by providing a comma-separated list
jira.com/project-key: abc,bcd,def # Comma-separated list of Jira project keys
```
### Optional annotations
Expand All @@ -113,7 +115,7 @@ kind: Component
metadata:
# ...
annotations:
jira.com/project-key: another-instance/value # The key of the Jira project to track for this entity, optionally prefixed with the instance name
jira.com/project-key: another-instance/value # The key of the Jira project to track for this entity, or Comma-separated list of Jira project keys optionally prefixed with the instance name
jira.com/components: component,component,component # Jira component name separated with a comma. The Roadie Backstage Jira Plugin Jira annotation `/component` is also supported here by default
jira.com/filter-ids: 12345,67890 # Jira filter id separated with a comma
jira.com/incoming-issues-status: Incoming # The name of the status for incoming issues in Jira. Default: New
Expand Down
1 change: 0 additions & 1 deletion plugins/jira-dashboard/api-report.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import { TableOptions } from '@backstage/core-components';
export const EntityJiraDashboardContent: (
props?:
| {
annotationPrefix?: string | undefined;
showFilters?: boolean | TableFilter[] | undefined;
}
| undefined,
Expand Down
20 changes: 20 additions & 0 deletions plugins/jira-dashboard/config.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
export interface Config {
/**
* Configuration options for the Jira Dashboard plugin
*/
jiraDashboard:
| {
/**
* Optional annotation prefix for retrieving a custom annotation. Defaut value is jira.com
* @visibility frontend
*/
annotationPrefix?: string;
}
| {
/**
* Optional annotation prefix for retrieving a custom annotation. Defaut value is jira.com
* @visibility frontend
*/
annotationPrefix?: string;
};
}
5 changes: 3 additions & 2 deletions plugins/jira-dashboard/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@axis-backstage/plugin-jira-dashboard",
"version": "1.14.0",
"version": "1.14.1",
"main": "src/index.ts",
"types": "src/index.ts",
"license": "Apache-2.0",
Expand Down Expand Up @@ -83,5 +83,6 @@
},
"files": [
"dist"
]
],
"configSchema": "config.d.ts"
}
10 changes: 2 additions & 8 deletions plugins/jira-dashboard/src/alpha/entityContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,15 @@ export const entityJiraContent = EntityContentBlueprint.makeWithOverrides({
optional: true,
}),
},
factory: (originalFactory, { inputs }) => {
factory: originalFactory => {
return originalFactory({
defaultPath: '/jira',
defaultTitle: 'Jira Dashboard',
filter: 'kind:component,group',
routeRef: convertLegacyRouteRef(rootRouteRef),
loader: async () =>
import('../components/JiraDashboardContent').then(m =>
compatWrapper(
<m.JiraDashboardContent
annotationPrefix={inputs.props?.get(
annotationPrefixExtensionDataRef.optional(),
)}
/>,
),
compatWrapper(<m.JiraDashboardContent />),
),
});
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { rest } from 'msw';
import { setupServer } from 'msw/node';
import { EntityProvider } from '@backstage/plugin-catalog-react';
import {
MockConfigApi,
MockFetchApi,
TestApiRegistry,
renderInTestApp,
Expand All @@ -13,6 +14,7 @@ import { JiraDashboardClient, jiraDashboardApiRef } from '../../api';
import { ApiProvider, UrlPatternDiscovery } from '@backstage/core-app-api';
import mockedJiraResponse from '../../../dev/__fixtures__/jiraResponse.json';
import mockedEntity from '../../../dev/__fixtures__/entity.json';
import { configApiRef } from '@backstage/core-plugin-api';

describe('JiraDashboardContent', () => {
const server = setupServer();
Expand Down Expand Up @@ -85,14 +87,25 @@ describe('JiraDashboardContent', () => {
});

it('renders missing annotations screen if annotation is not present', async () => {
const mockConfigApi = new MockConfigApi({
jiraDashboard: {
annotationPrefix: 'different-jira',
},
});

const mockedConfigApis = TestApiRegistry.from(
[configApiRef, mockConfigApi],
[jiraDashboardApiRef, jiraClient],
);

const rendered = await renderInTestApp(
<EntityProvider entity={mockedEntity}>
<ApiProvider apis={apis}>
<JiraDashboardContent annotationPrefix="different-prefix" />,
<ApiProvider apis={mockedConfigApis}>
<JiraDashboardContent />,
</ApiProvider>
</EntityProvider>,
);
expect(rendered.getByText(/Missing Annotation/)).toBeInTheDocument();
expect(rendered.getAllByText(/different-prefix/).length).toBeGreaterThan(0);
expect(rendered.getAllByText(/different-jira/)).toHaveLength(2);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import Link from '@mui/material/Link';
import React from 'react';
import { JiraProjectCard } from '../JiraProjectCard';
import { JiraTable } from '../JiraTable';
import { useApi } from '@backstage/core-plugin-api';
import { configApiRef, useApi } from '@backstage/core-plugin-api';
import {
MissingAnnotationEmptyState,
useEntity,
Expand All @@ -25,11 +25,15 @@ import { isJiraDashboardAvailable } from '../../plugin';
import { JiraDataResponse } from '@axis-backstage/plugin-jira-dashboard-common';

export const JiraDashboardContent = (props?: {
annotationPrefix?: string;
showFilters?: TableFilter[] | boolean;
}) => {
const { entity } = useEntity();
const api = useApi(jiraDashboardApiRef);
const config = useApi(configApiRef);
const annotationPrefix =
config
.getOptionalConfig('jiraDashboard')
?.getOptionalString('annotationPrefix') || 'jira.com';

const {
data: jiraResponse,
Expand All @@ -40,12 +44,8 @@ export const JiraDashboardContent = (props?: {
// In new frontend system, we can't yet conditionally render the tab content based on annotation key presence,
// so add back in a check for the missing annotation here / render a nicer screen if it's missing. Will
// still display the ResponseErrorPanel if the actual API call to jira fails.
if (!isJiraDashboardAvailable(entity, props?.annotationPrefix)) {
return (
<MissingAnnotationEmptyState
annotation={`${props?.annotationPrefix ?? 'jira.com'}`}
/>
);
if (!isJiraDashboardAvailable(entity, annotationPrefix)) {
return <MissingAnnotationEmptyState annotation={annotationPrefix} />;
}

if (loading) {
Expand Down
Loading

0 comments on commit e2bf385

Please sign in to comment.