@@ -5,16 +5,92 @@ import WatchedQueries from "./WatchedQueries";
55import Mutations from "./Mutations" ;
66import Explorer from "./Explorer" ;
77import Inspector from "./Inspector" ;
8- import Logger from "./Logger" ;
98import { Sidebar } from "./Sidebar" ;
109
1110import Apollo from "./Images/Apollo" ;
1211import GraphQL from "./Images/GraphQL" ;
13- import Store from "./Images/Store" ;
12+ import Cache from "./Images/Store" ;
1413import Queries from "./Images/Queries" ;
1514
1615import "../style.less" ;
1716
17+ const Shell = ( { children } ) => (
18+ < div
19+ style = { {
20+ backgroundImage :
21+ "linear-gradient(174deg,#1c2945 0,#2d4d5a 54%,#436a75 81%,#448b8e 100%)" ,
22+ display : "flex" ,
23+ alignItems : "center" ,
24+ justifyContent : "center" ,
25+ position : "absolute" ,
26+ top : 0 ,
27+ bottom : 0 ,
28+ left : 0 ,
29+ right : 0 ,
30+ } }
31+ >
32+ < div style = { { maxWidth : "50%" } } > { children } </ div >
33+ </ div >
34+ ) ;
35+
36+ const UpgradeNotice = ( { version } ) => (
37+ < Shell >
38+ < h1 style = { { color : "white" } } > Your Apollo Client needs updating!</ h1 >
39+ < h3 style = { { color : "white" } } >
40+ We've detected your version of Apollo Client to be v{ version } . The Apollo
41+ Devtools requires version 2.0.0 or greater. Luckily, upgrading is pretty
42+ painless and brings a whole bunch of new features! To learn how to
43+ upgrade, check out the migration guide{ " " }
44+ < a
45+ style = { { color : "white" } }
46+ href = "https://www.apollographql.com/docs/react/2.0-migration.html"
47+ target = "_blank"
48+ >
49+ here!
50+ </ a >
51+ </ h3 >
52+ < h3 style = { { color : "white" } } >
53+ To continue using the Devtools with v{ version } , check out this guide to
54+ < a
55+ style = { { color : "white" } }
56+ href = "https://github.com/apollographql/apollo-client-devtools#previous"
57+ target = "_blank"
58+ >
59+ using the previous version
60+ </ a >
61+ </ h3 >
62+ </ Shell >
63+ ) ;
64+
65+ const Loading = ( ) => (
66+ < Shell >
67+ < h2 style = { { color : "white" } } > Connecting to Apollo Client...</ h2 >
68+ </ Shell >
69+ ) ;
70+
71+ const NotFound = ( ) => (
72+ < Shell >
73+ < h1 style = { { color : "white" } } >
74+ We couldn't detect Apollo Client in your app!
75+ </ h1 >
76+ < h3 style = { { color : "white" } } >
77+ To use the Apollo Devtools, make sure that < code > connectToDevTools</ code > { " " }
78+ is not disabled. To learn more about setting up Apollo Client to work with
79+ the Devtools, checkout this{ " " }
80+ < a
81+ style = { { color : "white" } }
82+ href = "https://github.com/apollographql/apollo-client-devtools#configuration"
83+ target = "_blank"
84+ >
85+ link!
86+ </ a > { " " }
87+ The Devtools are turned off by default when running in production. To
88+ manually turn them on, set < code > connectToDevTools</ code > to be{ " " }
89+ < code > true</ code >
90+ </ h3 >
91+ </ Shell >
92+ ) ;
93+
1894export default class Panel extends Component {
1995 constructor ( props , context ) {
2096 super ( props , context ) ;
@@ -24,13 +100,17 @@ export default class Panel extends Component {
24100 tabData : { } ,
25101 runQuery : undefined ,
26102 runVariables : undefined ,
27- selectedRequestId : undefined ,
103+ version : undefined ,
28104 automaticallyRunQuery : undefined ,
105+ // assume success
106+ notFound : false ,
29107 } ;
30108
31- this . props . bridge . on ( "ready" , ( ) => {
109+ this . props . bridge . on ( "ready" , version => {
110+ this . setState ( { version } ) ;
32111 this . props . bridge . send ( "panel:ready" , "ready" ) ;
33112 } ) ;
113+
34114 this . props . bridge . on ( "broadcast:new" , _data => {
35115 const data = JSON . parse ( _data ) ;
36116 this . setState ( ( { tabData } ) => ( {
@@ -39,8 +119,15 @@ export default class Panel extends Component {
39119 } ) ;
40120 }
41121
122+ componentDidMount ( ) {
123+ this . _timeout = setTimeout ( ( ) => {
124+ if ( this . state . version ) return ;
125+ this . setState ( { notFound : true } ) ;
126+ } , 10000 ) ;
127+ }
128+
42129 componentWillUnmount ( ) {
43- clearTimeout ( this . _interval ) ;
130+ clearTimeout ( this . _timeout ) ;
44131 }
45132
46133 onRun = ( queryString , variables , tab , automaticallyRunQuery ) => {
@@ -63,10 +150,11 @@ export default class Panel extends Component {
63150 } ) ;
64151 } ;
65152
66- selectLogItem = id => this . setState ( { selectedRequestId : id } ) ;
67-
68153 render ( ) {
69- const { active, tabData } = this . state ;
154+ const { active, tabData, version, notFound } = this . state ;
155+ if ( notFound ) return < NotFound /> ;
156+ if ( ! version ) return < Loading /> ;
157+ if ( Number ( version [ 0 ] ) === 1 ) return < UpgradeNotice version = { version } /> ;
70158 let body ;
71159 switch ( active ) {
72160 case "queries" :
@@ -86,14 +174,7 @@ export default class Panel extends Component {
86174 query = { this . state . runQuery }
87175 variables = { this . state . runVariables }
88176 automaticallyRunQuery = { this . state . automaticallyRunQuery }
89- />
90- ) ;
91- break ;
92- case "logger" :
93- body = (
94- < Logger
95- onSelectLogItem = { this . selectLogItem }
96- selectedId = { this . state . selectedRequestId }
177+ theme = { this . props . theme }
97178 />
98179 ) ;
99180 break ;
@@ -119,15 +200,15 @@ export default class Panel extends Component {
119200 onClick = { ( ) => this . switchPane ( "graphiql" ) }
120201 >
121202 < GraphQL />
122- < div > GraphiQL</ div >
203+ < h4 > GraphiQL</ h4 >
123204 </ div >
124205 < div
125206 title = "Watched queries"
126207 className = { classnames ( "tab" , { active : active === "queries" } ) }
127208 onClick = { ( ) => this . switchPane ( "queries" ) }
128209 >
129210 < Queries />
130- < div > Queries</ div >
211+ < h4 > Queries</ h4 >
131212 </ div >
132213
133214 < div
@@ -136,15 +217,15 @@ export default class Panel extends Component {
136217 onClick = { ( ) => this . switchPane ( "mutations" ) }
137218 >
138219 < Queries />
139- < div > Mutations</ div >
220+ < h4 > Mutations</ h4 >
140221 </ div >
141222 < div
142223 title = "Apollo client store"
143224 className = { classnames ( "tab" , { active : active === "store" } ) }
144225 onClick = { ( ) => this . switchPane ( "store" ) }
145226 >
146- < Store />
147- < div > Store </ div >
227+ < Cache />
228+ < h4 > Cache </ h4 >
148229 </ div >
149230 </ Sidebar >
150231 { body }
0 commit comments