From 53d790027fa957ba44062aff98bfcd09e1769941 Mon Sep 17 00:00:00 2001 From: Omer Farooq <17722640+o-farooq@users.noreply.github.com> Date: Sun, 1 Nov 2020 19:01:34 +1300 Subject: [PATCH 1/5] add techradar entry history data structure --- plugins/tech-radar/src/api.ts | 12 ++- .../src/components/RadarComponent.tsx | 24 ++++- plugins/tech-radar/src/sampleData.ts | 101 +++++++++++++----- plugins/tech-radar/src/utils/types.ts | 8 ++ 4 files changed, 114 insertions(+), 31 deletions(-) diff --git a/plugins/tech-radar/src/api.ts b/plugins/tech-radar/src/api.ts index 7a6e790136..10b8f480f2 100644 --- a/plugins/tech-radar/src/api.ts +++ b/plugins/tech-radar/src/api.ts @@ -34,11 +34,17 @@ export interface RadarQuadrant { export interface RadarEntry { key: string; // react key id: string; - moved: MovedState; - quadrant: RadarQuadrant; - ring: RadarRing; + quadrant: string; title: string; url: string; + history: Array; +} + +export interface RadarEntryHistory { + date: Date; + ring: string; + description?: string; + moved?: MovedState; } /** diff --git a/plugins/tech-radar/src/components/RadarComponent.tsx b/plugins/tech-radar/src/components/RadarComponent.tsx index 99190202b9..525949d040 100644 --- a/plugins/tech-radar/src/components/RadarComponent.tsx +++ b/plugins/tech-radar/src/components/RadarComponent.tsx @@ -20,6 +20,7 @@ import { useAsync } from 'react-use'; import Radar from '../components/Radar'; import { TechRadarComponentProps, TechRadarLoaderResponse } from '../api'; import getSampleData from '../sampleData'; +import { Entry } from '../utils/types'; const useTechRadarLoader = (props: TechRadarComponentProps) => { const errorApi = useApi(errorApiRef); @@ -47,6 +48,27 @@ const useTechRadarLoader = (props: TechRadarComponentProps) => { const RadarComponent = (props: TechRadarComponentProps): JSX.Element => { const { loading, error, value: data } = useTechRadarLoader(props); + const mapToEntries = ( + loaderResponse: TechRadarLoaderResponse | undefined, + ): Array => { + return loaderResponse!.entries.map(entry => { + return { + id: entry.key, + quadrant: loaderResponse!.quadrants.find(q => q.id === entry.quadrant)!, + title: entry.title, + ring: loaderResponse!.rings.find(r => r.id === entry.history[0].ring)!, + history: entry.history.map(e => { + return { + date: e.date, + ring: loaderResponse!.rings.find(a => a.id === e.ring)!, + description: e.description, + moved: e.moved, + }; + }), + }; + }); + }; + return ( <> {loading && } @@ -55,7 +77,7 @@ const RadarComponent = (props: TechRadarComponentProps): JSX.Element => { {...props} rings={data!.rings} quadrants={data!.quadrants} - entries={data!.entries} + entries={mapToEntries(data)} /> )} diff --git a/plugins/tech-radar/src/sampleData.ts b/plugins/tech-radar/src/sampleData.ts index a9fa7efd7b..7d4ff6198f 100644 --- a/plugins/tech-radar/src/sampleData.ts +++ b/plugins/tech-radar/src/sampleData.ts @@ -35,85 +35,132 @@ quadrants.push({ id: 'process', name: 'Process' }); const entries = new Array(); entries.push({ - moved: 0, - ring: { id: 'use', name: 'USE', color: '#93c47d' }, + history: [ + { + moved: 0, + ring: 'use', + date: new Date('2020-08-06'), + description: + 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua', + }, + ], url: '#', key: 'javascript', id: 'javascript', title: 'JavaScript', - quadrant: { id: 'languages', name: 'Languages' }, + quadrant: 'languages', }); entries.push({ - moved: 0, - ring: { id: 'use', name: 'USE', color: '#93c47d' }, + history: [ + { + moved: 0, + ring: 'use', + date: new Date('2020-08-06'), + description: + 'Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat', + }, + ], url: '#', key: 'typescript', id: 'typescript', title: 'TypeScript', - quadrant: { id: 'languages', name: 'Languages' }, + quadrant: 'languages', }); entries.push({ - moved: 0, - ring: { id: 'use', name: 'USE', color: '#93c47d' }, + history: [ + { + moved: 0, + ring: 'use', + date: new Date('2020-08-06'), + }, + ], url: '#', key: 'webpack', id: 'webpack', title: 'Webpack', - quadrant: { id: 'frameworks', name: 'Frameworks' }, + quadrant: 'frameworks', }); entries.push({ - moved: 0, - ring: { id: 'use', name: 'USE', color: '#93c47d' }, + history: [ + { + moved: 0, + ring: 'use', + date: new Date('2020-08-06'), + }, + ], url: '#', key: 'react', id: 'react', title: 'React', - quadrant: { id: 'frameworks', name: 'Frameworks' }, + quadrant: 'frameworks', }); entries.push({ - moved: 0, - ring: { id: 'use', name: 'USE', color: '#93c47d' }, + history: [ + { + moved: 0, + ring: 'use', + date: new Date('2020-08-06'), + }, + ], url: '#', key: 'code-reviews', id: 'code-reviews', title: 'Code Reviews', - quadrant: { id: 'process', name: 'Process' }, + quadrant: 'process', }); entries.push({ - moved: 0, + history: [ + { + moved: 0, + ring: 'assess', + date: new Date('2020-08-06'), + }, + ], url: '#', key: 'mob-programming', id: 'mob-programming', title: 'Mob Programming', - quadrant: { id: 'process', name: 'Process' }, - ring: { id: 'assess', name: 'ASSESS', color: '#fbdb84' }, + quadrant: 'process', }); entries.push({ - moved: 0, + history: [ + { + moved: 0, + ring: 'use', + date: new Date('2020-08-06'), + }, + ], url: '#', key: 'docs-like-code', id: 'docs-like-code', title: 'Docs-like-code', - quadrant: { id: 'process', name: 'Process' }, - ring: { id: 'use', name: 'USE', color: '#93c47d' }, + quadrant: 'process', }); entries.push({ - moved: 0, + history: [ + { + ring: 'hold', + date: new Date('2020-08-06'), + }, + ], url: '#', key: 'force-push', id: 'force-push', title: 'Force push to master', - quadrant: { id: 'process', name: 'Process' }, - ring: { id: 'hold', name: 'HOLD', color: '#93c47d' }, + quadrant: 'process', }); entries.push({ - moved: 0, - ring: { id: 'use', name: 'USE', color: '#93c47d' }, + history: [ + { + ring: 'use', + date: new Date('2020-08-06'), + }, + ], url: '#', key: 'github-actions', id: 'github-actions', title: 'GitHub Actions', - quadrant: { id: 'infrastructure', name: 'Infrastructure' }, + quadrant: 'infrastructure', }); export default function getSampleData(): Promise { diff --git a/plugins/tech-radar/src/utils/types.ts b/plugins/tech-radar/src/utils/types.ts index f3933ee584..65c14f38c6 100644 --- a/plugins/tech-radar/src/utils/types.ts +++ b/plugins/tech-radar/src/utils/types.ts @@ -69,6 +69,14 @@ export type Entry = { // How this entry has recently moved; -1 for "down", +1 for "up", 0 for not moved moved?: MovedState; active?: boolean; + history?: Array; +}; + +export type EntryHistory = { + date: Date; + ring: Ring; + description?: string; + moved?: MovedState; }; // The same as Entry except quadrant/ring are declared by their string ID instead of being the actual objects From 59e2551801954c1a81e947b4390be143af095726 Mon Sep 17 00:00:00 2001 From: Omer Farooq <17722640+o-farooq@users.noreply.github.com> Date: Sat, 7 Nov 2020 23:10:41 +1300 Subject: [PATCH 2/5] updated names and added changeset --- .changeset/wicked-impalas-tan.md | 5 +++ plugins/tech-radar/src/api.ts | 6 ++-- .../src/components/RadarComponent.tsx | 8 +++-- plugins/tech-radar/src/sampleData.ts | 36 +++++++++---------- plugins/tech-radar/src/utils/types.ts | 4 +-- 5 files changed, 33 insertions(+), 26 deletions(-) create mode 100644 .changeset/wicked-impalas-tan.md diff --git a/.changeset/wicked-impalas-tan.md b/.changeset/wicked-impalas-tan.md new file mode 100644 index 0000000000..ea68175d74 --- /dev/null +++ b/.changeset/wicked-impalas-tan.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-tech-radar': minor +--- + +Added tech radar blip history backend support and normalized the datastructure diff --git a/plugins/tech-radar/src/api.ts b/plugins/tech-radar/src/api.ts index 10b8f480f2..0c30c9374c 100644 --- a/plugins/tech-radar/src/api.ts +++ b/plugins/tech-radar/src/api.ts @@ -37,12 +37,12 @@ export interface RadarEntry { quadrant: string; title: string; url: string; - history: Array; + timeline: Array; } -export interface RadarEntryHistory { +export interface RadarEntrySnapshot { date: Date; - ring: string; + ringId: string; description?: string; moved?: MovedState; } diff --git a/plugins/tech-radar/src/components/RadarComponent.tsx b/plugins/tech-radar/src/components/RadarComponent.tsx index 525949d040..583a7c91e0 100644 --- a/plugins/tech-radar/src/components/RadarComponent.tsx +++ b/plugins/tech-radar/src/components/RadarComponent.tsx @@ -56,11 +56,13 @@ const RadarComponent = (props: TechRadarComponentProps): JSX.Element => { id: entry.key, quadrant: loaderResponse!.quadrants.find(q => q.id === entry.quadrant)!, title: entry.title, - ring: loaderResponse!.rings.find(r => r.id === entry.history[0].ring)!, - history: entry.history.map(e => { + ring: loaderResponse!.rings.find( + r => r.id === entry.timeline[0].ringId, + )!, + history: entry.timeline.map(e => { return { date: e.date, - ring: loaderResponse!.rings.find(a => a.id === e.ring)!, + ring: loaderResponse!.rings.find(a => a.id === e.ringId)!, description: e.description, moved: e.moved, }; diff --git a/plugins/tech-radar/src/sampleData.ts b/plugins/tech-radar/src/sampleData.ts index 7d4ff6198f..914bc30931 100644 --- a/plugins/tech-radar/src/sampleData.ts +++ b/plugins/tech-radar/src/sampleData.ts @@ -35,10 +35,10 @@ quadrants.push({ id: 'process', name: 'Process' }); const entries = new Array(); entries.push({ - history: [ + timeline: [ { moved: 0, - ring: 'use', + ringId: 'use', date: new Date('2020-08-06'), description: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua', @@ -51,10 +51,10 @@ entries.push({ quadrant: 'languages', }); entries.push({ - history: [ + timeline: [ { moved: 0, - ring: 'use', + ringId: 'use', date: new Date('2020-08-06'), description: 'Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat', @@ -67,10 +67,10 @@ entries.push({ quadrant: 'languages', }); entries.push({ - history: [ + timeline: [ { moved: 0, - ring: 'use', + ringId: 'use', date: new Date('2020-08-06'), }, ], @@ -81,10 +81,10 @@ entries.push({ quadrant: 'frameworks', }); entries.push({ - history: [ + timeline: [ { moved: 0, - ring: 'use', + ringId: 'use', date: new Date('2020-08-06'), }, ], @@ -95,10 +95,10 @@ entries.push({ quadrant: 'frameworks', }); entries.push({ - history: [ + timeline: [ { moved: 0, - ring: 'use', + ringId: 'use', date: new Date('2020-08-06'), }, ], @@ -109,10 +109,10 @@ entries.push({ quadrant: 'process', }); entries.push({ - history: [ + timeline: [ { moved: 0, - ring: 'assess', + ringId: 'assess', date: new Date('2020-08-06'), }, ], @@ -123,10 +123,10 @@ entries.push({ quadrant: 'process', }); entries.push({ - history: [ + timeline: [ { moved: 0, - ring: 'use', + ringId: 'use', date: new Date('2020-08-06'), }, ], @@ -137,9 +137,9 @@ entries.push({ quadrant: 'process', }); entries.push({ - history: [ + timeline: [ { - ring: 'hold', + ringId: 'hold', date: new Date('2020-08-06'), }, ], @@ -150,9 +150,9 @@ entries.push({ quadrant: 'process', }); entries.push({ - history: [ + timeline: [ { - ring: 'use', + ringId: 'use', date: new Date('2020-08-06'), }, ], diff --git a/plugins/tech-radar/src/utils/types.ts b/plugins/tech-radar/src/utils/types.ts index 65c14f38c6..3322a67dcb 100644 --- a/plugins/tech-radar/src/utils/types.ts +++ b/plugins/tech-radar/src/utils/types.ts @@ -69,10 +69,10 @@ export type Entry = { // How this entry has recently moved; -1 for "down", +1 for "up", 0 for not moved moved?: MovedState; active?: boolean; - history?: Array; + timeline?: Array; }; -export type EntryHistory = { +export type EntrySnapshot = { date: Date; ring: Ring; description?: string; From 40bb4a2c7441eb9f2cb00eb467918c5197758fb5 Mon Sep 17 00:00:00 2001 From: Omer Farooq <17722640+o-farooq@users.noreply.github.com> Date: Sat, 7 Nov 2020 23:15:14 +1300 Subject: [PATCH 3/5] fix docs --- .changeset/wicked-impalas-tan.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/wicked-impalas-tan.md b/.changeset/wicked-impalas-tan.md index ea68175d74..8cfe919f5c 100644 --- a/.changeset/wicked-impalas-tan.md +++ b/.changeset/wicked-impalas-tan.md @@ -2,4 +2,4 @@ '@backstage/plugin-tech-radar': minor --- -Added tech radar blip history backend support and normalized the datastructure +Added tech radar blip history backend support and normalized the data structure From 3f7bfe7b1153e2477587669bb8234b98e19b6bd7 Mon Sep 17 00:00:00 2001 From: Omer Farooq Date: Wed, 30 Dec 2020 13:11:35 +1300 Subject: [PATCH 4/5] remove url check to support on-prem ADO --- .../backend-common/src/reading/AzureUrlReader.ts | 8 +------- packages/integration/src/azure/core.test.ts | 12 ++++++++++++ packages/integration/src/azure/core.ts | 1 - 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/packages/backend-common/src/reading/AzureUrlReader.ts b/packages/backend-common/src/reading/AzureUrlReader.ts index ca934ee42c..ea716a1d4a 100644 --- a/packages/backend-common/src/reading/AzureUrlReader.ts +++ b/packages/backend-common/src/reading/AzureUrlReader.ts @@ -47,13 +47,7 @@ export class AzureUrlReader implements UrlReader { constructor( private readonly options: AzureIntegrationConfig, private readonly deps: { treeResponseFactory: ReadTreeResponseFactory }, - ) { - if (options.host !== 'dev.azure.com') { - throw Error( - `Azure integration currently only supports 'dev.azure.com', tried to use host '${options.host}'`, - ); - } - } + ) {} async read(url: string): Promise { const builtUrl = getAzureFileFetchUrl(url); diff --git a/packages/integration/src/azure/core.test.ts b/packages/integration/src/azure/core.test.ts index 17041a9eb2..438e776eef 100644 --- a/packages/integration/src/azure/core.test.ts +++ b/packages/integration/src/azure/core.test.ts @@ -54,6 +54,18 @@ describe('azure core', () => { result: 'https://dev.azure.com/org-name/project-name/_apis/git/repositories/repo-name/items?path=my-template.yaml', }, + { + url: + 'https://api.com/org-name/project-name/_git/repo-name?path=my-template.yaml', + result: + 'https://api.com/org-name/project-name/_apis/git/repositories/repo-name/items?path=my-template.yaml', + }, + { + url: + 'https://api.com/org-name/project-name/_git/repo-name?path=my-template.yaml&version=GBmaster', + result: + 'https://api.com/org-name/project-name/_apis/git/repositories/repo-name/items?path=my-template.yaml&version=master', + }, ])('should handle happy path %#', async ({ url, result }) => { expect(getAzureFileFetchUrl(url)).toBe(result); }); diff --git a/packages/integration/src/azure/core.ts b/packages/integration/src/azure/core.ts index 44591f2509..7900774c79 100644 --- a/packages/integration/src/azure/core.ts +++ b/packages/integration/src/azure/core.ts @@ -43,7 +43,6 @@ export function getAzureFileFetchUrl(url: string): string { const ref = parsedUrl.searchParams.get('version')?.substr(2); if ( - parsedUrl.hostname !== 'dev.azure.com' || empty !== '' || userOrOrg === '' || project === '' || From c15c038919c9cdc6f0f391e248972cd16fd356ec Mon Sep 17 00:00:00 2001 From: Omer Farooq Date: Wed, 30 Dec 2020 13:21:08 +1300 Subject: [PATCH 5/5] rempove old changeset file --- .changeset/wicked-impalas-tan.md | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 .changeset/wicked-impalas-tan.md diff --git a/.changeset/wicked-impalas-tan.md b/.changeset/wicked-impalas-tan.md deleted file mode 100644 index 8cfe919f5c..0000000000 --- a/.changeset/wicked-impalas-tan.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@backstage/plugin-tech-radar': minor ---- - -Added tech radar blip history backend support and normalized the data structure