Merge pull request #18483 from npiyush97/fix-18413
Fixed issue: Date parsing is broken in the ADR plugin
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
---
|
||||
'@backstage/plugin-adr-common': patch
|
||||
'@backstage/plugin-adr': patch
|
||||
---
|
||||
|
||||
fixed error with date parsing.
|
||||
@@ -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:^"
|
||||
|
||||
@@ -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<Record<string, unknown>>(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,
|
||||
};
|
||||
};
|
||||
|
||||
@@ -68,9 +68,10 @@ const useStyles = makeStyles((theme: Theme) => ({
|
||||
color: theme.palette.grey[700],
|
||||
marginBottom: theme.spacing(1),
|
||||
},
|
||||
adrChip: {
|
||||
position: 'absolute',
|
||||
right: 0,
|
||||
adrBox: {
|
||||
display: 'flex',
|
||||
justifyContent: 'space-between',
|
||||
marginTop: '10px',
|
||||
},
|
||||
}));
|
||||
|
||||
@@ -131,7 +132,7 @@ const AdrListContainer = (props: {
|
||||
style: { whiteSpace: 'normal' },
|
||||
}}
|
||||
secondary={
|
||||
<Box>
|
||||
<Box className={classes.adrBox}>
|
||||
{adr.date}
|
||||
{adr.status && (
|
||||
<Chip
|
||||
@@ -139,7 +140,6 @@ const AdrListContainer = (props: {
|
||||
label={adr.status}
|
||||
size="small"
|
||||
variant="outlined"
|
||||
className={classes.adrChip}
|
||||
/>
|
||||
)}
|
||||
</Box>
|
||||
|
||||
Reference in New Issue
Block a user