diff --git a/src/App.jsx b/src/App.jsx index 04ca8c740f..e0e162e07b 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -24,9 +24,11 @@ class App extends Component { this.state = { ansible_version: null, - version: null, + custom_virtualenvs: null, isAboutModalOpen: false, isNavOpen, + version: null, + }; this.fetchConfig = this.fetchConfig.bind(this); @@ -41,6 +43,17 @@ class App extends Component { this.fetchConfig(); } + async fetchConfig () { + const { api } = this.props; + + try { + const { data: { ansible_version, custom_virtualenvs, version } } = await api.getConfig(); + this.setState({ ansible_version, custom_virtualenvs, version }); + } catch (err) { + this.setState({ ansible_version: null, custom_virtualenvs: null, version: null }); + } + } + async onLogout () { const { api } = this.props; @@ -48,17 +61,6 @@ class App extends Component { window.location.replace('/#/login') } - async fetchConfig () { - const { api } = this.props; - - try { - const { data: { ansible_version, version } } = await api.getConfig(); - this.setState({ ansible_version, version }); - } catch (err) { - this.setState({ ansible_version: null, version: null }); - } - } - onAboutModalOpen () { this.setState({ isAboutModalOpen: true }); } @@ -78,10 +80,12 @@ class App extends Component { render () { const { ansible_version, + custom_virtualenvs, isAboutModalOpen, isNavOpen, version, } = this.state; + const { render, routeGroups = [], @@ -90,6 +94,7 @@ class App extends Component { const config = { ansible_version, + custom_virtualenvs, version, }; @@ -134,7 +139,7 @@ class App extends Component { } > - { render ? render({ routeGroups }) : '' } + {render && render({ routeGroups, config })} @@ -252,7 +251,7 @@ export async function main (render, api) { ], }, ]} - render={({ routeGroups }) => ( + render={({ routeGroups, config }) => ( routeGroups .reduce((allRoutes, { routes }) => allRoutes.concat(routes), []) .map(({ component: PageComponent, path }) => ( @@ -263,6 +262,7 @@ export async function main (render, api) { )} />