diff --git a/actions/views/settings.js b/actions/views/settings.js new file mode 100644 index 000000000000..a032ecdb6fc6 --- /dev/null +++ b/actions/views/settings.js @@ -0,0 +1,11 @@ +// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. +// See LICENSE.txt for license information. + +import {ActionTypes} from 'utils/constants.jsx'; + +export function updateActiveSection(newActiveSection) { + return { + type: ActionTypes.UPDATE_ACTIVE_SECTION, + data: newActiveSection, + }; +} \ No newline at end of file diff --git a/components/channel_notifications_modal/components/__snapshots__/collapse_view.test.jsx.snap b/components/channel_notifications_modal/components/__snapshots__/collapse_view.test.jsx.snap index ebbd73a3c841..26757167064b 100644 --- a/components/channel_notifications_modal/components/__snapshots__/collapse_view.test.jsx.snap +++ b/components/channel_notifications_modal/components/__snapshots__/collapse_view.test.jsx.snap @@ -1,7 +1,7 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`components/channel_notifications_modal/CollapseView should match snapshot, DESKTOP on collapsed view 1`] = ` - } - focused={false} section="desktop" title={ } - focused={false} section="markUnread" title={ } - focused={false} section="push" title={ { e.preventDefault(); + this.props.actions.updateActiveSection(this.props.section); this.props.updateSection(this.props.section); } diff --git a/components/setting_item_min.test.jsx b/components/setting_item_min/setting_item_min.test.jsx similarity index 93% rename from components/setting_item_min.test.jsx rename to components/setting_item_min/setting_item_min.test.jsx index c012deba5082..db7c9334e6f0 100644 --- a/components/setting_item_min.test.jsx +++ b/components/setting_item_min/setting_item_min.test.jsx @@ -4,7 +4,7 @@ import React from 'react'; import {shallow} from 'enzyme'; -import SettingItemMin from 'components/setting_item_min.jsx'; +import SettingItemMin from './setting_item_min'; describe('components/SettingItemMin', () => { const baseProps = { @@ -13,6 +13,9 @@ describe('components/SettingItemMin', () => { section: 'section', updateSection: jest.fn(), describe: 'describe', + actions: { + updateActiveSection: jest.fn(), + }, }; test('should match snapshot', () => { diff --git a/components/team_general_tab/__snapshots__/team_general_tab.test.jsx.snap b/components/team_general_tab/__snapshots__/team_general_tab.test.jsx.snap index 2abc23f7b79c..853214cd00ce 100644 --- a/components/team_general_tab/__snapshots__/team_general_tab.test.jsx.snap +++ b/components/team_general_tab/__snapshots__/team_general_tab.test.jsx.snap @@ -53,8 +53,7 @@ exports[`components/TeamSettings hide invite code if no permissions for team inv
- - } - focused={false} section="description" title="Team Description" updateSection={[Function]} @@ -95,7 +93,7 @@ exports[`components/TeamSettings hide invite code if no permissions for team inv
- } - focused={false} section="allowed_domains" title="allowedDomains" updateSection={[Function]} @@ -111,9 +108,8 @@ exports[`components/TeamSettings hide invite code if no permissions for team inv
- - - - } - focused={false} section="description" title="Team Description" updateSection={[Function]} @@ -230,7 +223,7 @@ exports[`components/TeamSettings hide invite code if no permissions for team inv
- } - focused={false} section="allowed_domains" title="allowedDomains" updateSection={[Function]} @@ -246,9 +238,8 @@ exports[`components/TeamSettings hide invite code if no permissions for team inv
- - - - } describe={this.props.renderOnOffLabel(joinLeaveState)} - focused={this.props.prevActiveSection === AdvancedSections.JOIN_LEAVE} section={AdvancedSections.JOIN_LEAVE} updateSection={this.handleUpdateSection} /> diff --git a/components/user_settings/advanced/join_leave_section/join_leave_section.test.jsx b/components/user_settings/advanced/join_leave_section/join_leave_section.test.jsx index 63439c38990a..6484689faadd 100644 --- a/components/user_settings/advanced/join_leave_section/join_leave_section.test.jsx +++ b/components/user_settings/advanced/join_leave_section/join_leave_section.test.jsx @@ -7,7 +7,7 @@ import {shallow} from 'enzyme'; import {AdvancedSections} from 'utils/constants.jsx'; import SettingItemMax from 'components/setting_item_max.jsx'; -import SettingItemMin from 'components/setting_item_min.jsx'; +import SettingItemMin from 'components/setting_item_min'; import JoinLeaveSection from 'components/user_settings/advanced/join_leave_section/join_leave_section.jsx'; @@ -17,7 +17,6 @@ describe('components/user_settings/advanced/JoinLeaveSection', () => { currentUserId: 'current_user_id', joinLeave: 'true', onUpdateSection: jest.fn(), - prevActiveSection: AdvancedSections.FORMATTING, renderOnOffLabel: jest.fn(), actions: { savePreferences: jest.fn(() => { diff --git a/components/user_settings/advanced/user_settings_advanced.jsx b/components/user_settings/advanced/user_settings_advanced.jsx index d4c3500326e5..6a7cdad4b979 100644 --- a/components/user_settings/advanced/user_settings_advanced.jsx +++ b/components/user_settings/advanced/user_settings_advanced.jsx @@ -9,7 +9,7 @@ import {emitUserLoggedOutEvent} from 'actions/global_actions.jsx'; import Constants from 'utils/constants.jsx'; import * as Utils from 'utils/utils.jsx'; import SettingItemMax from 'components/setting_item_max.jsx'; -import SettingItemMin from 'components/setting_item_min.jsx'; +import SettingItemMin from 'components/setting_item_min'; import ConfirmModal from 'components/confirm_modal.jsx'; import BackIcon from 'components/widgets/icons/fa_back_icon'; @@ -27,7 +27,6 @@ export default class AdvancedSettingsDisplay extends React.PureComponent { joinLeave: PropTypes.string.isRequired, updateSection: PropTypes.func, activeSection: PropTypes.string, - prevActiveSection: PropTypes.string, closeModal: PropTypes.func.isRequired, collapseModal: PropTypes.func.isRequired, enablePreviewFeatures: PropTypes.bool, @@ -43,14 +42,6 @@ export default class AdvancedSettingsDisplay extends React.PureComponent { super(props); this.state = this.getStateFromProps(); - - this.prevSections = { - advancedCtrlSend: 'dummySectionName', // dummy value that should never match any section name - formatting: 'advancedCtrlSend', - join_leave: 'formatting', - advancedPreviewFeatures: 'join_leave', - deactivateAccount: 'advancedPreviewFeatures', - }; } getStateFromProps = () => { @@ -300,7 +291,6 @@ export default class AdvancedSettingsDisplay extends React.PureComponent { /> } describe={this.renderOnOffLabel(this.state.settings.formatting)} - focused={this.props.prevActiveSection === this.prevSections.formatting} section={'formatting'} updateSection={this.handleUpdateSection} /> @@ -425,7 +415,6 @@ export default class AdvancedSettingsDisplay extends React.PureComponent { /> } describe={this.renderCtrlEnterLabel()} - focused={this.props.prevActiveSection === this.prevSections.advancedCtrlSend} section={'advancedCtrlSend'} updateSection={this.handleUpdateSection} /> @@ -504,7 +493,6 @@ export default class AdvancedSettingsDisplay extends React.PureComponent { values={{count: this.state.enabledFeatures}} /> } - focused={this.props.prevActiveSection === this.prevSections.advancedPreviewFeatures} section={'advancedPreviewFeatures'} updateSection={this.handleUpdateSection} /> @@ -560,7 +548,6 @@ export default class AdvancedSettingsDisplay extends React.PureComponent { defaultMessage="Click 'Edit' to deactivate your account" /> } - focused={this.props.prevActiveSection === this.prevSections.deactivateAccount} section={'deactivateAccount'} updateSection={this.handleUpdateSection} /> @@ -641,7 +628,6 @@ export default class AdvancedSettingsDisplay extends React.PureComponent { {previewFeaturesSectionDivider} diff --git a/components/user_settings/display/__snapshots__/user_settings_display.test.jsx.snap b/components/user_settings/display/__snapshots__/user_settings_display.test.jsx.snap index 1914b4497844..7dc2f1f591f9 100644 --- a/components/user_settings/display/__snapshots__/user_settings_display.test.jsx.snap +++ b/components/user_settings/display/__snapshots__/user_settings_display.test.jsx.snap @@ -57,8 +57,7 @@ exports[`components/user_settings/display/UserSettingsDisplay should match snaps className="divider-dark first" />
-
- } - focused={true} section="name_format" title={
-
-
-
-
- } - focused={true} section="name_format" title={
-
-
-
-
-
-
- } - focused={true} section="name_format" title={
-
-
-
-
-
- } - focused={true} section="name_format" title={
-
-
-
-
-
- } - focused={true} section="name_format" title={
-
-
-
-
-
- } - focused={true} section="name_format" title={
-
-
-
-
-
- } - focused={true} section="name_format" title={
-
-
-
-
-
- } - focused={true} section="name_format" title={
-
-
-
-
-
-
- } - focused={true} section="name_format" title={
-
-
-
-
-
-
- } - focused={true} section="name_format" title={
-
-
-
-
-
-
- } - focused={true} section="name_format" title={
-
-
-
-
-
-
- } - focused={true} section="name_format" title={
-
-
-
-
- @@ -658,7 +656,6 @@ export default class UserSettingsDisplay extends React.Component { } width='medium' describe={locale} - focused={this.props.prevActiveSection === this.prevSections.languages} section={'languages'} updateSection={this.updateSection} /> @@ -681,7 +678,6 @@ export default class UserSettingsDisplay extends React.Component { setRequireConfirm={this.props.setRequireConfirm} setEnforceFocus={this.props.setEnforceFocus} allowCustomThemes={this.props.allowCustomThemes} - focused={this.props.prevActiveSection === this.prevSections.theme} />
diff --git a/components/user_settings/display/user_settings_display.test.jsx b/components/user_settings/display/user_settings_display.test.jsx index 0dc547adcc66..37e2355aadfe 100644 --- a/components/user_settings/display/user_settings_display.test.jsx +++ b/components/user_settings/display/user_settings_display.test.jsx @@ -2,7 +2,9 @@ // See LICENSE.txt for license information. import React from 'react'; +import PropTypes from 'prop-types'; import {shallow} from 'enzyme'; +import configureStore from 'redux-mock-store'; import {mountWithIntl} from 'tests/helpers/intl-test-helper.jsx'; import UserSettingsDisplay from 'components/user_settings/display/user_settings_display.jsx'; @@ -48,6 +50,14 @@ describe('components/user_settings/display/UserSettingsDisplay', () => { savePreferences: jest.fn(), }, }; + const mockStore = configureStore(); + const state = { + views: { + settings: {}, + }, + }; + + const store = mockStore(state); test('should match snapshot, no active section', () => { const wrapper = shallow(); @@ -140,7 +150,13 @@ describe('components/user_settings/display/UserSettingsDisplay', () => { const updateSection = jest.fn(); const props = {...requiredProps, updateSection}; - const wrapper = mountWithIntl(); + const wrapper = mountWithIntl( + , + { + context: {store}, + childContextTypes: {store: PropTypes.object}, + }, + ); await wrapper.instance().handleSubmit(); expect(updateSection).toHaveBeenCalledWith(''); @@ -149,7 +165,13 @@ describe('components/user_settings/display/UserSettingsDisplay', () => { test('should have called updateSection', () => { const updateSection = jest.fn(); const props = {...requiredProps, updateSection}; - const wrapper = mountWithIntl(); + const wrapper = mountWithIntl( + , + { + context: {store}, + childContextTypes: {store: PropTypes.object}, + }, + ); wrapper.instance().updateSection(''); expect(updateSection).toHaveBeenCalledWith(''); @@ -161,7 +183,13 @@ describe('components/user_settings/display/UserSettingsDisplay', () => { test('should have called closeModal', () => { const closeModal = jest.fn(); const props = {...requiredProps, closeModal}; - const wrapper = mountWithIntl(); + const wrapper = mountWithIntl( + , + { + context: {store}, + childContextTypes: {store: PropTypes.object}, + }, + ); wrapper.find('#closeButton').simulate('click'); expect(closeModal).toHaveBeenCalled(); @@ -170,14 +198,26 @@ describe('components/user_settings/display/UserSettingsDisplay', () => { test('should have called collapseModal', () => { const collapseModal = jest.fn(); const props = {...requiredProps, collapseModal}; - const wrapper = mountWithIntl(); + const wrapper = mountWithIntl( + , + { + context: {store}, + childContextTypes: {store: PropTypes.object}, + }, + ); wrapper.find('.fa-angle-left').simulate('click'); expect(collapseModal).toHaveBeenCalled(); }); test('should update militaryTime state', () => { - const wrapper = mountWithIntl(); + const wrapper = mountWithIntl( + , + { + context: {store}, + childContextTypes: {store: PropTypes.object}, + }, + ); wrapper.instance().handleClockRadio('false'); expect(wrapper.state('militaryTime')).toBe('false'); @@ -187,7 +227,13 @@ describe('components/user_settings/display/UserSettingsDisplay', () => { }); test('should update teammateNameDisplay state', () => { - const wrapper = mountWithIntl(); + const wrapper = mountWithIntl( + , + { + context: {store}, + childContextTypes: {store: PropTypes.object}, + }, + ); wrapper.instance().handleTeammateNameDisplayRadio('username'); expect(wrapper.state('teammateNameDisplay')).toBe('username'); @@ -200,7 +246,13 @@ describe('components/user_settings/display/UserSettingsDisplay', () => { }); test('should update channelDisplayMode state', () => { - const wrapper = mountWithIntl(); + const wrapper = mountWithIntl( + , + { + context: {store}, + childContextTypes: {store: PropTypes.object}, + }, + ); wrapper.instance().handleChannelDisplayModeRadio('full'); expect(wrapper.state('channelDisplayMode')).toBe('full'); @@ -210,7 +262,13 @@ describe('components/user_settings/display/UserSettingsDisplay', () => { }); test('should update messageDisplay state', () => { - const wrapper = mountWithIntl(); + const wrapper = mountWithIntl( + , + { + context: {store}, + childContextTypes: {store: PropTypes.object}, + }, + ); wrapper.instance().handlemessageDisplayRadio('clean'); expect(wrapper.state('messageDisplay')).toBe('clean'); @@ -220,7 +278,13 @@ describe('components/user_settings/display/UserSettingsDisplay', () => { }); test('should update collapseDisplay state', () => { - const wrapper = mountWithIntl(); + const wrapper = mountWithIntl( + , + { + context: {store}, + childContextTypes: {store: PropTypes.object}, + }, + ); wrapper.instance().handleCollapseRadio('false'); expect(wrapper.state('collapseDisplay')).toBe('false'); @@ -230,7 +294,13 @@ describe('components/user_settings/display/UserSettingsDisplay', () => { }); test('should update linkPreviewDisplay state', () => { - const wrapper = mountWithIntl(); + const wrapper = mountWithIntl( + , + { + context: {store}, + childContextTypes: {store: PropTypes.object}, + }, + ); wrapper.instance().handleLinkPreviewRadio('false'); expect(wrapper.state('linkPreviewDisplay')).toBe('false'); @@ -240,7 +310,13 @@ describe('components/user_settings/display/UserSettingsDisplay', () => { }); test('should update display state', () => { - const wrapper = mountWithIntl(); + const wrapper = mountWithIntl( + , + { + context: {store}, + childContextTypes: {store: PropTypes.object}, + }, + ); wrapper.instance().handleOnChange({display: 'linkPreviewDisplay'}); expect(wrapper.state('display')).toBe('linkPreviewDisplay'); diff --git a/components/user_settings/display/user_settings_theme/__snapshots__/user_settings_theme.test.jsx.snap b/components/user_settings/display/user_settings_theme/__snapshots__/user_settings_theme.test.jsx.snap index 178189f28130..1bc0a77d89c0 100644 --- a/components/user_settings/display/user_settings_theme/__snapshots__/user_settings_theme.test.jsx.snap +++ b/components/user_settings/display/user_settings_theme/__snapshots__/user_settings_theme.test.jsx.snap @@ -1,7 +1,7 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`components/user_settings/display/user_settings_theme/user_settings_theme.jsx should match snapshot 1`] = ` - } describe={describe} - focused={this.props.prevActiveSection === prevSections.email} section={'email'} updateSection={this.updateSection} /> @@ -890,7 +879,6 @@ class UserSettingsGeneralTab extends React.Component { @@ -992,7 +980,6 @@ class UserSettingsGeneralTab extends React.Component { @@ -1075,7 +1062,6 @@ class UserSettingsGeneralTab extends React.Component { @@ -1178,7 +1164,6 @@ class UserSettingsGeneralTab extends React.Component { @@ -1236,7 +1221,6 @@ class UserSettingsGeneralTab extends React.Component { diff --git a/components/user_settings/general/user_settings_general.test.js b/components/user_settings/general/user_settings_general.test.js index c7562c58824b..5ef800f7deb9 100644 --- a/components/user_settings/general/user_settings_general.test.js +++ b/components/user_settings/general/user_settings_general.test.js @@ -2,6 +2,8 @@ // See LICENSE.txt for license information. import React from 'react'; +import {Provider} from 'react-redux'; +import configureStore from 'redux-mock-store'; import {shallowWithIntl, mountWithIntl} from 'tests/helpers/intl-test-helper.jsx'; @@ -18,7 +20,6 @@ describe('components/user_settings/general/UserSettingsGeneral', () => { updateSection: jest.fn(), updateTab: jest.fn(), activeSection: '', - prevActiveSection: '', closeModal: jest.fn(), collapseModal: jest.fn(), actions: { @@ -33,6 +34,15 @@ describe('components/user_settings/general/UserSettingsGeneral', () => { maxFileSize: 1024, }; + const mockStore = configureStore(); + const state = { + views: { + settings: {}, + }, + }; + + const store = mockStore(state); + test('submitUser() should have called updateMe', () => { const updateMe = jest.fn().mockResolvedValue({data: true}); const props = {...requiredProps, actions: {...requiredProps.actions, updateMe}}; @@ -97,21 +107,33 @@ describe('components/user_settings/general/UserSettingsGeneral', () => { props.ldapPositionAttributeSet = false; props.samlPositionAttributeSet = false; - let wrapper = mountWithIntl(); + let wrapper = mountWithIntl( + + + + ); expect(wrapper.find('#position').length).toBe(1); expect(wrapper.find('#position').is('input')).toBeTruthy(); props.ldapPositionAttributeSet = true; props.samlPositionAttributeSet = false; - wrapper = mountWithIntl(); + wrapper = mountWithIntl( + + + + ); expect(wrapper.find('#position').length).toBe(0); props.user.auth_service = 'saml'; props.ldapPositionAttributeSet = false; props.samlPositionAttributeSet = true; - wrapper = mountWithIntl(); + wrapper = mountWithIntl( + + + + ); expect(wrapper.find('#position').length).toBe(0); }); }); diff --git a/components/user_settings/modal/user_settings_modal.jsx b/components/user_settings/modal/user_settings_modal.jsx index 3dc9702df928..db1b0f042984 100644 --- a/components/user_settings/modal/user_settings_modal.jsx +++ b/components/user_settings/modal/user_settings_modal.jsx @@ -76,7 +76,6 @@ class UserSettingsModal extends React.Component { this.state = { active_tab: 'general', active_section: '', - prev_active_section: 'dummySectionName', // dummy value that should never match any section name showConfirmModal: false, enforceFocus: true, show: true, @@ -145,7 +144,6 @@ class UserSettingsModal extends React.Component { this.setState({ active_tab: 'general', active_section: '', - prev_active_section: 'dummySectionName', }); this.props.onHide(); } @@ -157,7 +155,6 @@ class UserSettingsModal extends React.Component { this.setState({ active_tab: '', active_section: '', - prev_active_section: '', }); } @@ -226,7 +223,6 @@ class UserSettingsModal extends React.Component { this.setState({ active_tab: tab, active_section: '', - prev_active_section: 'dummySectionName', }); } } @@ -236,7 +232,6 @@ class UserSettingsModal extends React.Component { this.showConfirmModal(() => this.updateSection(section, true)); } else { this.setState({ - prev_active_section: section ? '' : this.state.active_section, active_section: section, }); } @@ -296,7 +291,6 @@ class UserSettingsModal extends React.Component { doLoad={loadUserSettings} activeTab={this.state.active_tab} activeSection={this.state.active_section} - prevActiveSection={this.state.prev_active_section} updateSection={this.updateSection} updateTab={this.updateTab} closeModal={this.closeModal} diff --git a/components/user_settings/notifications/__snapshots__/desktop_notification_settings.test.jsx.snap b/components/user_settings/notifications/__snapshots__/desktop_notification_settings.test.jsx.snap index 40e6e30e4e72..471c28e4aff3 100644 --- a/components/user_settings/notifications/__snapshots__/desktop_notification_settings.test.jsx.snap +++ b/components/user_settings/notifications/__snapshots__/desktop_notification_settings.test.jsx.snap @@ -267,7 +267,7 @@ exports[`components/user_settings/notifications/DesktopNotificationSettings shou `; exports[`components/user_settings/notifications/DesktopNotificationSettings should match snapshot, on buildMinimizedSetting 1`] = ` - { diff --git a/components/user_settings/notifications/email_notification_setting/__snapshots__/email_notification_setting.test.jsx.snap b/components/user_settings/notifications/email_notification_setting/__snapshots__/email_notification_setting.test.jsx.snap index df7863a0572c..b1c1617a6656 100644 --- a/components/user_settings/notifications/email_notification_setting/__snapshots__/email_notification_setting.test.jsx.snap +++ b/components/user_settings/notifications/email_notification_setting/__snapshots__/email_notification_setting.test.jsx.snap @@ -284,7 +284,7 @@ exports[`components/user_settings/notifications/EmailNotificationSetting should `; exports[`components/user_settings/notifications/EmailNotificationSetting should match snapshot, active section != email and SendEmailNotifications !== true 1`] = ` - } - focused={false} section="email" title="Email notifications" updateSection={[Function]} @@ -300,7 +299,7 @@ exports[`components/user_settings/notifications/EmailNotificationSetting should `; exports[`components/user_settings/notifications/EmailNotificationSetting should match snapshot, active section != email and SendEmailNotifications = true 1`] = ` - } - focused={false} section="email" title="Email notifications" updateSection={[Function]} @@ -316,7 +314,7 @@ exports[`components/user_settings/notifications/EmailNotificationSetting should `; exports[`components/user_settings/notifications/EmailNotificationSetting should match snapshot, active section != email, SendEmailNotifications = true and enableEmail = true 1`] = ` - } - focused={false} section="email" title="Email notifications" updateSection={[Function]} diff --git a/components/user_settings/notifications/email_notification_setting/email_notification_setting.jsx b/components/user_settings/notifications/email_notification_setting/email_notification_setting.jsx index a647ffd61d80..880896416388 100644 --- a/components/user_settings/notifications/email_notification_setting/email_notification_setting.jsx +++ b/components/user_settings/notifications/email_notification_setting/email_notification_setting.jsx @@ -10,7 +10,7 @@ import {getEmailInterval} from 'mattermost-redux/utils/notify_props'; import {Preferences} from 'utils/constants.jsx'; import {localizeMessage} from 'utils/utils.jsx'; import SettingItemMax from 'components/setting_item_max.jsx'; -import SettingItemMin from 'components/setting_item_min.jsx'; +import SettingItemMin from 'components/setting_item_min'; const SECONDS_PER_MINUTE = 60; diff --git a/components/user_settings/notifications/user_settings_notifications.jsx b/components/user_settings/notifications/user_settings_notifications.jsx index f9bb90f700e9..d5e333a712fb 100644 --- a/components/user_settings/notifications/user_settings_notifications.jsx +++ b/components/user_settings/notifications/user_settings_notifications.jsx @@ -8,7 +8,7 @@ import {FormattedMessage} from 'react-intl'; import Constants, {NotificationLevels} from 'utils/constants.jsx'; import * as Utils from 'utils/utils.jsx'; import SettingItemMax from 'components/setting_item_max.jsx'; -import SettingItemMin from 'components/setting_item_min.jsx'; +import SettingItemMin from 'components/setting_item_min'; import DesktopNotificationSettings from './desktop_notification_settings.jsx'; import EmailNotificationSetting from './email_notification_setting'; @@ -107,20 +107,11 @@ function getNotificationsStateFromProps(props) { }; } -const prevSections = { - desktop: 'dummySectionName', // dummy value that should never match any section name - email: 'desktop', - push: 'email', - keys: 'push', - comments: 'keys', -}; - export default class NotificationsTab extends React.Component { static propTypes = { user: PropTypes.object, updateSection: PropTypes.func, activeSection: PropTypes.string, - prevActiveSection: PropTypes.string, closeModal: PropTypes.func.isRequired, collapseModal: PropTypes.func.isRequired, siteName: PropTypes.string, @@ -134,7 +125,6 @@ export default class NotificationsTab extends React.Component { static defaultProps = { user: null, activeSection: '', - prevActiveSection: '', activeTab: '', } @@ -515,7 +505,6 @@ export default class NotificationsTab extends React.Component { @@ -698,7 +687,6 @@ export default class NotificationsTab extends React.Component { @@ -822,7 +810,6 @@ export default class NotificationsTab extends React.Component { @@ -938,7 +925,6 @@ export default class NotificationsTab extends React.Component { cancel={this.handleCancel} error={this.state.serverError} active={this.props.activeSection === 'desktop'} - focused={this.props.prevActiveSection === prevSections.desktop} />
diff --git a/components/user_settings/notifications/user_settings_notifications.test.js b/components/user_settings/notifications/user_settings_notifications.test.js index 6374384d2158..d6dba9f1f01b 100644 --- a/components/user_settings/notifications/user_settings_notifications.test.js +++ b/components/user_settings/notifications/user_settings_notifications.test.js @@ -17,7 +17,6 @@ describe('components/user_settings/display/UserSettingsDisplay', () => { activeSection: '', closeModal: jest.fn(), collapseModal: jest.fn(), - prevActiveSection: '', actions: { updateMe: jest.fn(() => Promise.resolve({})), }, diff --git a/components/user_settings/security/mfa_section/__snapshots__/mfa_section.test.jsx.snap b/components/user_settings/security/mfa_section/__snapshots__/mfa_section.test.jsx.snap index aa9c187ae303..1472a5c074c3 100644 --- a/components/user_settings/security/mfa_section/__snapshots__/mfa_section.test.jsx.snap +++ b/components/user_settings/security/mfa_section/__snapshots__/mfa_section.test.jsx.snap @@ -3,7 +3,7 @@ exports[`MfaSection rendering should render nothing when MFA is not available 1`] = `""`; exports[`MfaSection rendering when section is collapsed and MFA is active 1`] = ` - } - focused={false} section="mfa" title={ } - focused={false} section="mfa" title={ - , ] } - focused={true} section="groupChannels" title={ - } - focused={false} section="channelSwitcher" title={ ); } @@ -587,7 +584,6 @@ export default class UserSettingsSidebar extends React.Component { describe={this.renderOrganizationLabel()} section={'groupChannels'} updateSection={this.updateSection} - focused={this.props.prevActiveSection === this.getPreviousSection('groupChannels')} /> ); } @@ -690,7 +686,6 @@ export default class UserSettingsSidebar extends React.Component { describe={this.renderChannelSwitcherLabel(this.props.channelSwitcherOption)} section={'channelSwitcher'} updateSection={this.updateSection} - focused={this.props.prevActiveSection === this.getPreviousSection('channelSwitcher')} /> ); }; diff --git a/components/user_settings/sidebar/user_settings_sidebar.test.jsx b/components/user_settings/sidebar/user_settings_sidebar.test.jsx index f01968b1e844..0c6f43c3ea1a 100644 --- a/components/user_settings/sidebar/user_settings_sidebar.test.jsx +++ b/components/user_settings/sidebar/user_settings_sidebar.test.jsx @@ -2,6 +2,8 @@ // See LICENSE.txt for license information. import React from 'react'; +import PropTypes from 'prop-types'; +import configureStore from 'redux-mock-store'; import {mountWithIntl, shallowWithIntl} from 'tests/helpers/intl-test-helper.jsx'; @@ -30,8 +32,15 @@ describe('components/user_settings/sidebar/UserSettingsSidebar', () => { actions: { savePreferences: () => true, }, - prevActiveSection: 'dummySectionName', }; + const mockStore = configureStore(); + const state = { + views: { + settings: {}, + }, + }; + + const store = mockStore(state); test('should match snapshot', () => { const wrapper = shallowWithIntl(); @@ -64,7 +73,13 @@ describe('components/user_settings/sidebar/UserSettingsSidebar', () => { test('should pass handleChange for channel grouping', () => { const props = {...defaultProps, activeSection: 'groupChannels'}; - const wrapper = mountWithIntl(); + const wrapper = mountWithIntl( + , + { + context: {store}, + childContextTypes: {store: PropTypes.object}, + }, + ); wrapper.find('#noneOption').simulate('change'); expect(wrapper.state('settings')).toEqual({ @@ -135,7 +150,13 @@ describe('components/user_settings/sidebar/UserSettingsSidebar', () => { ...defaultProps.sidebarPreference, grouping: 'none', }}; - const wrapper = mountWithIntl(); + const wrapper = mountWithIntl( + , + { + context: {store}, + childContextTypes: {store: PropTypes.object}, + }, + ); wrapper.find('#recentSectionEnabled').simulate('change'); expect(wrapper.state('settings')).toEqual({ diff --git a/components/user_settings/user_settings.jsx b/components/user_settings/user_settings.jsx index 118eb1b347e0..308f3f44a384 100644 --- a/components/user_settings/user_settings.jsx +++ b/components/user_settings/user_settings.jsx @@ -16,7 +16,6 @@ export default class UserSettings extends React.PureComponent { user: PropTypes.object.isRequired, activeTab: PropTypes.string, activeSection: PropTypes.string, - prevActiveSection: PropTypes.string, updateSection: PropTypes.func, updateTab: PropTypes.func, closeModal: PropTypes.func.isRequired, @@ -32,7 +31,6 @@ export default class UserSettings extends React.PureComponent {