mirror of
https://github.com/ansible/awx.git
synced 2026-03-03 09:48:51 -03:30
add config pass-through to inline render
This commit is contained in:
31
src/App.jsx
31
src/App.jsx
@@ -24,9 +24,11 @@ class App extends Component {
|
|||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
ansible_version: null,
|
ansible_version: null,
|
||||||
version: null,
|
custom_virtualenvs: null,
|
||||||
isAboutModalOpen: false,
|
isAboutModalOpen: false,
|
||||||
isNavOpen,
|
isNavOpen,
|
||||||
|
version: null,
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
this.fetchConfig = this.fetchConfig.bind(this);
|
this.fetchConfig = this.fetchConfig.bind(this);
|
||||||
@@ -41,6 +43,17 @@ class App extends Component {
|
|||||||
this.fetchConfig();
|
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 () {
|
async onLogout () {
|
||||||
const { api } = this.props;
|
const { api } = this.props;
|
||||||
|
|
||||||
@@ -48,17 +61,6 @@ class App extends Component {
|
|||||||
window.location.replace('/#/login')
|
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 () {
|
onAboutModalOpen () {
|
||||||
this.setState({ isAboutModalOpen: true });
|
this.setState({ isAboutModalOpen: true });
|
||||||
}
|
}
|
||||||
@@ -78,10 +80,12 @@ class App extends Component {
|
|||||||
render () {
|
render () {
|
||||||
const {
|
const {
|
||||||
ansible_version,
|
ansible_version,
|
||||||
|
custom_virtualenvs,
|
||||||
isAboutModalOpen,
|
isAboutModalOpen,
|
||||||
isNavOpen,
|
isNavOpen,
|
||||||
version,
|
version,
|
||||||
} = this.state;
|
} = this.state;
|
||||||
|
|
||||||
const {
|
const {
|
||||||
render,
|
render,
|
||||||
routeGroups = [],
|
routeGroups = [],
|
||||||
@@ -90,6 +94,7 @@ class App extends Component {
|
|||||||
|
|
||||||
const config = {
|
const config = {
|
||||||
ansible_version,
|
ansible_version,
|
||||||
|
custom_virtualenvs,
|
||||||
version,
|
version,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -134,7 +139,7 @@ class App extends Component {
|
|||||||
}
|
}
|
||||||
>
|
>
|
||||||
<ConfigContext.Provider value={config}>
|
<ConfigContext.Provider value={config}>
|
||||||
{ render ? render({ routeGroups }) : '' }
|
{render && render({ routeGroups, config })}
|
||||||
</ConfigContext.Provider>
|
</ConfigContext.Provider>
|
||||||
</Page>
|
</Page>
|
||||||
<About
|
<About
|
||||||
|
|||||||
@@ -73,8 +73,7 @@ const catalogs = { en, ja };
|
|||||||
export async function main (render, api) {
|
export async function main (render, api) {
|
||||||
const el = document.getElementById('app');
|
const el = document.getElementById('app');
|
||||||
// fetch additional config from server
|
// fetch additional config from server
|
||||||
const { data } = await api.getRoot();
|
const { data: { custom_logo, custom_login_info } } = await api.getRoot();
|
||||||
const { custom_logo, custom_login_info } = data;
|
|
||||||
|
|
||||||
const loginRoutes = (
|
const loginRoutes = (
|
||||||
<Switch>
|
<Switch>
|
||||||
@@ -252,7 +251,7 @@ export async function main (render, api) {
|
|||||||
],
|
],
|
||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
render={({ routeGroups }) => (
|
render={({ routeGroups, config }) => (
|
||||||
routeGroups
|
routeGroups
|
||||||
.reduce((allRoutes, { routes }) => allRoutes.concat(routes), [])
|
.reduce((allRoutes, { routes }) => allRoutes.concat(routes), [])
|
||||||
.map(({ component: PageComponent, path }) => (
|
.map(({ component: PageComponent, path }) => (
|
||||||
@@ -263,6 +262,7 @@ export async function main (render, api) {
|
|||||||
<PageComponent
|
<PageComponent
|
||||||
api={api}
|
api={api}
|
||||||
match={match}
|
match={match}
|
||||||
|
{...config}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
|
|||||||
Reference in New Issue
Block a user