Skip to content

Commit

Permalink
EPMRPP-EPMRPP-76242 || Extension point at login page (#3054)
Browse files Browse the repository at this point in the history
* EPMRPP-EPMRPP-76242 || Extension point at login page

* EPMRPP-EPMRPP-76242 || fixed error

* EPMRPP-EPMRPP-76242 || code review fixes - 2

* EPMRPP-76242 || code review fixes - 3

* EPMRPP-76242 || code review fixes - 4

* EPMRPP-76242 || code review fixes - 5

Co-authored-by: Artsiom Sadouski <artsiom_sadouski@epam.com>
  • Loading branch information
tr1ble and tr1ble authored Apr 5, 2022
1 parent 7b3edfb commit 9c3b349
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 8 deletions.
3 changes: 3 additions & 0 deletions app/src/controllers/plugins/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ export const availablePluginsSelector = createSelector(pluginsSelector, filterAv
export const enabledPluginNamesSelector = createSelector(pluginsSelector, (plugins) =>
filterEnabledPlugins(plugins).map((plugin) => plugin.name),
);
export const enabledPublicPluginNamesSelector = createSelector(publicPluginsSelector, (plugins) =>
filterEnabledPlugins(plugins).map((plugin) => plugin.name),
);

export const availableGroupedPluginsSelector = createSelector(
availablePluginsSelector,
Expand Down
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';
27 changes: 26 additions & 1 deletion app/src/controllers/plugins/uiExtensions/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,13 @@ 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 {
domainSelector,
enabledPluginNamesSelector,
enabledPublicPluginNamesSelector,
} from '../selectors';
import { uiExtensionMap } from './uiExtensionStorage';

export const extensionsLoadedSelector = (state) =>
Expand Down Expand Up @@ -44,6 +49,23 @@ export const createExtensionSelectorByType = (type) =>
},
);

export const createPublicExtensionSelectorByType = (type) =>
createSelector(
enabledPublicPluginNamesSelector,
extensionsMetadataSelector,
(pluginNames, extensionsMetadata) => {
const newExtensions = extensionsMetadata
.filter(({ pluginName }) => pluginNames.includes(pluginName))
.map(({ pluginName, scope, extensions }) =>
extensions.map((ext) => ({ ...ext, pluginName, scope })),
);

return newExtensions
.reduce((acc, val) => acc.concat(val), [])
.filter((extension) => extension.type === type);
},
);

export const uiExtensionSettingsTabsSelector = createExtensionSelectorByType(
EXTENSION_TYPE_SETTINGS_TAB,
);
Expand Down Expand Up @@ -72,3 +94,6 @@ export const uniqueErrorGridCellComponentSelector = createExtensionSelectorByTyp
export const uniqueErrorGridHeaderCellComponentSelector = createExtensionSelectorByType(
EXTENSION_TYPE_UNIQUE_ERROR_GRID_HEADER_CELL_COMPONENT,
);
export const uiExtensionLoginPageSelector = createPublicExtensionSelectorByType(
EXTENSION_TYPE_LOGIN_PAGE,
);
4 changes: 2 additions & 2 deletions app/src/pages/outside/loginPage/loginPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* 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';
Expand Down Expand Up @@ -77,8 +77,8 @@ export class LoginPage extends PureComponent {

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

let currentBlock = <LoginBlock />;
if (forgotPass) {
currentBlock = <ForgotPasswordBlock />;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@

import { defineMessages } from 'react-intl';
import { PageBlockContainer } from 'pages/outside/common/pageBlockContainer';
import { useSelector } from 'react-redux';
import React from 'react';
import { ExtensionLoader, extensionType } from 'components/extensionLoader';
import { uiExtensionLoginPageSelector } from 'controllers/plugins/uiExtensions';
import PropTypes from 'prop-types';
import { LoginForm } from './loginForm';

const messages = defineMessages({
Expand All @@ -29,8 +34,21 @@ const messages = defineMessages({
},
});

export const LoginBlock = () => (
<PageBlockContainer header={messages.welcome} hint={messages.login}>
<LoginForm />
</PageBlockContainer>
);
export const LoginBlock = () => {
const extensions = useSelector(uiExtensionLoginPageSelector);

return (
<PageBlockContainer header={messages.welcome} hint={messages.login}>
{extensions.map((extension) => (
<ExtensionLoader extension={extension} />
))}
<LoginForm />
</PageBlockContainer>
);
};
LoginBlock.propTypes = {
extensions: PropTypes.arrayOf(extensionType),
};
LoginBlock.defaultProps = {
extensions: [],
};

0 comments on commit 9c3b349

Please sign in to comment.