Merge pull request #7100 from paritytech/jg-dapp-localUrl

Local dapp development URL
This commit is contained in:
Marek Kotewicz 2017-11-21 20:42:51 +01:00 committed by GitHub
commit 309254348b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 56 additions and 8 deletions

View File

@ -26,6 +26,8 @@ pub struct App {
pub author: String, pub author: String,
#[serde(rename="iconUrl")] #[serde(rename="iconUrl")]
pub icon_url: String, pub icon_url: String,
#[serde(rename="localUrl")]
pub local_url: Option<String>,
} }
impl App { impl App {
@ -38,6 +40,7 @@ impl App {
version: info.version.to_owned(), version: info.version.to_owned(),
author: info.author.to_owned(), author: info.author.to_owned(),
icon_url: info.icon_url.to_owned(), icon_url: info.icon_url.to_owned(),
local_url: info.local_url.to_owned(),
} }
} }
} }
@ -50,6 +53,7 @@ impl Into<EndpointInfo> for App {
version: self.version, version: self.version,
author: self.author, author: self.author,
icon_url: self.icon_url, icon_url: self.icon_url,
local_url: self.local_url,
} }
} }
} }

View File

@ -306,6 +306,7 @@ mod tests {
version: "".into(), version: "".into(),
author: "".into(), author: "".into(),
icon_url: "".into(), icon_url: "".into(),
local_url: "".into(),
}, Default::default(), None); }, Default::default(), None);
// when // when

View File

@ -56,6 +56,7 @@ fn read_manifest(name: &str, mut path: PathBuf) -> EndpointInfo {
version: "0.0.0".into(), version: "0.0.0".into(),
author: "?".into(), author: "?".into(),
icon_url: "icon.png".into(), icon_url: "icon.png".into(),
local_url: None,
} }
}) })
} }

View File

@ -44,6 +44,7 @@ pub struct EndpointInfo {
pub version: String, pub version: String,
pub author: String, pub author: String,
pub icon_url: String, pub icon_url: String,
pub local_url: Option<String>,
} }
pub type Endpoints = BTreeMap<String, Box<Endpoint>>; pub type Endpoints = BTreeMap<String, Box<Endpoint>>;

View File

@ -132,6 +132,7 @@ impl From<Info> for EndpointInfo {
description: info.description.into(), description: info.description.into(),
author: info.author.into(), author: info.author.into(),
icon_url: info.icon_url.into(), icon_url: info.icon_url.into(),
local_url: None,
version: info.version.into(), version: info.version.into(),
} }
} }

35
js/package-lock.json generated
View File

@ -3147,6 +3147,11 @@
"resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz", "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz",
"integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=" "integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA="
}, },
"decode-uri-component": {
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/decode-uri-component/-/decode-uri-component-0.2.0.tgz",
"integrity": "sha1-6zkTMzRYd1y4TNGh+uBiEGu4dUU="
},
"deep-eql": { "deep-eql": {
"version": "0.1.3", "version": "0.1.3",
"resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-0.1.3.tgz", "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-0.1.3.tgz",
@ -5942,6 +5947,17 @@
"loose-envify": "1.3.1", "loose-envify": "1.3.1",
"query-string": "4.3.4", "query-string": "4.3.4",
"warning": "3.0.0" "warning": "3.0.0"
},
"dependencies": {
"query-string": {
"version": "4.3.4",
"resolved": "https://registry.npmjs.org/query-string/-/query-string-4.3.4.tgz",
"integrity": "sha1-u7aTucqRXCMlFbIosaArYJBD2+s=",
"requires": {
"object-assign": "4.1.1",
"strict-uri-encode": "1.1.0"
}
}
} }
}, },
"hmac-drbg": { "hmac-drbg": {
@ -8261,6 +8277,18 @@
"prepend-http": "1.0.4", "prepend-http": "1.0.4",
"query-string": "4.3.4", "query-string": "4.3.4",
"sort-keys": "1.1.2" "sort-keys": "1.1.2"
},
"dependencies": {
"query-string": {
"version": "4.3.4",
"resolved": "https://registry.npmjs.org/query-string/-/query-string-4.3.4.tgz",
"integrity": "sha1-u7aTucqRXCMlFbIosaArYJBD2+s=",
"dev": true,
"requires": {
"object-assign": "4.1.1",
"strict-uri-encode": "1.1.0"
}
}
} }
}, },
"npm-run-path": { "npm-run-path": {
@ -9907,10 +9935,11 @@
"integrity": "sha512-eRzhrN1WSINYCDCbrz796z37LOe3m5tmW7RQf6oBntukAG1nmovJvhnwHHRMAfeoItc1m2Hk02WER2aQ/iqs+A==" "integrity": "sha512-eRzhrN1WSINYCDCbrz796z37LOe3m5tmW7RQf6oBntukAG1nmovJvhnwHHRMAfeoItc1m2Hk02WER2aQ/iqs+A=="
}, },
"query-string": { "query-string": {
"version": "4.3.4", "version": "5.0.1",
"resolved": "https://registry.npmjs.org/query-string/-/query-string-4.3.4.tgz", "resolved": "https://registry.npmjs.org/query-string/-/query-string-5.0.1.tgz",
"integrity": "sha1-u7aTucqRXCMlFbIosaArYJBD2+s=", "integrity": "sha512-aM+MkQClojlNiKkO09tiN2Fv8jM/L7GWIjG2liWeKljlOdOPNWr+bW3KQ+w5V/uKprpezC7fAsAMsJtJ+2rLKA==",
"requires": { "requires": {
"decode-uri-component": "0.2.0",
"object-assign": "4.1.1", "object-assign": "4.1.1",
"strict-uri-encode": "1.1.0" "strict-uri-encode": "1.1.0"
} }

View File

@ -158,6 +158,7 @@
"lodash.uniq": "4.5.0", "lodash.uniq": "4.5.0",
"material-ui": "0.16.5", "material-ui": "0.16.5",
"prop-types": "15.5.10", "prop-types": "15.5.10",
"query-string": "5.0.1",
"react": "15.6.1", "react": "15.6.1",
"react-dom": "15.6.1", "react-dom": "15.6.1",
"react-intl": "2.1.5", "react-intl": "2.1.5",

View File

@ -110,7 +110,9 @@ export default class Dapp extends Component {
switch (app.type) { switch (app.type) {
case 'local': case 'local':
src = `${dappsUrl}/${app.id}/`; src = app.localUrl
? `${app.localUrl}?appId=${app.id}`
: `${dappsUrl}/${app.id}/`;
break; break;
case 'network': case 'network':

View File

@ -15,16 +15,19 @@
// along with Parity. If not, see <http://www.gnu.org/licenses/>. // along with Parity. If not, see <http://www.gnu.org/licenses/>.
import Api from '@parity/api'; import Api from '@parity/api';
import qs from 'query-string';
import Web3 from 'web3'; import Web3 from 'web3';
import web3extensions from './web3.extensions'; import web3extensions from './web3.extensions';
function initProvider () { function initProvider () {
const parts = window.location.pathname.split('/'); const path = window.location.pathname.split('/');
let appId = parts[1]; const query = qs.parse(window.location.search);
let appId = path[1] || query.appId;
if (appId === 'dapps') { if (appId === 'dapps') {
appId = parts[2]; appId = path[2];
} else if (!Api.util.isHex(appId)) { } else if (!Api.util.isHex(appId)) {
appId = Api.util.sha3(appId); appId = Api.util.sha3(appId);
} }

View File

@ -295,6 +295,7 @@ mod server {
version: app.version, version: app.version,
author: app.author, author: app.author,
icon_url: app.icon_url, icon_url: app.icon_url,
local_url: app.local_url,
}) })
.collect() .collect()
} }

View File

@ -31,6 +31,9 @@ pub struct LocalDapp {
/// Dapp icon /// Dapp icon
#[serde(rename="iconUrl")] #[serde(rename="iconUrl")]
pub icon_url: String, pub icon_url: String,
/// Local development Url
#[serde(rename="localUrl")]
pub local_url: Option<String>,
} }
#[cfg(test)] #[cfg(test)]
@ -40,7 +43,7 @@ mod tests {
#[test] #[test]
fn dapp_serialization() { fn dapp_serialization() {
let s = r#"{"id":"skeleton","name":"Skeleton","description":"A skeleton dapp","version":"0.1","author":"Parity Technologies Ltd","iconUrl":"title.png"}"#; let s = r#"{"id":"skeleton","name":"Skeleton","description":"A skeleton dapp","version":"0.1","author":"Parity Technologies Ltd","iconUrl":"title.png","localUrl":"http://localhost:5000"}"#;
let dapp = LocalDapp { let dapp = LocalDapp {
id: "skeleton".into(), id: "skeleton".into(),
@ -49,6 +52,7 @@ mod tests {
version: "0.1".into(), version: "0.1".into(),
author: "Parity Technologies Ltd".into(), author: "Parity Technologies Ltd".into(),
icon_url: "title.png".into(), icon_url: "title.png".into(),
local_url: "http://localhost:5000".into(),
}; };
let serialized = serde_json::to_string(&dapp).unwrap(); let serialized = serde_json::to_string(&dapp).unwrap();