* refactor: rename SiteHeader to Header * build: use frontend-build * fix: ensure that we can handle anonymous users * feat: anonymous header works now Up until now we haven’t had any microfrontends that allowed anonymous usage. The Header was encountering errors rendering in such situations, though it was close. Now it properly shows the Login and Sign Up buttons. * build: bump version of frontend-build
43 lines
1.2 KiB
JavaScript
43 lines
1.2 KiB
JavaScript
import 'babel-polyfill';
|
|
|
|
import React from 'react';
|
|
import ReactDOM from 'react-dom';
|
|
import { App, AppContext, APP_READY, AppProvider } from '@edx/frontend-base';
|
|
import { NewRelicLoggingService } from '@edx/frontend-logging';
|
|
import './index.scss';
|
|
import Header from '../src/';
|
|
|
|
App.subscribe(APP_READY, () => {
|
|
ReactDOM.render(
|
|
<AppProvider>
|
|
{/* We can fake out authentication by including another provider here with the data we want */}
|
|
<AppContext.Provider value={{
|
|
authenticatedUser: null,
|
|
config: App.config
|
|
}}>
|
|
<Header />
|
|
</AppContext.Provider>
|
|
<h5 className="mt-2 mb-5">Logged out state</h5>
|
|
|
|
{/* We can fake out authentication by including another provider here with the data we want */}
|
|
<AppContext.Provider value={{
|
|
authenticatedUser: {
|
|
userId: '123abc',
|
|
username: 'testuser',
|
|
roles: [],
|
|
administrator: false,
|
|
},
|
|
config: App.config
|
|
}}>
|
|
<Header />
|
|
</AppContext.Provider>
|
|
<h5 className="mt-2">Logged in state</h5>
|
|
</AppProvider>,
|
|
document.getElementById('root'),
|
|
);
|
|
});
|
|
|
|
App.initialize({
|
|
messages: []
|
|
});
|