-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: [DHIS2-16992] Fixed size for changelog modal and columns (#3834)
* feat: temp * feat: fixed size table and columns * fix: remove console log * fix: fixed size improvement
- Loading branch information
Showing
8 changed files
with
118 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
...e/components/WidgetsChangelog/common/ChangelogTable/ChangelogCells/ChangelogChangeCell.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// @flow | ||
import React from 'react'; | ||
import log from 'loglevel'; | ||
import { Tag } from '@dhis2/ui'; | ||
import i18n from '@dhis2/d2-i18n'; | ||
import { CHANGE_TYPES } from '../../Changelog/Changelog.constants'; | ||
import { errorCreator } from '../../../../../../capture-core-utils'; | ||
|
||
type Config = { | ||
label: string, | ||
variant: { | ||
neutral?: boolean, | ||
positive?: boolean, | ||
negative?: boolean, | ||
}, | ||
}; | ||
|
||
const changeTypeConfigs = { | ||
[CHANGE_TYPES.UPDATED]: { label: i18n.t('Updated'), variant: { neutral: true } }, | ||
[CHANGE_TYPES.CREATED]: { label: i18n.t('Created'), variant: { positive: true } }, | ||
[CHANGE_TYPES.DELETED]: { label: i18n.t('Deleted'), variant: { negative: true } }, | ||
}; | ||
|
||
const ChangelogChangeComponent = ({ label, variant }: Config) => ( | ||
<Tag {...variant}> | ||
{label} | ||
</Tag> | ||
); | ||
|
||
|
||
export const ChangelogChangeCell = ({ changeType }: Object) => { | ||
const config = changeTypeConfigs[changeType]; | ||
|
||
if (!config) { | ||
log.error(errorCreator('Changelog component not found')({ changeType })); | ||
return null; | ||
} | ||
|
||
return ( | ||
<ChangelogChangeComponent {...config} /> | ||
); | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
...es/capture-core/components/WidgetsChangelog/common/ChangelogTable/ChangelogCells/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// @flow | ||
|
||
export { ChangelogChangeCell } from './ChangelogChangeCell'; | ||
export { ChangelogValueCell } from './ChangelogValueCell'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 27 additions & 21 deletions
48
...dules/capture-core/components/WidgetsChangelog/common/ChangelogTable/ChangelogTableRow.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,35 @@ | ||
// @flow | ||
import React from 'react'; | ||
import { DataTableCell, DataTableRow } from '@dhis2/ui'; | ||
import { ChangelogChangeCell } from './ChangelogChangeCell'; | ||
import type { ChangelogRecord } from '../Changelog/Changelog.types'; | ||
import { withStyles } from '@material-ui/core/styles'; | ||
import { ChangelogChangeCell, ChangelogValueCell } from './ChangelogCells'; | ||
|
||
type Props = {| | ||
record: ChangelogRecord, | ||
|} | ||
type Props = { | ||
record: { | ||
date: string, | ||
user: string, | ||
dataItemLabel: string, | ||
changeType: string, | ||
}, | ||
classes: { | ||
dataItemColumn: string, | ||
valueColumn: string, | ||
}, | ||
}; | ||
|
||
export const ChangelogTableRow = ({ record }: Props) => ( | ||
<DataTableRow> | ||
<DataTableCell> | ||
{record.date} | ||
</DataTableCell> | ||
<DataTableCell> | ||
{record.user} | ||
</DataTableCell> | ||
<DataTableCell> | ||
{record.dataItemLabel} | ||
</DataTableCell> | ||
const styles = { | ||
dataItemColumn: { wordWrap: 'break-word', hyphens: 'auto' }, | ||
valueColumn: { wordWrap: 'break-word' }, | ||
}; | ||
|
||
<DataTableCell> | ||
<ChangelogChangeCell | ||
{...record} | ||
/> | ||
</DataTableCell> | ||
const ChangelogTableRowPlain = ({ record, classes }: Props) => ( | ||
<DataTableRow> | ||
<DataTableCell>{record.date}</DataTableCell> | ||
<DataTableCell>{record.user}</DataTableCell> | ||
<DataTableCell className={classes.dataItemColumn}>{record.dataItemLabel}</DataTableCell> | ||
<DataTableCell><ChangelogChangeCell changeType={record.changeType} /></DataTableCell> | ||
<DataTableCell className={classes.valueColumn}><ChangelogValueCell {...record} /></DataTableCell> | ||
</DataTableRow> | ||
); | ||
|
||
export const ChangelogTableRow = withStyles(styles)(ChangelogTableRowPlain); |
1 change: 0 additions & 1 deletion
1
src/core_modules/capture-core/components/WidgetsChangelog/common/ChangelogTable/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
// @flow | ||
|
||
export { ChangelogTableHeader } from './ChangelogTableHeader'; | ||
export { ChangelogChangeCell } from './ChangelogChangeCell'; | ||
export { ChangelogTableRow } from './ChangelogTableRow'; | ||
|