Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Embeddable ParityBar #4222

Merged
merged 6 commits into from Jan 23, 2017
Merged

Embeddable ParityBar #4222

merged 6 commits into from Jan 23, 2017

Conversation

tomusdrw
Copy link
Collaborator

Some changes required to deploy injectable ParityBar in Chrome Extension.

@tomusdrw tomusdrw added A0-pleasereview 🤓 Pull request needs code review. M7-ui labels Jan 19, 2017
@tomusdrw
Copy link
Collaborator Author

Probably it would be good to include embed.js in parity.js on NPM to use it in extension (I will look into it)

export default function (api, browserHistory, forEmbed = false) {
let middleware;
if (forEmbed) {
const errors = new ErrorsMiddleware();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move the common middle out of the if/else blocks. Use concat to add middleware.

@@ -56,8 +62,8 @@ export default class SecureApi extends Api {
}

get hostname () {
if (window.location.hostname === 'home.parity') {
return 'dapps.parity';
if (window.location.hostname === 'home.ethlink.io') {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not 100% sure what this is doing here, however...

  1. This is dependent on the ethlink branch (should be merged first)
  2. We have moved to web3.site
  3. We still have the proxy under settings, so this breaks that

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, included by mistake.

/**
* A safe localStorage wrapper
*/
class Storage {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of doing this, perfer the use of store, i.e. import store from 'store';

  1. Consistent with what we use elsewhere instead of adding yet another module
  2. No need for try/catch
  3. It does nice things like auto to/from JSON

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just replaced all occurences of window.localStorage with this, cause localStorage is not available in chrome extension. Hopefuly store will solve that too, will fix :)

@@ -14,13 +14,15 @@
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.

import storage from '~/util/storage';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

import store from 'store';

@@ -15,14 +15,15 @@
// along with Parity. If not, see <http://www.gnu.org/licenses/>.

import { action, observable } from 'mobx';
import storage from '~/util/storage';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

import store from 'store';

@coveralls
Copy link

Coverage Status

Coverage increased (+0.008%) to 84.871% when pulling 9f01f2f on embed into 5830e03 on master.

@gavofyork gavofyork added A5-grumble 🔥 Pull request has minor issues that must be addressed before merging. and removed A0-pleasereview 🤓 Pull request needs code review. labels Jan 20, 2017
@tomusdrw tomusdrw added A0-pleasereview 🤓 Pull request needs code review. and removed A5-grumble 🔥 Pull request has minor issues that must be addressed before merging. labels Jan 20, 2017
@@ -96,6 +117,23 @@ class ParityBar extends Component {
);
}

renderLink (button) {
const { externalLink } = this.props;
if (!externalLink) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer extra line break here https://github.com/ethcore/parity/pull/4234

}

return (
<a href={ externalLink } target='_parent'>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When doing multiple attributes, spreading them one per line is preferable.


injectTapEventPlugin();

import ParityBar from './views/ParityBar';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mixture of ~ (i.e. ui as used above) and ./ - doesn't make much difference here since it sits at the root, just noting it that generally we prefer ~ and if things are moved, it won't have any impact.

console.log('Calling', method, params);
return Promise.reject('not connected');
}
on () {}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Blank line before method & prefer

on () {
}

}

const api = new FrameSecureApi(window.secureTransport || new FakeTransport());
patchApi(api);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

newline after var declaration. ()Not trapped yet)

ContractInstances.create(api);

const store = initStore(api, null, true);
store.dispatch({ type: 'initAll', api });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

newline.

);

const container = document.createElement('div');
document.body.appendChild(container);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

newline.

}

const status = statusMiddleware();
const routeMiddleware = browserHistory ? routerMiddleware(browserHistory) : [];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

newline after.

@@ -18,9 +18,9 @@ import { uniq } from 'lodash';

import Api from './api';
import { LOG_KEYS, getLogger } from '~/config';
import store from 'store';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally prefer package imports to go at the top, then local src, then local to component.


constructor (url, nextToken, getTransport = SecureApi.getTransport) {
const sysuiToken = store.get('sysuiToken');
const transport = getTransport(url, sysuiToken);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

newline after.

@@ -29,7 +29,8 @@ import styles from './parityBar.css';
class ParityBar extends Component {
static propTypes = {
pending: PropTypes.array,
dapp: PropTypes.bool
dapp: PropTypes.bool,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bad example since this was not done, but we do prefer to re-arrange alphabetically when touching (have not done a bulk-re-arrange, but when touching we do do it.)

bubbles: true,
detail: { opened }
});
this.bar.dispatchEvent(event);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

newline before. (As per slightly stricter rules - things are growing, just trying to keep consistency going)

this.bar.dispatchEvent(event);
}

onRef = (el) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would have preferred slightly more descriptive variable naming, i.e. element (we gain understanding reading, lose nothing after compilation)

@@ -72,18 +92,19 @@ class ParityBar extends Component {
className={ styles.parityIcon }
/>
);
const parityButton = (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

newline before.


return (
<div className={ styles.bar }>
<div className={ styles.bar } ref={ this.onRef }>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Split multiple attributes to one per line.

@@ -15,6 +15,7 @@
// along with Parity. If not, see <http://www.gnu.org/licenses/>.

import defaultViews from './Views/defaults';
import store from 'store';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

package imports should go at the top.

@jacogr
Copy link
Contributor

jacogr commented Jan 20, 2017

Code style comments, but overall no serious issues or bugs found.


// Cleanup Loading
const $container = document.querySelector('#container');
$container.parentNode.removeChild($container);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not having React attached to the #container directly ?

@ngotchac
Copy link
Contributor

Looks good to me !

@gavofyork gavofyork added A5-grumble 🔥 Pull request has minor issues that must be addressed before merging. and removed A0-pleasereview 🤓 Pull request needs code review. labels Jan 21, 2017
@gavofyork
Copy link
Contributor

style grumbles and conflict but good to merge otherwise.

Tomasz Drwięga added 2 commits January 22, 2017 16:30
Conflicts:
	js/src/views/ParityBar/parityBar.js
@tomusdrw tomusdrw added A0-pleasereview 🤓 Pull request needs code review. and removed A5-grumble 🔥 Pull request has minor issues that must be addressed before merging. labels Jan 22, 2017
@tomusdrw
Copy link
Collaborator Author

Style issues addressed, thanks for pointing them out 👍

@ngotchac ngotchac added A8-looksgood 🦄 Pull request is reviewed well. and removed A0-pleasereview 🤓 Pull request needs code review. labels Jan 23, 2017
@jacogr jacogr merged commit 3e70e88 into master Jan 23, 2017
@jacogr jacogr deleted the embed branch January 23, 2017 12:04
tomusdrw added a commit that referenced this pull request Jan 24, 2017
* Embeddable ParityBar

* Replacing storage with store

* Fixing  references.

* Addressing style issues

* Supporting parity background

Conflicts:
	js/src/views/ParityBar/parityBar.js
gavofyork pushed a commit that referenced this pull request Jan 24, 2017
* Embeddable ParityBar

* Replacing storage with store

* Fixing  references.

* Addressing style issues

* Supporting parity background

Conflicts:
	js/src/views/ParityBar/parityBar.js
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A8-looksgood 🦄 Pull request is reviewed well.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants