From d24c5bd54b1a9600be467c02e8bd3626dfd779b8 Mon Sep 17 00:00:00 2001 From: Andrey Savihin Date: Thu, 12 Sep 2019 11:38:04 +0300 Subject: [PATCH 1/5] grammar fix --- products/ASC.People/Client/src/components/Layout/index.js | 2 +- web/ASC.Web.Client/src/components/Layout/index.js | 2 +- web/ASC.Web.Components/src/components/layout/index.js | 4 ++-- .../src/components/layout/layout.stories.js | 8 ++++---- .../src/components/layout/sub-components/nav-item.js | 8 ++++---- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/products/ASC.People/Client/src/components/Layout/index.js b/products/ASC.People/Client/src/components/Layout/index.js index e6f7e21fdf..0bf85bced6 100644 --- a/products/ASC.People/Client/src/components/Layout/index.js +++ b/products/ASC.People/Client/src/components/Layout/index.js @@ -67,7 +67,7 @@ class PurePeopleLayout extends React.Component { const getAvailableModules = (modules) => { - const separator = { seporator: true, id: 'nav-seporator-1' }; + const separator = { separator: true, id: 'nav-separator-1' }; const products = modules.map(product => { return { id: product.id, diff --git a/web/ASC.Web.Client/src/components/Layout/index.js b/web/ASC.Web.Client/src/components/Layout/index.js index 1113a8f8f6..9842b42db1 100644 --- a/web/ASC.Web.Client/src/components/Layout/index.js +++ b/web/ASC.Web.Client/src/components/Layout/index.js @@ -66,7 +66,7 @@ class PureStudioLayout extends React.Component { const getAvailableModules = modules => { - const separator = { seporator: true, id: "nav-seporator-1" }; + const separator = { separator: true, id: "nav-separator-1" }; const products = modules.map(product => { return { diff --git a/web/ASC.Web.Components/src/components/layout/index.js b/web/ASC.Web.Components/src/components/layout/index.js index d3e155cd69..c2973c5c09 100644 --- a/web/ASC.Web.Components/src/components/layout/index.js +++ b/web/ASC.Web.Components/src/components/layout/index.js @@ -66,7 +66,7 @@ class Layout extends React.Component { isolateModules.push(item); } else { mainModules.push(item); - if (item.seporator) continue; + if (item.separator) continue; totalNotifications+=item.notifications; } } @@ -195,7 +195,7 @@ class Layout extends React.Component { { this.state.mainModules.map(item => action('ProjectsIconBadge Clicked')(e) }, { - seporator: true, - id: 'nav-seporator-2' + separator: true, + id: 'nav-separator-2' }, { id: '55555555-5555-5555-5555-555555555555', diff --git a/web/ASC.Web.Components/src/components/layout/sub-components/nav-item.js b/web/ASC.Web.Components/src/components/layout/sub-components/nav-item.js index 343fa426de..01ba25d3b8 100644 --- a/web/ASC.Web.Components/src/components/layout/sub-components/nav-item.js +++ b/web/ASC.Web.Components/src/components/layout/sub-components/nav-item.js @@ -6,7 +6,7 @@ import { Icons } from '../../icons' const baseColor = '#7A95B0', activeColor = '#FFFFFF'; -const NavItemSeporator = styled.div` +const NavItemSeparator = styled.div` border-bottom: 1px solid ${baseColor}; margin: 0 16px; `; @@ -43,12 +43,12 @@ const NavItemBadge = styled(Badge)` const NavItem = React.memo(props => { //console.log("NavItem render"); - const { seporator, opened, active, iconName, children, badgeNumber, onClick, onBadgeClick } = props; + const { separator, opened, active, iconName, children, badgeNumber, onClick, onBadgeClick } = props; const color = active ? activeColor : baseColor; return ( - seporator - ? + separator + ? : {React.createElement(Icons[iconName], {size: "big", isfill: true, color: color})} {children && {children}} From 308455265a55eae65cbd298d86788dfbea652a85 Mon Sep 17 00:00:00 2001 From: Andrey Savihin Date: Thu, 12 Sep 2019 11:49:59 +0300 Subject: [PATCH 2/5] ASC.People: ProfileAction: translation --- .../pages/ProfileAction/Section/Body/createUserForm.js | 2 +- .../pages/ProfileAction/Section/Body/updateUserForm.js | 2 +- .../pages/ProfileAction/locales/en/translation.json | 6 +++++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/products/ASC.People/Client/src/components/pages/ProfileAction/Section/Body/createUserForm.js b/products/ASC.People/Client/src/components/pages/ProfileAction/Section/Body/createUserForm.js index 6c08fbffe8..c194b87778 100644 --- a/products/ASC.People/Client/src/components/pages/ProfileAction/Section/Body/createUserForm.js +++ b/products/ASC.People/Client/src/components/pages/ProfileAction/Section/Body/createUserForm.js @@ -269,7 +269,7 @@ class CreateUserForm extends React.Component { labelText={`${t("CustomDepartment", { department })}:`} isDisabled={isLoading} departments={profile.groups} - addButtonTitle={t("Add")} + addButtonTitle={t("AddButton")} onAddDepartment={this.onAddGroup} onRemoveDepartment={this.onGroupClose} /> diff --git a/products/ASC.People/Client/src/components/pages/ProfileAction/Section/Body/updateUserForm.js b/products/ASC.People/Client/src/components/pages/ProfileAction/Section/Body/updateUserForm.js index 1c428683d5..1de4212244 100644 --- a/products/ASC.People/Client/src/components/pages/ProfileAction/Section/Body/updateUserForm.js +++ b/products/ASC.People/Client/src/components/pages/ProfileAction/Section/Body/updateUserForm.js @@ -395,7 +395,7 @@ class UpdateUserForm extends React.Component { labelText={`${t("CustomDepartment", { department })}:`} isDisabled={isLoading} departments={profile.groups} - addButtonTitle={t("Add")} + addButtonTitle={t("AddButton")} onAddDepartment={this.onAddGroup} onRemoveDepartment={this.onGroupClose} /> diff --git a/products/ASC.People/Client/src/components/pages/ProfileAction/locales/en/translation.json b/products/ASC.People/Client/src/components/pages/ProfileAction/locales/en/translation.json index dabe25441e..f6c1758a89 100644 --- a/products/ASC.People/Client/src/components/pages/ProfileAction/locales/en/translation.json +++ b/products/ASC.People/Client/src/components/pages/ProfileAction/locales/en/translation.json @@ -12,7 +12,11 @@ "CancelButton": "Cancel", "CopyEmailAndPassword": "Copy e-mail & password", "UserType": "Type", - + "AddButton": "Add", + "ContactInformation": "Contact Information", + "AddContact": "Add contact", + "SocialProfiles": "Social Profiles", + "ActivationLink": "Activation link", "AddPhoto": "Add photo", "TemporaryPassword": "Temporary password", From 6e44af367dc09cf831120b8ae5766f301981e8ec Mon Sep 17 00:00:00 2001 From: Ilya Oleshko Date: Thu, 12 Sep 2019 13:58:17 +0300 Subject: [PATCH 3/5] web: Components: Added shouldComponentUpdate at PasswordInput component. --- .../src/components/password-input/index.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/web/ASC.Web.Components/src/components/password-input/index.js b/web/ASC.Web.Components/src/components/password-input/index.js index 46e3dce571..6e5276c09e 100644 --- a/web/ASC.Web.Components/src/components/password-input/index.js +++ b/web/ASC.Web.Components/src/components/password-input/index.js @@ -1,6 +1,7 @@ import React from 'react' import styled from 'styled-components' import PropTypes from 'prop-types' +import isEqual from "lodash/isEqual"; import { tablet } from '../../utils/device'; import InputBlock from '../input-block' @@ -66,16 +67,18 @@ const StyledTooltipItem = styled(Text.Body)` color: ${props => props.valid ? '#44bb00' : '#B40404'}; `; -class PasswordInput extends React.PureComponent { +class PasswordInput extends React.Component { constructor(props) { super(props); + const { inputValue, inputType } = props; + this.state = { - type: props.inputType, + type: inputType, progressColor: 'transparent', progressWidth: 0, - inputValue: '', + inputValue: inputValue, displayTooltip: false, validLength: false, validDigits: false, @@ -237,6 +240,10 @@ class PasswordInput extends React.PureComponent { onCopyToClipboard && onCopyToClipboard(formattedText); } + shouldComponentUpdate(nextProps,nextState) { + return !isEqual(this.props, nextProps) || !isEqual(this.state, nextState); + } + render() { //console.log('PasswordInput render()'); const { From 88c61677acfa6769d7586ec526107a65ecd3e1a9 Mon Sep 17 00:00:00 2001 From: Ilya Oleshko Date: Thu, 12 Sep 2019 13:58:55 +0300 Subject: [PATCH 4/5] web: Components: Added re-render tests at PasswordInput component. --- .../password-input/password-input.test.js | 42 ++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/web/ASC.Web.Components/src/components/password-input/password-input.test.js b/web/ASC.Web.Components/src/components/password-input/password-input.test.js index 6b52a00897..85b54bcf6a 100644 --- a/web/ASC.Web.Components/src/components/password-input/password-input.test.js +++ b/web/ASC.Web.Components/src/components/password-input/password-input.test.js @@ -1,5 +1,5 @@ import React from 'react'; -import { mount } from 'enzyme'; +import { mount, shallow } from 'enzyme'; import PasswordInput from '.'; const basePasswordSettings = { @@ -96,4 +96,44 @@ describe('', () => { expect(wrapper.prop('isDisabled')).toEqual(true); }); + + it('not re-render test', () => { + const wrapper = shallow().instance(); + + const shouldUpdate = wrapper.shouldComponentUpdate(wrapper.props, wrapper.state); + + expect(shouldUpdate).toBe(false); + }); + + it('re-render test', () => { + const wrapper = shallow().instance(); + + const shouldUpdate = wrapper.shouldComponentUpdate({ + inputName: 'demoPasswordInput', + emailInputName: 'demoEmailInput', + inputValue: '', + clipActionResource: 'Copy e-mail and password', + clipEmailResource: 'E-mail: ', + clipPasswordResource: 'Password: ', + tooltipPasswordTitle: 'Password must contain:', + tooltipPasswordLength: 'from 6 to 30 characters', + tooltipPasswordDigits: 'digits', + tooltipPasswordCapital: 'capital letters', + tooltipPasswordSpecial: 'special characters (!@#$%^&*)', + generatorSpecial: '!@#$%^&*', + passwordSettings: { + minLength: 8, + upperCase: false, + digits: false, + specSymbols: false + }, + isDisabled: false, + placeholder: 'password', + onChange: () => jest.fn(), + onValidateInput: () => jest.fn(), + onCopyToClipboard: () => jest.fn() + }, wrapper.state); + + expect(shouldUpdate).toBe(true); + }); }); From 2db845921c244d1015c3e858bd29c6400f6d89aa Mon Sep 17 00:00:00 2001 From: Ilya Oleshko Date: Thu, 12 Sep 2019 13:59:13 +0300 Subject: [PATCH 5/5] web: components: bump version --- web/ASC.Web.Components/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/ASC.Web.Components/package.json b/web/ASC.Web.Components/package.json index 9dcf387c1b..3e927bc362 100644 --- a/web/ASC.Web.Components/package.json +++ b/web/ASC.Web.Components/package.json @@ -1,6 +1,6 @@ { "name": "asc-web-components", - "version": "1.0.67", + "version": "1.0.68", "description": "Ascensio System SIA component library", "license": "AGPL-3.0", "main": "dist/asc-web-components.js",