Skip to content

Commit

Permalink
Add types for webapp-specific state (mattermost#4910)
Browse files Browse the repository at this point in the history
* Add types for webapp-specific state

* Update mattermost-redux
  • Loading branch information
hmhealey committed Mar 2, 2020
1 parent 0f0c08e commit e41241a
Show file tree
Hide file tree
Showing 36 changed files with 271 additions and 53 deletions.
4 changes: 3 additions & 1 deletion components/access_history_modal/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@

import {connect} from 'react-redux';
import {bindActionCreators, Dispatch} from 'redux';

import {getUserAudits} from 'mattermost-redux/actions/users';
import {getCurrentUserId, getUserAudits as getCurrentUserAudits} from 'mattermost-redux/selectors/entities/users';
import {GlobalState} from 'mattermost-redux/types/store';
import {GenericAction} from 'mattermost-redux/types/actions';

import {GlobalState} from 'types/store';

import AccessHistoryModal from './access_history_modal';

function mapStateToProps(state: GlobalState) {
Expand Down
3 changes: 2 additions & 1 deletion components/admin_console/admin_navbar_dropdown/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ import {bindActionCreators, Dispatch} from 'redux';
import {getMyTeams} from 'mattermost-redux/selectors/entities/teams';
import {getConfig} from 'mattermost-redux/selectors/entities/general';
import {GenericAction} from 'mattermost-redux/types/actions';
import {GlobalState} from 'mattermost-redux/types/store';

import {deferNavigation} from 'actions/admin_actions.jsx';
import {getCurrentLocale} from 'selectors/i18n';
import {getNavigationBlocked} from 'selectors/views/admin';

import {GlobalState} from 'types/store';

import AdminNavbarDropdown from './admin_navbar_dropdown';

function mapStateToProps(state: GlobalState) {
Expand Down
3 changes: 2 additions & 1 deletion components/admin_console/admin_sidebar_header/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
import {connect} from 'react-redux';

import {getCurrentUser} from 'mattermost-redux/selectors/entities/users';
import {GlobalState} from 'mattermost-redux/types/store';

import {GlobalState} from 'types/store';

import AdminSidebarHeader from './admin_sidebar_header';

Expand Down
4 changes: 3 additions & 1 deletion components/admin_console/audits/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@

import {connect} from 'react-redux';
import {bindActionCreators, Dispatch, ActionCreatorsMapObject} from 'redux';

import {ActionFunc, GenericAction} from 'mattermost-redux/types/actions';
import {GlobalState} from 'mattermost-redux/types/store';
import {getAudits} from 'mattermost-redux/actions/admin';
import * as Selectors from 'mattermost-redux/selectors/entities/admin';
import {getLicense} from 'mattermost-redux/selectors/entities/general';

import {GlobalState} from 'types/store';

import Audits from './audits';

type Actions = {
Expand Down
3 changes: 2 additions & 1 deletion components/admin_console/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import {isCurrentUserSystemAdmin, getCurrentUserId} from 'mattermost-redux/selec
import {getTeam} from 'mattermost-redux/selectors/entities/teams';

import {General} from 'mattermost-redux/constants';
import {GlobalState} from 'mattermost-redux/types/store';
import {GenericAction} from 'mattermost-redux/types/actions';

import {setNavigationBlocked, deferNavigation, cancelNavigation, confirmNavigation} from 'actions/admin_actions.jsx';
Expand All @@ -22,6 +21,8 @@ import {getAdminDefinition} from 'selectors/admin_console';

import LocalStorageStore from 'stores/local_storage_store';

import {GlobalState} from 'types/store';

import AdminConsole from './admin_console';

function mapStateToProps(state: GlobalState) {
Expand Down
8 changes: 5 additions & 3 deletions components/admin_console/reset_password_modal/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@
// See LICENSE.txt for license information.

import {connect} from 'react-redux';
import {bindActionCreators, Dispatch, ActionCreatorsMapObject} from 'redux';

import {updateUserPassword} from 'mattermost-redux/actions/users';
import {getConfig} from 'mattermost-redux/selectors/entities/general';
import {getCurrentUserId} from 'mattermost-redux/selectors/entities/users';
import {bindActionCreators, Dispatch, ActionCreatorsMapObject} from 'redux';
import {GlobalState} from 'mattermost-redux/types/store';
import {ActionFunc, ActionResult} from 'mattermost-redux/types/actions';
import {updateUserPassword} from 'mattermost-redux/actions/users';

import {GlobalState} from 'types/store';

import {getPasswordConfig} from 'utils/utils.jsx';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ import {updateUserActive, revokeAllSessionsForUser, promoteGuestToUser, demoteUs
import {getCurrentUser} from 'mattermost-redux/selectors/entities/users';
import {getBotAccounts} from 'mattermost-redux/selectors/entities/bots';
import {loadBots} from 'mattermost-redux/actions/bots';
import {GlobalState} from 'mattermost-redux/types/store';
import {getLicense} from 'mattermost-redux/selectors/entities/general';

import * as Selectors from 'mattermost-redux/selectors/entities/admin';

import {GlobalState} from 'types/store';

import SystemUsersDropdown from './system_users_dropdown';

type Actions = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import {createSelector} from 'reselect';
import {getAllChannelsWithCount as getData, searchAllChannels} from 'mattermost-redux/actions/channels';
import {getAllChannels} from 'mattermost-redux/selectors/entities/channels';
import {GenericAction} from 'mattermost-redux/types/actions';
import {GlobalState} from 'mattermost-redux/types/store';

import {t} from 'utils/i18n';
import {GlobalState} from 'types/store';

import {Constants} from 'utils/constants';
import {t} from 'utils/i18n';

import List from './channel_list';

Expand Down
3 changes: 2 additions & 1 deletion components/channel_layout/center_channel/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ import {connect} from 'react-redux';

import {getTeamByName} from 'mattermost-redux/selectors/entities/teams';
import {getRedirectChannelNameForTeam} from 'mattermost-redux/selectors/entities/channels';
import {GlobalState} from 'mattermost-redux/types/store';

import {getIsRhsOpen, getIsRhsMenuOpen} from 'selectors/rhs';
import {getIsLhsOpen} from 'selectors/lhs';
import {getLastViewedChannelNameByTeamName} from 'selectors/local_storage';

import {GlobalState} from 'types/store';

import CenterChannel from './center_channel';

type Props = {
Expand Down
4 changes: 3 additions & 1 deletion components/channel_members_modal/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@

import {bindActionCreators, Dispatch, ActionCreatorsMapObject} from 'redux';
import {connect} from 'react-redux';

import {canManageChannelMembers} from 'mattermost-redux/selectors/entities/channels';
import {GlobalState} from 'mattermost-redux/types/store';
import {ActionFunc} from 'mattermost-redux/types/actions';

import {openModal} from 'actions/views/modals';

import {GlobalState} from 'types/store';

import ChannelMembersModal from './channel_members_modal';

const mapStateToProps = (state: GlobalState) => ({
Expand Down
4 changes: 3 additions & 1 deletion components/error_page/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
// See LICENSE.txt for license information.

import {connect} from 'react-redux';

import {getConfig} from 'mattermost-redux/selectors/entities/general';
import {getCurrentUser} from 'mattermost-redux/selectors/entities/common';
import {GlobalState} from 'mattermost-redux/types/store';

import {GlobalState} from 'types/store';

import {isGuest} from 'utils/utils.jsx';

Expand Down
3 changes: 2 additions & 1 deletion components/file_attachment/file_thumbnail/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
import {connect} from 'react-redux';

import {getConfig} from 'mattermost-redux/selectors/entities/general';
import {GlobalState} from 'mattermost-redux/types/store';

import {GlobalState} from 'types/store';

import FileThumbnail from './file_thumbnail';

Expand Down
4 changes: 3 additions & 1 deletion components/file_info_preview/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
// See LICENSE.txt for license information.

import {connect} from 'react-redux';

import {getConfig} from 'mattermost-redux/selectors/entities/general';
import {GlobalState} from 'mattermost-redux/types/store';

import {GlobalState} from 'types/store';

import {canDownloadFiles} from 'utils/file_utils.jsx';

Expand Down
3 changes: 2 additions & 1 deletion components/leave_team_modal/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@ import {bindActionCreators, Dispatch} from 'redux';
import {getCurrentUserId} from 'mattermost-redux/selectors/entities/users';
import {getCurrentTeamId} from 'mattermost-redux/selectors/entities/teams';
import {removeUserFromTeam as leaveTeam} from 'mattermost-redux/actions/teams';
import {GlobalState} from 'mattermost-redux/types/store';
import {GenericAction} from 'mattermost-redux/types/actions';

import {toggleSideBarRightMenuAction} from 'actions/global_actions.jsx';
import {ModalIdentifiers} from 'utils/constants';

import {isModalOpen} from 'selectors/views/modals';

import {GlobalState} from 'types/store';

import LeaveTeamModal from './leave_team_modal';

function mapStateToProps(state: GlobalState) {
Expand Down
3 changes: 2 additions & 1 deletion components/linking_landing_page/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import {connect} from 'react-redux';
import {Client4} from 'mattermost-redux/client';
import {getConfig} from 'mattermost-redux/selectors/entities/general';
import {getTheme} from 'mattermost-redux/selectors/entities/preferences';
import {GlobalState} from 'mattermost-redux/types/store';

import {GlobalState} from 'types/store';

import LinkingLandingPage from './linking_landing_page';

Expand Down
3 changes: 2 additions & 1 deletion components/local_date_time/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ import {getCurrentUserId} from 'mattermost-redux/selectors/entities/users';
import {getUserTimezone} from 'mattermost-redux/selectors/entities/timezone';
import {getUserCurrentTimezone} from 'mattermost-redux/utils/timezone_utils';
import {getBool} from 'mattermost-redux/selectors/entities/preferences';
import {GlobalState} from 'mattermost-redux/types/store';
import {UserTimezone} from 'mattermost-redux/types/users';

import {areTimezonesEnabledAndSupported} from 'selectors/general';

import {GlobalState} from 'types/store';

import {Preferences} from 'utils/constants';

import LocalDateTime from './local_date_time';
Expand Down
13 changes: 3 additions & 10 deletions components/member_list_channel/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {getMembersInCurrentTeam} from 'mattermost-redux/selectors/entities/teams
import {getChannelStats} from 'mattermost-redux/actions/channels';
import {searchProfiles} from 'mattermost-redux/actions/users';
import {sortByUsername} from 'mattermost-redux/utils/user_utils';
import {GlobalState} from 'mattermost-redux/types/store';
import {UserProfile} from 'mattermost-redux/types/users';
import {Channel, ChannelMembership} from 'mattermost-redux/types/channels';
import {ActionFunc} from 'mattermost-redux/types/actions';
Expand All @@ -22,6 +21,8 @@ import {
import {loadStatusesForProfilesList} from 'actions/status_actions.jsx';
import {setModalSearchTerm} from 'actions/views/search';

import {GlobalState} from 'types/store';

import MemberListChannel from './member_list_channel';

const getUsersAndActionsToDisplay = createSelector(
Expand Down Expand Up @@ -60,15 +61,7 @@ const getUsersAndActionsToDisplay = createSelector(
}
);

interface State extends GlobalState {
views: {
search: {
modalSearch: string;
};
};
}

function mapStateToProps(state: State) {
function mapStateToProps(state: GlobalState) {
const searchTerm = state.views.search.modalSearch;

let users;
Expand Down
13 changes: 3 additions & 10 deletions components/member_list_team/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,16 @@ import {getMembersInCurrentTeam, getCurrentTeamStats} from 'mattermost-redux/sel
import {getProfilesInCurrentTeam, searchProfilesInCurrentTeam} from 'mattermost-redux/selectors/entities/users';
import {Permissions} from 'mattermost-redux/constants';
import {searchProfiles} from 'mattermost-redux/actions/users';
import {GlobalState} from 'mattermost-redux/types/store';
import {ActionFunc} from 'mattermost-redux/types/actions';
import {UserProfile} from 'mattermost-redux/types/users';

import {loadStatusesForProfilesList} from 'actions/status_actions.jsx';
import {loadProfilesAndTeamMembers, loadTeamMembersForProfilesList} from 'actions/user_actions.jsx';
import {setModalSearchTerm} from 'actions/views/search';

import MemberListTeam from './member_list_team';
import {GlobalState} from 'types/store';

interface State extends GlobalState {
views: {
search: {
modalSearch: string;
};
};
}
import MemberListTeam from './member_list_team';

type Props = {
teamId: string;
Expand All @@ -50,7 +43,7 @@ type Actions = {
}>;
}

function mapStateToProps(state: State, ownProps: Props) {
function mapStateToProps(state: GlobalState, ownProps: Props) {
const canManageTeamMembers = haveITeamPermission(state, {team: ownProps.teamId, permission: Permissions.MANAGE_TEAM_ROLES});

const searchTerm = state.views.search.modalSearch;
Expand Down
4 changes: 3 additions & 1 deletion components/msg_typing/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
// See LICENSE.txt for license information.

import {connect} from 'react-redux';

import {makeGetUsersTypingByChannelAndPost} from 'mattermost-redux/selectors/entities/typing';
import {GlobalState} from 'mattermost-redux/types/store';

import {GlobalState} from 'types/store';

import MsgTyping from './msg_typing';

Expand Down
3 changes: 2 additions & 1 deletion components/notify_counts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
import {connect} from 'react-redux';

import {getUnreadsInCurrentTeam} from 'mattermost-redux/selectors/entities/channels';
import {GlobalState} from 'mattermost-redux/types/store';

import {GlobalState} from 'types/store';

import NotifyCounts from './notify_counts';

Expand Down
3 changes: 2 additions & 1 deletion components/permissions_gates/team_permission_gate/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
import {connect} from 'react-redux';

import {haveITeamPermission} from 'mattermost-redux/selectors/entities/roles';
import {GlobalState} from 'mattermost-redux/types/store';

import {GlobalState} from 'types/store';

import TeamPermissionGate from './team_permission_gate';

Expand Down
3 changes: 2 additions & 1 deletion components/post_emoji/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
import {connect} from 'react-redux';

import {getEmojiImageUrl} from 'mattermost-redux/utils/emoji_utils';
import {GlobalState} from 'mattermost-redux/types/store';

import {getEmojiMap} from 'selectors/emojis';

import {GlobalState} from 'types/store';

import PostEmoji from './post_emoji';

type Props = {
Expand Down
3 changes: 2 additions & 1 deletion components/setting_item_min/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ import {connect} from 'react-redux';
import {bindActionCreators, Dispatch} from 'redux';

import {GenericAction} from 'mattermost-redux/types/actions';
import {GlobalState} from 'mattermost-redux/types/store';

import {getPreviousActiveSection} from 'selectors/views/settings';
import {updateActiveSection} from 'actions/views/settings';

import {GlobalState} from 'types/store';

import SettingItemMin from './setting_item_min';

function mapStateToProps(state: GlobalState) {
Expand Down
3 changes: 2 additions & 1 deletion components/team_members_modal/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@
import {connect} from 'react-redux';
import {bindActionCreators, Dispatch, ActionCreatorsMapObject} from 'redux';
import {getCurrentTeam} from 'mattermost-redux/selectors/entities/teams';
import {GlobalState} from 'mattermost-redux/types/store';
import {ActionFunc} from 'mattermost-redux/types/actions';

import {ModalIdentifiers} from 'utils/constants';
import {isModalOpen} from 'selectors/views/modals';
import {openModal} from 'actions/views/modals';

import {GlobalState} from 'types/store';

import TeamMembersModal from './team_members_modal';

type Actions = {
Expand Down
Loading

0 comments on commit e41241a

Please sign in to comment.