Skip to content

Commit 5a20741

Browse files
authored
Feat/news security info (#1292)
* feat(news): add warning and conditional rendering * feat(news): add checkbox and save choice
1 parent 328e832 commit 5a20741

File tree

2 files changed

+67
-4
lines changed

2 files changed

+67
-4
lines changed

app/addons/news/assets/less/news.less

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,14 @@
1010
// License for the specific language governing permissions and limitations under
1111
// the License.
1212

13-
#news-page {
13+
.news-page {
1414
width: 100%;
1515
height: 100%;
16+
17+
.news-checkbox {
18+
margin-top: 8px;
19+
input {
20+
margin: 0 4px 0 0;
21+
}
22+
}
1623
}

app/addons/news/components.js

Lines changed: 59 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,73 @@
99
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
1010
// License for the specific language governing permissions and limitations under
1111
// the License.
12+
import app from "../../app";
1213

1314
import React from "react";
1415

15-
const NewsPage = () => {
16+
const LoadNewsButton = ({ showNews, isChecked, toggleChange }) => {
1617
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>
1933
</div>
2034
);
2135
};
2236

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+
2379
export default {
2480
NewsPage: NewsPage
2581
};

0 commit comments

Comments
 (0)