Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/rewards integration #52

Closed
wants to merge 76 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
3a01479
Initial commit. Code works on staging with some temp workarounds
Apr 23, 2018
68e3b76
Removing temporary code.
Apr 23, 2018
4959ee1
hot dog
trickpattyFH20 Mar 27, 2018
0b7aba9
init circle
trickpattyFH20 Mar 29, 2018
6d40c48
react hot dog
trickpattyFH20 Mar 29, 2018
993133d
rewards hot dog ui
trickpattyFH20 Mar 30, 2018
a5d0b51
close circle
trickpattyFH20 Mar 30, 2018
9565d2f
routing and offer card
trickpattyFH20 Apr 2, 2018
a1c0870
reward card layout
trickpattyFH20 Apr 2, 2018
234e52d
more offer card styles
trickpattyFH20 Apr 2, 2018
5d68ff1
card footer + copy feedback + styling
trickpattyFH20 Apr 3, 2018
6ad8684
more styles
trickpattyFH20 Apr 3, 2018
bc6d97f
remove purple test style
trickpattyFH20 Apr 4, 2018
4a25316
test rewards postmessage
trickpattyFH20 Apr 4, 2018
dded606
one reward at a time for hot dog and offer card
trickpattyFH20 Apr 5, 2018
1560e23
header + footer + styles
trickpattyFH20 Apr 9, 2018
da5ee6b
react shadow
trickpattyFH20 Apr 13, 2018
ea7eae0
define MainView first
trickpattyFH20 Apr 13, 2018
1c00a47
lint
trickpattyFH20 Apr 16, 2018
d38fad7
add onmessage
trickpattyFH20 Apr 16, 2018
935aa87
fix selector and close button
trickpattyFH20 Apr 16, 2018
200feb3
iframe fallback
trickpattyFH20 Apr 17, 2018
a5ce6f3
fix ff beta logo
trickpattyFH20 Apr 17, 2018
b8b7cc0
data csp compatible images + class for index + text styles
trickpattyFH20 Apr 18, 2018
50fba55
disable rewards notification
trickpattyFH20 Apr 18, 2018
4b5ddf4
fix shadow FOUC
trickpattyFH20 Apr 18, 2018
84e2ec7
click outside settings
trickpattyFH20 Apr 18, 2018
a32a213
settings styles
trickpattyFH20 Apr 20, 2018
a127e39
settings actions
trickpattyFH20 Apr 23, 2018
7531d1a
show ghostery pizza offer
trickpattyFH20 Apr 24, 2018
f951291
fix event listener reward reference
trickpattyFH20 Apr 26, 2018
9f41082
setConfiguration - for DEBUG only
Apr 27, 2018
f61089b
Changing the way browser-core is loaded.
Apr 27, 2018
5a0d612
Merge remote-tracking branch 'upstream/feature/GH-732-hot-dog' into f…
trickpattyFH20 Apr 27, 2018
66b339f
handle signal
trickpattyFH20 Apr 30, 2018
8582711
mark offer read + delete offer
trickpattyFH20 Apr 30, 2018
78b1203
new signals
trickpattyFH20 Apr 30, 2018
5a59a39
refactor to sendSignal
trickpattyFH20 May 1, 2018
ce1b2a3
Create ToggleSlider component. Use it in Setup flow.
IAmThePan Apr 11, 2018
f7a3b16
GH-409 Update Rewards view: rewards list, toggle on/off, reducers, fa…
IAmThePan Apr 16, 2018
c6f4403
GH-409 Update Rewards view: reward details.
IAmThePan Apr 18, 2018
5d8819a
hot dog
trickpattyFH20 Mar 27, 2018
84bc961
Integrate panel rewards with background I
IAmThePan Apr 26, 2018
924241e
Integrate panel rewards with background II. Fix linting errors
IAmThePan Apr 30, 2018
768988a
Integrate panel rewards with Background III. Messages for read, remov…
IAmThePan Apr 30, 2018
11af136
Fix signal bug for content-script rewards
IAmThePan May 1, 2018
0a6e2bc
panel reward signals
trickpattyFH20 May 1, 2018
3526eed
reward prompt flow
trickpattyFH20 May 1, 2018
24b82ad
Finalize design for Rewards Panel
IAmThePan May 2, 2018
09fad40
clean rewards
trickpattyFH20 May 2, 2018
0fb4fd8
rewards conf handling
trickpattyFH20 May 3, 2018
ba44a18
update browser-core package and lock
trickpattyFH20 May 3, 2018
7e6c673
Add translations to Rewards Panel
IAmThePan May 3, 2018
21a6b40
Fix for Ghostery side enabling of offers
May 3, 2018
58e3707
Merge branch 'feature/rewards-integration' of https://github.com/ghos…
May 3, 2018
f92706f
styles. expiration. terms tt
trickpattyFH20 May 3, 2018
98f166d
enable offers by default
trickpattyFH20 May 3, 2018
9a4469c
start button styles
trickpattyFH20 May 3, 2018
e2fe731
Begin tests for the rewards panel
IAmThePan May 3, 2018
d11bfba
More and updated tests for Rewards Panel
IAmThePan May 3, 2018
0319a9c
Fix linting errors
IAmThePan May 3, 2018
089746d
signals
trickpattyFH20 May 4, 2018
f06a248
Add more signals, fix linting errors, fix bug
IAmThePan May 4, 2018
e4ec6c6
Removing offers from ABTest
May 7, 2018
5b43408
style adjustments
trickpattyFH20 May 7, 2018
e1f5105
GH-1051 fix null reward check
trickpattyFH20 May 8, 2018
03eee09
merge
trickpattyFH20 May 8, 2018
cb6aa87
GH-1055 fix - define onload evt first
trickpattyFH20 May 8, 2018
d51f739
button singleton + seen reward on offer card shown
trickpattyFH20 May 9, 2018
7a3e09e
typo
trickpattyFH20 May 9, 2018
55462b1
Removing enable_offers_abtest.
May 9, 2018
a9bc71e
Extra blanks
May 9, 2018
08fe23d
Removing checkbox for EDGE and CLIQZ unconditionally.
May 9, 2018
87caf7b
Restore default manifest state.
May 9, 2018
0957ffd
Update Rewards copy and add styling to non-happy-path Rewards panel
IAmThePan May 10, 2018
f9cd25c
Update test snapshots
IAmThePan May 10, 2018
File filter
Filter file types
Jump to
Jump to file
Failed to load files.

Always

Just for now

iframe fallback
  • Loading branch information
trickpattyFH20 committed Apr 23, 2018
commit 200feb34f647cac888e6b3708915b58f31717e3b
@@ -14,23 +14,36 @@ class HotDog extends Component {
this.state = {
closed: false
};

this.iframeEl = parent.document.getElementById('ghostery-iframe-container');
if (this.iframeEl) {
this.iframeEl.classList = '';
this.iframeEl.classList.add('hot-dog');
}

this.close = this.close.bind(this);
this.navigate = this.navigate.bind(this);
}

navigate() {
if (this.iframeEl) {
this.iframeEl.classList.add('offer-card');
}
this.props.history.push('/offercard');
}

close() {
if (this.iframeEl) {
this.iframeEl.classList = '';
}
this.setState({
closed: true
});
}

render() {
return (
<div>
<div className="ghostery-rewards-component">
{ this.state.closed !== true &&
<div>
<div onClick={this.navigate} className="hot-dog-container">
@@ -16,13 +16,23 @@ class OfferCard extends Component {
copyText: t('rewards_copy_code')
};

this.iframeEl = parent.document.getElementById('ghostery-iframe-container');
if (this.iframeEl) {
this.iframeEl.classList = '';
this.iframeEl.classList.add('offer-card');
}

this.close = this.close.bind(this);
this.copyCode = this.copyCode.bind(this);
}

copyCode() {
// copy code to clipboard
document.getElementsByClassName('shadowroot')[0].shadowRoot.querySelector('.reward-code-input').select();
if (document.getElementById('ghostery-shadow-root')) {
document.getElementById('ghostery-shadow-root').shadowRoot.querySelector('.reward-code-input').select();
} else {
document.getElementById('ghostery-iframe-container').contentWindow.document.querySelector('.reward-code-input').select();
}
document.execCommand('copy');

// 'copied' feedback for user
@@ -40,6 +50,9 @@ class OfferCard extends Component {
}

close() {
if (this.iframeEl) {
this.iframeEl.classList = '';
}
this.setState({
closed: true
});
@@ -48,7 +61,7 @@ class OfferCard extends Component {
render() {
console.log('render props:', this.props);
return (
<div>
<div className="ghostery-rewards-component">
{ this.state.closed !== true &&
<div className="ghostery-reward-card">
<div className="reward-card-header">
@@ -76,7 +89,7 @@ class OfferCard extends Component {
{/* { this.state.description } */}
</p>
</div>
<div onClick={this.copyCode} className="reward-code">
<div className="reward-code">
<input readOnly className="reward-code-input" value={this.props.reward.rewardCode} type="text" />
<a onClick={this.copyCode}>{this.state.copyText}</a>
</div>
@@ -28,11 +28,15 @@ import ShadowDOM from 'react-shadow';

const { BROWSER_INFO, onMessage } = globals;
const viewport = document.getElementById('viewport');
const rewardsContainer = document.createElement('div');
const channelsSupported = (typeof chrome.runtime.connect === 'function');

let rewardsContainer = document.createElement('div');
let rewardsApp = document.createElement('div');
let rewardsIframe;
let iframeStyle;
let port;
/* TODO remove test reward data */
let MainView;

/* TODO massage offerz object into front end and remove mock data */
const reward = {
rewardCode: 'SDF75DSUI90',
expireTime: '14 days',
@@ -43,16 +47,67 @@ const reward = {
description: 'Description of the offer. There is a lot of exciting stuff going on.'
};

rewardsContainer.id = 'ghostery-rewards-container';
rewardsContainer.className = 'show ghostery-rewards-container';
// rewardsContainer.attachShadow({mode: 'open'});
rewardsApp.id = 'ghostery-rewards-app';
rewardsApp.className = 'show';

document.addEventListener('DOMContentLoaded', (event) => {
if (BROWSER_INFO.name === 'chrome') {
// use shadowDOM to encapsulate CSS - fully supported in Chrome
rewardsContainer.appendChild(rewardsApp);
document.body.appendChild(rewardsContainer);
MainView = (props) => {
return (
<Router history={history}>
<ShadowDOM include={[chrome.extension.getURL('dist/css/rewards_styles.css')]}>
<div id="ghostery-shadow-root">
<Route exact path="/" render={ ()=> <HotDog reward={props.reward} /> } />
<Route path="/hotdog" render={ ()=> <HotDog reward={props.reward} /> } />
<Route path="/offercard" render={ ()=> <OfferCard reward={props.reward} /> } />
</div>
</ShadowDOM>
</Router>
);
}
ReactDOM.render(<MainView reward={reward} />, rewardsApp);
} else {
// use iframe to encapsulate CSS - fallback for everything else besides chrome
rewardsIframe = document.createElement('iframe');
rewardsIframe.id = 'ghostery-iframe-container';
rewardsIframe.classList.add('hot-dog')
document.body.appendChild(rewardsIframe);
rewardsIframe.onload = () => {
iframeStyle = document.createElement('link');
iframeStyle.rel = 'stylesheet';
iframeStyle.type = 'text/css';
iframeStyle.href = chrome.extension.getURL('dist/css/rewards_styles.css');

rewardsIframe.contentWindow.document.head.appendChild(iframeStyle);
rewardsContainer = rewardsIframe.contentWindow.document.body;

rewardsApp.classList.add('iframe-child');
rewardsContainer.appendChild(rewardsApp);
MainView = (props) => {
return (
<Router history={history}>
<div>
<Route exact path="/" render={ ()=> <HotDog reward={props.reward} /> } />
<Route path="/hotdog" render={ ()=> <HotDog reward={props.reward} /> } />
<Route path="/offercard" render={ ()=> <OfferCard reward={props.reward} /> } />
</div>
</Router>
);
}
ReactDOM.render(<MainView reward={reward} />, rewardsApp);
}
};
});

function handleMessages(request, sender, response) {
console.log(request);
/* TODO get new reward from request, and set it as new reward */
if (document.readyState === 'complete') {
console.log('re render root react');
ReactDOM.render(<MainView reward={reward} />, document.getElementById('ghostery-rewards-container'));
ReactDOM.render(<MainView reward={reward} />, rewardsApp);
}
}

@@ -65,37 +120,3 @@ if (channelsSupported) {
} else {
onMessage.addListener(handleMessages);
}

let MainView;
if (BROWSER_INFO.name === 'chrome') {
MainView = (props) => {
return (
<Router history={history}>
<ShadowDOM include={[chrome.extension.getURL('dist/css/rewards_styles.css')]}>
<div className="shadowroot">
<Route exact path="/" render={ ()=> <HotDog reward={props.reward} /> } />
<Route path="/hotdog" render={ ()=> <HotDog reward={props.reward} /> } />
<Route path="/offercard" render={ ()=> <OfferCard reward={props.reward} /> } />
</div>
</ShadowDOM>
</Router>
);
}
} else {
MainView = (props) => {
return (
<Router history={history}>
<div>
<Route exact path="/" render={ ()=> <HotDog reward={props.reward} /> } />
<Route path="/hotdog" render={ ()=> <HotDog reward={props.reward} /> } />
<Route path="/offercard" render={ ()=> <OfferCard reward={props.reward} /> } />
</div>
</Router>
);
}
}

document.addEventListener('DOMContentLoaded', (event) => {
document.body.appendChild(rewardsContainer);
ReactDOM.render(<MainView reward={reward} />, document.getElementById('ghostery-rewards-container'));
});
@@ -1,12 +1,29 @@
//Import Global Partials
@import "settings"; //includes _colors.scss

.ghostery-rewards-container, :host {

#ghostery-rewards-app, #ghostery-iframe-container {
z-index: 2147483647 !important;
font-family: $body-font-family!important;
position: fixed;
top: 30px;
right: 30px;
}

#ghostery-iframe-container {
border: none;
&.hot-dog {
height: 59px;
width: 266px;
}

&.offer-card {
width: 268px;
height: 531px;
}
}

.ghostery-rewards-component {

.hide {
visibility: hidden;
@@ -264,3 +281,8 @@
}

}

#ghostery-rewards-app.iframe-child {
top: 9px;
right: 1px;
}
@@ -114,7 +114,7 @@ class EventHandlers {
tabInfo.setTabInfo(tabId, 'incognito', tab.incognito);
// purplebox.createBox() will first check to make sure this is a valid tab
this._createBox(tabId);
this.rewards.showCircle(tabId);
this.rewards.showHotDog(tabId);
}
}, () => {
// prefetched tabs will return an error from utils.getTab
@@ -30,12 +30,12 @@ const t = chrome.i18n.getMessage;
class Rewards {
constructor() {
this.rewardsData = {
rewardName: 'test-reward'

};
this.ports = new Map();
}

showCircle(tab_id) {
showHotDog(tab_id) {
/* @TODO get any initial data from cmp event and add to this.rewardsData */

const tab = tabInfo.getTabInfo(tab_id);
@@ -56,26 +56,15 @@ class Rewards {
this.ports.set(tabId, port);
this.ports.get(tabId).onMessage.addListener((message) => {
if (message.name === 'rewardsLoaded') {
this.ports.get(tabId).postMessage({ name: 'showCircle', message: this.rewardsData });
this.ports.get(tabId).postMessage({ name: 'showHotDog', message: this.rewardsData });
}
// else if (message.name === 'onCreateBox') {
// this.updateBox(tabId);
// } else if (message.name === 'onDestroyBox') {
// this.destroyBox(tabId);
// } else if (message.name === 'updateAlertConf') {
// conf.alert_expanded = message.message.alert_expanded;
// conf.alert_bubble_pos = message.message.alert_bubble_pos;
// conf.alert_bubble_timeout = message.message.alert_bubble_timeout;
// // push new settings to API
// accounts.pushUserSettings({ conf: accounts.buildUserSettings() });
// }
});
}
}
});

// console.log('INJECT REWARDS');
return injectScript(tab_id, 'dist/rewards.js', null, 'document_start').then(() => {
return injectScript(tab_id, 'dist/rewards.js', 'dist/css/rewards_styles.css', 'document_start').then(() => {
// console.log('REWARDS INJECTED');
}).catch((err) => {
log('rewards injectScript error', err);
ProTip! Use n and p to navigate between commits in a pull request.