Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add last published date to HistoryWidget #1585

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/library-authoring/collections/CollectionDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,7 @@ const CollectionDetails = () => {
{intl.formatMessage(messages.detailsTabHistoryTitle)}
</h3>
<HistoryWidget
created={collection.created ? new Date(collection.created) : null}
modified={collection.modified ? new Date(collection.modified) : null}
{...collection}
/>
</div>
</Stack>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,12 @@ describe('<ComponentDetails />', () => {
});

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();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ describe('<ComponentManagement />', () => {
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();
});

Expand Down
2 changes: 1 addition & 1 deletion src/library-authoring/data/api.mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
8 changes: 8 additions & 0 deletions src/library-authoring/generic/history-widget/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const CustomFormattedDate = ({ date }: { date: string | Date }) => (
type HistoryWidgedProps = {
modified: string | Date | null;
created: string | Date | null;
lastPublished?: string | Date | null;
};

/**
Expand All @@ -32,8 +33,15 @@ type HistoryWidgedProps = {
const HistoryWidget = ({
modified,
created,
lastPublished,
}: HistoryWidgedProps) => (
<Stack className="history-widget-bar small" gap={3}>
{lastPublished && (
<div>
<div className="text-muted"><FormattedMessage {...messages.lastPublishedTitle} /> </div>
<CustomFormattedDate date={lastPublished} />
</div>
)}
{modified && (
<div>
<div className="text-muted"><FormattedMessage {...messages.lastModifiedTitle} /> </div>
Expand Down
5 changes: 5 additions & 0 deletions src/library-authoring/generic/history-widget/messages.ts
Original file line number Diff line number Diff line change
@@ -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',
Expand Down
Loading