Skip to content

Commit 5f84b9b

Browse files
committed
refactor: Use new contributor field
1 parent 1773c33 commit 5f84b9b

5 files changed

Lines changed: 19 additions & 19 deletions

File tree

src/library-authoring/data/api.mocks.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1267,14 +1267,14 @@ const mockContributor = (username: string): api.LibraryPublishContributor => ({
12671267

12681268
mockLibraryBlockDraftHistory.data = [
12691269
{
1270-
changedBy: mockContributor('test_user_1'),
1270+
contributor: mockContributor('test_user_1'),
12711271
changedAt: '2026-03-16T11:00:00Z',
12721272
title: 'Electron Arcs',
12731273
action: 'edited',
12741274
itemType: 'html',
12751275
},
12761276
{
1277-
changedBy: mockContributor('test_user_2'),
1277+
contributor: mockContributor('test_user_2'),
12781278
changedAt: '2026-03-13T10:00:00Z',
12791279
title: 'More on Quarks',
12801280
action: 'renamed',
@@ -1330,7 +1330,7 @@ export async function mockLibraryBlockPublishHistoryEntries(
13301330
}
13311331
mockLibraryBlockPublishHistoryEntries.data = [
13321332
{
1333-
changedBy: mockContributor('test_user'),
1333+
contributor: mockContributor('test_user'),
13341334
changedAt: '2026-03-10T09:00:00Z',
13351335
title: 'Protons',
13361336
action: 'edited',
@@ -1365,14 +1365,14 @@ mockLibraryBlockCreationEntry.usageKeyThatNeverLoads = 'lb:Axim:infiniteLoading:
13651365
mockLibraryBlockCreationEntry.usageKey = 'lb:Axim:TEST1:html:571fe018-f3ce-45c9-8f53-5dafcb422fd1';
13661366
mockLibraryBlockCreationEntry.usageKeyEmpty = 'lb:Axim:TEST2:html:571fe018-f3ce-45c9-8f53-5dafcb422fd2';
13671367
mockLibraryBlockCreationEntry.data = {
1368-
changedBy: mockContributor('author'),
1368+
contributor: mockContributor('author'),
13691369
changedAt: '2024-01-01T00:00:00Z',
13701370
title: 'Introduction to Testing 1',
13711371
itemType: 'html',
13721372
action: 'created',
13731373
} satisfies api.LibraryHistoryEntry;
13741374
mockLibraryBlockCreationEntry.dataEmpty = {
1375-
changedBy: mockContributor('Author'),
1375+
contributor: mockContributor('Author'),
13761376
changedAt: '2024-01-01T00:00:00Z',
13771377
title: 'Introduction to Testing 2',
13781378
itemType: 'html',
@@ -1404,14 +1404,14 @@ mockLibraryContainerDraftHistory.containerKey = 'lct:Axim:TEST1:unit:571fe018-f3
14041404
mockLibraryContainerDraftHistory.containerKeyEmpty = 'lct:Axim:TEST2:unit:571fe018-f3ce-45c9-8f53-5dafcb422fd2';
14051405
mockLibraryContainerDraftHistory.data = [
14061406
{
1407-
changedBy: mockContributor('container_user_1'),
1407+
contributor: mockContributor('container_user_1'),
14081408
changedAt: '2026-03-16T11:00:00Z',
14091409
title: 'Intro Unit',
14101410
action: 'edited',
14111411
itemType: 'unit',
14121412
},
14131413
{
1414-
changedBy: mockContributor('container_user_2'),
1414+
contributor: mockContributor('container_user_2'),
14151415
changedAt: '2026-03-13T10:00:00Z',
14161416
title: 'Unit Renamed',
14171417
action: 'renamed',
@@ -1485,14 +1485,14 @@ mockLibraryContainerCreationEntry.usageKeyThatNeverLoads = 'lct:Axim:TEST1:unit:
14851485
mockLibraryContainerCreationEntry.usageKey = 'lct:Axim:TEST1:unit:571fe018-f3ce-45c9-8f53-5dafcb422fd1';
14861486
mockLibraryContainerCreationEntry.usageKeyEmpty = 'lct:Axim:TEST2:unit:571fe018-f3ce-45c9-8f53-5dafcb422fd2';
14871487
mockLibraryContainerCreationEntry.data = {
1488-
changedBy: mockContributor('author'),
1488+
contributor: mockContributor('author'),
14891489
changedAt: '2024-01-01T00:00:00Z',
14901490
title: 'Introduction to Testing Unit 1',
14911491
itemType: 'unit',
14921492
action: 'created',
14931493
} satisfies api.LibraryHistoryEntry;
14941494
mockLibraryContainerCreationEntry.dataEmpty = {
1495-
changedBy: mockContributor('Author'),
1495+
contributor: mockContributor('Author'),
14961496
changedAt: '2024-01-01T00:00:00Z',
14971497
title: 'Introduction to Testing Unit 2',
14981498
itemType: 'unit',

src/library-authoring/data/api.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1009,7 +1009,7 @@ export interface LibraryPublishContributor {
10091009
}
10101010

10111011
export interface LibraryHistoryEntry {
1012-
changedBy: LibraryPublishContributor;
1012+
contributor: LibraryPublishContributor;
10131013
changedAt: string;
10141014
title: string;
10151015
itemType: string;

src/library-authoring/generic/history-log/HistoryLog.test.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,12 +104,12 @@ describe('<HistoryComponentLog />', () => {
104104
expect(await findByDeepTextContent(/Author created.*Introduction to Testing 1/i)).toBeInTheDocument();
105105
});
106106

107-
it('shows fallback "Author" for draft entry when changedBy has no username', async () => {
107+
it('shows fallback "Author" for draft entry when contributor has no username', async () => {
108108
const user = userEvent.setup();
109109
const originalData = mockLibraryBlockDraftHistory.data;
110110
mockLibraryBlockDraftHistory.data = [
111111
{
112-
changedBy: mockContributorNoUsername(),
112+
contributor: mockContributorNoUsername(),
113113
changedAt: '2026-03-16T11:00:00Z',
114114
title: 'Anonymous Component',
115115
itemType: 'html',
@@ -141,7 +141,7 @@ describe('<HistoryComponentLog />', () => {
141141
const originalData = mockLibraryBlockDraftHistory.data;
142142
mockLibraryBlockDraftHistory.data = [
143143
{
144-
changedBy: {
144+
contributor: {
145145
username: 'creator_user',
146146
profileImageUrls: {
147147
full: 'icon/mock/path',
@@ -224,7 +224,7 @@ describe('<HistoryContainerLog />', () => {
224224
const originalData = mockLibraryContainerDraftHistory.data;
225225
mockLibraryContainerDraftHistory.data = [
226226
{
227-
changedBy: {
227+
contributor: {
228228
username: 'creator_user',
229229
profileImageUrls: {
230230
full: 'icon/mock/path',

src/library-authoring/generic/history-log/HistoryLog.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export const HistoryComponentLog = ({ componentId }: { componentId: string; }) =
5656
)}
5757
{creationEntry && (
5858
<HistoryCreatedLogGroup
59-
user={creationEntry.changedBy?.username}
59+
user={creationEntry.contributor?.username}
6060
displayName={creationEntry.title}
6161
itemType={creationEntry.itemType}
6262
createdAt={creationEntry.changedAt}
@@ -111,7 +111,7 @@ export const HistoryContainerLog = ({ containerId }: { containerId: string; }) =
111111
)}
112112
{creationEntry && (
113113
<HistoryCreatedLogGroup
114-
user={creationEntry.changedBy?.username}
114+
user={creationEntry.contributor?.username}
115115
displayName={creationEntry.title}
116116
itemType={creationEntry.itemType}
117117
createdAt={creationEntry.changedAt}

src/library-authoring/generic/history-log/HistoryLogGroup.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,8 @@ const HistoryLogGroupEntries = ({
128128
<div key={entry.changedAt}>
129129
<Stack direction="horizontal" gap={2} className="ml-1.5">
130130
<ContributorAvatar
131-
username={entry.changedBy?.username || intl.formatMessage(messages.historyEntryDefaultUser)}
132-
src={entry.changedBy.profileImageUrls.medium}
131+
username={entry.contributor?.username || intl.formatMessage(messages.historyEntryDefaultUser)}
132+
src={entry.contributor.profileImageUrls.medium}
133133
className="history-log-group-avatar small-avatar"
134134
size="sm"
135135
/>
@@ -138,7 +138,7 @@ const HistoryLogGroupEntries = ({
138138
<FormattedMessage
139139
{...entryMessage}
140140
values={{
141-
user: entry.changedBy.username ?? intl.formatMessage(messages.historyEntryDefaultUser),
141+
user: entry.contributor.username ?? intl.formatMessage(messages.historyEntryDefaultUser),
142142
displayName: <span className="history-log-title text-truncate">{entry.title}</span>,
143143
icon: <Icon src={getItemIcon(entry.itemType)} />,
144144
}}

0 commit comments

Comments
 (0)