MM-10717: Update longpress buttons when add reaction, edit post, or d… (#1779)
* MM-10717: Update longpress buttons when add reaction, edit post, or delete post permissions change. * MM-10717: Makes tooltip actions prop required. * MM-10717: Switches all direct access of 'config' and 'license' to use selectors.
This commit is contained in:
parent
ae6ce503c3
commit
3bde858a64
21 changed files with 83 additions and 24 deletions
|
|
@ -4,11 +4,12 @@
|
|||
import {updateMe} from 'mattermost-redux/actions/users';
|
||||
import {Preferences} from 'mattermost-redux/constants';
|
||||
import {savePreferences} from 'mattermost-redux/actions/preferences';
|
||||
import {getConfig} from 'mattermost-redux/selectors/entities/general';
|
||||
|
||||
export function handleUpdateUserNotifyProps(notifyProps) {
|
||||
return async (dispatch, getState) => {
|
||||
const state = getState();
|
||||
const config = state.entities.general.config;
|
||||
const config = getConfig(state);
|
||||
const {currentUserId} = state.entities.users;
|
||||
|
||||
const {interval, user_id: userId, ...otherProps} = notifyProps;
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import {getCurrentUserId} from 'mattermost-redux/selectors/entities/users';
|
|||
|
||||
import {ViewTypes} from 'app/constants';
|
||||
import {app} from 'app/mattermost';
|
||||
import {getConfig, getLicense} from 'mattermost-redux/selectors/entities/general';
|
||||
|
||||
export function handleLoginIdChanged(loginId) {
|
||||
return async (dispatch, getState) => {
|
||||
|
|
@ -30,7 +31,8 @@ export function handlePasswordChanged(password) {
|
|||
export function handleSuccessfulLogin() {
|
||||
return async (dispatch, getState) => {
|
||||
const state = getState();
|
||||
const {config, license} = state.entities.general;
|
||||
const config = getConfig(state);
|
||||
const license = getLicense(state);
|
||||
const token = Client4.getToken();
|
||||
const url = Client4.getUrl();
|
||||
const deviceToken = state.entities.general.deviceToken;
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ import {getCurrentChannelId} from 'mattermost-redux/selectors/entities/channels'
|
|||
import {NavigationTypes} from 'app/constants';
|
||||
|
||||
import {setChannelDisplayName} from './channel';
|
||||
import {getConfig} from 'mattermost-redux/selectors/entities/general';
|
||||
|
||||
export function handleTeamChange(teamId, selectChannel = true) {
|
||||
return async (dispatch, getState) => {
|
||||
|
|
@ -40,7 +41,7 @@ export function selectDefaultTeam() {
|
|||
return async (dispatch, getState) => {
|
||||
const state = getState();
|
||||
|
||||
const {ExperimentalPrimaryTeam} = state.entities.general.config;
|
||||
const {ExperimentalPrimaryTeam} = getConfig(state);
|
||||
const {teams: allTeams, myMembers} = state.entities.teams;
|
||||
const teams = Object.keys(myMembers).map((key) => allTeams[key]);
|
||||
|
||||
|
|
|
|||
|
|
@ -16,11 +16,13 @@ import {getCurrentTeamId} from 'mattermost-redux/selectors/entities/teams';
|
|||
import {getTheme, getFavoritesPreferences} from 'mattermost-redux/selectors/entities/preferences';
|
||||
import {showCreateOption} from 'mattermost-redux/utils/channel_utils';
|
||||
import {isAdmin as checkIsAdmin, isSystemAdmin as checkIsSystemAdmin} from 'mattermost-redux/utils/user_utils';
|
||||
import {getConfig, getLicense} from 'mattermost-redux/selectors/entities/general';
|
||||
|
||||
import List from './list';
|
||||
|
||||
function mapStateToProps(state) {
|
||||
const {config, license} = state.entities.general;
|
||||
const config = getConfig(state);
|
||||
const license = getLicense(state);
|
||||
const roles = getCurrentUserId(state) ? getCurrentUserRoles(state) : '';
|
||||
const unreadChannelIds = getSortedUnreadChannelIds(state);
|
||||
const favoriteChannelIds = getSortedFavoriteChannelIds(state);
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ import {getMyPreferences, getTheme} from 'mattermost-redux/selectors/entities/pr
|
|||
import {getCurrentTeamUrl, getCurrentTeamId} from 'mattermost-redux/selectors/entities/teams';
|
||||
import {canDeletePost, canEditPost, isPostFlagged} from 'mattermost-redux/utils/post_utils';
|
||||
import {isAdmin as checkIsAdmin, isSystemAdmin as checkIsSystemAdmin} from 'mattermost-redux/utils/user_utils';
|
||||
import {getConfig, getLicense} from 'mattermost-redux/selectors/entities/general';
|
||||
|
||||
import {insertToDraft, setPostTooltipVisible} from 'app/actions/views/channel';
|
||||
import {addReaction} from 'app/actions/views/emoji';
|
||||
|
|
@ -22,7 +23,8 @@ import Post from './post';
|
|||
function mapStateToProps(state, ownProps) {
|
||||
const post = getPost(state, ownProps.postId);
|
||||
|
||||
const {config, license} = state.entities.general;
|
||||
const config = getConfig(state);
|
||||
const license = getLicense(state);
|
||||
const roles = getCurrentUserId(state) ? getCurrentUserRoles(state) : '';
|
||||
const myPreferences = getMyPreferences(state);
|
||||
const currentUserId = getCurrentUserId(state);
|
||||
|
|
|
|||
|
|
@ -9,18 +9,23 @@ import {
|
|||
General,
|
||||
Posts,
|
||||
} from 'mattermost-redux/constants';
|
||||
import {getChannel, canManageChannelMembers} from 'mattermost-redux/selectors/entities/channels';
|
||||
import {getChannel, canManageChannelMembers, getCurrentChannelId} from 'mattermost-redux/selectors/entities/channels';
|
||||
import {getPost} from 'mattermost-redux/selectors/entities/posts';
|
||||
import {getTheme} from 'mattermost-redux/selectors/entities/preferences';
|
||||
import {hasNewPermissions} from 'mattermost-redux/selectors/entities/general';
|
||||
import {hasNewPermissions, getConfig, getLicense} from 'mattermost-redux/selectors/entities/general';
|
||||
import {haveIChannelPermission} from 'mattermost-redux/selectors/entities/roles';
|
||||
import {getCurrentUserId, getCurrentUserRoles} from 'mattermost-redux/selectors/entities/users';
|
||||
import {getCurrentTeamId} from 'mattermost-redux/selectors/entities/teams';
|
||||
import Permissions from 'mattermost-redux/constants/permissions';
|
||||
|
||||
import {
|
||||
isEdited,
|
||||
isPostEphemeral,
|
||||
isSystemMessage,
|
||||
canEditPost,
|
||||
canDeletePost,
|
||||
} from 'mattermost-redux/utils/post_utils';
|
||||
import {isAdmin as checkIsAdmin, isSystemAdmin as checkIsSystemAdmin} from 'mattermost-redux/utils/user_utils';
|
||||
|
||||
import PostBody from './post_body';
|
||||
|
||||
|
|
@ -52,6 +57,21 @@ function mapStateToProps(state, ownProps) {
|
|||
const isUserCanManageMembers = canManageChannelMembers(state);
|
||||
const isEphemeralPost = isPostEphemeral(post);
|
||||
|
||||
const config = getConfig(state);
|
||||
const license = getLicense(state);
|
||||
const currentUserId = getCurrentUserId(state);
|
||||
const currentTeamId = getCurrentTeamId(state);
|
||||
const currentChannelId = getCurrentChannelId(state);
|
||||
const roles = getCurrentUserId(state) ? getCurrentUserRoles(state) : '';
|
||||
const isAdmin = checkIsAdmin(roles);
|
||||
const isSystemAdmin = checkIsSystemAdmin(roles);
|
||||
let canDelete = false;
|
||||
let canEdit = false;
|
||||
if (post) {
|
||||
canDelete = canDeletePost(state, config, license, currentTeamId, currentChannelId, currentUserId, post, isAdmin, isSystemAdmin);
|
||||
canEdit = canEditPost(state, config, license, currentTeamId, currentChannelId, currentUserId, post);
|
||||
}
|
||||
|
||||
let isPostAddChannelMember = false;
|
||||
if (
|
||||
channel &&
|
||||
|
|
@ -79,6 +99,8 @@ function mapStateToProps(state, ownProps) {
|
|||
message: post.message,
|
||||
theme: getTheme(state),
|
||||
canAddReaction,
|
||||
canDelete,
|
||||
canEdit,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,13 +9,14 @@ import {getBool, getTeammateNameDisplaySetting, getTheme} from 'mattermost-redux
|
|||
import {getUser} from 'mattermost-redux/selectors/entities/users';
|
||||
import {isPostPendingOrFailed, isSystemMessage} from 'mattermost-redux/utils/post_utils';
|
||||
import {displayUsername} from 'mattermost-redux/utils/user_utils';
|
||||
import {getConfig} from 'mattermost-redux/selectors/entities/general';
|
||||
|
||||
import PostHeader from './post_header';
|
||||
|
||||
function makeMapStateToProps() {
|
||||
const getCommentCountForPost = makeGetCommentCountForPost();
|
||||
return function mapStateToProps(state, ownProps) {
|
||||
const {config} = state.entities.general;
|
||||
const config = getConfig(state);
|
||||
const post = getPost(state, ownProps.postId);
|
||||
const commentedOnUser = getUser(state, ownProps.commentedOnUserId);
|
||||
const user = getUser(state, post.user_id) || {};
|
||||
|
|
|
|||
|
|
@ -7,11 +7,12 @@ import {getPost} from 'mattermost-redux/selectors/entities/posts';
|
|||
import {isSystemMessage} from 'mattermost-redux/utils/post_utils';
|
||||
|
||||
import {getTheme} from 'mattermost-redux/selectors/entities/preferences';
|
||||
import {getConfig} from 'mattermost-redux/selectors/entities/general';
|
||||
|
||||
import PostProfilePicture from './post_profile_picture';
|
||||
|
||||
function mapStateToProps(state, ownProps) {
|
||||
const {config} = state.entities.general;
|
||||
const config = getConfig(state);
|
||||
const post = getPost(state, ownProps.postId);
|
||||
|
||||
return {
|
||||
|
|
|
|||
|
|
@ -5,12 +5,13 @@ import React, {PureComponent} from 'react';
|
|||
import PropTypes from 'prop-types';
|
||||
import RNToolTip from 'react-native-tooltip';
|
||||
|
||||
import {setToolTipVisible} from 'app/utils/tooltip';
|
||||
import {setToolTipVisible, getToolTipVisible} from 'app/utils/tooltip';
|
||||
|
||||
export default class ToolTip extends PureComponent {
|
||||
static propTypes = {
|
||||
onHide: PropTypes.func,
|
||||
onShow: PropTypes.func,
|
||||
actions: PropTypes.array.isRequired,
|
||||
};
|
||||
|
||||
handleHide = () => {
|
||||
|
|
@ -39,6 +40,13 @@ export default class ToolTip extends PureComponent {
|
|||
}
|
||||
};
|
||||
|
||||
componentDidUpdate(prevProps) {
|
||||
if (prevProps.actions.length !== this.props.actions.length && getToolTipVisible()) {
|
||||
this.refs.toolTip.hideMenu();
|
||||
setTimeout(() => this.refs.toolTip.showMenu(), 1);
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<RNToolTip
|
||||
|
|
|
|||
|
|
@ -4,11 +4,13 @@
|
|||
import {connect} from 'react-redux';
|
||||
|
||||
import {getTheme} from 'mattermost-redux/selectors/entities/preferences';
|
||||
import {getConfig, getLicense} from 'mattermost-redux/selectors/entities/general';
|
||||
|
||||
import About from './about';
|
||||
|
||||
function mapStateToProps(state) {
|
||||
const {config, license} = state.entities.general;
|
||||
const config = getConfig(state);
|
||||
const license = getLicense(state);
|
||||
|
||||
return {
|
||||
config,
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ import {
|
|||
import {getCurrentUserId, getUser, getStatusForUserId, getCurrentUserRoles} from 'mattermost-redux/selectors/entities/users';
|
||||
import {getUserIdFromChannelName, isChannelMuted, showDeleteOption, showManagementOptions} from 'mattermost-redux/utils/channel_utils';
|
||||
import {isAdmin as checkIsAdmin, isChannelAdmin as checkIsChannelAdmin, isSystemAdmin as checkIsSystemAdmin} from 'mattermost-redux/utils/user_utils';
|
||||
import {getConfig, getLicense} from 'mattermost-redux/selectors/entities/general';
|
||||
|
||||
import {
|
||||
closeDMChannel,
|
||||
|
|
@ -37,7 +38,8 @@ import {
|
|||
import ChannelInfo from './channel_info';
|
||||
|
||||
function mapStateToProps(state) {
|
||||
const {config, license} = state.entities.general;
|
||||
const config = getConfig(state);
|
||||
const license = getLicense(state);
|
||||
const currentChannel = getCurrentChannel(state) || {};
|
||||
const currentChannelCreator = getUser(state, currentChannel.creator_id);
|
||||
const currentChannelCreatorName = currentChannelCreator && currentChannelCreator.username;
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import {connect} from 'react-redux';
|
|||
|
||||
import {setDeviceToken} from 'mattermost-redux/actions/general';
|
||||
import {getTheme} from 'mattermost-redux/selectors/entities/preferences';
|
||||
import {getConfig} from 'mattermost-redux/selectors/entities/general';
|
||||
|
||||
import {isLandscape} from 'app/selectors/device';
|
||||
|
||||
|
|
@ -13,7 +14,7 @@ const lazyLoadEntry = () => {
|
|||
};
|
||||
|
||||
function mapStateToProps(state) {
|
||||
const {config} = state.entities.general;
|
||||
const config = getConfig(state);
|
||||
|
||||
return {
|
||||
config,
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import {connect} from 'react-redux';
|
|||
|
||||
import LoginActions from 'app/actions/views/login';
|
||||
import {getTheme} from 'mattermost-redux/selectors/entities/preferences';
|
||||
import {getConfig, getLicense} from 'mattermost-redux/selectors/entities/general';
|
||||
|
||||
import {checkMfa, login} from 'mattermost-redux/actions/users';
|
||||
|
||||
|
|
@ -13,7 +14,8 @@ import Login from './login.js';
|
|||
|
||||
function mapStateToProps(state) {
|
||||
const {checkMfa: checkMfaRequest, login: loginRequest} = state.requests.users;
|
||||
const {config, license} = state.entities.general;
|
||||
const config = getConfig(state);
|
||||
const license = getLicense(state);
|
||||
return {
|
||||
...state.views.login,
|
||||
checkMfaRequest,
|
||||
|
|
|
|||
|
|
@ -4,11 +4,13 @@
|
|||
import {connect} from 'react-redux';
|
||||
|
||||
import {getTheme} from 'mattermost-redux/selectors/entities/preferences';
|
||||
import {getConfig, getLicense} from 'mattermost-redux/selectors/entities/general';
|
||||
|
||||
import LoginOptions from './login_options';
|
||||
|
||||
function mapStateToProps(state) {
|
||||
const {config, license} = state.entities.general;
|
||||
const config = getConfig(state);
|
||||
const license = getLicense(state);
|
||||
return {
|
||||
config,
|
||||
license,
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ import {isAdmin, isSystemAdmin} from 'mattermost-redux/utils/user_utils';
|
|||
|
||||
import {handleSelectChannel, setChannelDisplayName} from 'app/actions/views/channel';
|
||||
import {getTheme} from 'mattermost-redux/selectors/entities/preferences';
|
||||
import {getConfig, getLicense} from 'mattermost-redux/selectors/entities/general';
|
||||
|
||||
import MoreChannels from './more_channels';
|
||||
|
||||
|
|
@ -31,7 +32,8 @@ function mapStateToProps(state) {
|
|||
const {currentUserId} = state.entities.users;
|
||||
const {currentTeamId} = state.entities.teams;
|
||||
const {getChannels: requestStatus} = state.requests.channels;
|
||||
const {config, license} = state.entities.general;
|
||||
const config = getConfig(state);
|
||||
const license = getLicense(state);
|
||||
const roles = getCurrentUserRoles(state);
|
||||
const channels = joinableChannels(state);
|
||||
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import {getDimensions} from 'app/selectors/device';
|
|||
import {getChannel} from 'mattermost-redux/selectors/entities/channels';
|
||||
import {getTeammateNameDisplaySetting, getTheme} from 'mattermost-redux/selectors/entities/preferences';
|
||||
import {getUser} from 'mattermost-redux/selectors/entities/users';
|
||||
import {getConfig} from 'mattermost-redux/selectors/entities/general';
|
||||
|
||||
import Notification from './notification';
|
||||
|
||||
|
|
@ -26,9 +27,9 @@ function mapStateToProps(state, ownProps) {
|
|||
if (data.channel_id) {
|
||||
channel = getChannel(state, data.channel_id);
|
||||
}
|
||||
|
||||
const config = getConfig(state);
|
||||
return {
|
||||
config: state.entities.general.config,
|
||||
config,
|
||||
channel,
|
||||
deviceWidth,
|
||||
user,
|
||||
|
|
|
|||
|
|
@ -13,11 +13,13 @@ import {loadConfigAndLicense} from 'app/actions/views/root';
|
|||
import {handleServerUrlChanged} from 'app/actions/views/select_server';
|
||||
import getClientUpgrade from 'app/selectors/client_upgrade';
|
||||
import {getTheme} from 'mattermost-redux/selectors/entities/preferences';
|
||||
import {getConfig, getLicense} from 'mattermost-redux/selectors/entities/general';
|
||||
|
||||
import SelectServer from './select_server';
|
||||
|
||||
function mapStateToProps(state) {
|
||||
const {config, license} = state.entities.general;
|
||||
const config = getConfig(state);
|
||||
const license = getLicense(state);
|
||||
const {currentVersion, latestVersion, minVersion} = getClientUpgrade(state);
|
||||
|
||||
return {
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import {connect} from 'react-redux';
|
|||
|
||||
import {clearErrors} from 'mattermost-redux/actions/errors';
|
||||
import {getCurrentUrl} from 'mattermost-redux/selectors/entities/general';
|
||||
import {getJoinableTeams} from 'mattermost-redux/selectors/entities/teams';
|
||||
import {getJoinableTeams, getConfig} from 'mattermost-redux/selectors/entities/teams';
|
||||
|
||||
import {purgeOfflineStore} from 'app/actions/views/root';
|
||||
import {getTheme} from 'mattermost-redux/selectors/entities/preferences';
|
||||
|
|
@ -15,7 +15,7 @@ import {removeProtocol} from 'app/utils/url';
|
|||
import Settings from './settings';
|
||||
|
||||
function mapStateToProps(state) {
|
||||
const {config} = state.entities.general;
|
||||
const config = getConfig(state);
|
||||
|
||||
return {
|
||||
config,
|
||||
|
|
|
|||
|
|
@ -8,12 +8,14 @@ import {getCurrentUser} from 'mattermost-redux/selectors/entities/users';
|
|||
import {getMyPreferences, getTheme} from 'mattermost-redux/selectors/entities/preferences';
|
||||
|
||||
import {handleUpdateUserNotifyProps} from 'app/actions/views/account_notifications';
|
||||
import {getConfig} from 'mattermost-redux/selectors/entities/general';
|
||||
|
||||
import NotificationSettings from './notification_settings';
|
||||
|
||||
function mapStateToProps(state) {
|
||||
const config = getConfig(state);
|
||||
return {
|
||||
config: state.entities.general.config,
|
||||
config,
|
||||
currentUser: getCurrentUser(state),
|
||||
myPreferences: getMyPreferences(state),
|
||||
updateMeRequest: state.requests.users.updateMe,
|
||||
|
|
|
|||
|
|
@ -10,11 +10,12 @@ import {makeDirectChannel} from 'app/actions/views/more_dms';
|
|||
import {getCurrentChannel} from 'mattermost-redux/selectors/entities/channels';
|
||||
import {getTeammateNameDisplaySetting, getTheme} from 'mattermost-redux/selectors/entities/preferences';
|
||||
import {getCurrentUserId} from 'mattermost-redux/selectors/entities/users';
|
||||
import {getConfig} from 'mattermost-redux/selectors/entities/general';
|
||||
|
||||
import UserProfile from './user_profile';
|
||||
|
||||
function mapStateToProps(state, ownProps) {
|
||||
const {config} = state.entities.general;
|
||||
const config = getConfig(state);
|
||||
const {createChannel: createChannelRequest} = state.requests.channels;
|
||||
|
||||
return {
|
||||
|
|
|
|||
|
|
@ -6,13 +6,15 @@ import {connect} from 'react-redux';
|
|||
import {getCurrentChannelId} from 'mattermost-redux/selectors/entities/channels';
|
||||
import {getCurrentTeamId} from 'mattermost-redux/selectors/entities/teams';
|
||||
import {getCurrentUserId} from 'mattermost-redux/selectors/entities/users';
|
||||
import {getConfig} from 'mattermost-redux/selectors/entities/general';
|
||||
|
||||
import {getAllowedServerMaxFileSize} from 'app/utils/file';
|
||||
|
||||
import ExtensionPost from './extension_post';
|
||||
|
||||
function mapStateToProps(state) {
|
||||
const {config, credentials} = state.entities.general;
|
||||
const config = getConfig(state);
|
||||
const {credentials} = state.entities.general;
|
||||
const {token, url} = credentials;
|
||||
|
||||
return {
|
||||
|
|
|
|||
Loading…
Reference in a new issue