MM-20790 Mark as Unread option should not be available on mobile if the server does not support it (#3655)
* MM-20790 Mark as Unread option should not be available on mobile if the server does not support it * Check for server version with min 5.18v for showing the option to mark as unread * Change if condition
This commit is contained in:
parent
da858797d3
commit
a8ad077086
4 changed files with 37 additions and 4 deletions
|
|
@ -22,6 +22,7 @@ import {getTheme} from 'mattermost-redux/selectors/entities/preferences';
|
|||
import {haveIChannelPermission} from 'mattermost-redux/selectors/entities/roles';
|
||||
import {getCurrentTeamId, getCurrentTeamUrl} from 'mattermost-redux/selectors/entities/teams';
|
||||
import {canEditPost} from 'mattermost-redux/utils/post_utils';
|
||||
import {isMinimumServerVersion} from 'mattermost-redux/utils/helpers';
|
||||
|
||||
import {MAX_ALLOWED_REACTIONS} from 'app/constants/emoji';
|
||||
import {THREAD} from 'app/constants/screen';
|
||||
|
|
@ -43,6 +44,8 @@ export function makeMapStateToProps() {
|
|||
const currentChannelId = getCurrentChannelId(state);
|
||||
const reactions = getReactionsForPostSelector(state, post.id);
|
||||
const channelIsArchived = channel.delete_at !== 0;
|
||||
const {serverVersion} = state.entities.general;
|
||||
const canMarkAsUnread = isMinimumServerVersion(serverVersion, 5, 18);
|
||||
|
||||
let canAddReaction = true;
|
||||
let canReply = true;
|
||||
|
|
@ -115,9 +118,9 @@ export function makeMapStateToProps() {
|
|||
canDelete,
|
||||
canFlag,
|
||||
canPin,
|
||||
canMarkAsUnread,
|
||||
currentTeamUrl: getCurrentTeamUrl(state),
|
||||
currentUserId,
|
||||
isMyPost: currentUserId === post.user_id,
|
||||
theme: getTheme(state),
|
||||
isLandscape: isLandscape(state),
|
||||
};
|
||||
|
|
|
|||
|
|
@ -35,6 +35,9 @@ describe('makeMapStateToProps', () => {
|
|||
post_id: {},
|
||||
},
|
||||
},
|
||||
general: {
|
||||
serverVersion: '5.18',
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
|
|
@ -65,4 +68,25 @@ describe('makeMapStateToProps', () => {
|
|||
const props = mapStateToProps(baseState, ownProps);
|
||||
expect(props.canFlag).toBe(true);
|
||||
});
|
||||
|
||||
test('canMarkAsUnread is true when isMinimumServerVersion is 5.18v', () => {
|
||||
const mapStateToProps = makeMapStateToProps();
|
||||
const props = mapStateToProps(baseState, baseOwnProps);
|
||||
expect(props.canMarkAsUnread).toBe(true);
|
||||
});
|
||||
|
||||
test('canMarkAsUnread is false when isMinimumServerVersion is not 5.18v', () => {
|
||||
const state = {
|
||||
entities: {
|
||||
...baseState.entities,
|
||||
general: {
|
||||
serverVersion: '5.17',
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const mapStateToProps = makeMapStateToProps();
|
||||
const props = mapStateToProps(state, baseOwnProps);
|
||||
expect(props.canMarkAsUnread).toBe(false);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -38,12 +38,12 @@ export default class PostOptions extends PureComponent {
|
|||
canFlag: PropTypes.bool,
|
||||
canPin: PropTypes.bool,
|
||||
canEdit: PropTypes.bool,
|
||||
canMarkAsUnread: PropTypes.bool, //#backwards-compatibility:5.18v
|
||||
canEditUntil: PropTypes.number.isRequired,
|
||||
currentTeamUrl: PropTypes.string.isRequired,
|
||||
currentUserId: PropTypes.string.isRequired,
|
||||
deviceHeight: PropTypes.number.isRequired,
|
||||
isFlagged: PropTypes.bool,
|
||||
isMyPost: PropTypes.bool,
|
||||
post: PropTypes.object.isRequired,
|
||||
theme: PropTypes.object.isRequired,
|
||||
isLandscape: PropTypes.bool.isRequired,
|
||||
|
|
@ -231,7 +231,7 @@ export default class PostOptions extends PureComponent {
|
|||
const {post, isLandscape, theme} = this.props;
|
||||
const {formatMessage} = this.context.intl;
|
||||
|
||||
if (!isSystemMessage(post)) {
|
||||
if (!isSystemMessage(post) && this.props.canMarkAsUnread) {
|
||||
return (
|
||||
<PostOption
|
||||
key='markUnread'
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ describe('PostOptions', () => {
|
|||
canDelete: true,
|
||||
canPin: true,
|
||||
canEdit: true,
|
||||
canMarkAsUnread: true,
|
||||
canEditUntil: -1,
|
||||
channelIsReadOnly: false,
|
||||
currentTeamUrl: 'http://localhost:8065/team-name',
|
||||
|
|
@ -45,7 +46,6 @@ describe('PostOptions', () => {
|
|||
deviceHeight: 600,
|
||||
hasBeenDeleted: false,
|
||||
isFlagged: false,
|
||||
isMyPost: true,
|
||||
isSystemMessage: false,
|
||||
managedConfig: {},
|
||||
post,
|
||||
|
|
@ -98,6 +98,12 @@ describe('PostOptions', () => {
|
|||
expect(wrapper.findWhere((node) => node.key() === 'reply')).toMatchObject({});
|
||||
});
|
||||
|
||||
test('should not show mark as unread option', () => {
|
||||
const wrapper = getWrapper({canMarkAsUnread: false});
|
||||
|
||||
expect(wrapper.findWhere((node) => node.key() === 'markUnread')).toMatchObject({});
|
||||
});
|
||||
|
||||
test('should remove post after delete', () => {
|
||||
const wrapper = getWrapper();
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue