Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EPMRPP-76242 || Sign up extension point at login page #3054

Merged
merged 6 commits into from
Apr 5, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/src/controllers/plugins/uiExtensions/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export const EXTENSION_TYPE_UNIQUE_ERROR_GRID_CELL_COMPONENT =
'uiExtension:uniqueErrorGridCellComponent';
export const EXTENSION_TYPE_UNIQUE_ERROR_GRID_HEADER_CELL_COMPONENT =
'uiExtension:uniqueErrorGridHeaderCellComponent';
export const EXTENSION_TYPE_LOGIN_PAGE = 'uiExtension:loginPage';

export const COMMAND_GET_FILE = 'getFile';
export const COMMAND_GET_ISSUE_TYPES = 'getIssueTypes';
Expand Down
1 change: 1 addition & 0 deletions app/src/controllers/plugins/uiExtensions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ export {
uiExtensionPostIssueFormSelector,
uniqueErrorGridCellComponentSelector,
uniqueErrorGridHeaderCellComponentSelector,
uiExtensionLoginPageSelector,
} from './selectors';
export { uiExtensionsReducer } from './reducer';
4 changes: 4 additions & 0 deletions app/src/controllers/plugins/uiExtensions/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
EXTENSION_TYPE_POST_ISSUE_FORM,
EXTENSION_TYPE_UNIQUE_ERROR_GRID_CELL_COMPONENT,
EXTENSION_TYPE_UNIQUE_ERROR_GRID_HEADER_CELL_COMPONENT,
EXTENSION_TYPE_LOGIN_PAGE,
} from './constants';
import { domainSelector, enabledPluginNamesSelector } from '../selectors';
import { uiExtensionMap } from './uiExtensionStorage';
Expand Down Expand Up @@ -72,3 +73,6 @@ export const uniqueErrorGridCellComponentSelector = createExtensionSelectorByTyp
export const uniqueErrorGridHeaderCellComponentSelector = createExtensionSelectorByType(
EXTENSION_TYPE_UNIQUE_ERROR_GRID_HEADER_CELL_COMPONENT,
);
export const uiExtensionLoginPageSelector = createExtensionSelectorByType(
AmsterGet marked this conversation as resolved.
Show resolved Hide resolved
EXTENSION_TYPE_LOGIN_PAGE,
);
42 changes: 37 additions & 5 deletions app/src/pages/outside/loginPage/loginPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,16 @@
* limitations under the License.
*/

import { PureComponent } from 'react';
import React, { PureComponent } from 'react';
import track from 'react-tracking';
import classNames from 'classnames/bind';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { referenceDictionary, connectRouter } from 'common/utils';
import { LOGIN_PAGE } from 'components/main/analytics/events';
import { showDefaultErrorNotification } from 'controllers/notification';
import { ExtensionLoader, extensionType } from 'components/extensionLoader';
import { uiExtensionLoginPageSelector } from 'controllers/plugins/uiExtensions';
import styles from './loginPage.scss';
import { LoginPageSection } from './loginPageSection';
import { SocialSection } from './socialSection';
Expand All @@ -39,9 +41,14 @@ const cx = classNames.bind(styles);
errorAuth,
multipleAuth,
}))
@connect(null, {
showDefaultErrorNotification,
})
@connect(
(state) => ({
extensions: uiExtensionLoginPageSelector(state),
}),
{
showDefaultErrorNotification,
},
)
@track({ page: LOGIN_PAGE })
export class LoginPage extends PureComponent {
static propTypes = {
Expand All @@ -50,13 +57,15 @@ export class LoginPage extends PureComponent {
errorAuth: PropTypes.string,
multipleAuth: PropTypes.string,
showDefaultErrorNotification: PropTypes.func,
extensions: PropTypes.arrayOf(extensionType),
};
static defaultProps = {
forgotPass: '',
reset: '',
errorAuth: '',
multipleAuth: '',
showDefaultErrorNotification: () => {},
extensions: [],
};

componentDidMount() {
Expand All @@ -77,8 +86,9 @@ export class LoginPage extends PureComponent {

getCurrentBlock = () => {
const { forgotPass, reset, multipleAuth } = this.props;
let currentBlock = <LoginBlock />;
const extensions = this.getLoginPageExtensions();

let currentBlock = <LoginBlock />;
AmsterGet marked this conversation as resolved.
Show resolved Hide resolved
if (forgotPass) {
currentBlock = <ForgotPasswordBlock />;
}
Expand All @@ -88,10 +98,32 @@ export class LoginPage extends PureComponent {
if (multipleAuth) {
currentBlock = <MultipleAuthBlock multipleAuthKey={multipleAuth} />;
}
// TODO constant
if (extensions.signUp) {
currentBlock = extensions.signUp.component;
}

return currentBlock;
};

getLoginPageExtensions = () => {
const { extensions } = this.props;

return extensions.reduce(
(acc, extension) => ({
...acc,
[extension.name]: {
name: extension.title || extension.name,
// TODO link generation
link: '/signUp',
component: <ExtensionLoader extension={extension} />,
mobileDisabled: true,
},
}),
{},
);
};

render() {
const currentBlock = this.getCurrentBlock();

Expand Down