Skip to content

Commit bcd3552

Browse files
committed
feat: replace postinstall script with patch-package and remove patchGlobal.js
1 parent a8ee049 commit bcd3552

File tree

4 files changed

+304
-226
lines changed

4 files changed

+304
-226
lines changed

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,21 @@
1616
"format:text": "d2-style apply text",
1717
"format:staged": "yarn format:js --staged && yarn format:text --staged",
1818
"format": "yarn format:js && yarn format:text",
19-
"postinstall": "node patchGlobal.js"
19+
"postinstall": "patch-package"
2020
},
2121
"devDependencies": {
2222
"@dhis2/cli-app-scripts": "^12.3.0",
2323
"@dhis2/cli-style": "^10.7.6"
2424
},
2525
"dependencies": {
26+
"patch-package": "^8.0.0",
27+
"postinstall-postinstall": "^2.1.0",
2628
"@dhis2/app-runtime": "^3.13.1",
2729
"@dhis2/app-runtime-adapter-d2": "^1.0.2",
2830
"@dhis2/d2-i18n": "^1.1.0",
2931
"@dhis2/ui": "^10.1.11",
3032
"d2": "^31.9.0",
3133
"d2-ui": "^29.0.35",
32-
"fixed-data-table": "0.6.5",
3334
"history": "4.7.2",
3435
"loglevel": "^1.9.2",
3536
"material-design-icons-iconfont": "^6.1.0",

patchGlobal.js

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

src/metadata-settings/metadataSettings.component.jsx

Lines changed: 141 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,13 @@ import i18n from '@dhis2/d2-i18n'
22
import { Button } from '@dhis2/ui'
33
import { getInstance as getD2 } from 'd2'
44
import FormBuilder from 'd2-ui/lib/forms/FormBuilder.component.js'
5-
import { Table, Column, Cell } from 'fixed-data-table'
65
import CircularProgress from 'material-ui/CircularProgress'
76
import { RadioButtonGroup, RadioButton } from 'material-ui/RadioButton'
87
import PropTypes from 'prop-types'
98
import React, { Component } from 'react'
109
import Checkbox from '../form-fields/check-box.jsx'
1110
import settingsActions from '../settingsActions.js'
1211
import settingsStore from '../settingsStore.js'
13-
import 'fixed-data-table/dist/fixed-data-table.css'
1412

1513
class MetadataSettings extends Component {
1614
constructor(props, context) {
@@ -185,17 +183,39 @@ class MetadataSettings extends Component {
185183
top: '-7px',
186184
float: 'left',
187185
},
186+
tableContainerVisible: { display: 'block' },
187+
tableContainerHidden: { display: 'none' },
188+
table: {
189+
width: '670px',
190+
borderCollapse: 'collapse',
191+
marginTop: '10px',
192+
fontFamily: 'Arial, sans-serif',
193+
textAlign: 'left',
194+
},
195+
theadRow: { backgroundColor: '#f4f4f4' },
196+
th: {
197+
border: '1px solid #ddd',
198+
padding: '12px',
199+
fontWeight: 'bold',
200+
},
201+
thVersion: { width: '135px' },
202+
thWhen: { width: '205px' },
203+
thType: { width: '145px' },
204+
thLastSync: { width: '185px' },
205+
tbodyRowEven: { height: '50px', backgroundColor: '#fff' },
206+
tbodyRowOdd: { height: '50px', backgroundColor: '#f9f9f9' },
207+
td: { border: '1px solid #ddd', padding: '10px' },
188208
}
189209

190-
const fieldGetter =
191-
(field, filter = (x) => x) =>
192-
// eslint-disable-next-line react/display-name, react/prop-types
193-
({ rowIndex, ...props }) =>
194-
(
195-
<Cell {...props}>
196-
{filter(this.state.metadataVersions[rowIndex][field])}
197-
</Cell>
198-
)
210+
// const fieldGetter =
211+
// (field, filter = (x) => x) =>
212+
// // eslint-disable-next-line react/display-name, react/prop-types
213+
// ({ rowIndex, ...props }) =>
214+
// (
215+
// <Cell {...props}>
216+
// {filter(this.state.metadataVersions[rowIndex][field])}
217+
// </Cell>
218+
// )
199219

200220
const dateFmt = (str) => new Date(str).toLocaleString()
201221

@@ -298,34 +318,61 @@ class MetadataSettings extends Component {
298318
: styles.hidden
299319
}
300320
>
301-
<Table
302-
rowHeight={50}
303-
rowsCount={this.state.metadataVersions.length}
304-
width={670}
305-
maxHeight={50 * 6}
306-
headerHeight={50}
307-
>
308-
<Column
309-
header={<Cell>Version</Cell>}
310-
cell={fieldGetter('name')}
311-
width={135}
312-
/>
313-
<Column
314-
header={<Cell>When</Cell>}
315-
cell={fieldGetter('created', dateFmt)}
316-
width={205}
317-
/>
318-
<Column
319-
header={<Cell>Type</Cell>}
320-
cell={fieldGetter('type')}
321-
width={145}
322-
/>
323-
<Column
324-
header={<Cell>Last Sync</Cell>}
325-
cell={fieldGetter('importdate')}
326-
width={185}
327-
/>
328-
</Table>
321+
<table style={styles.table}>
322+
<thead>
323+
<tr style={styles.theadRow}>
324+
<th
325+
style={{
326+
...styles.th,
327+
...styles.thVersion,
328+
}}
329+
>
330+
Version
331+
</th>
332+
<th style={{ ...styles.th, ...styles.thWhen }}>
333+
When
334+
</th>
335+
<th style={{ ...styles.th, ...styles.thType }}>
336+
Type
337+
</th>
338+
<th
339+
style={{
340+
...styles.th,
341+
...styles.thLastSync,
342+
}}
343+
>
344+
Last Sync
345+
</th>
346+
</tr>
347+
</thead>
348+
<tbody>
349+
{this.state.metadataVersions.map(
350+
(version, index) => (
351+
<tr
352+
key={index}
353+
style={
354+
index % 2 === 0
355+
? styles.tbodyRowEven
356+
: styles.tbodyRowOdd
357+
}
358+
>
359+
<td style={styles.td}>
360+
{version.name}
361+
</td>
362+
<td style={styles.td}>
363+
{dateFmt(version.created)}
364+
</td>
365+
<td style={styles.td}>
366+
{version.type}
367+
</td>
368+
<td style={styles.td}>
369+
{version.importdate}
370+
</td>
371+
</tr>
372+
)
373+
)}
374+
</tbody>
375+
</table>
329376
</div>
330377

331378
<div
@@ -335,29 +382,61 @@ class MetadataSettings extends Component {
335382
: styles.visible
336383
}
337384
>
338-
<Table
339-
rowHeight={50}
340-
rowsCount={this.state.metadataVersions.length}
341-
width={670}
342-
maxHeight={50 * 6}
343-
headerHeight={50}
344-
>
345-
<Column
346-
header={<Cell>Version</Cell>}
347-
cell={fieldGetter('name')}
348-
width={190}
349-
/>
350-
<Column
351-
header={<Cell>When</Cell>}
352-
cell={fieldGetter('created')}
353-
width={280}
354-
/>
355-
<Column
356-
header={<Cell>Type</Cell>}
357-
cell={fieldGetter('type')}
358-
width={200}
359-
/>
360-
</Table>
385+
<table style={styles.table}>
386+
<thead>
387+
<tr style={styles.theadRow}>
388+
<th
389+
style={{
390+
...styles.th,
391+
...styles.thVersion,
392+
}}
393+
>
394+
Version
395+
</th>
396+
<th style={{ ...styles.th, ...styles.thWhen }}>
397+
When
398+
</th>
399+
<th style={{ ...styles.th, ...styles.thType }}>
400+
Type
401+
</th>
402+
<th
403+
style={{
404+
...styles.th,
405+
...styles.thLastSync,
406+
}}
407+
>
408+
Last Sync
409+
</th>
410+
</tr>
411+
</thead>
412+
<tbody>
413+
{this.state.metadataVersions.map(
414+
(version, index) => (
415+
<tr
416+
key={index}
417+
style={
418+
index % 2 === 0
419+
? styles.tbodyRowEven
420+
: styles.tbodyRowOdd
421+
}
422+
>
423+
<td style={styles.td}>
424+
{version.name}
425+
</td>
426+
<td style={styles.td}>
427+
{dateFmt(version.created)}
428+
</td>
429+
<td style={styles.td}>
430+
{version.type}
431+
</td>
432+
<td style={styles.td}>
433+
{version.importdate}
434+
</td>
435+
</tr>
436+
)
437+
)}
438+
</tbody>
439+
</table>
361440
</div>
362441

363442
<div

0 commit comments

Comments
 (0)