Skip to content

Commit

Permalink
fix: revert new folder structure
Browse files Browse the repository at this point in the history
  • Loading branch information
henrikmv committed Nov 28, 2024
1 parent 2cc1be8 commit 91c1890
Show file tree
Hide file tree
Showing 9 changed files with 91 additions and 255 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ 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';
import { CHANGE_TYPES } from '../../Changelog/Changelog.constants';
import { errorCreator } from '../../../../../../capture-core-utils';

type Config = {
label: string,
Expand Down Expand Up @@ -40,4 +40,3 @@ export const ChangelogChangeCell = ({ changeType }: Object) => {
<ChangelogChangeComponent {...config} />
);
};

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
// @flow
import React from 'react';
import log from 'loglevel';
import { colors, IconArrowRight16, spacers } from '@dhis2/ui';
import { withStyles } from '@material-ui/core/styles';
import { CHANGE_TYPES } from '../../Changelog/Changelog.constants';
import { errorCreator } from '../../../../../../capture-core-utils';

type Props = {
changeType: $Values<typeof CHANGE_TYPES>,
previousValue?: string,
currentValue?: string,
classes: {
container: string,
previousValue: string,
currentValue: string,
arrow: string,
}
}

const styles = {
container: {
display: 'flex',
flexDirection: 'row',
alignItems: 'center',
height: '100%',
},
buttonContainer: {
display: 'flex',
justifyContent: 'center',
},
previousValue: {
color: colors.grey700,
wordBreak: 'break-word',
},
currentValue: {
color: colors.grey900,
wordBreak: 'break-word',
maxWidth: '82%',
},
updateArrow: {
margin: spacers.dp4,
},
};

const Updated = ({ previousValue, currentValue, classes }) => (
<div className={classes.container}>
<div className={classes.previousValue}>{previousValue}</div>
<div className={classes.arrow}><IconArrowRight16 /></div>
<div className={classes.currentValue}>{currentValue}</div>
</div>
);

const Created = ({ currentValue, classes }) => (
<div className={classes.container}>
<span className={classes.currentValue}>{currentValue}</span>
</div>
);

const Deleted = ({ previousValue, classes }) => (
<div className={classes.container}>
<span className={classes.previousValue}>{previousValue}</span>
</div>
);

const ChangelogComponentsByType = {
[CHANGE_TYPES.UPDATED]: Updated,
[CHANGE_TYPES.CREATED]: Created,
[CHANGE_TYPES.DELETED]: Deleted,
};

const ChangelogValueCellPlain = ({ changeType, currentValue, previousValue, classes }: Props) => {
const ChangelogComponent = ChangelogComponentsByType[changeType];

if (!ChangelogComponent) {
log.error(errorCreator('Changelog component not found')({ changeType }));
return null;
}

return (
<ChangelogComponent
classes={classes}
previousValue={previousValue}
currentValue={currentValue}
/>
);
};

export const ChangelogValueCell = withStyles(styles)(ChangelogValueCellPlain);

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

0 comments on commit 91c1890

Please sign in to comment.