Skip to content
Permalink
Browse files

Extend the code to show core and crate version.

  • Loading branch information...
Vassyli committed Jul 22, 2016
1 parent 9d448d7 commit 12162e44e64915e16e3ea033ee0ad0b2cb260af4
Showing with 74 additions and 9 deletions.
  1. +43 −9 app/components/App.js
  2. +31 −0 app/components/Configuration.js
@@ -1,25 +1,59 @@
import React from 'react';
import Relay from 'react-relay';

import Configuration from './Configuration';

var Title = React.createClass({
render() {
return (
<h1>{this.props.val}</h1>
);
}
});

var Connection = React.createClass({
render() {
return (
<div>
Connected to {this.props.name}.
</div>
);
}
});

class App extends React.Component {
render() {
console.log(this.props)
return (
<div>
<h1>Daenerys Web Client</h1>
render() {
var Realm = this.props.viewer;

return (
<div>
Currently connected to <strong>{this.props.viewer.name}</strong> at <emph>{this.props.viewer.url}</emph>
<Title val="Daenerys Web client" />
<Connection name={Realm.name} />


<Configuration
type="core"
Lib={Realm.configuration.core}
/>
<Configuration
type="crate"
Lib={Realm.configuration.crate}
/>
</div>
</div>
);
}
);
}
}

export default Relay.createContainer(App, {
fragments: {
viewer: () => Relay.QL`
fragment on Realm {
name
url
configuration {
core {${Configuration.getFragment('Lib')}}
crate {${Configuration.getFragment('Lib')}}
}
}
`,
},
@@ -0,0 +1,31 @@
import React from 'react';
import Relay from 'react-relay';

class Configuration extends React.Component {
render() {
var lib = this.props.Lib;
var type = this.props.type;

if (type === "core") {
return (
<div>Core: Using {lib.library} in version {lib.version}</div>
);
}
else {
return (
<div>Crate: Using {lib.library} in version {lib.version}</div>
);
}
}
}

export default Relay.createContainer(Configuration, {
fragments: {
Lib: () => Relay.QL`
fragment on Library {
library
version
}
`,
},
});

0 comments on commit 12162e4

Please sign in to comment.
You can’t perform that action at this time.