From 80d75adf3a772c41434df809e03d01a6efc244ae Mon Sep 17 00:00:00 2001 From: Mengnan Gong Date: Tue, 18 Oct 2022 16:05:43 +0800 Subject: [PATCH] Cleanup the momentjs dependency in @backstage/plugin-github-pull-requests-board As per [ADR010: Use the Luxon Date Library](https://github.com/backstage/backstage/blob/master/docs/architecture-decisions/adr010-luxon-date-library.md), we should replace momentjs with luxon. Signed-off-by: Mengnan Gong --- .changeset/curvy-islands-marry.md | 5 +++++ plugins/github-pull-requests-board/package.json | 2 +- plugins/github-pull-requests-board/src/utils/functions.ts | 4 ++-- yarn.lock | 2 +- 4 files changed, 9 insertions(+), 4 deletions(-) create mode 100644 .changeset/curvy-islands-marry.md diff --git a/.changeset/curvy-islands-marry.md b/.changeset/curvy-islands-marry.md new file mode 100644 index 0000000000..2d3bad31ac --- /dev/null +++ b/.changeset/curvy-islands-marry.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-github-pull-requests-board': patch +--- + +Replace the momentjs dependency with luxon. diff --git a/plugins/github-pull-requests-board/package.json b/plugins/github-pull-requests-board/package.json index cc15d368ee..e2956099ac 100644 --- a/plugins/github-pull-requests-board/package.json +++ b/plugins/github-pull-requests-board/package.json @@ -44,7 +44,7 @@ "@material-ui/icons": "^4.9.1", "@material-ui/lab": "4.0.0-alpha.57", "@octokit/rest": "^19.0.3", - "moment": "^2.29.1", + "luxon": "^3.0.0", "react-use": "^17.2.4" }, "devDependencies": { diff --git a/plugins/github-pull-requests-board/src/utils/functions.ts b/plugins/github-pull-requests-board/src/utils/functions.ts index 69b3ecf794..5644530689 100644 --- a/plugins/github-pull-requests-board/src/utils/functions.ts +++ b/plugins/github-pull-requests-board/src/utils/functions.ts @@ -14,7 +14,7 @@ * limitations under the License. */ import { Entity } from '@backstage/catalog-model'; -import moment from 'moment'; +import { DateTime } from 'luxon'; import { Reviews, PullRequests, @@ -58,7 +58,7 @@ export const filterSameUser = (users: Author[]): Author[] => { }; export const getElapsedTime = (start: string): string => { - return moment(start).fromNow(); + return DateTime.fromISO(start).toRelative() ?? start; }; export const formatPRsByReviewDecision = ( diff --git a/yarn.lock b/yarn.lock index 05d79d90b3..83ca72c771 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5674,7 +5674,7 @@ __metadata: "@types/node": ^16.11.26 "@types/react": ^16.13.1 || ^17.0.0 cross-fetch: ^3.1.5 - moment: ^2.29.1 + luxon: ^3.0.0 msw: ^0.47.0 react-use: ^17.2.4 peerDependencies: