From d4b8e0a67fecf57ed782c20c933f4b5e15d66d2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=B4mulo=20Penido?= Date: Mon, 13 Jan 2025 11:11:12 -0300 Subject: [PATCH] feat: add last published date to HistoryWidget --- src/library-authoring/collections/CollectionDetails.tsx | 3 +-- .../component-info/ComponentDetails.test.tsx | 4 +++- .../component-info/ComponentManagement.test.tsx | 2 +- src/library-authoring/data/api.mocks.ts | 2 +- src/library-authoring/generic/history-widget/index.tsx | 8 ++++++++ src/library-authoring/generic/history-widget/messages.ts | 5 +++++ 6 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/library-authoring/collections/CollectionDetails.tsx b/src/library-authoring/collections/CollectionDetails.tsx index d6b4f168cf..4594ed58ae 100644 --- a/src/library-authoring/collections/CollectionDetails.tsx +++ b/src/library-authoring/collections/CollectionDetails.tsx @@ -166,8 +166,7 @@ const CollectionDetails = () => { {intl.formatMessage(messages.detailsTabHistoryTitle)} diff --git a/src/library-authoring/component-info/ComponentDetails.test.tsx b/src/library-authoring/component-info/ComponentDetails.test.tsx index 33fb4c211a..8278b3727c 100644 --- a/src/library-authoring/component-info/ComponentDetails.test.tsx +++ b/src/library-authoring/component-info/ComponentDetails.test.tsx @@ -53,10 +53,12 @@ describe('', () => { }); it('should render the component history', async () => { - render(mockLibraryBlockMetadata.usageKeyNeverPublished); + render(mockLibraryBlockMetadata.usageKeyPublished); // Show created date expect(await screen.findByText('June 20, 2024')).toBeInTheDocument(); // Show modified date expect(await screen.findByText('June 21, 2024')).toBeInTheDocument(); + // Show last published date + expect(await screen.findByText('June 22, 2024')).toBeInTheDocument(); }); }); diff --git a/src/library-authoring/component-info/ComponentManagement.test.tsx b/src/library-authoring/component-info/ComponentManagement.test.tsx index b9f9e0a7c9..6c1cdc0b6e 100644 --- a/src/library-authoring/component-info/ComponentManagement.test.tsx +++ b/src/library-authoring/component-info/ComponentManagement.test.tsx @@ -68,7 +68,7 @@ describe('', () => { expect(await screen.findByText('Published')).toBeInTheDocument(); expect(screen.getByText('Published')).toBeInTheDocument(); expect( - screen.getByText(matchInnerText('SPAN', 'Last published on June 21, 2024 at 24:00 by Luke.')), + screen.getByText(matchInnerText('SPAN', 'Last published on June 22, 2024 at 24:00 by Luke.')), ).toBeInTheDocument(); }); diff --git a/src/library-authoring/data/api.mocks.ts b/src/library-authoring/data/api.mocks.ts index 0e064f8a0f..ce4be29168 100644 --- a/src/library-authoring/data/api.mocks.ts +++ b/src/library-authoring/data/api.mocks.ts @@ -356,7 +356,7 @@ mockLibraryBlockMetadata.dataPublished = { defKey: null, blockType: 'html', displayName: 'Introduction to Testing 2', - lastPublished: '2024-06-21T00:00:00', + lastPublished: '2024-06-22T00:00:00', publishedBy: 'Luke', lastDraftCreated: null, lastDraftCreatedBy: '2024-06-20T20:00:00Z', diff --git a/src/library-authoring/generic/history-widget/index.tsx b/src/library-authoring/generic/history-widget/index.tsx index 8b49d03d77..7f63b15842 100644 --- a/src/library-authoring/generic/history-widget/index.tsx +++ b/src/library-authoring/generic/history-widget/index.tsx @@ -15,6 +15,7 @@ const CustomFormattedDate = ({ date }: { date: string | Date }) => ( type HistoryWidgedProps = { modified: string | Date | null; created: string | Date | null; + lastPublished?: string | Date | null; }; /** @@ -32,8 +33,15 @@ type HistoryWidgedProps = { const HistoryWidget = ({ modified, created, + lastPublished, }: HistoryWidgedProps) => ( + {lastPublished && ( +
+
+ +
+ )} {modified && (
diff --git a/src/library-authoring/generic/history-widget/messages.ts b/src/library-authoring/generic/history-widget/messages.ts index b0c84a85e7..4b0176a90c 100644 --- a/src/library-authoring/generic/history-widget/messages.ts +++ b/src/library-authoring/generic/history-widget/messages.ts @@ -1,6 +1,11 @@ import { defineMessages } from '@edx/frontend-platform/i18n'; const messages = defineMessages({ + lastPublishedTitle: { + id: 'course-authoring.library-authoring.generic.history-widget.last-published', + defaultMessage: 'Last Published', + description: 'Title of the last published section in the library authoring sidebar.', + }, lastModifiedTitle: { id: 'course-authoring.library-authoring.generic.history-widget.last-modified', defaultMessage: 'Last Modified',