#38: Enhance new repertory release available notification - partial

This commit is contained in:
2020-02-21 12:33:01 -06:00
parent 0eb40e5a65
commit a70359d36b
2 changed files with 72 additions and 5 deletions

View File

@@ -1,17 +1,40 @@
import React from 'react';
import {connect} from 'react-redux';
import * as Constants from '../../../constants';
import Button from '../../UI/Button/Button';
import {formatLinesForDisplay, getChangesForRepertoryVersion} from '../../../utils';
import {
notifyError,
notifyInfo
} from '../../../redux/actions/error_actions';
const mapDispatchToProps = dispatch => {
return {
notifyError: msg => dispatch(notifyError(msg)),
notifyInfo: (title, msg) => dispatch(notifyInfo(title, msg)),
};
};
export default connect(null, mapDispatchToProps)(({release, lastItem, notifyError, notifyInfo}) => {
const title = '[' + Constants.RELEASE_TYPES[release.Release] + '] ' + release.Display;
const displayChanges = async () => {
try {
const lines = await getChangesForRepertoryVersion(release.VersionString);
notifyInfo(title, formatLinesForDisplay(lines));
} catch (e) {
notifyError(e);
}
};
export default ({release, lastItem}) => {
return (
<div>
<h2>{'[' + Constants.RELEASE_TYPES[release.Release] + '] ' + release.Display }</h2>
<h2>{title}</h2>
<table cellSpacing={0} cellPadding={0} width="97%">
<tbody>
<tr style={{height: '4px'}}/>
<tr>
<td width="50%">
<Button buttonStyles={{width: '100%'}}>Changes</Button>
<Button buttonStyles={{width: '100%'}} clicked={displayChanges}>Changes</Button>
</td>
<td>
<div style={{width: 'var(--default_spacing)'}}/>
@@ -25,4 +48,4 @@ export default ({release, lastItem}) => {
</table>
</div>
);
};
});