-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
331 additions
and
63 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
|
||
Flowpack: | ||
JobQueue: | ||
Common: | ||
|
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
93 changes: 72 additions & 21 deletions
93
Resources/Private/NewsletterView/src/ConfirmationDialog.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,27 +1,78 @@ | ||
import React from 'react'; | ||
import React, {PureComponent} from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import {Button, Dialog} from '@neos-project/react-ui-components'; | ||
|
||
const ConfirmationDialog = ({isOpen, translate, close, send}) => { | ||
return ( | ||
<Dialog | ||
isOpen={isOpen} | ||
title={translate('Psmb.Newsletter:Main:js.testConfirmationTitle')} | ||
onRequestClose={close} | ||
actions={[ | ||
<Button onClick={close} style="clean">{translate('Neos.Neos:Main:cancel')}</Button>, | ||
<Button onClick={send} style="brand">{translate('Psmb.Newsletter:Main:js.send')}</Button> | ||
]} | ||
> | ||
<div style={{padding: '16px'}}>{translate('Psmb.Newsletter:Main:js.confirmationDescription')}</div> | ||
</Dialog> | ||
); | ||
}; | ||
ConfirmationDialog.propTypes = { | ||
isOpen: PropTypes.bool, | ||
translate: PropTypes.func.isRequired, | ||
close: PropTypes.func.isRequired, | ||
send: PropTypes.func.isRequired | ||
class ConfirmationDialog extends PureComponent { | ||
static propTypes = { | ||
isOpen: PropTypes.bool, | ||
translate: PropTypes.func.isRequired, | ||
close: PropTypes.func.isRequired, | ||
send: PropTypes.func.isRequired, | ||
subscription: PropTypes.string.isRequired, | ||
dataSourceAdditionalArguments: PropTypes.object | ||
}; | ||
|
||
state = { | ||
isLoading: false, | ||
subscribers: [] | ||
}; | ||
|
||
componentDidUpdate(prevProps) { | ||
if (this.props.subscription !== prevProps.subscription || (prevProps.isOpen === false && this.props.isOpen === true)) { | ||
this.fetchPreview(); | ||
} | ||
} | ||
|
||
fetchPreview() { | ||
if (this.props.subscription && this.props.isOpen) { | ||
this.setState({isLoading: true, subscribers: []}); | ||
const dataSourceAdditionalArguments = this.props.dataSourceAdditionalArguments; | ||
const data = new URLSearchParams(); | ||
if (dataSourceAdditionalArguments) { | ||
Object.keys(dataSourceAdditionalArguments).forEach(option => { | ||
data.set('dataSourceAdditionalArguments[' + option + ']', dataSourceAdditionalArguments[option]); | ||
}); | ||
} | ||
fetch(`/newsletter/preview?subscription=${this.props.subscription}&${data.toString()}`, { | ||
credentials: 'include' | ||
}) | ||
.then(response => response.json()) | ||
.then(subscribers => { | ||
this.setState({subscribers, isLoading: false}); | ||
}); | ||
} | ||
} | ||
render() { | ||
const {isOpen, translate, close, send} = this.props; | ||
|
||
const keys = this.state.subscribers[0] ? Object.keys(this.state.subscribers[0]) : []; | ||
return ( | ||
<Dialog | ||
isOpen={isOpen} | ||
title={translate('Psmb.Newsletter:Main:js.confirmationTitle')} | ||
onRequestClose={close} | ||
actions={[ | ||
<Button onClick={close} style="clean">{translate('Neos.Neos:Main:cancel')}</Button>, | ||
<Button onClick={send} style="brand">{translate('Psmb.Newsletter:Main:js.send')}</Button> | ||
]} | ||
> | ||
<div style={{padding: '16px'}}> | ||
<div>{translate('Psmb.Newsletter:Main:js.confirmationDescription')}</div> | ||
{this.state.isLoading ? translate('Psmb.Newsletter:Main:js.loading') : ( | ||
<div> | ||
<div style={{padding: '16px 0'}}>{translate('Psmb.Newsletter:Main:js.recepients')}: <strong>{this.state.subscribers.length}</strong></div> | ||
<table> | ||
<tr>{keys.map(key => <th>{key}</th>)}</tr> | ||
{this.state.subscribers.map(subscriber => { | ||
return <tr>{keys.map(key => <td>{subscriber[key]}</td>)}</tr>; | ||
})} | ||
</table> | ||
</div> | ||
)} | ||
</div> | ||
</Dialog> | ||
); | ||
} | ||
}; | ||
|
||
export default ConfirmationDialog; |
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
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
Oops, something went wrong.