Skip to content

Commit afa93e9

Browse files
docs: add example of actual authenticated state in example app
1 parent 71cdbab commit afa93e9

File tree

1 file changed

+63
-49
lines changed

1 file changed

+63
-49
lines changed

example/index.js

+63-49
Original file line numberDiff line numberDiff line change
@@ -6,62 +6,76 @@ import ReactDOM from 'react-dom';
66
import { AppContext, AppProvider } from '@edx/frontend-platform/react';
77
import { initialize, getConfig, subscribe, APP_READY } from '@edx/frontend-platform';
88
import Header, { StudioHeader } from '@edx/frontend-component-header';
9+
import { Stack } from '@edx/paragon';
910

1011
import './index.scss';
1112

1213
subscribe(APP_READY, () => {
1314
ReactDOM.render(
1415
<AppProvider>
15-
{/* We can fake out authentication by including another provider here with the data we want */}
16-
<AppContext.Provider value={{
17-
authenticatedUser: null,
18-
config: getConfig(),
19-
}}>
20-
<Header />
21-
</AppContext.Provider>
22-
<h5 className="mt-2 mb-5">Logged out state</h5>
16+
<Stack gap={5}>
17+
{/* We can fake out authentication by including another provider here with the data we want, an unauthenticated user. */}
18+
<div>
19+
<h4>Logged out state</h4>
20+
<AppContext.Provider value={{
21+
authenticatedUser: null,
22+
config: getConfig(),
23+
}}>
24+
<Header />
25+
</AppContext.Provider>
26+
</div>
2327

24-
{/* We can fake out authentication by including another provider here with the data we want */}
25-
<AppContext.Provider value={{
26-
authenticatedUser: {
27-
userId: '123abc',
28-
username: 'testuser',
29-
roles: [],
30-
administrator: false,
31-
},
32-
config: getConfig(),
33-
}}>
34-
<Header />
35-
</AppContext.Provider>
36-
<h5 className="mt-2 mb-5">Logged in state</h5>
37-
<AppContext.Provider value={{
38-
authenticatedUser: {
39-
userId: '123abc',
40-
username: 'testuser',
41-
roles: [],
42-
administrator: false,
43-
},
44-
config: getConfig(),
45-
}}>
46-
<StudioHeader
47-
number="run123"
48-
org="testX"
49-
title="Course Name"
50-
isHiddenMainMenu={false}
51-
mainMenuDropdowns={[
52-
{
53-
id: 'content-dropdown',
54-
buttonTitle: 'Content',
55-
items: [{
56-
href: '#',
57-
title: 'Outline',
58-
}],
59-
},
60-
]}
61-
outlineLink="#"
62-
/>
63-
</AppContext.Provider>
64-
<h5 className="mt-2">Logged in state for Studio header</h5>
28+
{/* We can fake out authentication by including another provider here with the data we want, an authenticated user. */}
29+
<AppContext.Provider value={{
30+
authenticatedUser: {
31+
userId: '123abc',
32+
username: 'testuser',
33+
roles: [],
34+
administrator: false,
35+
},
36+
config: getConfig(),
37+
}}>
38+
{/* Default header */}
39+
<div>
40+
<h4>Logged in state</h4>
41+
<Header />
42+
</div>
43+
44+
{/* Studio header */}
45+
<div>
46+
<h4>Logged in state for Studio header</h4>
47+
<StudioHeader
48+
number="run123"
49+
org="testX"
50+
title="Course Name"
51+
isHiddenMainMenu={false}
52+
mainMenuDropdowns={[
53+
{
54+
id: 'content-dropdown',
55+
buttonTitle: 'Content',
56+
items: [{
57+
href: '#',
58+
title: 'Outline',
59+
}],
60+
},
61+
]}
62+
outlineLink="#"
63+
/>
64+
</div>
65+
</AppContext.Provider>
66+
67+
{/* Default header, using actual `AppContext` values */}
68+
<div>
69+
<h4>Actual logged in state</h4>
70+
<Header />
71+
<p className="small mt-2 px-2">
72+
If you are authenticated with the LMS (<code>edx-platform</code>), you will see the logged in state. Additionally, if
73+
you are an enterprise learner, you should see a custom logo and Dashboard links
74+
that direct you to http://localhost:8734 (<code>frontend-app-learner-portal-enterprise</code>). Otherwise,
75+
you will see the logged out state.
76+
</p>
77+
</div>
78+
</Stack>
6579
</AppProvider>,
6680
document.getElementById('root'),
6781
);

0 commit comments

Comments
 (0)