Skip to content
This repository has been archived by the owner on Apr 17, 2023. It is now read-only.

Commit

Permalink
Merge branch 'release/0.23.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
larrysalibra committed Feb 1, 2018
2 parents 9286aa4 + f2ad178 commit 906de2e
Show file tree
Hide file tree
Showing 32 changed files with 650 additions and 971 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ app/js/components/*
app/js/store/*
app/js/utils/*
!app/js/utils/account-utils*
!app/js/utils/api-utils*

app/js/profiles/store/*
app/js/profiles/tabs/*
Expand Down
132 changes: 3 additions & 129 deletions app/js/account/StorageProvidersPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ import { connect } from 'react-redux'
import { AccountActions } from '../account/store/account'
import { SettingsActions } from '../account/store/settings'

import { DROPBOX, BLOCKSTACK_INC } from './utils/index'
import { getDropboxAccessTokenFromHash,
redirectToConnectToDropbox } from './utils/dropbox'
import { BLOCKSTACK_INC } from './utils/index'

import { connectToGaiaHub } from './utils/blockstack-inc'

Expand All @@ -15,7 +13,6 @@ import log4js from 'log4js'

const logger = log4js.getLogger('storage/StorageProvidersPage.js')

const Dropbox = require('dropbox')

function mapStateToProps(state) {
return {
Expand Down Expand Up @@ -51,47 +48,18 @@ class StorageProvidersPage extends Component {
this.state = {
hide: true
}
this.connectDropbox = this.connectDropbox.bind(this)
this.disconnectDropbox = this.disconnectDropbox.bind(this)
this.updateApi = this.updateApi.bind(this)
}

componentWillMount() {
const api = this.props.api
const dropboxAccessToken = getDropboxAccessTokenFromHash(window.location.hash)
const needToConnectGaiaHub = window.location.hash === '#gaiahub'
const needToConnectDropbox = dropboxAccessToken != null
if (needToConnectDropbox) {
const newApi = Object.assign({}, api, { dropboxAccessToken })
this.props.updateApi(newApi)
const identityIndex = 0
const identity = this.props.localIdentities[identityIndex]
const identityAddress = identity.ownerAddress
const profileSigningKeypair = this.props.identityKeypairs[identityIndex]
const profile = identity.profile

// This is okay selecting storage right now is only done during on-boarding
const firstDropboxUpload = true

setCoreStorageConfig(newApi, identityIndex, identityAddress,
profile, profileSigningKeypair, firstDropboxUpload)
.then((indexUrl) => {
logger.debug(`componentDidMount: indexUrl: ${indexUrl}`)
// TODO add index URL to token file
logger.debug('componentDidMount: storage initialized')
const newApi2 = Object.assign({}, newApi, { storageConnected: true })
this.props.updateApi(newApi2)
this.props.storageIsConnected()
logger.debug('componentDidMount: storage configured')
})
}
if (needToConnectGaiaHub) {
logger.debug('componentDidMount: trying to connect gaia hub...')
this.connectSharedService()
}

// We can show the page contents since there's not going to be a redirect
if (!(needToConnectGaiaHub || needToConnectDropbox)) {
if (!(needToConnectGaiaHub)) {
this.setState({ hide: false })
}
}
Expand All @@ -109,17 +77,6 @@ class StorageProvidersPage extends Component {
}
}

connectDropbox() {
redirectToConnectToDropbox()
}

disconnectDropbox() {
const api = this.props.api
const dbx = new Dropbox({ accessToken: api.dropboxAccessToken })
dbx.authTokenRevoke()
this.props.updateApi(Object.assign({}, api, { dropboxAccessToken: null }))
}

connectSharedService() {
const storageProvider = this.props.api.gaiaHubUrl
const signer = this.props.identityKeypairs[0].key
Expand All @@ -135,7 +92,7 @@ class StorageProvidersPage extends Component {
const profileSigningKeypair = this.props.identityKeypairs[identityIndex]
const profile = identity.profile
setCoreStorageConfig(newApi, identityIndex, identityAddress,
profile, profileSigningKeypair)
profile, profileSigningKeypair, identity)
.then((indexUrl) => {
logger.debug(`componentDidMount: indexUrl: ${indexUrl}`)
// TODO add index URL to token file
Expand Down Expand Up @@ -204,89 +161,6 @@ class StorageProvidersPage extends Component {
Run your own Gaia storage hub
</a>
</p>
<p>
{api.hostedDataLocation !== DROPBOX ?
<button
onClick={this.connectDropbox}
className="btn btn-primary btn-storage btn-lg btn-block"
disabled={this.props.storageIsConnected}
>
Connect Dropbox
</button>
:
<button
onClick={this.disconnectDropbox}
className="btn btn-primary btn-storage btn-lg btn-block"
title="Changing storage service providers will be supported in a future version."
disabled
>
Disconnect Dropbox
</button>
}
</p>
<p>
<button
disabled
className="btn btn-primary btn-storage btn-lg btn-block"
title="Coming soon!"
>
Connect IPFS
</button>
</p>
<p>
<button
disabled
className="btn btn-primary btn-storage btn-lg btn-block"
title="Coming soon!"
>
Connect self-hosted storage
</button>
</p>
<p>
<button
disabled
className="btn btn-primary btn-storage btn-lg btn-block"
title="Coming soon!"
>
Connect Sia
</button>
</p>
<p>
<button
disabled
className="btn btn-primary btn-storage btn-lg btn-block"
title="Coming soon!"
>
Connect Storj
</button>
</p>
<p>
<button
disabled
className="btn btn-primary btn-storage btn-lg btn-block"
title="Coming soon!"
>
Connect Google Drive
</button>
</p>
<p>
<button
disabled
className="btn btn-primary btn-storage btn-lg btn-block"
title="Coming soon!"
>
Connect Amazon Cloud Drive
</button>
</p>
<p>
<button
disabled
className="btn btn-primary btn-storage btn-lg btn-block"
title="Coming soon!"
>
Connect Microsoft OneDrive
</button>
</p>
</div>
</div>
}
Expand Down
6 changes: 0 additions & 6 deletions app/js/account/store/settings/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,25 +33,19 @@ function refreshBtcPrice(btcPriceUrl) {

function resetApi(api) {
logger.trace('resetApi')
let dropboxAccessToken = api.dropboxAccessToken
let coreAPIPassword = api.coreAPIPassword
let gaiaHubConfig = api.gaiaHubConfig

if (gaiaHubConfig === undefined) {
gaiaHubConfig = null
}

if (dropboxAccessToken === undefined) {
dropboxAccessToken = null
}

if (coreAPIPassword === undefined) {
coreAPIPassword = null
}
return dispatch => {
dispatch(updateApi(Object.assign({}, DEFAULT_API, {
gaiaHubConfig,
dropboxAccessToken,
coreAPIPassword
})))
}
Expand Down
8 changes: 2 additions & 6 deletions app/js/account/store/settings/default.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DROPBOX } from '../../../account/utils/index'
import { BLOCKSTACK_INC } from '../../../account/utils/index'
import { isCoreEndpointDisabled } from '../../../utils/window-utils'

export const REGTEST_CORE_API_PASSWORD = 'blockstack_integration_test_api_password'
Expand Down Expand Up @@ -42,15 +42,11 @@ const DEFAULT_API = {
}
},
browserServerUrl: 'https://blockstack-browser-server.appartisan.com',
hostedDataLocation: DROPBOX,
hostedDataLocation: BLOCKSTACK_INC,
coreHost: 'localhost',
corePort: 6270,
coreAPIPassword: null,
logServerPort: '',
s3ApiKey: '',
s3ApiSecret: '',
s3Bucket: '',
dropboxAccessToken: null,
storageConnected: false,
gaiaHubConfig: null,
gaiaHubUrl: 'https://hub.blockstack.org',
Expand Down
18 changes: 1 addition & 17 deletions app/js/account/utils/blockstack-inc.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,9 @@
// @flow
import log4js from 'log4js'
import { uploadToGaiaHub, connectToGaiaHub, GaiaHubConfig } from 'blockstack'
import { connectToGaiaHub, GaiaHubConfig } from 'blockstack'

const logger = log4js.getLogger('account/utils/blockstack-inc.js')

export function uploadPhotoToGaiaHub(api: {gaiaHubConfig: GaiaHubConfig },
identityIndex: number, identityAddress: string, photoFile: any, photoIndex: number) {
logger.trace('uploadPhotoToGaiaHub')
const hubConfig = api.gaiaHubConfig
const filename = `${identityIndex}/avatar-${photoIndex}`
return uploadToGaiaHub(filename, photoFile, hubConfig)
}

export function uploadProfileToGaiaHub(api: {gaiaHubConfig: GaiaHubConfig},
identityIndex: number, identityAddress: string, signedProfileTokenData: string) {
logger.trace('uploadProfileToGaiaHub')
const hubConfig = api.gaiaHubConfig
const filename = `${identityIndex}/profile.json`
return uploadToGaiaHub(filename, signedProfileTokenData, hubConfig, 'application/json')
}

export function redirectToConnectToGaiaHub() {
logger.trace('redirectToConnectToGaiaHub')
const port = location.port === '' ? 80 : location.port
Expand Down
Loading

0 comments on commit 906de2e

Please sign in to comment.