diff --git a/.changeset/short-buckets-reflect.md b/.changeset/short-buckets-reflect.md new file mode 100644 index 00000000..8c264fe5 --- /dev/null +++ b/.changeset/short-buckets-reflect.md @@ -0,0 +1,19 @@ +--- +'@axis-backstage/plugin-jira-dashboard': major +'app': minor +'backend': minor +'@axis-backstage/plugin-analytics-module-umami': minor +'@axis-backstage/plugin-jira-dashboard-backend': minor +'@axis-backstage/plugin-jira-dashboard-common': minor +'@axis-backstage/plugin-readme': minor +'@axis-backstage/plugin-readme-backend': minor +'@axis-backstage/plugin-statuspage': minor +'@axis-backstage/plugin-statuspage-backend': minor +'@axis-backstage/plugin-statuspage-common': minor +--- + +Implemented project key support for fetching Jira data in the Jira Dashboard plugin. +Updated the getJiraResponseByEntity method signature in JiraDashboardApi.tsx to include a projectKey parameter. +Enhanced the JiraDashboardContent.tsx file to extract the project key from entity metadata annotations and pass it to the useJira hook. +Modified the JiraTable.tsx file to include an optional prop project of type Project to accommodate the project key. +Updated the useJira.ts file to include the projectKey parameter in the useJira hook signature and pass it to the getJiraResponseByEntity method. \ No newline at end of file diff --git a/plugins/jira-dashboard/src/api/JiraDashboardApi.tsx b/plugins/jira-dashboard/src/api/JiraDashboardApi.tsx index d02b5a3c..12040820 100644 --- a/plugins/jira-dashboard/src/api/JiraDashboardApi.tsx +++ b/plugins/jira-dashboard/src/api/JiraDashboardApi.tsx @@ -6,6 +6,9 @@ export const jiraDashboardApiRef = createApiRef({ }); export type JiraDashboardApi = { - getJiraResponseByEntity(entityRef: string): Promise; + getJiraResponseByEntity( + entityRef: string, + projectKey: string, + ): Promise; getProjectAvatar(entityRef: string): any; }; diff --git a/plugins/jira-dashboard/src/components/JiraDashboardContent/JiraDashboardContent.tsx b/plugins/jira-dashboard/src/components/JiraDashboardContent/JiraDashboardContent.tsx index da607385..9d1cd21a 100644 --- a/plugins/jira-dashboard/src/components/JiraDashboardContent/JiraDashboardContent.tsx +++ b/plugins/jira-dashboard/src/components/JiraDashboardContent/JiraDashboardContent.tsx @@ -17,17 +17,22 @@ import { useEntity } from '@backstage/plugin-catalog-react'; import { stringifyEntityRef } from '@backstage/catalog-model'; import { jiraDashboardApiRef } from '../../api'; import { useJira } from '../../hooks/useJira'; -import { JiraDataResponse } from '@axis-backstage/plugin-jira-dashboard-common'; +import { + JiraDataResponse, + PROJECT_KEY_NAME, +} from '@axis-backstage/plugin-jira-dashboard-common'; export const JiraDashboardContent = () => { const { entity } = useEntity(); + const projectKey = + entity?.metadata.annotations?.[PROJECT_KEY_NAME]?.split(',')[0]!; const api = useApi(jiraDashboardApiRef); const { data: jiraResponse, loading, error, - } = useJira(stringifyEntityRef(entity), api); + } = useJira(stringifyEntityRef(entity), projectKey, api); if (loading) { return ; @@ -37,7 +42,7 @@ export const JiraDashboardContent = () => { return ( ); @@ -70,7 +75,10 @@ export const JiraDashboardContent = () => { {jiraResponse.data.map((value: JiraDataResponse) => ( - + ))} diff --git a/plugins/jira-dashboard/src/components/JiraTable/JiraTable.tsx b/plugins/jira-dashboard/src/components/JiraTable/JiraTable.tsx index 81c8ed44..6efc03b1 100644 --- a/plugins/jira-dashboard/src/components/JiraTable/JiraTable.tsx +++ b/plugins/jira-dashboard/src/components/JiraTable/JiraTable.tsx @@ -1,12 +1,16 @@ import React from 'react'; import Typography from '@mui/material/Typography'; -import { JiraDataResponse } from '@axis-backstage/plugin-jira-dashboard-common'; +import { + JiraDataResponse, + Project, +} from '@axis-backstage/plugin-jira-dashboard-common'; import { ErrorPanel, Table } from '@backstage/core-components'; import { capitalize } from 'lodash'; import { columns } from './columns'; type Props = { tableContent: JiraDataResponse; + project?: Project; }; export const JiraTable = ({ tableContent }: Props) => { diff --git a/plugins/jira-dashboard/src/hooks/useJira.ts b/plugins/jira-dashboard/src/hooks/useJira.ts index ff74a1e3..577d4fa0 100644 --- a/plugins/jira-dashboard/src/hooks/useJira.ts +++ b/plugins/jira-dashboard/src/hooks/useJira.ts @@ -4,6 +4,7 @@ import { JiraDashboardApi } from '../api'; export function useJira( entityRef: string, + projectKey: string, jiraDashboardApi: JiraDashboardApi, ): { data: JiraResponse | undefined; @@ -15,7 +16,10 @@ export function useJira( loading, error, } = useAsync(async (): Promise => { - const response = await jiraDashboardApi.getJiraResponseByEntity(entityRef); + const response = await jiraDashboardApi.getJiraResponseByEntity( + entityRef, + projectKey, + ); response.project.avatarUrls = await jiraDashboardApi.getProjectAvatar( entityRef, );