-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Embeddable ParityBar #4222
Embeddable ParityBar #4222
Conversation
Probably it would be good to include |
export default function (api, browserHistory, forEmbed = false) { | ||
let middleware; | ||
if (forEmbed) { | ||
const errors = new ErrorsMiddleware(); |
There was a problem hiding this comment.
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') { |
There was a problem hiding this comment.
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...
- This is dependent on the ethlink branch (should be merged first)
- We have moved to
web3.site
- We still have the proxy under settings, so this breaks that
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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';
- Consistent with what we use elsewhere instead of adding yet another module
- No need for try/catch
- It does nice things like auto to/from JSON
There was a problem hiding this comment.
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'; |
There was a problem hiding this comment.
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'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import store from 'store';
@@ -96,6 +117,23 @@ class ParityBar extends Component { | |||
); | |||
} | |||
|
|||
renderLink (button) { | |||
const { externalLink } = this.props; | |||
if (!externalLink) { |
There was a problem hiding this comment.
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'> |
There was a problem hiding this comment.
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'; |
There was a problem hiding this comment.
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 () {} |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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 }); |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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) : []; |
There was a problem hiding this comment.
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'; |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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) => { |
There was a problem hiding this comment.
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 = ( |
There was a problem hiding this comment.
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 }> |
There was a problem hiding this comment.
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'; |
There was a problem hiding this comment.
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.
Code style comments, but overall no serious issues or bugs found. |
|
||
// Cleanup Loading | ||
const $container = document.querySelector('#container'); | ||
$container.parentNode.removeChild($container); |
There was a problem hiding this comment.
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 ?
Looks good to me ! |
style grumbles and conflict but good to merge otherwise. |
Conflicts: js/src/views/ParityBar/parityBar.js
Style issues addressed, thanks for pointing them out 👍 |
* Embeddable ParityBar * Replacing storage with store * Fixing references. * Addressing style issues * Supporting parity background Conflicts: js/src/views/ParityBar/parityBar.js
Some changes required to deploy injectable ParityBar in Chrome Extension.