|
9 | 9 | // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
10 | 10 | // License for the specific language governing permissions and limitations under
|
11 | 11 | // the License.
|
| 12 | +import app from "../../app"; |
12 | 13 |
|
13 | 14 | import React from "react";
|
14 | 15 |
|
15 |
| -const NewsPage = () => { |
| 16 | +const LoadNewsButton = ({ showNews, isChecked, toggleChange }) => { |
16 | 17 | return (
|
17 |
| - <div id="news-page" className=""> |
18 |
| - <iframe src="https://blog.couchdb.org" width="100%" height="100%"></iframe> |
| 18 | + <div> |
| 19 | + <p> |
| 20 | + When you click this button, you are requesting content and sharing your IP address with <a href="https://blog.couchdb.org/">blog.couchdb.org</a> which is edited by the Apache CouchDB PMC and maintained by <a href="https://wordpress.com/">wordpress.com</a>. |
| 21 | + </p> |
| 22 | + <p> |
| 23 | + If you don’t want to share your IP address, do not click the button. |
| 24 | + </p> |
| 25 | + <button className="btn btn-primary" onClick={showNews}>Load News</button> |
| 26 | + <label className="news-checkbox"> |
| 27 | + <input type="checkbox" |
| 28 | + checked={isChecked} |
| 29 | + onChange={toggleChange} |
| 30 | + /> |
| 31 | + Remember my choice |
| 32 | + </label> |
19 | 33 | </div>
|
20 | 34 | );
|
21 | 35 | };
|
22 | 36 |
|
| 37 | +class NewsPage extends React.Component { |
| 38 | + constructor (props) { |
| 39 | + super(props); |
| 40 | + this.showNews = this.showNews.bind(this); |
| 41 | + this.toggleChange = this.toggleChange.bind(this); |
| 42 | + |
| 43 | + const allowsIpSharing = !!app.utils.localStorageGet('allow-IP-sharing'); |
| 44 | + |
| 45 | + this.state = { |
| 46 | + showNews: allowsIpSharing ? true : false, |
| 47 | + allowsIpSharing |
| 48 | + }; |
| 49 | + } |
| 50 | + |
| 51 | + showNews() { |
| 52 | + this.setState({ showNews: true }); |
| 53 | + } |
| 54 | + |
| 55 | + toggleChange() { |
| 56 | + const allowsIpSharing = this.state.allowsIpSharing; |
| 57 | + this.setState({ allowsIpSharing: !allowsIpSharing }); |
| 58 | + app.utils.localStorageSet('allow-IP-sharing', !allowsIpSharing); |
| 59 | + } |
| 60 | + |
| 61 | + render() { |
| 62 | + let newsContent = <LoadNewsButton |
| 63 | + showNews={this.showNews} |
| 64 | + toggleChange={this.toggleChange} |
| 65 | + isChecked={this.state.allowsIpSharing}></LoadNewsButton>; |
| 66 | + |
| 67 | + if (this.state.showNews) { |
| 68 | + newsContent = <iframe src="https://blog.couchdb.org" width="100%" height="100%"></iframe>; |
| 69 | + } |
| 70 | + |
| 71 | + return ( |
| 72 | + <div className="news-page"> |
| 73 | + {newsContent} |
| 74 | + </div> |
| 75 | + ); |
| 76 | + } |
| 77 | +} |
| 78 | + |
23 | 79 | export default {
|
24 | 80 | NewsPage: NewsPage
|
25 | 81 | };
|
0 commit comments