Repository navigation
fix: type the audit-log renderers (CM-1528) #4903
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
Changes from all commits
8e745ed
792edbe
04ba041
11631e8
390591f
09093c4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,15 @@ | ||
| import type { LogRenderingConfig } from '@/modules/lf/config/audit-logs/log-rendering/index'; | ||
| import type { LogChanges, LogRenderingConfig } from '@/modules/lf/config/audit-logs/log-rendering/index'; | ||
| import { OrganizationService } from '@/modules/organization/organization-service'; | ||
| import { dateHelper } from '@/shared/date-helper/date-helper'; | ||
|
|
||
| const formatDateRange = (dateStart, dateEnd) => { | ||
| interface MemberOrganizationStateRow { | ||
| organizationId: string; | ||
| title?: string | null; | ||
| dateStart: string | null; | ||
| dateEnd: string | null; | ||
| } | ||
|
|
||
| const formatDateRange = (dateStart: string | null, dateEnd: string | null) => { | ||
| // eslint-disable-next-line no-nested-ternary | ||
| const dateStartFormat = dateStart | ||
| ? dateHelper(dateStart) | ||
|
|
@@ -18,10 +25,10 @@ const formatDateRange = (dateStart, dateEnd) => { | |
| return `${dateStartFormat} -> ${dateEndFormat}`; | ||
| }; | ||
|
|
||
| const membersEditOrganizations: LogRenderingConfig = { | ||
| const membersEditOrganizations: LogRenderingConfig<MemberOrganizationStateRow[]> = { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This PR only adds types here; the renderer logic is unchanged from main, so the behaviour you describe exists today and is out of scope for CM-1528. Noted for a separate look at the producer/renderer contract. |
||
| label: 'Profile work experience updated', | ||
| changes: async (log) => { | ||
| const changes = { | ||
| const changes: LogChanges = { | ||
| removals: [], | ||
| additions: [], | ||
| changes: [], | ||
|
|
@@ -41,8 +48,8 @@ const membersEditOrganizations: LogRenderingConfig = { | |
| ]), | ||
| ]; | ||
|
|
||
| const orgs = await OrganizationService.listByIds(orgIds); | ||
| const orgById = orgs.reduce((obj, org) => ({ | ||
| const orgs: { id: string; displayName: string }[] = await OrganizationService.listByIds(orgIds); | ||
| const orgById = orgs.reduce<Record<string, string>>((obj, org) => ({ | ||
| ...obj, | ||
| [org.id]: org.displayName, | ||
| }), {}); | ||
|
|
@@ -52,7 +59,7 @@ const membersEditOrganizations: LogRenderingConfig = { | |
| if (!newStateMap.has(org.organizationId)) { | ||
| changes.removals.push(`<span>Organization:</span> ${org.organizationId ? (orgById[org.organizationId]) : 'Individual'}`); | ||
| } else { | ||
| const newOrg = newStateMap.get(org.organizationId); | ||
| const newOrg = newStateMap.get(org.organizationId)!; | ||
| if ( | ||
| formatDateRange(org.dateStart, org.dateEnd) !== formatDateRange(newOrg.dateStart, newOrg.dateEnd) | ||
| || (org.title || '') !== (newOrg.title || '')) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,9 @@ | ||
| import type { LogRenderingConfig } from '@/modules/lf/config/audit-logs/log-rendering/index'; | ||
| import { lfIdentities } from '@/config/identities'; | ||
|
|
||
| const organizationsEditIdentities: LogRenderingConfig = { | ||
| type OrganizationIdentitiesState = Record<string, { value: string; type: string; verified: boolean }[]>; | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This PR only adds types here; the renderer logic is unchanged from main, so the behaviour you describe exists today and is out of scope for CM-1528. Noted for a separate look at the producer/renderer contract. |
||
|
|
||
| const organizationsEditIdentities: LogRenderingConfig<OrganizationIdentitiesState> = { | ||
| label: 'Organization identities updated', | ||
| changes: ({ oldState, newState }) => { | ||
| const additions: any[] = []; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| { "errors": 534 } | ||
| { "errors": 488 } | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Description corrected to 534 -> 488. |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR only adds types here; the renderer logic is unchanged from main, so the behaviour you describe exists today and is out of scope for CM-1528. Noted for a separate look at the producer/renderer contract.