From 2b4513abb7842a75d693ce4c46b9da98ecf75499 Mon Sep 17 00:00:00 2001 From: npiyush97 Date: Wed, 28 Jun 2023 18:59:28 +0530 Subject: [PATCH] fix-18413 Signed-off-by: npiyush97 --- .changeset/tender-oranges-change.md | 6 ++++++ plugins/adr-common/package.json | 3 ++- plugins/adr-common/src/index.ts | 5 ++++- .../src/components/EntityAdrContent/EntityAdrContent.tsx | 5 ----- yarn.lock | 8 ++++++++ 5 files changed, 20 insertions(+), 7 deletions(-) create mode 100644 .changeset/tender-oranges-change.md diff --git a/.changeset/tender-oranges-change.md b/.changeset/tender-oranges-change.md new file mode 100644 index 0000000000..b4c28fb712 --- /dev/null +++ b/.changeset/tender-oranges-change.md @@ -0,0 +1,6 @@ +--- +'@backstage/plugin-adr-common': patch +'@backstage/plugin-adr': patch +--- + +fixed error with date parsing. diff --git a/plugins/adr-common/package.json b/plugins/adr-common/package.json index 30c4a2ad11..bbce6fdf4e 100644 --- a/plugins/adr-common/package.json +++ b/plugins/adr-common/package.json @@ -32,7 +32,8 @@ "@backstage/catalog-model": "workspace:^", "@backstage/integration": "workspace:^", "@backstage/plugin-search-common": "workspace:^", - "front-matter": "^4.0.2" + "front-matter": "^4.0.2", + "luxon": "3.0.0" }, "devDependencies": { "@backstage/cli": "workspace:^" diff --git a/plugins/adr-common/src/index.ts b/plugins/adr-common/src/index.ts index 194f4899d1..97c82b2047 100644 --- a/plugins/adr-common/src/index.ts +++ b/plugins/adr-common/src/index.ts @@ -21,6 +21,7 @@ import { Entity, getEntitySourceLocation } from '@backstage/catalog-model'; import { IndexableDocument } from '@backstage/plugin-search-common'; import { ScmIntegrationRegistry } from '@backstage/integration'; import frontMatter from 'front-matter'; +import { DateTime } from 'luxon'; /** * ADR plugin annotation. @@ -135,10 +136,12 @@ export const parseMadrWithFrontmatter = (content: string): ParsedMadr => { const parsed = frontMatter>(content); const status = parsed.attributes.status; const date = parsed.attributes.date; + const luxdate = DateTime.fromJSDate(new Date(`${date}`)); + const formattedDate = luxdate.toISODate(); return { content: parsed.body, status: status ? String(status) : undefined, - date: date ? String(date) : undefined, + date: date ? String(formattedDate) : undefined, attributes: parsed.attributes, }; }; diff --git a/plugins/adr/src/components/EntityAdrContent/EntityAdrContent.tsx b/plugins/adr/src/components/EntityAdrContent/EntityAdrContent.tsx index da575d884f..80418b4aac 100644 --- a/plugins/adr/src/components/EntityAdrContent/EntityAdrContent.tsx +++ b/plugins/adr/src/components/EntityAdrContent/EntityAdrContent.tsx @@ -68,10 +68,6 @@ const useStyles = makeStyles((theme: Theme) => ({ color: theme.palette.grey[700], marginBottom: theme.spacing(1), }, - adrChip: { - position: 'absolute', - right: 0, - }, })); const AdrListContainer = (props: { @@ -139,7 +135,6 @@ const AdrListContainer = (props: { label={adr.status} size="small" variant="outlined" - className={classes.adrChip} /> )} diff --git a/yarn.lock b/yarn.lock index 79561514f7..4a97897ed1 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4589,6 +4589,7 @@ __metadata: "@backstage/integration": "workspace:^" "@backstage/plugin-search-common": "workspace:^" front-matter: ^4.0.2 + luxon: 3.0.0 languageName: unknown linkType: soft @@ -31149,6 +31150,13 @@ __metadata: languageName: node linkType: hard +"luxon@npm:3.0.0": + version: 3.0.0 + resolution: "luxon@npm:3.0.0" + checksum: c2d13ec1939962a318f5568fc750611346b64fe41041a2ab1c677450b7b41c699ee12ef080ff04d5a2027bf26d962d46661c7c87e394a20f6d60f14edb832c54 + languageName: node + linkType: hard + "luxon@npm:^2.0.2": version: 2.5.2 resolution: "luxon@npm:2.5.2"