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

Commit

Permalink
Merge pull request #7100 from paritytech/jg-dapp-localUrl
Browse files Browse the repository at this point in the history
Local dapp development URL
  • Loading branch information
debris committed Nov 21, 2017
2 parents d160fee + e7543f6 commit 3092543
Show file tree
Hide file tree
Showing 11 changed files with 56 additions and 8 deletions.
4 changes: 4 additions & 0 deletions dapps/src/apps/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ pub struct App {
pub author: String,
#[serde(rename="iconUrl")]
pub icon_url: String,
#[serde(rename="localUrl")]
pub local_url: Option<String>,
}

impl App {
Expand All @@ -38,6 +40,7 @@ impl App {
version: info.version.to_owned(),
author: info.author.to_owned(),
icon_url: info.icon_url.to_owned(),
local_url: info.local_url.to_owned(),
}
}
}
Expand All @@ -50,6 +53,7 @@ impl Into<EndpointInfo> for App {
version: self.version,
author: self.author,
icon_url: self.icon_url,
local_url: self.local_url,
}
}
}
1 change: 1 addition & 0 deletions dapps/src/apps/fetcher/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,7 @@ mod tests {
version: "".into(),
author: "".into(),
icon_url: "".into(),
local_url: "".into(),
}, Default::default(), None);

// when
Expand Down
1 change: 1 addition & 0 deletions dapps/src/apps/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ fn read_manifest(name: &str, mut path: PathBuf) -> EndpointInfo {
version: "0.0.0".into(),
author: "?".into(),
icon_url: "icon.png".into(),
local_url: None,
}
})
}
Expand Down
1 change: 1 addition & 0 deletions dapps/src/endpoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ pub struct EndpointInfo {
pub version: String,
pub author: String,
pub icon_url: String,
pub local_url: Option<String>,
}

pub type Endpoints = BTreeMap<String, Box<Endpoint>>;
Expand Down
1 change: 1 addition & 0 deletions dapps/src/page/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ impl From<Info> for EndpointInfo {
description: info.description.into(),
author: info.author.into(),
icon_url: info.icon_url.into(),
local_url: None,
version: info.version.into(),
}
}
Expand Down
35 changes: 32 additions & 3 deletions js/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@
"lodash.uniq": "4.5.0",
"material-ui": "0.16.5",
"prop-types": "15.5.10",
"query-string": "5.0.1",
"react": "15.6.1",
"react-dom": "15.6.1",
"react-intl": "2.1.5",
Expand Down
4 changes: 3 additions & 1 deletion js/src/Dapp/dapp.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,9 @@ export default class Dapp extends Component {

switch (app.type) {
case 'local':
src = `${dappsUrl}/${app.id}/`;
src = app.localUrl
? `${app.localUrl}?appId=${app.id}`
: `${dappsUrl}/${app.id}/`;
break;

case 'network':
Expand Down
9 changes: 6 additions & 3 deletions js/src/inject.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,19 @@
// along with Parity. If not, see <http://www.gnu.org/licenses/>.

import Api from '@parity/api';
import qs from 'query-string';
import Web3 from 'web3';

import web3extensions from './web3.extensions';

function initProvider () {
const parts = window.location.pathname.split('/');
let appId = parts[1];
const path = window.location.pathname.split('/');
const query = qs.parse(window.location.search);

let appId = path[1] || query.appId;

if (appId === 'dapps') {
appId = parts[2];
appId = path[2];
} else if (!Api.util.isHex(appId)) {
appId = Api.util.sha3(appId);
}
Expand Down
1 change: 1 addition & 0 deletions parity/dapps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@ mod server {
version: app.version,
author: app.author,
icon_url: app.icon_url,
local_url: app.local_url,
})
.collect()
}
Expand Down
6 changes: 5 additions & 1 deletion rpc/src/v1/types/dapps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ pub struct LocalDapp {
/// Dapp icon
#[serde(rename="iconUrl")]
pub icon_url: String,
/// Local development Url
#[serde(rename="localUrl")]
pub local_url: Option<String>,
}

#[cfg(test)]
Expand All @@ -40,7 +43,7 @@ mod tests {

#[test]
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 {
id: "skeleton".into(),
Expand All @@ -49,6 +52,7 @@ mod tests {
version: "0.1".into(),
author: "Parity Technologies Ltd".into(),
icon_url: "title.png".into(),
local_url: "http://localhost:5000".into(),
};

let serialized = serde_json::to_string(&dapp).unwrap();
Expand Down

0 comments on commit 3092543

Please sign in to comment.