Skip to content

Commit 8dc612c

Browse files
committed
fixup! fixup! feat: Add plugin slot for login page
1 parent 55d04eb commit 8dc612c

File tree

5 files changed

+63
-12
lines changed

5 files changed

+63
-12
lines changed

src/logistration/Logistration.jsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import {
2525
getTpaHint, getTpaProvider, updatePathWithQueryParams,
2626
} from '../data/utils';
2727
import { backupLoginForm } from '../login/data/actions';
28-
import LoginPageSlot from '../plugin-slots/LoginPage';
28+
import LoginComponentSlot from '../plugin-slots/LoginComponentSlot';
2929
import { RegistrationPage } from '../register';
3030
import { backupRegistrationForm } from '../register/data/actions';
3131

@@ -116,7 +116,7 @@ const Logistration = ({
116116
{!institutionLogin && (
117117
<h3 className="mb-4.5">{formatMessage(messages['logistration.sign.in'])}</h3>
118118
)}
119-
<LoginPageSlot institutionLogin={institutionLogin} handleInstitutionLogin={handleInstitutionLogin} />
119+
<LoginComponentSlot institutionLogin={institutionLogin} handleInstitutionLogin={handleInstitutionLogin} />
120120
</div>
121121
</>
122122
)
@@ -149,7 +149,7 @@ const Logistration = ({
149149
)}
150150
{selectedPage === LOGIN_PAGE
151151
? (
152-
<LoginPageSlot
152+
<LoginComponentSlot
153153
institutionLogin={institutionLogin}
154154
handleInstitutionLogin={handleInstitutionLogin}
155155
/>
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Login Component Slot
2+
3+
### Slot ID: `org.openedx.frontend.authn.login_component.v1`
4+
5+
### Slot ID Aliases
6+
* `login_component_slot`
7+
8+
## Description
9+
10+
This slot is used to replace/modify/hide the login component.
11+
12+
## Example
13+
14+
### Default content
15+
![Default Login Page](./default_component.png)
16+
17+
### With a prepended message
18+
![Login Page with ](./component_with_prefix.png)
19+
20+
The following `env.config.jsx` will add a message before the login component.
21+
22+
```js
23+
import { DIRECT_PLUGIN, PLUGIN_OPERATIONS } from '@openedx/frontend-plugin-framework';
24+
25+
// Load environment variables from .env file
26+
const config = {
27+
...process.env,
28+
pluginSlots: {
29+
'org.openedx.frontend.authn.login_component.v1': {
30+
keepDefault: true,
31+
plugins: [
32+
{
33+
op: PLUGIN_OPERATIONS.Insert,
34+
widget: {
35+
id: 'test_plugin',
36+
type: DIRECT_PLUGIN,
37+
priority: 1,
38+
RenderWidget: () => (
39+
<h2>You're logging into TEST Instance.</h2>
40+
)
41+
},
42+
},
43+
],
44+
},
45+
},
46+
};
47+
48+
export default config;
49+
50+
```
13.4 KB
Loading
7.84 KB
Loading
Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,22 @@
11
import React from 'react';
22

33
import { PluginSlot } from '@openedx/frontend-plugin-framework';
4-
import PropTypes from 'prop-types';
54

65
import LoginPage from '../../login/LoginPage';
76

8-
const LoginPageSlot = ({
7+
const LoginComponentSlot = ({
98
institutionLogin,
109
handleInstitutionLogin,
10+
}: {
11+
institutionLogin: boolean,
12+
handleInstitutionLogin: (value: boolean) => void,
1113
}) => (
1214
<PluginSlot
13-
id="login_page_slot"
15+
id="org.openedx.frontend.authn.login_component.v1"
16+
pluginProps={{
17+
isInstitutionLogin: institutionLogin,
18+
setInstitutionLogin: handleInstitutionLogin,
19+
}}
1420
>
1521
<LoginPage
1622
institutionLogin={institutionLogin}
@@ -19,9 +25,4 @@ const LoginPageSlot = ({
1925
</PluginSlot>
2026
);
2127

22-
LoginPageSlot.propTypes = {
23-
institutionLogin: PropTypes.bool.isRequired,
24-
handleInstitutionLogin: PropTypes.func.isRequired,
25-
};
26-
27-
export default LoginPageSlot;
28+
export default LoginComponentSlot;

0 commit comments

Comments
 (0)