User popToRoot over resetToChannel (#3018)
This commit is contained in:
parent
a0b021d21d
commit
0a93ec134c
3 changed files with 14 additions and 10 deletions
|
|
@ -18,8 +18,9 @@ import {getCurrentUserId} from 'mattermost-redux/selectors/entities/users';
|
|||
import {
|
||||
setButtons,
|
||||
dismissModal,
|
||||
resetToChannel,
|
||||
goToScreen,
|
||||
dismissAllModals,
|
||||
popToRoot,
|
||||
} from 'app/actions/navigation';
|
||||
|
||||
import UserProfile from './user_profile';
|
||||
|
|
@ -52,8 +53,9 @@ function mapDispatchToProps(dispatch) {
|
|||
loadBot,
|
||||
setButtons,
|
||||
dismissModal,
|
||||
resetToChannel,
|
||||
goToScreen,
|
||||
dismissAllModals,
|
||||
popToRoot,
|
||||
}, dispatch),
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,8 +37,9 @@ export default class UserProfile extends PureComponent {
|
|||
loadBot: PropTypes.func.isRequired,
|
||||
setButtons: PropTypes.func.isRequired,
|
||||
dismissModal: PropTypes.func.isRequired,
|
||||
resetToChannel: PropTypes.func.isRequired,
|
||||
goToScreen: PropTypes.func.isRequired,
|
||||
dismissAllModals: PropTypes.func.isRequired,
|
||||
popToRoot: PropTypes.func.isRequired,
|
||||
}).isRequired,
|
||||
componentId: PropTypes.string,
|
||||
config: PropTypes.object.isRequired,
|
||||
|
|
@ -102,17 +103,15 @@ export default class UserProfile extends PureComponent {
|
|||
}
|
||||
|
||||
close = () => {
|
||||
const {actions, fromSettings} = this.props;
|
||||
const {actions, fromSettings, componentId} = this.props;
|
||||
|
||||
if (fromSettings) {
|
||||
actions.dismissModal();
|
||||
return;
|
||||
}
|
||||
|
||||
const passProps = {
|
||||
disableTermsModal: true,
|
||||
};
|
||||
actions.resetToChannel(passProps);
|
||||
actions.dismissAllModals();
|
||||
actions.popToRoot(componentId);
|
||||
};
|
||||
|
||||
getDisplayName = () => {
|
||||
|
|
|
|||
|
|
@ -25,8 +25,9 @@ describe('user_profile', () => {
|
|||
loadBot: jest.fn(),
|
||||
setButtons: jest.fn(),
|
||||
dismissModal: jest.fn(),
|
||||
resetToChannel: jest.fn(),
|
||||
goToScreen: jest.fn(),
|
||||
dismissAllModals: jest.fn(),
|
||||
popToRoot: jest.fn(),
|
||||
};
|
||||
const baseProps = {
|
||||
actions,
|
||||
|
|
@ -171,6 +172,8 @@ describe('user_profile', () => {
|
|||
props.fromSettings = false;
|
||||
wrapper.setProps({...props});
|
||||
wrapper.instance().navigationButtonPressed(event);
|
||||
expect(props.actions.resetToChannel).toHaveBeenCalledTimes(1);
|
||||
expect(props.actions.dismissAllModals).toHaveBeenCalledTimes(1);
|
||||
expect(props.actions.popToRoot).toHaveBeenCalledTimes(1);
|
||||
expect(props.actions.popToRoot).toHaveBeenCalledWith(props.componentId);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue