Skip to content

Commit 7427528

Browse files
authored
fix: clean up frontend audit presentation [DHIS2-20126] (#487)
1 parent 85f14d9 commit 7427528

6 files changed

Lines changed: 31 additions & 170 deletions

File tree

‎i18n/en.pot‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ msgstr ""
55
"Content-Type: text/plain; charset=utf-8\n"
66
"Content-Transfer-Encoding: 8bit\n"
77
"Plural-Forms: nplurals=2; plural=(n != 1)\n"
8-
"POT-Creation-Date: 2025-07-04T13:29:52.415Z\n"
9-
"PO-Revision-Date: 2025-07-04T13:29:52.415Z\n"
8+
"POT-Creation-Date: 2025-09-16T12:04:32.693Z\n"
9+
"PO-Revision-Date: 2025-09-16T12:04:32.694Z\n"
1010

1111
msgid "Not authorized"
1212
msgstr "Not authorized"
@@ -357,6 +357,9 @@ msgstr "Change"
357357
msgid "audit dates are given in {{- timeZone}} time"
358358
msgstr "audit dates are given in {{- timeZone}} time"
359359

360+
msgid "log displays only changes made while audit was enabled"
361+
msgstr "log displays only changes made while audit was enabled"
362+
360363
msgid "Unmark for follow-up"
361364
msgstr "Unmark for follow-up"
362365

‎src/data-workspace/data-details-sidebar/audit-log.jsx‎

Lines changed: 19 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ export default function AuditLog({ item }) {
103103
{audits.map((audit) => {
104104
const {
105105
modifiedBy: user,
106-
previousValue: nonParsedPreviousValue,
107106
value: nonParsedValue,
108107
created,
109108
auditType,
@@ -122,15 +121,6 @@ export default function AuditLog({ item }) {
122121
calendar
123122
)
124123
: nonParsedValue
125-
const previousValue = [
126-
VALUE_TYPES.DATETIME,
127-
VALUE_TYPES.DATE,
128-
].includes(item.valueType)
129-
? convertFromIso8601ToString(
130-
nonParsedPreviousValue,
131-
calendar
132-
)
133-
: nonParsedPreviousValue
134124

135125
const key = `${de}-${pe}-${ou}-${coc}-${created}`
136126

@@ -152,14 +142,7 @@ export default function AuditLog({ item }) {
152142
)}
153143
{['UPDATE', 'CREATE'].includes(
154144
auditType
155-
) && (
156-
<UpdatedValue
157-
value={value}
158-
previousValue={
159-
previousValue
160-
}
161-
/>
162-
)}
145+
) && <UpdatedValue value={value} />}
163146
</div>
164147
</DataTableCell>
165148
</DataTableRow>
@@ -168,11 +151,18 @@ export default function AuditLog({ item }) {
168151
</TableBody>
169152
</DataTable>
170153
{audits.length > 0 && (
171-
<div className={styles.timeZoneNote}>
172-
{i18n.t(
173-
'audit dates are given in {{- timeZone}} time',
174-
{ timeZone }
175-
)}
154+
<div>
155+
<div className={styles.timeZoneNote}>
156+
{i18n.t(
157+
'audit dates are given in {{- timeZone}} time',
158+
{ timeZone }
159+
)}
160+
</div>
161+
<div className={styles.timeZoneNote}>
162+
{i18n.t(
163+
'log displays only changes made while audit was enabled'
164+
)}
165+
</div>
176166
</div>
177167
)}
178168
</div>
@@ -191,21 +181,21 @@ AuditLog.propTypes = {
191181

192182
function DeletedValue({ value }) {
193183
return (
194-
<Tag negative className={styles.lineThrough}>
195-
{value}
196-
</Tag>
184+
<div className={styles.alignToEnd}>
185+
<Tag negative className={styles.lineThrough}>
186+
{value}
187+
</Tag>
188+
</div>
197189
)
198190
}
199191

200192
DeletedValue.propTypes = {
201193
value: PropTypes.string.isRequired,
202194
}
203195

204-
function UpdatedValue({ value, previousValue }) {
196+
function UpdatedValue({ value }) {
205197
return (
206198
<div className={styles.alignToEnd}>
207-
{previousValue && <Tag>{previousValue}</Tag>}
208-
{/* arrow-right*/}
209199
{i18n.dir() === 'rtl' ? (
210200
<span className={styles.rightArrow}>&larr;</span>
211201
) : (
@@ -219,5 +209,4 @@ function UpdatedValue({ value, previousValue }) {
219209

220210
UpdatedValue.propTypes = {
221211
value: PropTypes.string.isRequired,
222-
previousValue: PropTypes.string,
223212
}

‎src/data-workspace/data-details-sidebar/audit-log.test.jsx‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ describe('<AuditLog />', () => {
8888
auditType: 'UPDATE',
8989
created: new Date('2021-02-01').toISOString(),
9090
modifiedBy: 'Firstname2 Lastname2',
91-
previousValue: '19',
9291
value: '21',
9392
},
9493
{
@@ -135,6 +134,7 @@ describe('<AuditLog />', () => {
135134
expect(secondChangeName).toBeInTheDocument()
136135
const secondChangeValue = within(auditRows[2]).getByText('21', {})
137136
expect(secondChangeValue).toBeInTheDocument()
137+
expect(auditRows[2].textContent).toContain('→21')
138138

139139
const thirdChangeName = within(auditRows[3]).getByText(
140140
'Firstname3 Lastname3',
@@ -143,11 +143,17 @@ describe('<AuditLog />', () => {
143143
expect(thirdChangeName).toBeInTheDocument()
144144
const thirdChangeValue = within(auditRows[3]).getByText('19', {})
145145
expect(thirdChangeValue).toBeInTheDocument()
146+
expect(auditRows[3].textContent).toContain('→19')
146147

147148
// check that note about time zone appears
148149
expect(
149150
getByText('audit dates are given in UTC time')
150151
).toBeInTheDocument()
152+
153+
// check that warning about limited audit history appears
154+
expect(
155+
getByText('log displays only changes made while audit was enabled')
156+
).toBeInTheDocument()
151157
})
152158

153159
it('renders the date/datetime values in system calendar (ethiopian)', async () => {
@@ -167,7 +173,6 @@ describe('<AuditLog />', () => {
167173
auditType: 'UPDATE',
168174
created: new Date('2021-02-01').toISOString(),
169175
modifiedBy: 'Firstname2 Lastname2',
170-
previousValue: '2021-09-10',
171176
value: '2021-09-11',
172177
},
173178
]
@@ -241,7 +246,6 @@ describe('<AuditLog />', () => {
241246
auditType: 'UPDATE',
242247
created: new Date('2021-02-01').toISOString(),
243248
modifiedBy: 'Firstname2 Lastname2',
244-
previousValue: '2021-09-10',
245249
value: '2021-09-11',
246250
},
247251
]

‎src/data-workspace/data-details-sidebar/process-audits.js‎

Lines changed: 0 additions & 23 deletions
This file was deleted.

‎src/data-workspace/data-details-sidebar/process-audits.test.js‎

Lines changed: 0 additions & 102 deletions
This file was deleted.

‎src/data-workspace/data-details-sidebar/use-data-value-context.js‎

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import {
77
usePeriodId,
88
} from '../../shared/index.js'
99
import * as queryKeyFactory from '../query-key-factory.js'
10-
import processAudits from './process-audits.js'
1110

1211
/**
1312
* @returns PropTypes.shape({
@@ -17,7 +16,6 @@ import processAudits from './process-audits.js'
1716
* auditType: PropTypes.oneOf(['UPDATE', 'DELETE']).isRequired,
1817
* created: PropTypes.string,
1918
* modifiedBy: PropTypes.string,
20-
* prevValue: PropTypes.string,
2119
* value: PropTypes.string,
2220
* })
2321
* ),
@@ -56,13 +54,5 @@ export default function useDataValueContext(item, enabled) {
5654

5755
return useQuery(dataValueContextQueryKey, {
5856
enabled: enabled && online && isValidSelection,
59-
select: (data) => {
60-
const { audits } = data
61-
62-
return {
63-
...data,
64-
audits: processAudits(audits, item),
65-
}
66-
},
6757
})
6858
}

0 commit comments

Comments
 (0)