* Always dispatch thunk actions instead of calling them

* Properly dispatch actions in SwitchChannelProvider

* Fix tests relying on bad types

* Properly pass actions into ManageTokens

* Make other logic changes to support new types

* Do the big type migrations without any logic changes

* Revert "Properly dispatch actions in SwitchChannelProvider"

This reverts commit 28c8c7af2ef324c6814087a81baca66c60477daa.

* Revert "Revert "Properly dispatch actions in SwitchChannelProvider""

This reverts commit 47115c5217ae90547040e7b7de32979a33f0845b.
Этот коммит содержится в:
Harrison Healey
2024-01-10 09:47:05 -05:00
коммит произвёл GitHub
родитель 0a4e9eeb92
Коммит 978f335925
362 изменённых файлов: 2306 добавлений и 3535 удалений

Просмотреть файл

@@ -15,7 +15,6 @@ import store from 'stores/redux_store';
import {ActionTypes} from 'utils/constants'; import {ActionTypes} from 'utils/constants';
const dispatch = store.dispatch; const dispatch = store.dispatch;
const getState = store.getState;
export async function reloadConfig(success, error) { export async function reloadConfig(success, error) {
const {data, error: err} = await dispatch(AdminActions.reloadConfig()); const {data, error: err} = await dispatch(AdminActions.reloadConfig());
@@ -29,7 +28,7 @@ export async function reloadConfig(success, error) {
} }
export async function adminResetMfa(userId, success, error) { export async function adminResetMfa(userId, success, error) {
const {data, error: err} = await UserActions.updateUserMfa(userId, false)(dispatch, getState); const {data, error: err} = await dispatch(UserActions.updateUserMfa(userId, false));
if (data && success) { if (data && success) {
success(data); success(data);
} else if (err && error) { } else if (err && error) {
@@ -38,7 +37,7 @@ export async function adminResetMfa(userId, success, error) {
} }
export async function getClusterStatus(success, error) { export async function getClusterStatus(success, error) {
const {data, error: err} = await AdminActions.getClusterStatus()(dispatch, getState); const {data, error: err} = await dispatch(AdminActions.getClusterStatus());
if (data && success) { if (data && success) {
success(data); success(data);
} else if (err && error) { } else if (err && error) {
@@ -47,7 +46,7 @@ export async function getClusterStatus(success, error) {
} }
export async function ldapTest(success, error) { export async function ldapTest(success, error) {
const {data, error: err} = await AdminActions.testLdap()(dispatch, getState); const {data, error: err} = await dispatch(AdminActions.testLdap());
if (data && success) { if (data && success) {
success(data); success(data);
} else if (err && error) { } else if (err && error) {
@@ -56,7 +55,7 @@ export async function ldapTest(success, error) {
} }
export async function invalidateAllCaches(success, error) { export async function invalidateAllCaches(success, error) {
const {data, error: err} = await AdminActions.invalidateCaches()(dispatch, getState); const {data, error: err} = await dispatch(AdminActions.invalidateCaches());
if (data && success) { if (data && success) {
success(data); success(data);
} else if (err && error) { } else if (err && error) {
@@ -65,7 +64,7 @@ export async function invalidateAllCaches(success, error) {
} }
export async function recycleDatabaseConnection(success, error) { export async function recycleDatabaseConnection(success, error) {
const {data, error: err} = await AdminActions.recycleDatabase()(dispatch, getState); const {data, error: err} = await dispatch(AdminActions.recycleDatabase());
if (data && success) { if (data && success) {
success(data); success(data);
} else if (err && error) { } else if (err && error) {
@@ -74,7 +73,7 @@ export async function recycleDatabaseConnection(success, error) {
} }
export async function adminResetEmail(user, success, error) { export async function adminResetEmail(user, success, error) {
const {data, error: err} = await UserActions.patchUser(user)(dispatch, getState); const {data, error: err} = await dispatch(UserActions.patchUser(user));
if (data && success) { if (data && success) {
success(data); success(data);
} else if (err && error) { } else if (err && error) {
@@ -83,7 +82,7 @@ export async function adminResetEmail(user, success, error) {
} }
export async function samlCertificateStatus(success, error) { export async function samlCertificateStatus(success, error) {
const {data, error: err} = await AdminActions.getSamlCertificateStatus()(dispatch, getState); const {data, error: err} = await dispatch(AdminActions.getSamlCertificateStatus());
if (data && success) { if (data && success) {
success(data); success(data);
} else if (err && error) { } else if (err && error) {
@@ -92,7 +91,7 @@ export async function samlCertificateStatus(success, error) {
} }
export async function getIPFilters(success, error) { export async function getIPFilters(success, error) {
const {data, error: err} = await AdminActions.getIPFilters()(dispatch, getState); const {data, error: err} = await dispatch(AdminActions.getIPFilters());
if (data && success) { if (data && success) {
success(data); success(data);
} else if (err && error) { } else if (err && error) {
@@ -101,7 +100,7 @@ export async function getIPFilters(success, error) {
} }
export async function getCurrentIP(success, error) { export async function getCurrentIP(success, error) {
const {data, error: err} = await AdminActions.getCurrentIP()(dispatch, getState); const {data, error: err} = await dispatch(AdminActions.getCurrentIP());
if (data && success) { if (data && success) {
success(data); success(data);
} else if (err && error) { } else if (err && error) {
@@ -110,7 +109,7 @@ export async function getCurrentIP(success, error) {
} }
export async function applyIPFilters(ipList, success, error) { export async function applyIPFilters(ipList, success, error) {
const {data, error: err} = await AdminActions.applyIPFilters(ipList)(dispatch, getState); const {data, error: err} = await dispatch(AdminActions.applyIPFilters(ipList));
if (data && success) { if (data && success) {
success(data); success(data);
} else if (err && error) { } else if (err && error) {
@@ -118,6 +117,10 @@ export async function applyIPFilters(ipList, success, error) {
} }
} }
/**
* @param {string | null} clientId
* @returns {ActionResult<OAuthApp>}
*/
export function getOAuthAppInfo(clientId) { export function getOAuthAppInfo(clientId) {
return bindClientFunc({ return bindClientFunc({
clientFunc: Client4.getOAuthAppInfo, clientFunc: Client4.getOAuthAppInfo,
@@ -125,6 +128,10 @@ export function getOAuthAppInfo(clientId) {
}); });
} }
/**
* @param {*}
* @returns {ActionResult<{redirect: string}>}
*/
export function allowOAuth2({responseType, clientId, redirectUri, state, scope}) { export function allowOAuth2({responseType, clientId, redirectUri, state, scope}) {
return bindClientFunc({ return bindClientFunc({
clientFunc: Client4.authorizeOAuthApp, clientFunc: Client4.authorizeOAuthApp,
@@ -133,7 +140,7 @@ export function allowOAuth2({responseType, clientId, redirectUri, state, scope})
} }
export async function emailToLdap(loginId, password, token, ldapId, ldapPassword, success, error) { export async function emailToLdap(loginId, password, token, ldapId, ldapPassword, success, error) {
const {data, error: err} = await UserActions.switchEmailToLdap(loginId, password, ldapId, ldapPassword, token)(dispatch, getState); const {data, error: err} = await dispatch(UserActions.switchEmailToLdap(loginId, password, ldapId, ldapPassword, token));
if (data && success) { if (data && success) {
success(data); success(data);
} else if (err && error) { } else if (err && error) {
@@ -142,7 +149,7 @@ export async function emailToLdap(loginId, password, token, ldapId, ldapPassword
} }
export async function emailToOAuth(loginId, password, token, newType, success, error) { export async function emailToOAuth(loginId, password, token, newType, success, error) {
const {data, error: err} = await UserActions.switchEmailToOAuth(newType, loginId, password, token)(dispatch, getState); const {data, error: err} = await dispatch(UserActions.switchEmailToOAuth(newType, loginId, password, token));
if (data && success) { if (data && success) {
success(data); success(data);
} else if (err && error) { } else if (err && error) {
@@ -151,7 +158,7 @@ export async function emailToOAuth(loginId, password, token, newType, success, e
} }
export async function oauthToEmail(currentService, email, password, success, error) { export async function oauthToEmail(currentService, email, password, success, error) {
const {data, error: err} = await UserActions.switchOAuthToEmail(currentService, email, password)(dispatch, getState); const {data, error: err} = await dispatch(UserActions.switchOAuthToEmail(currentService, email, password));
if (data) { if (data) {
if (data.follow_link) { if (data.follow_link) {
emitUserLoggedOutEvent(data.follow_link); emitUserLoggedOutEvent(data.follow_link);
@@ -165,7 +172,7 @@ export async function oauthToEmail(currentService, email, password, success, err
} }
export async function uploadBrandImage(brandImage, success, error) { export async function uploadBrandImage(brandImage, success, error) {
const {data, error: err} = await AdminActions.uploadBrandImage(brandImage)(dispatch, getState); const {data, error: err} = await dispatch(AdminActions.uploadBrandImage(brandImage));
if (data && success) { if (data && success) {
success(data); success(data);
} else if (err && error) { } else if (err && error) {
@@ -174,7 +181,7 @@ export async function uploadBrandImage(brandImage, success, error) {
} }
export async function deleteBrandImage(success, error) { export async function deleteBrandImage(success, error) {
const {data, error: err} = await AdminActions.deleteBrandImage()(dispatch, getState); const {data, error: err} = await dispatch(AdminActions.deleteBrandImage());
if (data && success) { if (data && success) {
success(data); success(data);
} else if (err && error) { } else if (err && error) {
@@ -183,7 +190,7 @@ export async function deleteBrandImage(success, error) {
} }
export async function uploadPublicSamlCertificate(file, success, error) { export async function uploadPublicSamlCertificate(file, success, error) {
const {data, error: err} = await AdminActions.uploadPublicSamlCertificate(file)(dispatch, getState); const {data, error: err} = await dispatch(AdminActions.uploadPublicSamlCertificate(file));
if (data && success) { if (data && success) {
success('saml-public.crt'); success('saml-public.crt');
} else if (err && error) { } else if (err && error) {
@@ -192,7 +199,7 @@ export async function uploadPublicSamlCertificate(file, success, error) {
} }
export async function uploadPrivateSamlCertificate(file, success, error) { export async function uploadPrivateSamlCertificate(file, success, error) {
const {data, error: err} = await AdminActions.uploadPrivateSamlCertificate(file)(dispatch, getState); const {data, error: err} = await dispatch(AdminActions.uploadPrivateSamlCertificate(file));
if (data && success) { if (data && success) {
success('saml-private.key'); success('saml-private.key');
} else if (err && error) { } else if (err && error) {
@@ -201,7 +208,7 @@ export async function uploadPrivateSamlCertificate(file, success, error) {
} }
export async function uploadPublicLdapCertificate(file, success, error) { export async function uploadPublicLdapCertificate(file, success, error) {
const {data, error: err} = await AdminActions.uploadPublicLdapCertificate(file)(dispatch, getState); const {data, error: err} = await dispatch(AdminActions.uploadPublicLdapCertificate(file));
if (data && success) { if (data && success) {
success('ldap-public.crt'); success('ldap-public.crt');
} else if (err && error) { } else if (err && error) {
@@ -209,7 +216,7 @@ export async function uploadPublicLdapCertificate(file, success, error) {
} }
} }
export async function uploadPrivateLdapCertificate(file, success, error) { export async function uploadPrivateLdapCertificate(file, success, error) {
const {data, error: err} = await AdminActions.uploadPrivateLdapCertificate(file)(dispatch, getState); const {data, error: err} = await dispatch(AdminActions.uploadPrivateLdapCertificate(file));
if (data && success) { if (data && success) {
success('ldap-private.key'); success('ldap-private.key');
} else if (err && error) { } else if (err && error) {
@@ -218,7 +225,7 @@ export async function uploadPrivateLdapCertificate(file, success, error) {
} }
export async function uploadIdpSamlCertificate(file, success, error) { export async function uploadIdpSamlCertificate(file, success, error) {
const {data, error: err} = await AdminActions.uploadIdpSamlCertificate(file)(dispatch, getState); const {data, error: err} = await dispatch(AdminActions.uploadIdpSamlCertificate(file));
if (data && success) { if (data && success) {
success('saml-idp.crt'); success('saml-idp.crt');
} else if (err && error) { } else if (err && error) {
@@ -227,7 +234,7 @@ export async function uploadIdpSamlCertificate(file, success, error) {
} }
export async function removePublicSamlCertificate(success, error) { export async function removePublicSamlCertificate(success, error) {
const {data, error: err} = await AdminActions.removePublicSamlCertificate()(dispatch, getState); const {data, error: err} = await dispatch(AdminActions.removePublicSamlCertificate());
if (data && success) { if (data && success) {
success(data); success(data);
} else if (err && error) { } else if (err && error) {
@@ -236,7 +243,7 @@ export async function removePublicSamlCertificate(success, error) {
} }
export async function removePrivateSamlCertificate(success, error) { export async function removePrivateSamlCertificate(success, error) {
const {data, error: err} = await AdminActions.removePrivateSamlCertificate()(dispatch, getState); const {data, error: err} = await dispatch(AdminActions.removePrivateSamlCertificate());
if (data && success) { if (data && success) {
success(data); success(data);
} else if (err && error) { } else if (err && error) {
@@ -245,7 +252,7 @@ export async function removePrivateSamlCertificate(success, error) {
} }
export async function removePublicLdapCertificate(success, error) { export async function removePublicLdapCertificate(success, error) {
const {data, error: err} = await AdminActions.removePublicLdapCertificate()(dispatch, getState); const {data, error: err} = await dispatch(AdminActions.removePublicLdapCertificate());
if (data && success) { if (data && success) {
success(data); success(data);
} else if (err && error) { } else if (err && error) {
@@ -254,7 +261,7 @@ export async function removePublicLdapCertificate(success, error) {
} }
export async function removePrivateLdapCertificate(success, error) { export async function removePrivateLdapCertificate(success, error) {
const {data, error: err} = await AdminActions.removePrivateLdapCertificate()(dispatch, getState); const {data, error: err} = await dispatch(AdminActions.removePrivateLdapCertificate());
if (data && success) { if (data && success) {
success(data); success(data);
} else if (err && error) { } else if (err && error) {
@@ -263,7 +270,7 @@ export async function removePrivateLdapCertificate(success, error) {
} }
export async function removeIdpSamlCertificate(success, error) { export async function removeIdpSamlCertificate(success, error) {
const {data, error: err} = await AdminActions.removeIdpSamlCertificate()(dispatch, getState); const {data, error: err} = await dispatch(AdminActions.removeIdpSamlCertificate());
if (data && success) { if (data && success) {
success(data); success(data);
} else if (err && error) { } else if (err && error) {
@@ -272,27 +279,27 @@ export async function removeIdpSamlCertificate(success, error) {
} }
export async function getStandardAnalytics(teamId) { export async function getStandardAnalytics(teamId) {
await AdminActions.getStandardAnalytics(teamId)(dispatch, getState); await dispatch(AdminActions.getStandardAnalytics(teamId));
} }
export async function getAdvancedAnalytics(teamId) { export async function getAdvancedAnalytics(teamId) {
await AdminActions.getAdvancedAnalytics(teamId)(dispatch, getState); await dispatch(AdminActions.getAdvancedAnalytics(teamId));
} }
export async function getBotPostsPerDayAnalytics(teamId) { export async function getBotPostsPerDayAnalytics(teamId) {
await AdminActions.getBotPostsPerDayAnalytics(teamId)(dispatch, getState); await dispatch(AdminActions.getBotPostsPerDayAnalytics(teamId));
} }
export async function getPostsPerDayAnalytics(teamId) { export async function getPostsPerDayAnalytics(teamId) {
await AdminActions.getPostsPerDayAnalytics(teamId)(dispatch, getState); await dispatch(AdminActions.getPostsPerDayAnalytics(teamId));
} }
export async function getUsersPerDayAnalytics(teamId) { export async function getUsersPerDayAnalytics(teamId) {
await AdminActions.getUsersPerDayAnalytics(teamId)(dispatch, getState); await dispatch(AdminActions.getUsersPerDayAnalytics(teamId));
} }
export async function elasticsearchTest(config, success, error) { export async function elasticsearchTest(config, success, error) {
const {data, error: err} = await AdminActions.testElasticsearch(config)(dispatch, getState); const {data, error: err} = await dispatch(AdminActions.testElasticsearch(config));
if (data && success) { if (data && success) {
success(data); success(data);
} else if (err && error) { } else if (err && error) {
@@ -301,7 +308,7 @@ export async function elasticsearchTest(config, success, error) {
} }
export async function testS3Connection(success, error) { export async function testS3Connection(success, error) {
const {data, error: err} = await AdminActions.testS3Connection()(dispatch, getState); const {data, error: err} = await dispatch(AdminActions.testS3Connection());
if (data && success) { if (data && success) {
success(data); success(data);
} else if (err && error) { } else if (err && error) {
@@ -310,7 +317,7 @@ export async function testS3Connection(success, error) {
} }
export async function elasticsearchPurgeIndexes(success, error) { export async function elasticsearchPurgeIndexes(success, error) {
const {data, error: err} = await AdminActions.purgeElasticsearchIndexes()(dispatch, getState); const {data, error: err} = await dispatch(AdminActions.purgeElasticsearchIndexes());
if (data && success) { if (data && success) {
success(data); success(data);
} else if (err && error) { } else if (err && error) {
@@ -441,7 +448,7 @@ export async function getSamlMetadataFromIdp(success, error, samlMetadataURL) {
} }
export async function setSamlIdpCertificateFromMetadata(success, error, certData) { export async function setSamlIdpCertificateFromMetadata(success, error, certData) {
const {data, error: err} = await AdminActions.setSamlIdpCertificateFromMetadata(certData)(dispatch, getState); const {data, error: err} = await dispatch(AdminActions.setSamlIdpCertificateFromMetadata(certData));
if (data && success) { if (data && success) {
success('saml-idp.crt'); success('saml-idp.crt');
} else if (err && error) { } else if (err && error) {

Просмотреть файл

@@ -1,13 +1,16 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information. // See LICENSE.txt for license information.
import type {AnyAction, Action as ReduxAction} from 'redux';
import type {ThunkAction} from 'redux-thunk';
import type {AppCallResponse, AppForm, AppCallRequest, AppContext, AppBinding} from '@mattermost/types/apps'; import type {AppCallResponse, AppForm, AppCallRequest, AppContext, AppBinding} from '@mattermost/types/apps';
import type {CommandArgs} from '@mattermost/types/integrations'; import type {CommandArgs} from '@mattermost/types/integrations';
import type {Post} from '@mattermost/types/posts'; import type {Post} from '@mattermost/types/posts';
import {Client4} from 'mattermost-redux/client'; import {Client4} from 'mattermost-redux/client';
import {AppCallResponseTypes} from 'mattermost-redux/constants/apps'; import {AppCallResponseTypes} from 'mattermost-redux/constants/apps';
import type {Action, ActionFunc, DispatchFunc} from 'mattermost-redux/types/actions'; import type {ActionFunc, NewActionFuncAsync} from 'mattermost-redux/types/actions';
import {cleanForm} from 'mattermost-redux/utils/apps'; import {cleanForm} from 'mattermost-redux/utils/apps';
import {openModal} from 'actions/views/modals'; import {openModal} from 'actions/views/modals';
@@ -19,10 +22,15 @@ import {getHistory} from 'utils/browser_history';
import {ModalIdentifiers} from 'utils/constants'; import {ModalIdentifiers} from 'utils/constants';
import {getSiteURL, shouldOpenInNewTab} from 'utils/url'; import {getSiteURL, shouldOpenInNewTab} from 'utils/url';
import type {DoAppCallResult} from 'types/apps';
import type {GlobalState} from 'types/store';
import {sendEphemeralPost} from './global_actions'; import {sendEphemeralPost} from './global_actions';
export function handleBindingClick<Res=unknown>(binding: AppBinding, context: AppContext, intl: any): ActionFunc { export type AppsActionFunc<Res = unknown> = ThunkAction<Promise<Res>, GlobalState, unknown, ReduxAction>;
return async (dispatch: DispatchFunc) => {
export function handleBindingClick<Res=unknown>(binding: AppBinding, context: AppContext, intl: any): AppsActionFunc<DoAppCallResult<Res>> {
return async (dispatch) => {
// Fetch form // Fetch form
let form = binding.form; let form = binding.form;
if (form?.source) { if (form?.source) {
@@ -31,7 +39,7 @@ export function handleBindingClick<Res=unknown>(binding: AppBinding, context: Ap
if (res.error) { if (res.error) {
return res; return res;
} }
form = res.data.form; form = res.data!.form;
} }
// Open form // Open form
@@ -45,7 +53,7 @@ export function handleBindingClick<Res=unknown>(binding: AppBinding, context: Ap
return {error: makeCallErrorResponse(errMsg)}; return {error: makeCallErrorResponse(errMsg)};
} }
const res: AppCallResponse = { const res: AppCallResponse<Res> = {
type: AppCallResponseTypes.FORM, type: AppCallResponseTypes.FORM,
form, form,
}; };
@@ -72,7 +80,7 @@ export function handleBindingClick<Res=unknown>(binding: AppBinding, context: Ap
}; };
} }
export function doAppSubmit<Res=unknown>(inCall: AppCallRequest, intl: any): ActionFunc { export function doAppSubmit<Res=unknown>(inCall: AppCallRequest, intl: any): ThunkAction<Promise<DoAppCallResult<Res>>, GlobalState, unknown, ReduxAction> {
return async () => { return async () => {
try { try {
const call: AppCallRequest = { const call: AppCallRequest = {
@@ -136,7 +144,7 @@ export function doAppSubmit<Res=unknown>(inCall: AppCallRequest, intl: any): Act
}; };
} }
export function doAppFetchForm<Res=unknown>(call: AppCallRequest, intl: any): ActionFunc { export function doAppFetchForm<Res=unknown>(call: AppCallRequest, intl: any): ThunkAction<Promise<DoAppCallResult<Res>>, GlobalState, unknown, ReduxAction> {
return async () => { return async () => {
try { try {
const res = await Client4.executeAppCall(call, false) as AppCallResponse<Res>; const res = await Client4.executeAppCall(call, false) as AppCallResponse<Res>;
@@ -173,7 +181,7 @@ export function doAppFetchForm<Res=unknown>(call: AppCallRequest, intl: any): Ac
}; };
} }
export function doAppLookup<Res=unknown>(call: AppCallRequest, intl: any): ActionFunc { export function doAppLookup<Res=unknown>(call: AppCallRequest, intl: any): ThunkAction<Promise<DoAppCallResult<Res>>, GlobalState, unknown, ReduxAction> {
return async () => { return async () => {
try { try {
const res = await Client4.executeAppCall(call, false) as AppCallResponse<Res>; const res = await Client4.executeAppCall(call, false) as AppCallResponse<Res>;
@@ -203,8 +211,8 @@ export function doAppLookup<Res=unknown>(call: AppCallRequest, intl: any): Actio
}; };
} }
export function makeFetchBindings(location: string): (channelId: string, teamId: string) => ActionFunc { export function makeFetchBindings(location: string): (channelId: string, teamId: string) => NewActionFuncAsync<AppBinding[]> {
return (channelId: string, teamId: string): ActionFunc => { return (channelId: string, teamId: string): NewActionFuncAsync<AppBinding[]> => {
return async () => { return async () => {
try { try {
const allBindings = await Client4.getAppsBindings(channelId, teamId); const allBindings = await Client4.getAppsBindings(channelId, teamId);
@@ -218,7 +226,7 @@ export function makeFetchBindings(location: string): (channelId: string, teamId:
}; };
} }
export function openAppsModal(form: AppForm, context: AppContext): Action { export function openAppsModal(form: AppForm, context: AppContext): AnyAction {
return openModal({ return openModal({
modalId: ModalIdentifiers.APPS_MODAL, modalId: ModalIdentifiers.APPS_MODAL,
dialogType: AppsForm, dialogType: AppsForm,

Просмотреть файл

@@ -14,7 +14,7 @@ import {getChannelByName, getUnreadChannelIds, getChannel} from 'mattermost-redu
import {getMyChannelMemberships} from 'mattermost-redux/selectors/entities/common'; import {getMyChannelMemberships} from 'mattermost-redux/selectors/entities/common';
import {getCurrentTeamUrl, getCurrentTeamId} from 'mattermost-redux/selectors/entities/teams'; import {getCurrentTeamUrl, getCurrentTeamId} from 'mattermost-redux/selectors/entities/teams';
import {getCurrentUserId} from 'mattermost-redux/selectors/entities/users'; import {getCurrentUserId} from 'mattermost-redux/selectors/entities/users';
import type {ActionFunc} from 'mattermost-redux/types/actions'; import type {ActionFunc, NewActionFuncAsync} from 'mattermost-redux/types/actions';
import {trackEvent} from 'actions/telemetry_actions.jsx'; import {trackEvent} from 'actions/telemetry_actions.jsx';
import {loadNewDMIfNeeded, loadNewGMIfNeeded, loadProfilesForSidebar} from 'actions/user_actions'; import {loadNewDMIfNeeded, loadNewGMIfNeeded, loadProfilesForSidebar} from 'actions/user_actions';
@@ -23,7 +23,7 @@ import {getHistory} from 'utils/browser_history';
import {Constants, Preferences, NotificationLevels} from 'utils/constants'; import {Constants, Preferences, NotificationLevels} from 'utils/constants';
import {getDirectChannelName} from 'utils/utils'; import {getDirectChannelName} from 'utils/utils';
export function openDirectChannelToUserId(userId: UserProfile['id']): ActionFunc { export function openDirectChannelToUserId(userId: UserProfile['id']): NewActionFuncAsync<Channel> {
return async (dispatch, getState) => { return async (dispatch, getState) => {
const state = getState(); const state = getState();
const currentUserId = getCurrentUserId(state); const currentUserId = getCurrentUserId(state);
@@ -31,7 +31,7 @@ export function openDirectChannelToUserId(userId: UserProfile['id']): ActionFunc
const channel = getChannelByName(state, channelName); const channel = getChannelByName(state, channelName);
if (!channel) { if (!channel) {
return dispatch(ChannelActions.createDirectChannel(currentUserId, userId)); return dispatch(ChannelActions.createDirectChannel(currentUserId, userId) as any); // HARRISONTODO ActionFunc needs migration
} }
trackEvent('api', 'api_channels_join_direct'); trackEvent('api', 'api_channels_join_direct');
@@ -64,7 +64,7 @@ export function openDirectChannelToUserId(userId: UserProfile['id']): ActionFunc
}; };
} }
export function openGroupChannelToUserIds(userIds: Array<UserProfile['id']>): ActionFunc { export function openGroupChannelToUserIds(userIds: Array<UserProfile['id']>): NewActionFuncAsync<Channel> {
return async (dispatch, getState) => { return async (dispatch, getState) => {
const result = await dispatch(ChannelActions.createGroupChannel(userIds)); const result = await dispatch(ChannelActions.createGroupChannel(userIds));
@@ -116,7 +116,7 @@ export function searchMoreChannels(term: string, showArchivedChannels: boolean,
}; };
} }
export function autocompleteChannels(term: string, success: (channels: Channel[]) => void, error?: (err: ServerError) => void): ActionFunc { export function autocompleteChannels(term: string, success: (channels: Channel[]) => void, error?: (err: ServerError) => void): NewActionFuncAsync<boolean> {
return async (dispatch, getState) => { return async (dispatch, getState) => {
const state = getState(); const state = getState();
const teamId = getCurrentTeamId(state); const teamId = getCurrentTeamId(state);
@@ -135,7 +135,7 @@ export function autocompleteChannels(term: string, success: (channels: Channel[]
}; };
} }
export function autocompleteChannelsForSearch(term: string, success: (channels: Channel[]) => void, error: (err: ServerError) => void): ActionFunc { export function autocompleteChannelsForSearch(term: string, success?: (channels: Channel[]) => void, error?: (err: ServerError) => void): NewActionFuncAsync {
return async (dispatch, getState) => { return async (dispatch, getState) => {
const state = getState(); const state = getState();
const teamId = getCurrentTeamId(state); const teamId = getCurrentTeamId(state);
@@ -154,12 +154,12 @@ export function autocompleteChannelsForSearch(term: string, success: (channels:
}; };
} }
export function addUsersToChannel(channelId: Channel['id'], userIds: Array<UserProfile['id']>): ActionFunc { export function addUsersToChannel(channelId: Channel['id'], userIds: Array<UserProfile['id']>): NewActionFuncAsync {
return async (dispatch) => { return async (dispatch) => {
try { try {
const requests = userIds.map((uId) => dispatch(ChannelActions.addChannelMember(channelId, uId))); const requests = userIds.map((uId) => dispatch(ChannelActions.addChannelMember(channelId, uId)));
return await Promise.all(requests); return await Promise.all(requests) as any; // HARRISONTODO This incorrectly returns an ActionResult[]
} catch (error) { } catch (error) {
return {error}; return {error};
} }

Просмотреть файл

@@ -272,7 +272,7 @@ export function retryFailedCloudFetches() {
} }
if (errors.limits) { if (errors.limits) {
getCloudLimits()(dispatch, getState); dispatch(getCloudLimits());
} }
return {data: true}; return {data: true};

Просмотреть файл

@@ -15,7 +15,7 @@ import {isMarketplaceEnabled} from 'mattermost-redux/selectors/entities/general'
import {haveICurrentTeamPermission} from 'mattermost-redux/selectors/entities/roles'; import {haveICurrentTeamPermission} from 'mattermost-redux/selectors/entities/roles';
import {getCurrentRelativeTeamUrl, getCurrentTeamId} from 'mattermost-redux/selectors/entities/teams'; import {getCurrentRelativeTeamUrl, getCurrentTeamId} from 'mattermost-redux/selectors/entities/teams';
import {getCurrentUserId} from 'mattermost-redux/selectors/entities/users'; import {getCurrentUserId} from 'mattermost-redux/selectors/entities/users';
import type {ActionFunc, DispatchFunc, GetStateFunc} from 'mattermost-redux/types/actions'; import type {NewActionFuncAsync} from 'mattermost-redux/types/actions';
import * as GlobalActions from 'actions/global_actions'; import * as GlobalActions from 'actions/global_actions';
import * as PostActions from 'actions/post_actions'; import * as PostActions from 'actions/post_actions';
@@ -34,14 +34,13 @@ import {isUrlSafe, getSiteURL} from 'utils/url';
import * as UserAgent from 'utils/user_agent'; import * as UserAgent from 'utils/user_agent';
import {localizeMessage, getUserIdFromChannelName} from 'utils/utils'; import {localizeMessage, getUserIdFromChannelName} from 'utils/utils';
import type {DoAppCallResult} from 'types/apps';
import type {GlobalState} from 'types/store'; import type {GlobalState} from 'types/store';
import {doAppSubmit, openAppsModal, postEphemeralCallResponseForCommandArgs} from './apps'; import {doAppSubmit, openAppsModal, postEphemeralCallResponseForCommandArgs} from './apps';
import {trackEvent} from './telemetry_actions'; import {trackEvent} from './telemetry_actions';
export function executeCommand(message: string, args: CommandArgs): ActionFunc { export function executeCommand(message: string, args: CommandArgs): NewActionFuncAsync<boolean, GlobalState> {
return async (dispatch: DispatchFunc, getState: GetStateFunc) => { return async (dispatch, getState) => {
const state = getState() as GlobalState; const state = getState() as GlobalState;
let msg = message; let msg = message;
@@ -155,7 +154,7 @@ export function executeCommand(message: string, args: CommandArgs): ActionFunc {
return createErrorMessage(errorMessage!); return createErrorMessage(errorMessage!);
} }
const res = await dispatch(doAppSubmit(creq, intlShim)) as DoAppCallResult; const res = await dispatch(doAppSubmit(creq, intlShim));
if (res.error) { if (res.error) {
const errorResponse = res.error; const errorResponse = res.error;

Просмотреть файл

@@ -1,6 +1,10 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information. // See LICENSE.txt for license information.
/**
* @param {Post} originalPost
* @returns {NewActionFuncAsync<Post>}
*/
export function runMessageWillBePostedHooks(originalPost) { export function runMessageWillBePostedHooks(originalPost) {
return async (dispatch, getState) => { return async (dispatch, getState) => {
const hooks = getState().plugins.components.MessageWillBePosted; const hooks = getState().plugins.components.MessageWillBePosted;

Просмотреть файл

@@ -7,11 +7,11 @@ import * as IntegrationActions from 'mattermost-redux/actions/integrations';
import {getProfilesByIds} from 'mattermost-redux/actions/users'; import {getProfilesByIds} from 'mattermost-redux/actions/users';
import {appsEnabled} from 'mattermost-redux/selectors/entities/apps'; import {appsEnabled} from 'mattermost-redux/selectors/entities/apps';
import {getUser} from 'mattermost-redux/selectors/entities/users'; import {getUser} from 'mattermost-redux/selectors/entities/users';
import type {ActionFunc} from 'mattermost-redux/types/actions'; import type {ActionFunc, NewActionFuncAsync} from 'mattermost-redux/types/actions';
const DEFAULT_PAGE_SIZE = 100; const DEFAULT_PAGE_SIZE = 100;
export function loadIncomingHooksAndProfilesForTeam(teamId: string, page = 0, perPage = DEFAULT_PAGE_SIZE): ActionFunc { export function loadIncomingHooksAndProfilesForTeam(teamId: string, page = 0, perPage = DEFAULT_PAGE_SIZE): NewActionFuncAsync<IncomingWebhook[]> {
return async (dispatch) => { return async (dispatch) => {
const {data} = await dispatch(IntegrationActions.getIncomingHooks(teamId, page, perPage)); const {data} = await dispatch(IntegrationActions.getIncomingHooks(teamId, page, perPage));
if (data) { if (data) {
@@ -42,7 +42,7 @@ export function loadProfilesForIncomingHooks(hooks: IncomingWebhook[]): ActionFu
}; };
} }
export function loadOutgoingHooksAndProfilesForTeam(teamId: string, page = 0, perPage = DEFAULT_PAGE_SIZE): ActionFunc { export function loadOutgoingHooksAndProfilesForTeam(teamId: string, page = 0, perPage = DEFAULT_PAGE_SIZE): NewActionFuncAsync<OutgoingWebhook[]> {
return async (dispatch) => { return async (dispatch) => {
const {data} = await dispatch(IntegrationActions.getOutgoingHooks('', teamId, page, perPage)); const {data} = await dispatch(IntegrationActions.getOutgoingHooks('', teamId, page, perPage));
if (data) { if (data) {
@@ -104,7 +104,7 @@ export function loadProfilesForCommands(commands: Command[]): ActionFunc {
}; };
} }
export function loadOAuthAppsAndProfiles(page = 0, perPage = DEFAULT_PAGE_SIZE): ActionFunc { export function loadOAuthAppsAndProfiles(page = 0, perPage = DEFAULT_PAGE_SIZE): NewActionFuncAsync {
return async (dispatch, getState) => { return async (dispatch, getState) => {
if (appsEnabled(getState())) { if (appsEnabled(getState())) {
dispatch(IntegrationActions.getAppsOAuthAppIDs()); dispatch(IntegrationActions.getAppsOAuthAppIDs());

Просмотреть файл

@@ -4,8 +4,6 @@
import type {Channel} from '@mattermost/types/channels'; import type {Channel} from '@mattermost/types/channels';
import type {UserProfile} from '@mattermost/types/users'; import type {UserProfile} from '@mattermost/types/users';
import type {DispatchFunc, GetStateFunc} from 'mattermost-redux/types/actions';
import {sendMembersInvites, sendGuestsInvites} from 'actions/invite_actions'; import {sendMembersInvites, sendGuestsInvites} from 'actions/invite_actions';
import mockStore from 'tests/test_store'; import mockStore from 'tests/test_store';
@@ -124,7 +122,7 @@ describe('actions/invite_actions', () => {
describe('sendMembersInvites', () => { describe('sendMembersInvites', () => {
it('should generate and empty list if nothing is passed', async () => { it('should generate and empty list if nothing is passed', async () => {
const response = await sendMembersInvites('correct', [], [])(store.dispatch as DispatchFunc, store.getState as GetStateFunc); const response = await store.dispatch(sendMembersInvites('correct', [], []));
expect(response).toEqual({ expect(response).toEqual({
data: { data: {
sent: [], sent: [],
@@ -135,7 +133,7 @@ describe('actions/invite_actions', () => {
it('should generate list of success for emails', async () => { it('should generate list of success for emails', async () => {
const emails = ['email-one@email-one.com', 'email-two@email-two.com', 'email-three@email-three.com']; const emails = ['email-one@email-one.com', 'email-two@email-two.com', 'email-three@email-three.com'];
const response = await sendMembersInvites('correct', [], emails)(store.dispatch as DispatchFunc, store.getState as GetStateFunc); const response = await store.dispatch(sendMembersInvites('correct', [], emails));
expect(response).toEqual({ expect(response).toEqual({
data: { data: {
notSent: [], notSent: [],
@@ -159,7 +157,7 @@ describe('actions/invite_actions', () => {
it('should generate list of failures for emails on invite fails', async () => { it('should generate list of failures for emails on invite fails', async () => {
const emails = ['email-one@email-one.com', 'email-two@email-two.com', 'email-three@email-three.com']; const emails = ['email-one@email-one.com', 'email-two@email-two.com', 'email-three@email-three.com'];
const response = await sendMembersInvites('error', [], emails)(store.dispatch as DispatchFunc, store.getState as GetStateFunc); const response = await store.dispatch(sendMembersInvites('error', [], emails));
expect(response).toEqual({ expect(response).toEqual({
data: { data: {
sent: [], sent: [],
@@ -188,7 +186,7 @@ describe('actions/invite_actions', () => {
{id: 'other-user', roles: 'system_user'}, {id: 'other-user', roles: 'system_user'},
{id: 'other-guest', roles: 'system_guest'}, {id: 'other-guest', roles: 'system_guest'},
] as UserProfile[]; ] as UserProfile[];
const response = await sendMembersInvites('correct', users, [])(store.dispatch as DispatchFunc, store.getState as GetStateFunc); const response = await store.dispatch(sendMembersInvites('correct', users, []));
expect(response).toEqual({ expect(response).toEqual({
data: { data: {
sent: [ sent: [
@@ -234,7 +232,7 @@ describe('actions/invite_actions', () => {
{id: 'other-user', roles: 'system_user'}, {id: 'other-user', roles: 'system_user'},
{id: 'other-guest', roles: 'system_guest'}, {id: 'other-guest', roles: 'system_guest'},
] as UserProfile[]; ] as UserProfile[];
const response = await sendMembersInvites('error', users, [])(store.dispatch as DispatchFunc, store.getState as GetStateFunc); const response = await store.dispatch(sendMembersInvites('error', users, []));
expect(response).toEqual({ expect(response).toEqual({
data: { data: {
sent: [{user: {id: 'other-user', roles: 'system_user'}, reason: 'This member has been added to the team.'}], sent: [{user: {id: 'other-user', roles: 'system_user'}, reason: 'This member has been added to the team.'}],
@@ -275,7 +273,7 @@ describe('actions/invite_actions', () => {
reason: 'Invite emails rate limit exceeded.', reason: 'Invite emails rate limit exceeded.',
}); });
} }
const response = await sendMembersInvites('correct', [], emails)(store.dispatch as DispatchFunc, store.getState as GetStateFunc); const response = await store.dispatch(sendMembersInvites('correct', [], emails));
expect(response).toEqual({ expect(response).toEqual({
data: { data: {
notSent: expectedNotSent, notSent: expectedNotSent,
@@ -286,7 +284,7 @@ describe('actions/invite_actions', () => {
it('should generate a failure for smtp config', async () => { it('should generate a failure for smtp config', async () => {
const emails = ['email-one@email-one.com']; const emails = ['email-one@email-one.com'];
const response = await sendMembersInvites('incorrect-default-smtp', [], emails)(store.dispatch as DispatchFunc, store.getState as GetStateFunc); const response = await store.dispatch(sendMembersInvites('incorrect-default-smtp', [], emails));
expect(response).toEqual({ expect(response).toEqual({
data: { data: {
notSent: [ notSent: [
@@ -306,7 +304,7 @@ describe('actions/invite_actions', () => {
describe('sendGuestsInvites', () => { describe('sendGuestsInvites', () => {
it('should generate and empty list if nothing is passed', async () => { it('should generate and empty list if nothing is passed', async () => {
const response = await sendGuestsInvites('correct', [], [], [], '')(store.dispatch as DispatchFunc, store.getState as GetStateFunc); const response = await store.dispatch(sendGuestsInvites('correct', [], [], [], ''));
expect(response).toEqual({ expect(response).toEqual({
data: { data: {
sent: [], sent: [],
@@ -318,7 +316,7 @@ describe('actions/invite_actions', () => {
it('should generate list of success for emails', async () => { it('should generate list of success for emails', async () => {
const channels = [{id: 'correct'}] as Channel[]; const channels = [{id: 'correct'}] as Channel[];
const emails = ['email-one@email-one.com', 'email-two@email-two.com', 'email-three@email-three.com']; const emails = ['email-one@email-one.com', 'email-two@email-two.com', 'email-three@email-three.com'];
const response = await sendGuestsInvites('correct', channels, [], emails, 'message')(store.dispatch as DispatchFunc, store.getState as GetStateFunc); const response = await store.dispatch(sendGuestsInvites('correct', channels, [], emails, 'message'));
expect(response).toEqual({ expect(response).toEqual({
data: { data: {
notSent: [], notSent: [],
@@ -343,7 +341,7 @@ describe('actions/invite_actions', () => {
it('should generate list of failures for emails on invite fails', async () => { it('should generate list of failures for emails on invite fails', async () => {
const channels = [{id: 'correct'}] as Channel[]; const channels = [{id: 'correct'}] as Channel[];
const emails = ['email-one@email-one.com', 'email-two@email-two.com', 'email-three@email-three.com']; const emails = ['email-one@email-one.com', 'email-two@email-two.com', 'email-three@email-three.com'];
const response = await sendGuestsInvites('error', channels, [], emails, 'message')(store.dispatch as DispatchFunc, store.getState as GetStateFunc); const response = await store.dispatch(sendGuestsInvites('error', channels, [], emails, 'message'));
expect(response).toEqual({ expect(response).toEqual({
data: { data: {
sent: [], sent: [],
@@ -373,7 +371,7 @@ describe('actions/invite_actions', () => {
{id: 'other-user', roles: 'system_user'}, {id: 'other-user', roles: 'system_user'},
{id: 'other-guest', roles: 'system_guest'}, {id: 'other-guest', roles: 'system_guest'},
] as UserProfile[]; ] as UserProfile[];
const response = await sendGuestsInvites('correct', channels, users, [], 'message')(store.dispatch as DispatchFunc, store.getState as GetStateFunc); const response = await store.dispatch(sendGuestsInvites('correct', channels, users, [], 'message'));
expect(response).toEqual({ expect(response).toEqual({
data: { data: {
sent: [ sent: [
@@ -425,7 +423,7 @@ describe('actions/invite_actions', () => {
{id: 'guest2', roles: 'system_guest'}, {id: 'guest2', roles: 'system_guest'},
{id: 'guest3', roles: 'system_guest'}, {id: 'guest3', roles: 'system_guest'},
] as UserProfile[]; ] as UserProfile[];
const response = await sendGuestsInvites('correct', [{id: 'correct'}, {id: 'correct2'}] as Channel[], users, [], 'message')(store.dispatch as DispatchFunc, store.getState as GetStateFunc); const response = await store.dispatch(sendGuestsInvites('correct', [{id: 'correct'}, {id: 'correct2'}] as Channel[], users, [], 'message'));
expect(response).toEqual({ expect(response).toEqual({
data: { data: {
sent: [], sent: [],
@@ -456,7 +454,7 @@ describe('actions/invite_actions', () => {
{id: 'other-user', roles: 'system_user'}, {id: 'other-user', roles: 'system_user'},
{id: 'other-guest', roles: 'system_guest'}, {id: 'other-guest', roles: 'system_guest'},
] as UserProfile[]; ] as UserProfile[];
const response = await sendGuestsInvites('error', [{id: 'correct'}] as Channel[], users, [], 'message')(store.dispatch as DispatchFunc, store.getState as GetStateFunc); const response = await store.dispatch(sendGuestsInvites('error', [{id: 'correct'}] as Channel[], users, [], 'message'));
expect(response).toEqual({ expect(response).toEqual({
data: { data: {
@@ -515,7 +513,7 @@ describe('actions/invite_actions', () => {
{id: 'other-user', roles: 'system_user'}, {id: 'other-user', roles: 'system_user'},
{id: 'other-guest', roles: 'system_guest'}, {id: 'other-guest', roles: 'system_guest'},
] as UserProfile[]; ] as UserProfile[];
const response = await sendGuestsInvites('correct', [{id: 'error'}] as Channel[], users, [], 'message')(store.dispatch as DispatchFunc, store.getState as GetStateFunc); const response = await store.dispatch(sendGuestsInvites('correct', [{id: 'error'}] as Channel[], users, [], 'message'));
expect(response).toEqual({ expect(response).toEqual({
data: { data: {
sent: [], sent: [],
@@ -564,7 +562,7 @@ describe('actions/invite_actions', () => {
}); });
} }
const response = await sendGuestsInvites('correct', [{id: 'correct'}] as Channel[], [], emails, 'message')(store.dispatch as DispatchFunc, store.getState as GetStateFunc); const response = await store.dispatch(sendGuestsInvites('correct', [{id: 'correct'}] as Channel[], [], emails, 'message'));
expect(response).toEqual({ expect(response).toEqual({
data: { data: {
notSent: expectedNotSent, notSent: expectedNotSent,
@@ -575,7 +573,7 @@ describe('actions/invite_actions', () => {
it('should generate a failure for smtp config', async () => { it('should generate a failure for smtp config', async () => {
const emails = ['email-one@email-one.com']; const emails = ['email-one@email-one.com'];
const response = await sendGuestsInvites('incorrect-default-smtp', [{id: 'error'}] as Channel[], [], emails, 'message')(store.dispatch as DispatchFunc, store.getState as GetStateFunc); const response = await store.dispatch(sendGuestsInvites('incorrect-default-smtp', [{id: 'error'}] as Channel[], [], emails, 'message'));
expect(response).toEqual({ expect(response).toEqual({
data: { data: {
notSent: [ notSent: [

Просмотреть файл

@@ -11,17 +11,19 @@ import * as TeamActions from 'mattermost-redux/actions/teams';
import {getChannelMembersInChannels} from 'mattermost-redux/selectors/entities/channels'; import {getChannelMembersInChannels} from 'mattermost-redux/selectors/entities/channels';
import {getTeamMember} from 'mattermost-redux/selectors/entities/teams'; import {getTeamMember} from 'mattermost-redux/selectors/entities/teams';
import {isCurrentUserSystemAdmin} from 'mattermost-redux/selectors/entities/users'; import {isCurrentUserSystemAdmin} from 'mattermost-redux/selectors/entities/users';
import type {ActionFunc, DispatchFunc, GetStateFunc} from 'mattermost-redux/types/actions'; import type {DispatchFunc, NewActionFuncAsync} from 'mattermost-redux/types/actions';
import {isGuest} from 'mattermost-redux/utils/user_utils'; import {isGuest} from 'mattermost-redux/utils/user_utils';
import {addUsersToTeam} from 'actions/team_actions'; import {addUsersToTeam} from 'actions/team_actions';
import type {InviteResults} from 'components/invitation_modal/result_view';
import {ConsolePages} from 'utils/constants'; import {ConsolePages} from 'utils/constants';
import {t} from 'utils/i18n'; import {t} from 'utils/i18n';
import {localizeMessage} from 'utils/utils'; import {localizeMessage} from 'utils/utils';
export function sendMembersInvites(teamId: string, users: UserProfile[], emails: string[]): ActionFunc { export function sendMembersInvites(teamId: string, users: UserProfile[], emails: string[]): NewActionFuncAsync<InviteResults> {
return async (dispatch: DispatchFunc, getState: GetStateFunc) => { return async (dispatch, getState) => {
if (users.length > 0) { if (users.length > 0) {
await dispatch(TeamActions.getTeamMembersByIds(teamId, users.map((u) => u.id))); await dispatch(TeamActions.getTeamMembersByIds(teamId, users.map((u) => u.id)));
} }
@@ -62,7 +64,12 @@ export function sendMembersInvites(teamId: string, users: UserProfile[], emails:
try { try {
response = await dispatch(TeamActions.sendEmailInvitesToTeamGracefully(teamId, emails)); response = await dispatch(TeamActions.sendEmailInvitesToTeamGracefully(teamId, emails));
} catch (e) { } catch (e) {
response = {data: emails.map((email) => ({email, error: {error: localizeMessage('invite.members.unable-to-add-the-user-to-the-team', 'Unable to add the user to the team.')}}))}; response = {
data: emails.map((email) => ({
email,
error: {error: localizeMessage('invite.members.unable-to-add-the-user-to-the-team', 'Unable to add the user to the team.')},
})) as any, // HARRISONTODO These error handling cases return slightly different types
};
} }
const invitesWithErrors = response.data || []; const invitesWithErrors = response.data || [];
if (response.error) { if (response.error) {
@@ -151,8 +158,8 @@ export function sendGuestsInvites(
users: UserProfile[], users: UserProfile[],
emails: string[], emails: string[],
message: string, message: string,
): ActionFunc { ): NewActionFuncAsync<InviteResults> {
return async (dispatch: DispatchFunc, getState: GetStateFunc) => { return async (dispatch, getState) => {
const state = getState(); const state = getState();
const sent = []; const sent = [];
const notSent = []; const notSent = [];
@@ -173,7 +180,12 @@ export function sendGuestsInvites(
try { try {
response = await dispatch(TeamActions.sendEmailGuestInvitesToChannelsGracefully(teamId, channels.map((x) => x.id), emails, message)); response = await dispatch(TeamActions.sendEmailGuestInvitesToChannelsGracefully(teamId, channels.map((x) => x.id), emails, message));
} catch (e) { } catch (e) {
response = {data: emails.map((email) => ({email, error: {error: localizeMessage('invite.guests.unable-to-add-the-user-to-the-channels', 'Unable to add the guest to the channels.')}}))}; response = {
data: emails.map((email) => ({
email,
error: {error: localizeMessage('invite.guests.unable-to-add-the-user-to-the-channels', 'Unable to add the guest to the channels.')},
})),
} as any; // HARRISONTODO These error handling cases return slightly different types
} }
if (response.error) { if (response.error) {
@@ -214,8 +226,8 @@ export function sendMembersInvitesToChannels(
users: UserProfile[], users: UserProfile[],
emails: string[], emails: string[],
message: string, message: string,
): ActionFunc { ): NewActionFuncAsync<InviteResults> {
return async (dispatch: DispatchFunc, getState: GetStateFunc) => { return async (dispatch, getState) => {
if (users.length > 0) { if (users.length > 0) {
// used to preload in the global store the teammembers info, used later to validate // used to preload in the global store the teammembers info, used later to validate
// if one of the invites is already part of the team by getTeamMembers > getMembersInTeam. // if one of the invites is already part of the team by getTeamMembers > getMembersInTeam.
@@ -265,7 +277,12 @@ export function sendMembersInvitesToChannels(
), ),
); );
} catch (e) { } catch (e) {
response = {data: emails.map((email) => ({email, error: {error: localizeMessage('invite.members.unable-to-add-the-user-to-the-team', 'Unable to add the user to the team.')}}))}; response = {
data: emails.map((email) => ({
email,
error: {error: localizeMessage('invite.members.unable-to-add-the-user-to-the-team', 'Unable to add the user to the team.')},
})) as any, // HARRISONTODO These error handling cases return slightly different types
};
} }
const invitesWithErrors = response.data || []; const invitesWithErrors = response.data || [];
if (response.error) { if (response.error) {

Просмотреть файл

@@ -15,7 +15,7 @@ import * as PostSelectors from 'mattermost-redux/selectors/entities/posts';
import {isCollapsedThreadsEnabled} from 'mattermost-redux/selectors/entities/preferences'; import {isCollapsedThreadsEnabled} from 'mattermost-redux/selectors/entities/preferences';
import {getCurrentTeamId} from 'mattermost-redux/selectors/entities/teams'; import {getCurrentTeamId} from 'mattermost-redux/selectors/entities/teams';
import {getCurrentUserId, isCurrentUserSystemAdmin} from 'mattermost-redux/selectors/entities/users'; import {getCurrentUserId, isCurrentUserSystemAdmin} from 'mattermost-redux/selectors/entities/users';
import type {DispatchFunc, GetStateFunc} from 'mattermost-redux/types/actions'; import type {DispatchFunc, GetStateFunc, NewActionFunc, NewActionFuncAsync, NewActionFuncOldVariantDoNotUse} from 'mattermost-redux/types/actions';
import {canEditPost, comparePosts} from 'mattermost-redux/utils/post_utils'; import {canEditPost, comparePosts} from 'mattermost-redux/utils/post_utils';
import {addRecentEmoji, addRecentEmojis} from 'actions/emoji_actions'; import {addRecentEmoji, addRecentEmojis} from 'actions/emoji_actions';
@@ -146,8 +146,8 @@ function storeCommentDraft(rootPostId: string, draft: null) {
}; };
} }
export function submitReaction(postId: string, action: string, emojiName: string) { export function submitReaction(postId: string, action: string, emojiName: string): NewActionFuncOldVariantDoNotUse {
return (dispatch: DispatchFunc, getState: GetStateFunc) => { return (dispatch, getState) => {
const state = getState() as GlobalState; const state = getState() as GlobalState;
const getIsReactionAlreadyAddedToPost = makeGetIsReactionAlreadyAddedToPost(); const getIsReactionAlreadyAddedToPost = makeGetIsReactionAlreadyAddedToPost();
@@ -162,8 +162,8 @@ export function submitReaction(postId: string, action: string, emojiName: string
}; };
} }
export function toggleReaction(postId: string, emojiName: string) { export function toggleReaction(postId: string, emojiName: string): NewActionFuncOldVariantDoNotUse {
return (dispatch: DispatchFunc, getState: GetStateFunc) => { return (dispatch, getState) => {
const state = getState() as GlobalState; const state = getState() as GlobalState;
const getIsReactionAlreadyAddedToPost = makeGetIsReactionAlreadyAddedToPost(); const getIsReactionAlreadyAddedToPost = makeGetIsReactionAlreadyAddedToPost();
@@ -176,9 +176,9 @@ export function toggleReaction(postId: string, emojiName: string) {
}; };
} }
export function addReaction(postId: string, emojiName: string) { export function addReaction(postId: string, emojiName: string): NewActionFunc {
const getUniqueEmojiNameReactionsForPost = makeGetUniqueEmojiNameReactionsForPost(); const getUniqueEmojiNameReactionsForPost = makeGetUniqueEmojiNameReactionsForPost();
return (dispatch: DispatchFunc, getState: GetStateFunc) => { return (dispatch, getState) => {
const state = getState() as GlobalState; const state = getState() as GlobalState;
const config = getConfig(state); const config = getConfig(state);
const uniqueEmojiNames = getUniqueEmojiNameReactionsForPost(state, postId) ?? []; const uniqueEmojiNames = getUniqueEmojiNameReactionsForPost(state, postId) ?? [];
@@ -277,8 +277,8 @@ export function unpinPost(postId: string) {
}; };
} }
export function setEditingPost(postId = '', refocusId = '', title = '', isRHS = false) { export function setEditingPost(postId = '', refocusId = '', title = '', isRHS = false): NewActionFunc<boolean> {
return async (dispatch: DispatchFunc, getState: GetStateFunc) => { return (dispatch, getState) => {
const state = getState(); const state = getState();
const post = PostSelectors.getPost(state, postId); const post = PostSelectors.getPost(state, postId);
@@ -316,8 +316,8 @@ export function unsetEditingPost() {
}; };
} }
export function markPostAsUnread(post: Post, location: string) { export function markPostAsUnread(post: Post, location?: string): NewActionFuncAsync {
return async (dispatch: DispatchFunc, getState: GetStateFunc) => { return async (dispatch, getState) => {
const state = getState(); const state = getState();
const userId = getCurrentUserId(state); const userId = getCurrentUserId(state);
const currentTeamId = getCurrentTeamId(state); const currentTeamId = getCurrentTeamId(state);
@@ -355,8 +355,8 @@ export function markMostRecentPostInChannelAsUnread(channelId: string) {
} }
// Action called by DeletePostModal when the post is deleted // Action called by DeletePostModal when the post is deleted
export function deleteAndRemovePost(post: Post) { export function deleteAndRemovePost(post: Post): NewActionFuncAsync<boolean> {
return async (dispatch: DispatchFunc, getState: GetStateFunc) => { return async (dispatch, getState) => {
const {error} = await dispatch(PostActions.deletePost(post)); const {error} = await dispatch(PostActions.deletePost(post));
if (error) { if (error) {
return {error}; return {error};
@@ -425,7 +425,7 @@ export function resetInlineImageVisibility() {
* *
* @param {string} emittedFrom - It can be either "CENTER", "RHS_ROOT" or "NO_WHERE" * @param {string} emittedFrom - It can be either "CENTER", "RHS_ROOT" or "NO_WHERE"
*/ */
export function emitShortcutReactToLastPostFrom(emittedFrom: 'CENTER' | 'RHS_ROOT' | 'NO_WHERE') { export function emitShortcutReactToLastPostFrom(emittedFrom: keyof typeof Constants.Locations) {
return { return {
type: ActionTypes.EMITTED_SHORTCUT_REACT_TO_LAST_POST, type: ActionTypes.EMITTED_SHORTCUT_REACT_TO_LAST_POST,
payload: emittedFrom, payload: emittedFrom,

Просмотреть файл

@@ -8,7 +8,7 @@ import {getCurrentChannelId} from 'mattermost-redux/selectors/entities/channels'
import {getPostsInCurrentChannel} from 'mattermost-redux/selectors/entities/posts'; import {getPostsInCurrentChannel} from 'mattermost-redux/selectors/entities/posts';
import {getDirectShowPreferences} from 'mattermost-redux/selectors/entities/preferences'; import {getDirectShowPreferences} from 'mattermost-redux/selectors/entities/preferences';
import {getCurrentUserId} from 'mattermost-redux/selectors/entities/users'; import {getCurrentUserId} from 'mattermost-redux/selectors/entities/users';
import type {ActionFunc, DispatchFunc, GetStateFunc} from 'mattermost-redux/types/actions'; import type {ActionFunc, DispatchFunc, GetStateFunc, NewActionFunc} from 'mattermost-redux/types/actions';
import {loadCustomEmojisForCustomStatusesByUserIds} from 'actions/emoji_actions'; import {loadCustomEmojisForCustomStatusesByUserIds} from 'actions/emoji_actions';
@@ -49,8 +49,8 @@ export function loadStatusesForChannelAndSidebar(): ActionFunc {
}; };
} }
export function loadStatusesForProfilesList(users: UserProfile[] | null) { export function loadStatusesForProfilesList(users: UserProfile[] | null): NewActionFunc<boolean> {
return (dispatch: DispatchFunc) => { return (dispatch) => {
if (users == null) { if (users == null) {
return {data: false}; return {data: false};
} }

Просмотреть файл

@@ -2,7 +2,7 @@
// See LICENSE.txt for license information. // See LICENSE.txt for license information.
import type {ServerError} from '@mattermost/types/errors'; import type {ServerError} from '@mattermost/types/errors';
import type {Team} from '@mattermost/types/teams'; import type {Team, TeamMemberWithError} from '@mattermost/types/teams';
import type {UserProfile} from '@mattermost/types/users'; import type {UserProfile} from '@mattermost/types/users';
import {TeamTypes} from 'mattermost-redux/action_types'; import {TeamTypes} from 'mattermost-redux/action_types';
@@ -15,12 +15,12 @@ import {getUser} from 'mattermost-redux/actions/users';
import {Client4} from 'mattermost-redux/client'; import {Client4} from 'mattermost-redux/client';
import {getCurrentChannelId} from 'mattermost-redux/selectors/entities/channels'; import {getCurrentChannelId} from 'mattermost-redux/selectors/entities/channels';
import {getCurrentUserId} from 'mattermost-redux/selectors/entities/users'; import {getCurrentUserId} from 'mattermost-redux/selectors/entities/users';
import type {ActionFunc, DispatchFunc, GetStateFunc} from 'mattermost-redux/types/actions'; import type {ActionFunc, DispatchFunc, GetStateFunc, NewActionFuncAsync} from 'mattermost-redux/types/actions';
import {getHistory} from 'utils/browser_history'; import {getHistory} from 'utils/browser_history';
import {Preferences} from 'utils/constants'; import {Preferences} from 'utils/constants';
export function removeUserFromTeamAndGetStats(teamId: Team['id'], userId: UserProfile['id']): ActionFunc { export function removeUserFromTeamAndGetStats(teamId: Team['id'], userId: UserProfile['id']): NewActionFuncAsync {
return async (dispatch, getState) => { return async (dispatch, getState) => {
const response = await dispatch(TeamActions.removeUserFromTeam(teamId, userId)); const response = await dispatch(TeamActions.removeUserFromTeam(teamId, userId));
dispatch(getUser(userId)); dispatch(getUser(userId));
@@ -30,7 +30,7 @@ export function removeUserFromTeamAndGetStats(teamId: Team['id'], userId: UserPr
}; };
} }
export function addUserToTeamFromInvite(token: string, inviteId: string): ActionFunc { export function addUserToTeamFromInvite(token: string, inviteId: string): NewActionFuncAsync<Team> {
return async (dispatch) => { return async (dispatch) => {
const {data: member, error} = await dispatch(TeamActions.addUserToTeamFromInvite(token, inviteId)); const {data: member, error} = await dispatch(TeamActions.addUserToTeamFromInvite(token, inviteId));
if (member) { if (member) {
@@ -52,7 +52,7 @@ export function addUserToTeamFromInvite(token: string, inviteId: string): Action
}; };
} }
export function addUserToTeam(teamId: Team['id'], userId: UserProfile['id']): ActionFunc<Team, ServerError> { export function addUserToTeam(teamId: Team['id'], userId: UserProfile['id']): NewActionFuncAsync<Team> {
return async (dispatch) => { return async (dispatch) => {
const {data: member, error} = await dispatch(TeamActions.addUserToTeam(teamId, userId)); const {data: member, error} = await dispatch(TeamActions.addUserToTeam(teamId, userId));
if (member) { if (member) {
@@ -74,7 +74,7 @@ export function addUserToTeam(teamId: Team['id'], userId: UserProfile['id']): Ac
}; };
} }
export function addUsersToTeam(teamId: Team['id'], userIds: Array<UserProfile['id']>): ActionFunc { export function addUsersToTeam(teamId: Team['id'], userIds: Array<UserProfile['id']>): NewActionFuncAsync<TeamMemberWithError[]> {
return async (dispatch, getState) => { return async (dispatch, getState) => {
const {data, error} = await dispatch(TeamActions.addUsersToTeamGracefully(teamId, userIds)); const {data, error} = await dispatch(TeamActions.addUsersToTeamGracefully(teamId, userIds));

Просмотреть файл

@@ -22,7 +22,7 @@ import {
import {getBool, isCollapsedThreadsEnabled} from 'mattermost-redux/selectors/entities/preferences'; import {getBool, isCollapsedThreadsEnabled} from 'mattermost-redux/selectors/entities/preferences';
import {getCurrentTeamId, getTeamMember} from 'mattermost-redux/selectors/entities/teams'; import {getCurrentTeamId, getTeamMember} from 'mattermost-redux/selectors/entities/teams';
import * as Selectors from 'mattermost-redux/selectors/entities/users'; import * as Selectors from 'mattermost-redux/selectors/entities/users';
import type {ActionResult, DispatchFunc, GetStateFunc} from 'mattermost-redux/types/actions'; import type {ActionResult, DispatchFunc, GetStateFunc, NewActionFuncAsync} from 'mattermost-redux/types/actions';
import {calculateUnreadCount} from 'mattermost-redux/utils/channel_utils'; import {calculateUnreadCount} from 'mattermost-redux/utils/channel_utils';
import {loadCustomEmojisForCustomStatusesByUserIds} from 'actions/emoji_actions'; import {loadCustomEmojisForCustomStatusesByUserIds} from 'actions/emoji_actions';
@@ -79,8 +79,8 @@ export function loadProfilesAndReloadChannelMembers(page: number, perPage?: numb
}; };
} }
export function loadProfilesAndTeamMembers(page: number, perPage: number, teamId: string, options?: Record<string, any>) { export function loadProfilesAndTeamMembers(page: number, perPage: number, teamId: string, options?: Record<string, any>): NewActionFuncAsync {
return async (doDispatch: DispatchFunc, doGetState: GetStateFunc) => { return async (doDispatch, doGetState) => {
const newTeamId = teamId || getCurrentTeamId(doGetState()); const newTeamId = teamId || getCurrentTeamId(doGetState());
const {data} = await doDispatch(UserActions.getProfilesInTeam(newTeamId, page, perPage, '', options)); const {data} = await doDispatch(UserActions.getProfilesInTeam(newTeamId, page, perPage, '', options));
if (data) { if (data) {
@@ -122,8 +122,8 @@ export function searchProfilesAndChannelMembers(term: string, options: Record<st
}; };
} }
export function loadProfilesAndTeamMembersAndChannelMembers(page: number, perPage: number, teamId: string, channelId: string, options?: {active?: boolean}) { export function loadProfilesAndTeamMembersAndChannelMembers(page: number, perPage: number, teamId: string, channelId: string, options?: {active?: boolean}): NewActionFuncAsync {
return async (doDispatch: DispatchFunc, doGetState: GetStateFunc) => { return async (doDispatch, doGetState) => {
const state = doGetState(); const state = doGetState();
const teamIdParam = teamId || getCurrentTeamId(state); const teamIdParam = teamId || getCurrentTeamId(state);
const channelIdParam = channelId || getCurrentChannelId(state); const channelIdParam = channelId || getCurrentChannelId(state);
@@ -227,10 +227,10 @@ export function loadNewDMIfNeeded(channelId: string) {
const pref = getBool(state, Preferences.CATEGORY_DIRECT_CHANNEL_SHOW, userId, false); const pref = getBool(state, Preferences.CATEGORY_DIRECT_CHANNEL_SHOW, userId, false);
if (pref === false) { if (pref === false) {
const now = Utils.getTimestamp(); const now = Utils.getTimestamp();
savePreferences(currentUserId, [ doDispatch(savePreferences(currentUserId, [
{user_id: currentUserId, category: Preferences.CATEGORY_DIRECT_CHANNEL_SHOW, name: userId, value: 'true'}, {user_id: currentUserId, category: Preferences.CATEGORY_DIRECT_CHANNEL_SHOW, name: userId, value: 'true'},
{user_id: currentUserId, category: Preferences.CATEGORY_CHANNEL_OPEN_TIME, name: channelId, value: now.toString()}, {user_id: currentUserId, category: Preferences.CATEGORY_CHANNEL_OPEN_TIME, name: channelId, value: now.toString()},
])(doDispatch); ]));
loadProfilesForDM(); loadProfilesForDM();
return {data: true}; return {data: true};
} }
@@ -243,7 +243,7 @@ export function loadNewDMIfNeeded(channelId: string) {
if (channel) { if (channel) {
result = checkPreference(channel); result = checkPreference(channel);
} else { } else {
result = await getChannelAndMyMember(channelId)(doDispatch, doGetState) as ActionResult; result = await doDispatch(getChannelAndMyMember(channelId));
if (result.data) { if (result.data) {
result = checkPreference(result.data.channel); result = checkPreference(result.data.channel);
} }
@@ -269,7 +269,7 @@ export function loadNewGMIfNeeded(channelId: string) {
const channel = getChannel(state, channelId); const channel = getChannel(state, channelId);
if (!channel) { if (!channel) {
await getChannelAndMyMember(channelId)(doDispatch, doGetState); await doDispatch(getChannelAndMyMember(channelId));
} }
return checkPreference(); return checkPreference();
}; };
@@ -406,13 +406,13 @@ export async function loadProfilesForDM() {
} }
if (newPreferences.length > 0) { if (newPreferences.length > 0) {
savePreferences(currentUserId, newPreferences)(dispatch); dispatch(savePreferences(currentUserId, newPreferences));
} }
if (profilesToLoad.length > 0) { if (profilesToLoad.length > 0) {
await UserActions.getProfilesByIds(profilesToLoad)(dispatch, getState); await dispatch(UserActions.getProfilesByIds(profilesToLoad));
} }
await loadCustomEmojisForCustomStatusesByUserIds(profileIds)(dispatch, getState); await dispatch(loadCustomEmojisForCustomStatusesByUserIds(profileIds));
} }
export function autocompleteUsersInTeam(username: string) { export function autocompleteUsersInTeam(username: string) {
@@ -431,9 +431,9 @@ export function autocompleteUsers(username: string) {
} }
export function autoResetStatus() { export function autoResetStatus() {
return async (doDispatch: DispatchFunc, doGetState: GetStateFunc): Promise<{data: UserStatus}> => { return async (doDispatch: DispatchFunc): Promise<{data: UserStatus}> => {
const {currentUserId} = getState().entities.users; const {currentUserId} = getState().entities.users;
const {data: userStatus} = await (UserActions.getStatus(currentUserId)(doDispatch, doGetState) as Promise<{data: UserStatus}>); const {data: userStatus} = await doDispatch(UserActions.getStatus(currentUserId));
if (userStatus.status === UserStatuses.OUT_OF_OFFICE || !userStatus.manual) { if (userStatus.status === UserStatuses.OUT_OF_OFFICE || !userStatus.manual) {
return {data: userStatus}; return {data: userStatus};
@@ -442,7 +442,7 @@ export function autoResetStatus() {
const autoReset = getBool(getState(), PreferencesRedux.CATEGORY_AUTO_RESET_MANUAL_STATUS, currentUserId, false); const autoReset = getBool(getState(), PreferencesRedux.CATEGORY_AUTO_RESET_MANUAL_STATUS, currentUserId, false);
if (autoReset) { if (autoReset) {
UserActions.setStatus({user_id: currentUserId, status: 'online'})(doDispatch, doGetState); doDispatch(UserActions.setStatus({user_id: currentUserId, status: 'online'}));
return {data: userStatus}; return {data: userStatus};
} }

Просмотреть файл

@@ -1,11 +1,9 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information. // See LICENSE.txt for license information.
import type {GenericAction} from 'mattermost-redux/types/actions';
import {Constants, ActionTypes, WindowSizes} from 'utils/constants'; import {Constants, ActionTypes, WindowSizes} from 'utils/constants';
export function emitBrowserWindowResized(windowSize?: string): GenericAction { export function emitBrowserWindowResized(windowSize?: string) {
let newWindowSize = windowSize; let newWindowSize = windowSize;
if (!windowSize) { if (!windowSize) {
const width = window.innerWidth; const width = window.innerWidth;

Просмотреть файл

@@ -41,7 +41,7 @@ import {
} from 'mattermost-redux/selectors/entities/teams'; } from 'mattermost-redux/selectors/entities/teams';
import {getCurrentUserId, getUserByUsername} from 'mattermost-redux/selectors/entities/users'; import {getCurrentUserId, getUserByUsername} from 'mattermost-redux/selectors/entities/users';
import {makeAddLastViewAtToProfiles} from 'mattermost-redux/selectors/entities/utils'; import {makeAddLastViewAtToProfiles} from 'mattermost-redux/selectors/entities/utils';
import type {DispatchFunc, GetStateFunc} from 'mattermost-redux/types/actions'; import type {DispatchFunc, GetStateFunc, NewActionFuncAsync} from 'mattermost-redux/types/actions';
import {getChannelByName} from 'mattermost-redux/utils/channel_utils'; import {getChannelByName} from 'mattermost-redux/utils/channel_utils';
import EventEmitter from 'mattermost-redux/utils/event_emitter'; import EventEmitter from 'mattermost-redux/utils/event_emitter';
@@ -98,8 +98,8 @@ export function loadIfNecessaryAndSwitchToChannelById(channelId: string) {
}; };
} }
export function switchToChannel(channel: Channel & {userId?: string}) { export function switchToChannel(channel: Channel & {userId?: string}): NewActionFuncAsync {
return async (dispatch: DispatchFunc, getState: GetStateFunc) => { return async (dispatch, getState) => {
const state = getState(); const state = getState();
const selectedTeamId = channel.team_id; const selectedTeamId = channel.team_id;
const teamUrl = selectedTeamId ? `/${getTeam(state, selectedTeamId).name}` : getCurrentRelativeTeamUrl(state); const teamUrl = selectedTeamId ? `/${getTeam(state, selectedTeamId).name}` : getCurrentRelativeTeamUrl(state);
@@ -234,8 +234,8 @@ export function autocompleteUsersInChannel(prefix: string, channelId: string) {
}; };
} }
export function loadUnreads(channelId: string, prefetch = false) { export function loadUnreads(channelId: string, prefetch = false): NewActionFuncAsync<{atLatestMessage: boolean; atOldestMessage: boolean}> {
return async (dispatch: DispatchFunc) => { return async (dispatch) => {
const time = Date.now(); const time = Date.now();
if (prefetch) { if (prefetch) {
dispatch({ dispatch({
@@ -259,13 +259,13 @@ export function loadUnreads(channelId: string, prefetch = false) {
atOldestmessage: false, atOldestmessage: false,
}; };
} }
dispatch(loadCustomStatusEmojisForPostList(data.posts)); dispatch(loadCustomStatusEmojisForPostList(data!.posts));
const actions = []; const actions = [];
actions.push({ actions.push({
type: ActionTypes.INCREASE_POST_VISIBILITY, type: ActionTypes.INCREASE_POST_VISIBILITY,
data: channelId, data: channelId,
amount: data.order.length, amount: data!.order.length,
}); });
if (prefetch) { if (prefetch) {
@@ -276,7 +276,7 @@ export function loadUnreads(channelId: string, prefetch = false) {
}); });
} }
if (data.next_post_id === '') { if (data!.next_post_id === '') {
actions.push({ actions.push({
type: ActionTypes.RECEIVED_POSTS_FOR_CHANNEL_AT_TIME, type: ActionTypes.RECEIVED_POSTS_FOR_CHANNEL_AT_TIME,
channelId, channelId,
@@ -286,8 +286,8 @@ export function loadUnreads(channelId: string, prefetch = false) {
dispatch(batchActions(actions)); dispatch(batchActions(actions));
return { return {
atLatestMessage: data.next_post_id === '', atLatestMessage: data!.next_post_id === '',
atOldestmessage: data.prev_post_id === '', atOldestmessage: data!.prev_post_id === '',
}; };
}; };
} }
@@ -460,8 +460,8 @@ export function syncPostsInChannel(channelId: string, since: number, prefetch =
}; };
} }
export function prefetchChannelPosts(channelId: string, jitter: number) { export function prefetchChannelPosts(channelId: string, jitter?: number): NewActionFuncAsync {
return async (dispatch: DispatchFunc, getState: GetStateFunc) => { return async (dispatch, getState) => {
const state = getState(); const state = getState();
const recentPostIdInChannel = getMostRecentPostIdInChannel(state, channelId); const recentPostIdInChannel = getMostRecentPostIdInChannel(state, channelId);

Просмотреть файл

@@ -6,7 +6,7 @@ import {General} from 'mattermost-redux/constants';
import {CategoryTypes} from 'mattermost-redux/constants/channel_categories'; import {CategoryTypes} from 'mattermost-redux/constants/channel_categories';
import {getCategory, makeGetChannelIdsForCategory} from 'mattermost-redux/selectors/entities/channel_categories'; import {getCategory, makeGetChannelIdsForCategory} from 'mattermost-redux/selectors/entities/channel_categories';
import {getCurrentChannelId} from 'mattermost-redux/selectors/entities/channels'; import {getCurrentChannelId} from 'mattermost-redux/selectors/entities/channels';
import type {DispatchFunc, GetStateFunc} from 'mattermost-redux/types/actions'; import type {DispatchFunc, GetStateFunc, NewActionFuncAsync} from 'mattermost-redux/types/actions';
import {insertMultipleWithoutDuplicates} from 'mattermost-redux/utils/array_utils'; import {insertMultipleWithoutDuplicates} from 'mattermost-redux/utils/array_utils';
import {getCategoriesForCurrentTeam, getChannelsInCategoryOrder, getDisplayedChannels} from 'selectors/views/channel_sidebar'; import {getCategoriesForCurrentTeam, getChannelsInCategoryOrder, getDisplayedChannels} from 'selectors/views/channel_sidebar';
@@ -33,8 +33,8 @@ export function stopDragging() {
return {type: ActionTypes.SIDEBAR_DRAGGING_STOP}; return {type: ActionTypes.SIDEBAR_DRAGGING_STOP};
} }
export function createCategory(teamId: string, displayName: string, channelIds?: string[]) { export function createCategory(teamId: string, displayName: string, channelIds?: string[]): NewActionFuncAsync {
return async (dispatch: DispatchFunc, getState: GetStateFunc) => { return async (dispatch, getState) => {
if (channelIds) { if (channelIds) {
const state = getState() as GlobalState; const state = getState() as GlobalState;
const multiSelectedChannelIds = state.views.channelSidebar.multiSelectedChannelIds; const multiSelectedChannelIds = state.views.channelSidebar.multiSelectedChannelIds;

Просмотреть файл

@@ -18,7 +18,7 @@ import {
} from 'mattermost-redux/selectors/entities/posts'; } from 'mattermost-redux/selectors/entities/posts';
import {getCurrentTeamId} from 'mattermost-redux/selectors/entities/teams'; import {getCurrentTeamId} from 'mattermost-redux/selectors/entities/teams';
import {getCurrentUserId} from 'mattermost-redux/selectors/entities/users'; import {getCurrentUserId} from 'mattermost-redux/selectors/entities/users';
import type {DispatchFunc, GetStateFunc} from 'mattermost-redux/types/actions'; import type {DispatchFunc, GetStateFunc, NewActionFunc, NewActionFuncAsync} from 'mattermost-redux/types/actions';
import {isPostPendingOrFailed} from 'mattermost-redux/utils/post_utils'; import {isPostPendingOrFailed} from 'mattermost-redux/utils/post_utils';
import {executeCommand} from 'actions/command'; import {executeCommand} from 'actions/command';
@@ -143,8 +143,8 @@ export function submitCommand(channelId: string, rootId: string, draft: PostDraf
}; };
} }
export function makeOnSubmit(channelId: string, rootId: string, latestPostId: string) { export function makeOnSubmit(channelId: string, rootId: string, latestPostId: string): (draft: PostDraft, options?: {ignoreSlash?: boolean}) => NewActionFuncAsync {
return (draft: PostDraft, options: {ignoreSlash?: boolean} = {}) => async (dispatch: DispatchFunc, getState: () => GlobalState) => { return (draft, options = {}) => async (dispatch, getState) => {
const {message} = draft; const {message} = draft;
dispatch(addMessageIntoHistory(message)); dispatch(addMessageIntoHistory(message));
@@ -218,10 +218,10 @@ function makeGetCurrentUsersLatestReply() {
); );
} }
export function makeOnEditLatestPost(rootId: string) { export function makeOnEditLatestPost(rootId: string): () => NewActionFunc<boolean> {
const getCurrentUsersLatestPost = makeGetCurrentUsersLatestReply(); const getCurrentUsersLatestPost = makeGetCurrentUsersLatestReply();
return () => (dispatch: DispatchFunc, getState: GetStateFunc) => { return () => (dispatch, getState) => {
const state = getState(); const state = getState();
const lastPost = getCurrentUsersLatestPost(state, rootId); const lastPost = getCurrentUsersLatestPost(state, rootId);

Просмотреть файл

@@ -19,7 +19,7 @@ export type CloseModalType = {
modalId: string; modalId: string;
} }
export function closeModal(modalId: string): CloseModalType { export function closeModal(modalId: string) {
return { return {
type: ActionTypes.MODAL_CLOSE, type: ActionTypes.MODAL_CLOSE,
modalId, modalId,

Просмотреть файл

@@ -21,8 +21,8 @@ import {getTimestamp} from 'utils/utils';
import {runMessageWillBePostedHooks} from '../hooks'; import {runMessageWillBePostedHooks} from '../hooks';
export function editPost(post) { export function editPost(post) {
return async (dispatch, getState) => { return async (dispatch) => {
const result = await PostActions.editPost(post)(dispatch, getState); const result = await dispatch(PostActions.editPost(post));
// Send to error bar if it's an edit post error about time limit. // Send to error bar if it's an edit post error about time limit.
if (result.error && result.error.server_error_id === 'api.post.update_post.permissions_time_limit.app_error') { if (result.error && result.error.server_error_id === 'api.post.update_post.permissions_time_limit.app_error') {

Просмотреть файл

@@ -3,10 +3,10 @@
import {getChannelMember} from 'mattermost-redux/actions/channels'; import {getChannelMember} from 'mattermost-redux/actions/channels';
import {getTeamMember} from 'mattermost-redux/actions/teams'; import {getTeamMember} from 'mattermost-redux/actions/teams';
import type {DispatchFunc} from 'mattermost-redux/types/actions'; import type {NewActionFuncOldVariantDoNotUse} from 'mattermost-redux/types/actions';
export function getMembershipForEntities(teamId: string, userId: string, channelId?: string) { export function getMembershipForEntities(teamId: string, userId: string, channelId?: string): NewActionFuncOldVariantDoNotUse {
return (dispatch: DispatchFunc) => { return (dispatch) => {
return Promise.all([ return Promise.all([
dispatch(getTeamMember(teamId, userId)), dispatch(getTeamMember(teamId, userId)),
channelId && dispatch(getChannelMember(channelId, userId)), channelId && dispatch(getChannelMember(channelId, userId)),

Просмотреть файл

@@ -24,7 +24,7 @@ import {getPost} from 'mattermost-redux/selectors/entities/posts';
import {getCurrentTeamId} from 'mattermost-redux/selectors/entities/teams'; import {getCurrentTeamId} from 'mattermost-redux/selectors/entities/teams';
import {getCurrentTimezone} from 'mattermost-redux/selectors/entities/timezone'; import {getCurrentTimezone} from 'mattermost-redux/selectors/entities/timezone';
import {getCurrentUser, getCurrentUserMentionKeys} from 'mattermost-redux/selectors/entities/users'; import {getCurrentUser, getCurrentUserMentionKeys} from 'mattermost-redux/selectors/entities/users';
import type {Action, ActionResult, DispatchFunc, GenericAction, GetStateFunc} from 'mattermost-redux/types/actions'; import type {DispatchFunc, GetStateFunc} from 'mattermost-redux/types/actions';
import {trackEvent} from 'actions/telemetry_actions.jsx'; import {trackEvent} from 'actions/telemetry_actions.jsx';
import {getSearchTerms, getRhsState, getPluggableId, getFilesSearchExtFilter, getPreviousRhsState} from 'selectors/rhs'; import {getSearchTerms, getRhsState, getPluggableId, getFilesSearchExtFilter, getPreviousRhsState} from 'selectors/rhs';
@@ -72,10 +72,10 @@ function selectPostCardFromRightHandSideSearchWithPreviousState(post: Post, prev
export function updateRhsState(rhsState: string, channelId?: string, previousRhsState?: RhsState) { export function updateRhsState(rhsState: string, channelId?: string, previousRhsState?: RhsState) {
return (dispatch: DispatchFunc, getState: GetStateFunc) => { return (dispatch: DispatchFunc, getState: GetStateFunc) => {
const action = { const action: AnyAction = {
type: ActionTypes.UPDATE_RHS_STATE, type: ActionTypes.UPDATE_RHS_STATE,
state: rhsState, state: rhsState,
} as GenericAction; };
if ([ if ([
RHSStates.PIN, RHSStates.PIN,
@@ -130,7 +130,7 @@ export function selectPostCardFromRightHandSideSearch(post: Post) {
export function selectPostFromRightHandSideSearchByPostId(postId: string) { export function selectPostFromRightHandSideSearchByPostId(postId: string) {
return async (dispatch: DispatchFunc, getState: GetStateFunc) => { return async (dispatch: DispatchFunc, getState: GetStateFunc) => {
const post = getPost(getState(), postId); const post = getPost(getState(), postId);
return selectPostFromRightHandSideSearch(post)(dispatch, getState); return dispatch(selectPostFromRightHandSideSearch(post));
}; };
} }
@@ -393,7 +393,7 @@ export function showPinnedPosts(channelId?: string) {
} }
export function showChannelFiles(channelId: string) { export function showChannelFiles(channelId: string) {
return async (dispatch: (action: Action, getState?: GetStateFunc | null) => Promise<ActionResult|[ActionResult, ActionResult]>, getState: GetStateFunc) => { return async (dispatch: DispatchFunc, getState: GetStateFunc) => {
const state = getState() as GlobalState; const state = getState() as GlobalState;
const teamId = getCurrentTeamId(state); const teamId = getCurrentTeamId(state);
@@ -614,39 +614,39 @@ export function openRHSSearch() {
export function openAtPrevious(previous: any) { // TODO Could not find the proper type. Seems to be in several props around export function openAtPrevious(previous: any) { // TODO Could not find the proper type. Seems to be in several props around
return (dispatch: DispatchFunc, getState: GetStateFunc) => { return (dispatch: DispatchFunc, getState: GetStateFunc) => {
if (!previous) { if (!previous) {
return openRHSSearch()(dispatch); return dispatch(openRHSSearch());
} }
if (previous.isChannelInfo) { if (previous.isChannelInfo) {
const currentChannelId = getCurrentChannelId(getState()); const currentChannelId = getCurrentChannelId(getState());
return showChannelInfo(currentChannelId)(dispatch); return dispatch(showChannelInfo(currentChannelId));
} }
if (previous.isChannelMembers) { if (previous.isChannelMembers) {
const currentChannelId = getCurrentChannelId(getState()); const currentChannelId = getCurrentChannelId(getState());
return showChannelMembers(currentChannelId)(dispatch, getState); return dispatch(showChannelMembers(currentChannelId));
} }
if (previous.isMentionSearch) { if (previous.isMentionSearch) {
return showMentions()(dispatch, getState); return dispatch(showMentions());
} }
if (previous.isPinnedPosts) { if (previous.isPinnedPosts) {
return showPinnedPosts()(dispatch, getState); return dispatch(showPinnedPosts());
} }
if (previous.isFlaggedPosts) { if (previous.isFlaggedPosts) {
return showFlaggedPosts()(dispatch, getState); return dispatch(showFlaggedPosts());
} }
if (previous.selectedPostId) { if (previous.selectedPostId) {
const post = getPost(getState(), previous.selectedPostId); const post = getPost(getState(), previous.selectedPostId);
return post ? selectPostFromRightHandSideSearchWithPreviousState(post, previous.previousRhsState)(dispatch, getState) : openRHSSearch()(dispatch); return post ? dispatch(selectPostFromRightHandSideSearchWithPreviousState(post, previous.previousRhsState)) : dispatch(openRHSSearch());
} }
if (previous.selectedPostCardId) { if (previous.selectedPostCardId) {
const post = getPost(getState(), previous.selectedPostCardId); const post = getPost(getState(), previous.selectedPostCardId);
return post ? selectPostCardFromRightHandSideSearchWithPreviousState(post, previous.previousRhsState)(dispatch, getState) : openRHSSearch()(dispatch); return post ? dispatch(selectPostCardFromRightHandSideSearchWithPreviousState(post, previous.previousRhsState)) : dispatch(openRHSSearch());
} }
if (previous.searchVisible) { if (previous.searchVisible) {
return showSearchResults()(dispatch, getState); return dispatch(showSearchResults());
} }
return openRHSSearch()(dispatch); return dispatch(openRHSSearch());
}; };
} }

Просмотреть файл

@@ -1278,7 +1278,7 @@ function handleStatusChangedEvent(msg) {
} }
function handleHelloEvent(msg) { function handleHelloEvent(msg) {
setServerVersion(msg.data.server_version)(dispatch, getState); dispatch(setServerVersion(msg.data.server_version));
dispatch(setConnectionId(msg.data.connection_id)); dispatch(setConnectionId(msg.data.connection_id));
} }

Просмотреть файл

@@ -12,6 +12,7 @@ import type {Post} from '@mattermost/types/posts';
import {AppCallResponseTypes} from 'mattermost-redux/constants/apps'; import {AppCallResponseTypes} from 'mattermost-redux/constants/apps';
import Permissions from 'mattermost-redux/constants/permissions'; import Permissions from 'mattermost-redux/constants/permissions';
import type {ActionResult} from 'mattermost-redux/types/actions';
import FormattedMarkdownMessage from 'components/formatted_markdown_message'; import FormattedMarkdownMessage from 'components/formatted_markdown_message';
import OverlayTrigger from 'components/overlay_trigger'; import OverlayTrigger from 'components/overlay_trigger';
@@ -83,7 +84,7 @@ export type Props = {
/** /**
* Function to get the post menu bindings for this post. * Function to get the post menu bindings for this post.
*/ */
fetchBindings: (channelId: string, teamId: string) => Promise<{data: AppBinding[]}>; fetchBindings: (channelId: string, teamId: string) => Promise<ActionResult<AppBinding[]>>;
}; // TechDebt: Made non-mandatory while converting to typescript }; // TechDebt: Made non-mandatory while converting to typescript
} }

Просмотреть файл

@@ -4,7 +4,7 @@
import type {ComponentProps} from 'react'; import type {ComponentProps} from 'react';
import {connect} from 'react-redux'; import {connect} from 'react-redux';
import {bindActionCreators} from 'redux'; import {bindActionCreators} from 'redux';
import type {ActionCreatorsMapObject, Dispatch} from 'redux'; import type {Dispatch} from 'redux';
import type {AppBinding} from '@mattermost/types/apps'; import type {AppBinding} from '@mattermost/types/apps';
import type {Post} from '@mattermost/types/posts'; import type {Post} from '@mattermost/types/posts';
@@ -25,8 +25,6 @@ import {makeFetchBindings, postEphemeralCallResponseForPost, handleBindingClick,
import {openModal} from 'actions/views/modals'; import {openModal} from 'actions/views/modals';
import {getIsMobileView} from 'selectors/views/browser'; import {getIsMobileView} from 'selectors/views/browser';
import type {ModalData} from 'types/actions';
import type {HandleBindingClick, OpenAppsModal, PostEphemeralCallResponseForPost} from 'types/apps';
import type {GlobalState} from 'types/store'; import type {GlobalState} from 'types/store';
import ActionsMenu from './actions_menu'; import ActionsMenu from './actions_menu';
@@ -75,17 +73,9 @@ function mapStateToProps(state: GlobalState, ownProps: Props) {
}; };
} }
type Actions = {
handleBindingClick: HandleBindingClick;
fetchBindings: (channelId: string, teamId: string) => Promise<{data: AppBinding[]}>;
openModal: <P>(modalData: ModalData<P>) => void;
openAppsModal: OpenAppsModal;
postEphemeralCallResponseForPost: PostEphemeralCallResponseForPost;
}
function mapDispatchToProps(dispatch: Dispatch<GenericAction>) { function mapDispatchToProps(dispatch: Dispatch<GenericAction>) {
return { return {
actions: bindActionCreators<ActionCreatorsMapObject<any>, Actions>({ actions: bindActionCreators({
handleBindingClick, handleBindingClick,
fetchBindings, fetchBindings,
openModal, openModal,

Просмотреть файл

@@ -7,7 +7,7 @@ import {FormattedMessage} from 'react-intl';
import type {Session} from '@mattermost/types/sessions'; import type {Session} from '@mattermost/types/sessions';
import type {ActionFunc} from 'mattermost-redux/types/actions'; import type {ActionResult} from 'mattermost-redux/types/actions';
import ActivityLog from 'components/activity_log_modal/components/activity_log'; import ActivityLog from 'components/activity_log_modal/components/activity_log';
@@ -38,12 +38,12 @@ export type Props = {
/** /**
* Function to refresh sessions from server * Function to refresh sessions from server
*/ */
getSessions: (userId: string) => ActionFunc; getSessions: (userId: string) => void;
/** /**
* Function to revoke a particular session * Function to revoke a particular session
*/ */
revokeSession: (userId: string, sessionId: string) => Promise<{ data: boolean }>; revokeSession: (userId: string, sessionId: string) => Promise<ActionResult>;
}; };
} }

Просмотреть файл

@@ -3,18 +3,16 @@
import {connect} from 'react-redux'; import {connect} from 'react-redux';
import {bindActionCreators} from 'redux'; import {bindActionCreators} from 'redux';
import type {ActionCreatorsMapObject, Dispatch} from 'redux'; import type {Dispatch} from 'redux';
import {getSessions, revokeSession} from 'mattermost-redux/actions/users'; import {getSessions, revokeSession} from 'mattermost-redux/actions/users';
import {getCurrentUserId, getUserSessions} from 'mattermost-redux/selectors/entities/users'; import {getCurrentUserId, getUserSessions} from 'mattermost-redux/selectors/entities/users';
import type {ActionFunc, GenericAction} from 'mattermost-redux/types/actions';
import {getCurrentLocale} from 'selectors/i18n'; import {getCurrentLocale} from 'selectors/i18n';
import type {GlobalState} from 'types/store'; import type {GlobalState} from 'types/store';
import ActivityLogModal from './activity_log_modal'; import ActivityLogModal from './activity_log_modal';
import type {Props} from './activity_log_modal';
function mapStateToProps(state: GlobalState) { function mapStateToProps(state: GlobalState) {
return { return {
@@ -24,9 +22,9 @@ function mapStateToProps(state: GlobalState) {
}; };
} }
function mapDispatchToProps(dispatch: Dispatch<GenericAction>) { function mapDispatchToProps(dispatch: Dispatch) {
return { return {
actions: bindActionCreators<ActionCreatorsMapObject<ActionFunc| GenericAction>, Props['actions']>({ actions: bindActionCreators({
getSessions, getSessions,
revokeSession, revokeSession,
}, dispatch), }, dispatch),

Просмотреть файл

@@ -10,7 +10,7 @@ import type {ServerError} from '@mattermost/types/errors';
import type {Group, SyncablePatch} from '@mattermost/types/groups'; import type {Group, SyncablePatch} from '@mattermost/types/groups';
import {SyncableType} from '@mattermost/types/groups'; import {SyncableType} from '@mattermost/types/groups';
import type {ActionFunc} from 'mattermost-redux/types/actions'; import type {ActionResult} from 'mattermost-redux/types/actions';
import MultiSelect from 'components/multiselect/multiselect'; import MultiSelect from 'components/multiselect/multiselect';
import type {Value} from 'components/multiselect/multiselect'; import type {Value} from 'components/multiselect/multiselect';
@@ -38,12 +38,12 @@ export type Props = {
onAddCallback?: (groupIDs: string[]) => void; onAddCallback?: (groupIDs: string[]) => void;
actions: { actions: {
getGroupsNotAssociatedToChannel: (channelID: string, q?: string, page?: number | null, perPage?: number | null, filterParentTeamPermitted?: boolean) => Promise<ActionFunc>; getGroupsNotAssociatedToChannel: (channelID: string, q?: string, page?: number, perPage?: number, filterParentTeamPermitted?: boolean) => Promise<ActionResult>;
setModalSearchTerm: (term: string) => { type: string; data: string}; setModalSearchTerm: (term: string) => void;
linkGroupSyncable: (groupID: string, syncableID: string, syncableType: string, patch: Partial<SyncablePatch>) => Promise<{error?: ServerError; data?: null}>; linkGroupSyncable: (groupID: string, syncableID: string, syncableType: SyncableType, patch: Partial<SyncablePatch>) => Promise<ActionResult>;
getAllGroupsAssociatedToChannel: (channelID: string, filterAllowReference: boolean, includeMemberCount: boolean) => ActionFunc; getAllGroupsAssociatedToChannel: (channelID: string, filterAllowReference: boolean, includeMemberCount: boolean) => Promise<ActionResult>;
getTeam: (teamId: string) => ActionFunc; getTeam: (teamId: string) => Promise<ActionResult>;
getAllGroupsAssociatedToTeam: (teamID: string, filterAllowReference: boolean, includeMemberCount: boolean) => ActionFunc; getAllGroupsAssociatedToTeam: (teamID: string, filterAllowReference: boolean, includeMemberCount: boolean) => Promise<ActionResult>;
}; };
} }
@@ -100,7 +100,7 @@ export class AddGroupsToChannelModal extends React.PureComponent<Props, State> {
this.searchTimeoutId = window.setTimeout( this.searchTimeoutId = window.setTimeout(
async () => { async () => {
this.setGroupsLoadingState(true); this.setGroupsLoadingState(true);
await this.props.actions.getGroupsNotAssociatedToChannel(this.props.currentChannelId, searchTerm, null, null, true); await this.props.actions.getGroupsNotAssociatedToChannel(this.props.currentChannelId, searchTerm, undefined, undefined, true);
this.setGroupsLoadingState(false); this.setGroupsLoadingState(false);
}, },
Constants.SEARCH_TIMEOUT_MILLISECONDS, Constants.SEARCH_TIMEOUT_MILLISECONDS,

Просмотреть файл

@@ -3,7 +3,7 @@
import {connect} from 'react-redux'; import {connect} from 'react-redux';
import {bindActionCreators} from 'redux'; import {bindActionCreators} from 'redux';
import type {ActionCreatorsMapObject, Dispatch} from 'redux'; import type {Dispatch} from 'redux';
import type {Channel} from '@mattermost/types/channels'; import type {Channel} from '@mattermost/types/channels';
import type {Group} from '@mattermost/types/groups'; import type {Group} from '@mattermost/types/groups';
@@ -12,14 +12,12 @@ import {getGroupsNotAssociatedToChannel, linkGroupSyncable, getAllGroupsAssociat
import {getTeam} from 'mattermost-redux/actions/teams'; import {getTeam} from 'mattermost-redux/actions/teams';
import {getCurrentChannel} from 'mattermost-redux/selectors/entities/channels'; import {getCurrentChannel} from 'mattermost-redux/selectors/entities/channels';
import {getGroupsNotAssociatedToChannel as selectGroupsNotAssociatedToChannel} from 'mattermost-redux/selectors/entities/groups'; import {getGroupsNotAssociatedToChannel as selectGroupsNotAssociatedToChannel} from 'mattermost-redux/selectors/entities/groups';
import type {ActionFunc, GenericAction} from 'mattermost-redux/types/actions';
import {setModalSearchTerm} from 'actions/views/search'; import {setModalSearchTerm} from 'actions/views/search';
import type {GlobalState} from 'types/store'; import type {GlobalState} from 'types/store';
import AddGroupsToChannelModal from './add_groups_to_channel_modal'; import AddGroupsToChannelModal from './add_groups_to_channel_modal';
import type {Props} from './add_groups_to_channel_modal';
type OwnProps = { type OwnProps = {
channel: Channel; channel: Channel;
@@ -51,9 +49,9 @@ function mapStateToProps(state: GlobalState, ownProps: OwnProps) {
}; };
} }
function mapDispatchToProps(dispatch: Dispatch<GenericAction>) { function mapDispatchToProps(dispatch: Dispatch) {
return { return {
actions: bindActionCreators<ActionCreatorsMapObject<ActionFunc| GenericAction>, Props['actions']>({ actions: bindActionCreators({
getGroupsNotAssociatedToChannel, getGroupsNotAssociatedToChannel,
setModalSearchTerm, setModalSearchTerm,
linkGroupSyncable, linkGroupSyncable,

Просмотреть файл

@@ -7,9 +7,11 @@ import {Modal} from 'react-bootstrap';
import type {IntlShape} from 'react-intl'; import type {IntlShape} from 'react-intl';
import {injectIntl, FormattedMessage} from 'react-intl'; import {injectIntl, FormattedMessage} from 'react-intl';
import type {Group, GroupsWithCount, SyncablePatch} from '@mattermost/types/groups'; import type {Group, SyncablePatch} from '@mattermost/types/groups';
import {SyncableType} from '@mattermost/types/groups'; import {SyncableType} from '@mattermost/types/groups';
import type {ActionResult} from 'mattermost-redux/types/actions';
import Nbsp from 'components/html_entities/nbsp'; import Nbsp from 'components/html_entities/nbsp';
import MultiSelect from 'components/multiselect/multiselect'; import MultiSelect from 'components/multiselect/multiselect';
import type {Value} from 'components/multiselect/multiselect'; import type {Value} from 'components/multiselect/multiselect';
@@ -40,10 +42,10 @@ type Props = {
} }
export type Actions = { export type Actions = {
getGroupsNotAssociatedToTeam: (teamID: string, q?: string, page?: number, perPage?: number) => Promise<{ data: Group[] } | { error: Error }>; getGroupsNotAssociatedToTeam: (teamID: string, q?: string, page?: number, perPage?: number) => Promise<ActionResult>;
setModalSearchTerm: (term: string) => void; setModalSearchTerm: (term: string) => void;
linkGroupSyncable: (groupID: string, syncableID: string, syncableType: SyncableType, patch: SyncablePatch) => Promise<{ data?: boolean; error?: Error }>; linkGroupSyncable: (groupID: string, syncableID: string, syncableType: SyncableType, patch: SyncablePatch) => Promise<ActionResult>;
getAllGroupsAssociatedToTeam: (teamID: string, filterAllowReference: boolean, includeMemberCount: boolean) => Promise<{ data: GroupsWithCount } | { error: Error }>; getAllGroupsAssociatedToTeam: (teamID: string, filterAllowReference: boolean, includeMemberCount: boolean) => Promise<ActionResult>;
}; };
type State = { type State = {

Просмотреть файл

@@ -3,7 +3,7 @@
import {connect} from 'react-redux'; import {connect} from 'react-redux';
import {bindActionCreators} from 'redux'; import {bindActionCreators} from 'redux';
import type {ActionCreatorsMapObject, Dispatch} from 'redux'; import type {Dispatch} from 'redux';
import type {Group} from '@mattermost/types/groups'; import type {Group} from '@mattermost/types/groups';
import type {Team} from '@mattermost/types/teams'; import type {Team} from '@mattermost/types/teams';
@@ -11,14 +11,13 @@ import type {Team} from '@mattermost/types/teams';
import {getGroupsNotAssociatedToTeam, linkGroupSyncable, getAllGroupsAssociatedToTeam} from 'mattermost-redux/actions/groups'; import {getGroupsNotAssociatedToTeam, linkGroupSyncable, getAllGroupsAssociatedToTeam} from 'mattermost-redux/actions/groups';
import {getGroupsNotAssociatedToTeam as selectGroupsNotAssociatedToTeam} from 'mattermost-redux/selectors/entities/groups'; import {getGroupsNotAssociatedToTeam as selectGroupsNotAssociatedToTeam} from 'mattermost-redux/selectors/entities/groups';
import {getCurrentTeam} from 'mattermost-redux/selectors/entities/teams'; import {getCurrentTeam} from 'mattermost-redux/selectors/entities/teams';
import type {ActionFunc, GenericAction} from 'mattermost-redux/types/actions'; import type {GenericAction} from 'mattermost-redux/types/actions';
import {setModalSearchTerm} from 'actions/views/search'; import {setModalSearchTerm} from 'actions/views/search';
import type {GlobalState} from 'types/store'; import type {GlobalState} from 'types/store';
import AddGroupsToTeamModal from './add_groups_to_team_modal'; import AddGroupsToTeamModal from './add_groups_to_team_modal';
import type {Actions} from './add_groups_to_team_modal';
type Props = { type Props = {
team?: Team; team?: Team;
@@ -51,7 +50,7 @@ function mapStateToProps(state: GlobalState, ownProps: Props) {
function mapDispatchToProps(dispatch: Dispatch<GenericAction>) { function mapDispatchToProps(dispatch: Dispatch<GenericAction>) {
return { return {
actions: bindActionCreators<ActionCreatorsMapObject<ActionFunc|GenericAction>, Actions>({ actions: bindActionCreators({
getGroupsNotAssociatedToTeam, getGroupsNotAssociatedToTeam,
setModalSearchTerm, setModalSearchTerm,
linkGroupSyncable, linkGroupSyncable,

Просмотреть файл

@@ -3,16 +3,14 @@
import {connect} from 'react-redux'; import {connect} from 'react-redux';
import {bindActionCreators} from 'redux'; import {bindActionCreators} from 'redux';
import type {ActionCreatorsMapObject, Dispatch} from 'redux'; import type {Dispatch} from 'redux';
import type {GlobalState} from '@mattermost/types/store'; import type {GlobalState} from '@mattermost/types/store';
import {addChannelMember, getChannelMember, autocompleteChannelsForSearch} from 'mattermost-redux/actions/channels'; import {addChannelMember, getChannelMember, autocompleteChannelsForSearch} from 'mattermost-redux/actions/channels';
import {getChannelMembersInChannels} from 'mattermost-redux/selectors/entities/channels'; import {getChannelMembersInChannels} from 'mattermost-redux/selectors/entities/channels';
import type {ActionFunc} from 'mattermost-redux/types/actions';
import AddUserToChannelModal from './add_user_to_channel_modal'; import AddUserToChannelModal from './add_user_to_channel_modal';
import type {Props} from './add_user_to_channel_modal';
function mapStateToProps(state: GlobalState) { function mapStateToProps(state: GlobalState) {
const channelMembers = getChannelMembersInChannels(state) || {}; const channelMembers = getChannelMembersInChannels(state) || {};
@@ -23,7 +21,7 @@ function mapStateToProps(state: GlobalState) {
function mapDispatchToProps(dispatch: Dispatch) { function mapDispatchToProps(dispatch: Dispatch) {
return { return {
actions: bindActionCreators<ActionCreatorsMapObject<ActionFunc>, Props['actions']>({ actions: bindActionCreators({
addChannelMember, addChannelMember,
getChannelMember, getChannelMember,
autocompleteChannelsForSearch, autocompleteChannelsForSearch,

Просмотреть файл

@@ -3,13 +3,12 @@
import {connect} from 'react-redux'; import {connect} from 'react-redux';
import {bindActionCreators} from 'redux'; import {bindActionCreators} from 'redux';
import type {ActionCreatorsMapObject, Dispatch} from 'redux'; import type {Dispatch} from 'redux';
import type {UserProfile} from '@mattermost/types/users'; import type {UserProfile} from '@mattermost/types/users';
import {getProfilesNotInGroup, searchProfiles, getProfiles} from 'mattermost-redux/actions/users'; import {getProfilesNotInGroup, searchProfiles, getProfiles} from 'mattermost-redux/actions/users';
import {getProfilesNotInCurrentGroup, getUserStatuses, getProfiles as getUsers} from 'mattermost-redux/selectors/entities/users'; import {getProfilesNotInCurrentGroup, getUserStatuses, getProfiles as getUsers} from 'mattermost-redux/selectors/entities/users';
import type {Action, ActionResult} from 'mattermost-redux/types/actions';
import {loadStatusesForProfilesList} from 'actions/status_actions'; import {loadStatusesForProfilesList} from 'actions/status_actions';
@@ -42,16 +41,9 @@ function mapStateToProps(state: GlobalState, props: OwnProps) {
}; };
} }
type Actions = {
getProfiles: (page?: number, perPage?: number) => Promise<ActionResult>;
getProfilesNotInGroup: (groupId: string, page?: number, perPage?: number) => Promise<ActionResult>;
loadStatusesForProfilesList: (users: UserProfile[]) => void;
searchProfiles: (term: string, options: any) => Promise<ActionResult>;
}
function mapDispatchToProps(dispatch: Dispatch) { function mapDispatchToProps(dispatch: Dispatch) {
return { return {
actions: bindActionCreators<ActionCreatorsMapObject<Action>, Actions>({ actions: bindActionCreators({
getProfiles, getProfiles,
getProfilesNotInGroup, getProfilesNotInGroup,
loadStatusesForProfilesList, loadStatusesForProfilesList,

Просмотреть файл

@@ -3,24 +3,17 @@
import {connect} from 'react-redux'; import {connect} from 'react-redux';
import {bindActionCreators} from 'redux'; import {bindActionCreators} from 'redux';
import type {ActionCreatorsMapObject, Dispatch} from 'redux'; import type {Dispatch} from 'redux';
import {addUsersToGroup} from 'mattermost-redux/actions/groups'; import {addUsersToGroup} from 'mattermost-redux/actions/groups';
import {getGroup} from 'mattermost-redux/selectors/entities/groups'; import {getGroup} from 'mattermost-redux/selectors/entities/groups';
import type {Action, ActionResult} from 'mattermost-redux/types/actions';
import {openModal} from 'actions/views/modals'; import {openModal} from 'actions/views/modals';
import type {ModalData} from 'types/actions';
import type {GlobalState} from 'types/store'; import type {GlobalState} from 'types/store';
import AddUsersToGroupModal from './add_users_to_group_modal'; import AddUsersToGroupModal from './add_users_to_group_modal';
type Actions = {
addUsersToGroup: (groupId: string, userIds: string[]) => Promise<ActionResult>;
openModal: <P>(modalData: ModalData<P>) => void;
}
type OwnProps = { type OwnProps = {
groupId: string; groupId: string;
} }
@@ -35,7 +28,7 @@ function mapStateToProps(state: GlobalState, props: OwnProps) {
function mapDispatchToProps(dispatch: Dispatch) { function mapDispatchToProps(dispatch: Dispatch) {
return { return {
actions: bindActionCreators<ActionCreatorsMapObject<Action>, Actions>({ actions: bindActionCreators({
addUsersToGroup, addUsersToGroup,
openModal, openModal,
}, dispatch), }, dispatch),

Просмотреть файл

@@ -10,6 +10,7 @@ import type {Team} from '@mattermost/types/teams';
import type {UserProfile} from '@mattermost/types/users'; import type {UserProfile} from '@mattermost/types/users';
import {Client4} from 'mattermost-redux/client'; import {Client4} from 'mattermost-redux/client';
import type {ActionResult} from 'mattermost-redux/types/actions';
import {isGuest} from 'mattermost-redux/utils/user_utils'; import {isGuest} from 'mattermost-redux/utils/user_utils';
import MultiSelect from 'components/multiselect/multiselect'; import MultiSelect from 'components/multiselect/multiselect';
@@ -36,8 +37,8 @@ type Props = {
onExited?: () => void; onExited?: () => void;
actions: { actions: {
getProfilesNotInTeam: (teamId: string, groupConstrained: boolean, page: number, perPage?: number, options?: Record<string, any>) => Promise<{ data: UserProfile[] }>; getProfilesNotInTeam: (teamId: string, groupConstrained: boolean, page: number, perPage?: number, options?: Record<string, any>) => Promise<ActionResult<UserProfile[]>>;
searchProfiles: (term: string, options?: Record<string, any>) => Promise<{ data: UserProfile[] }>; searchProfiles: (term: string, options?: Record<string, any>) => Promise<ActionResult<UserProfile[]>>;
}; };
} }
@@ -91,7 +92,7 @@ export class AddUsersToTeamModal extends React.PureComponent<Props, State> {
const search = term !== ''; const search = term !== '';
if (search) { if (search) {
const {data} = await this.props.actions.searchProfiles(term, {not_in_team_id: this.props.team.id, replace: true, ...this.state.filterOptions}); const {data} = await this.props.actions.searchProfiles(term, {not_in_team_id: this.props.team.id, replace: true, ...this.state.filterOptions});
searchResults = data; searchResults = data!;
} else { } else {
await this.props.actions.getProfilesNotInTeam(this.props.team.id, false, 0, USERS_PER_PAGE * 2); await this.props.actions.getProfilesNotInTeam(this.props.team.id, false, 0, USERS_PER_PAGE * 2);
} }

Просмотреть файл

@@ -3,7 +3,7 @@
import {connect} from 'react-redux'; import {connect} from 'react-redux';
import {bindActionCreators} from 'redux'; import {bindActionCreators} from 'redux';
import type {Dispatch, ActionCreatorsMapObject} from 'redux'; import type {Dispatch} from 'redux';
import type {GlobalState} from '@mattermost/types/store'; import type {GlobalState} from '@mattermost/types/store';
import type {Team} from '@mattermost/types/teams'; import type {Team} from '@mattermost/types/teams';
@@ -11,7 +11,6 @@ import type {UserProfile} from '@mattermost/types/users';
import {getProfilesNotInTeam, searchProfiles} from 'mattermost-redux/actions/users'; import {getProfilesNotInTeam, searchProfiles} from 'mattermost-redux/actions/users';
import {getProfilesNotInTeam as selectProfilesNotInTeam} from 'mattermost-redux/selectors/entities/users'; import {getProfilesNotInTeam as selectProfilesNotInTeam} from 'mattermost-redux/selectors/entities/users';
import type {GenericAction, ActionFunc} from 'mattermost-redux/types/actions';
import AddUsersToTeamModal from './add_users_to_team_modal'; import AddUsersToTeamModal from './add_users_to_team_modal';
@@ -20,11 +19,6 @@ type Props = {
filterExcludeGuests?: boolean; filterExcludeGuests?: boolean;
}; };
type Actions = {
getProfilesNotInTeam: (teamId: string, groupConstrained: boolean, page: number, perPage?: number, options?: {[key: string]: any}) => Promise<{ data: UserProfile[] }>;
searchProfiles: (term: string, options?: any) => Promise<{ data: UserProfile[] }>;
};
function mapStateToProps(state: GlobalState, props: Props) { function mapStateToProps(state: GlobalState, props: Props) {
const {id: teamId} = props.team; const {id: teamId} = props.team;
@@ -40,9 +34,9 @@ function mapStateToProps(state: GlobalState, props: Props) {
}; };
} }
function mapDispatchToProps(dispatch: Dispatch<GenericAction>) { function mapDispatchToProps(dispatch: Dispatch) {
return { return {
actions: bindActionCreators<ActionCreatorsMapObject<ActionFunc>, Actions>({ actions: bindActionCreators({
getProfilesNotInTeam, getProfilesNotInTeam,
searchProfiles, searchProfiles,
}, dispatch), }, dispatch),

Просмотреть файл

@@ -10,7 +10,7 @@ import type {AdminConfig, EnvironmentConfig} from '@mattermost/types/config';
import type {Role} from '@mattermost/types/roles'; import type {Role} from '@mattermost/types/roles';
import type {DeepPartial} from '@mattermost/types/utilities'; import type {DeepPartial} from '@mattermost/types/utilities';
import type {ActionFunc} from 'mattermost-redux/types/actions'; import type {ActionResult} from 'mattermost-redux/types/actions';
import SchemaAdminSettings from 'components/admin_console/schema_admin_settings'; import SchemaAdminSettings from 'components/admin_console/schema_admin_settings';
import AnnouncementBarController from 'components/announcement_bar'; import AnnouncementBarController from 'components/announcement_bar';
@@ -45,7 +45,7 @@ type ExtraProps = {
setNavigationBlocked?: () => void; setNavigationBlocked?: () => void;
roles?: Record<string, Role>; roles?: Record<string, Role>;
editRole?: (role: Role) => void; editRole?: (role: Role) => void;
updateConfig?: (config: AdminConfig) => ActionFunc; updateConfig?: (config: AdminConfig) => Promise<ActionResult>;
cloud: CloudState; cloud: CloudState;
isCurrentUserSystemAdmin: boolean; isCurrentUserSystemAdmin: boolean;
} }

Просмотреть файл

@@ -4,16 +4,13 @@
import {connect} from 'react-redux'; import {connect} from 'react-redux';
import type {ConnectedProps} from 'react-redux'; import type {ConnectedProps} from 'react-redux';
import {bindActionCreators} from 'redux'; import {bindActionCreators} from 'redux';
import type {ActionCreatorsMapObject, Dispatch} from 'redux'; import type {Dispatch} from 'redux';
import type {PluginsResponse} from '@mattermost/types/plugins';
import {getPlugins} from 'mattermost-redux/actions/admin'; import {getPlugins} from 'mattermost-redux/actions/admin';
import {getSubscriptionProduct} from 'mattermost-redux/selectors/entities/cloud'; import {getSubscriptionProduct} from 'mattermost-redux/selectors/entities/cloud';
import {getConfig, getLicense} from 'mattermost-redux/selectors/entities/general'; import {getConfig, getLicense} from 'mattermost-redux/selectors/entities/general';
import {getBool} from 'mattermost-redux/selectors/entities/preferences'; import {getBool} from 'mattermost-redux/selectors/entities/preferences';
import {isFirstAdmin} from 'mattermost-redux/selectors/entities/users'; import {isFirstAdmin} from 'mattermost-redux/selectors/entities/users';
import type {ActionFunc} from 'mattermost-redux/types/actions';
import {getAdminDefinition, getConsoleAccess} from 'selectors/admin_console'; import {getAdminDefinition, getConsoleAccess} from 'selectors/admin_console';
import {getNavigationBlocked} from 'selectors/views/admin'; import {getNavigationBlocked} from 'selectors/views/admin';
@@ -53,13 +50,9 @@ function mapStateToProps(state: GlobalState) {
}; };
} }
type Actions = {
getPlugins: () => Promise<{data: PluginsResponse}>;
}
function mapDispatchToProps(dispatch: Dispatch) { function mapDispatchToProps(dispatch: Dispatch) {
return { return {
actions: bindActionCreators<ActionCreatorsMapObject<ActionFunc>, Actions>({ actions: bindActionCreators({
getPlugins, getPlugins,
}, dispatch), }, dispatch),
}; };

Просмотреть файл

@@ -7,6 +7,8 @@ import {FormattedMessage} from 'react-intl';
import type {Audit} from '@mattermost/types/audits'; import type {Audit} from '@mattermost/types/audits';
import type {ActionResult} from 'mattermost-redux/types/actions';
import ComplianceReports from 'components/admin_console/compliance_reports'; import ComplianceReports from 'components/admin_console/compliance_reports';
import AuditTable from 'components/audit_table'; import AuditTable from 'components/audit_table';
import LoadingScreen from 'components/loading_screen'; import LoadingScreen from 'components/loading_screen';
@@ -17,7 +19,7 @@ type Props = {
audits: Audit[]; audits: Audit[];
isDisabled?: boolean; isDisabled?: boolean;
actions: { actions: {
getAudits: () => Promise<{data: Audit[]}>; getAudits: () => Promise<ActionResult<Audit[]>>;
}; };
}; };

Просмотреть файл

@@ -3,23 +3,16 @@
import {connect} from 'react-redux'; import {connect} from 'react-redux';
import {bindActionCreators} from 'redux'; import {bindActionCreators} from 'redux';
import type {Dispatch, ActionCreatorsMapObject} from 'redux'; import type {Dispatch} from 'redux';
import type {Audit} from '@mattermost/types/audits';
import {getAudits} from 'mattermost-redux/actions/admin'; import {getAudits} from 'mattermost-redux/actions/admin';
import * as Selectors from 'mattermost-redux/selectors/entities/admin'; import * as Selectors from 'mattermost-redux/selectors/entities/admin';
import {getLicense} from 'mattermost-redux/selectors/entities/general'; import {getLicense} from 'mattermost-redux/selectors/entities/general';
import type {ActionFunc, GenericAction} from 'mattermost-redux/types/actions';
import type {GlobalState} from 'types/store'; import type {GlobalState} from 'types/store';
import Audits from './audits'; import Audits from './audits';
type Actions = {
getAudits: () => Promise<{data: Audit[]}>;
}
function mapStateToProps(state: GlobalState) { function mapStateToProps(state: GlobalState) {
const license = getLicense(state); const license = getLicense(state);
const isLicensed = license.Compliance === 'true'; const isLicensed = license.Compliance === 'true';
@@ -30,9 +23,9 @@ function mapStateToProps(state: GlobalState) {
}; };
} }
function mapDispatchToProps(dispatch: Dispatch<GenericAction>) { function mapDispatchToProps(dispatch: Dispatch) {
return { return {
actions: bindActionCreators<ActionCreatorsMapObject<ActionFunc>, Actions>({ actions: bindActionCreators({
getAudits, getAudits,
}, dispatch), }, dispatch),
}; };

Просмотреть файл

@@ -8,6 +8,7 @@ import type {Compliance} from '@mattermost/types/compliance';
import type {UserProfile} from '@mattermost/types/users'; import type {UserProfile} from '@mattermost/types/users';
import {Client4} from 'mattermost-redux/client'; import {Client4} from 'mattermost-redux/client';
import type {ActionResult} from 'mattermost-redux/types/actions';
import LoadingScreen from 'components/loading_screen'; import LoadingScreen from 'components/loading_screen';
import ReloadIcon from 'components/widgets/icons/fa_reload_icon'; import ReloadIcon from 'components/widgets/icons/fa_reload_icon';
@@ -44,12 +45,12 @@ type Props = {
/* /*
* Function to get compliance reports * Function to get compliance reports
*/ */
getComplianceReports: () => Promise<{data: Compliance[]}>; getComplianceReports: () => Promise<ActionResult<Compliance[]>>;
/* /*
* Function to save compliance reports * Function to save compliance reports
*/ */
createComplianceReport: (job: Partial<Compliance>) => Promise<{data: Compliance; error?: Error}>; createComplianceReport: (job: Partial<Compliance>) => Promise<ActionResult<Compliance>>;
}; };
} }

Просмотреть файл

@@ -3,9 +3,8 @@
import {connect} from 'react-redux'; import {connect} from 'react-redux';
import {bindActionCreators} from 'redux'; import {bindActionCreators} from 'redux';
import type {ActionCreatorsMapObject, Dispatch} from 'redux'; import type {Dispatch} from 'redux';
import type {Compliance} from '@mattermost/types/compliance';
import type {GlobalState} from '@mattermost/types/store'; import type {GlobalState} from '@mattermost/types/store';
import type {UserProfile} from '@mattermost/types/users'; import type {UserProfile} from '@mattermost/types/users';
@@ -13,15 +12,9 @@ import {createComplianceReport, getComplianceReports} from 'mattermost-redux/act
import {createSelector} from 'mattermost-redux/selectors/create_selector'; import {createSelector} from 'mattermost-redux/selectors/create_selector';
import {getComplianceReports as selectComplianceReports, getConfig} from 'mattermost-redux/selectors/entities/admin'; import {getComplianceReports as selectComplianceReports, getConfig} from 'mattermost-redux/selectors/entities/admin';
import {getLicense} from 'mattermost-redux/selectors/entities/general'; import {getLicense} from 'mattermost-redux/selectors/entities/general';
import type {ActionFunc, GenericAction} from 'mattermost-redux/types/actions';
import ComplianceReports from './compliance_reports'; import ComplianceReports from './compliance_reports';
type Actions = {
getComplianceReports: () => Promise<{data: Compliance[]}>;
createComplianceReport: (job: Partial<Compliance>) => Promise<{data: Compliance; error?: Error}>;
}
const getUsersForReports = createSelector( const getUsersForReports = createSelector(
'getUsersForReports', 'getUsersForReports',
(state: GlobalState) => state.entities.users.profiles, (state: GlobalState) => state.entities.users.profiles,
@@ -67,9 +60,9 @@ function mapStateToProps(state: GlobalState) {
}; };
} }
function mapDispatchToProps(dispatch: Dispatch<GenericAction>) { function mapDispatchToProps(dispatch: Dispatch) {
return { return {
actions: bindActionCreators<ActionCreatorsMapObject<ActionFunc>, Actions>({ actions: bindActionCreators({
getComplianceReports, getComplianceReports,
createComplianceReport, createComplianceReport,
}, dispatch), }, dispatch),

Просмотреть файл

@@ -7,6 +7,8 @@ import {FormattedMessage} from 'react-intl';
import type {AdminConfig, ClientLicense} from '@mattermost/types/config'; import type {AdminConfig, ClientLicense} from '@mattermost/types/config';
import type {TermsOfService} from '@mattermost/types/terms_of_service'; import type {TermsOfService} from '@mattermost/types/terms_of_service';
import type {ActionResult} from 'mattermost-redux/types/actions';
import AdminSettings from 'components/admin_console/admin_settings'; import AdminSettings from 'components/admin_console/admin_settings';
import type {BaseProps, BaseState} from 'components/admin_console/admin_settings'; import type {BaseProps, BaseState} from 'components/admin_console/admin_settings';
import BooleanSetting from 'components/admin_console/boolean_setting'; import BooleanSetting from 'components/admin_console/boolean_setting';
@@ -19,8 +21,8 @@ import {Constants} from 'utils/constants';
type Props = BaseProps & { type Props = BaseProps & {
actions: { actions: {
getTermsOfService: () => Promise<{data: TermsOfService}>; getTermsOfService: () => Promise<ActionResult<TermsOfService>>;
createTermsOfService: (text: string) => Promise<{data: TermsOfService; error?: Error}>; createTermsOfService: (text: string) => Promise<ActionResult<TermsOfService>>;
}; };
config: AdminConfig; config: AdminConfig;
license: ClientLicense; license: ClientLicense;

Просмотреть файл

@@ -3,23 +3,15 @@
import {connect} from 'react-redux'; import {connect} from 'react-redux';
import {bindActionCreators} from 'redux'; import {bindActionCreators} from 'redux';
import type {ActionCreatorsMapObject, Dispatch} from 'redux'; import type {Dispatch} from 'redux';
import type {TermsOfService} from '@mattermost/types/terms_of_service';
import {getTermsOfService, createTermsOfService} from 'mattermost-redux/actions/users'; import {getTermsOfService, createTermsOfService} from 'mattermost-redux/actions/users';
import type {GenericAction, ActionFunc} from 'mattermost-redux/types/actions';
import CustomTermsOfServiceSettings from './custom_terms_of_service_settings'; import CustomTermsOfServiceSettings from './custom_terms_of_service_settings';
type Actions = { function mapDispatchToProps(dispatch: Dispatch) {
getTermsOfService: () => Promise<{data: TermsOfService}>;
createTermsOfService: (text: string) => Promise<{data: TermsOfService; error?: Error}>;
};
function mapDispatchToProps(dispatch: Dispatch<GenericAction>) {
return { return {
actions: bindActionCreators<ActionCreatorsMapObject<ActionFunc>, Actions>({ actions: bindActionCreators({
getTermsOfService, getTermsOfService,
createTermsOfService, createTermsOfService,
}, dispatch), }, dispatch),

Просмотреть файл

@@ -36,10 +36,10 @@ type Props = {
channelsToAdd: Record<string, ChannelWithTeamData>; channelsToAdd: Record<string, ChannelWithTeamData>;
actions: { actions: {
searchChannels: (id: string, term: string, opts: ChannelSearchOpts) => Promise<{ data: ChannelWithTeamData[] }>; searchChannels: (id: string, term: string, opts: ChannelSearchOpts) => Promise<ActionResult>;
getDataRetentionCustomPolicyChannels: (id: string, page: number, perPage: number) => Promise<{ data: ChannelWithTeamData[] }>; getDataRetentionCustomPolicyChannels: (id: string, page: number, perPage: number) => Promise<ActionResult>;
setChannelListSearch: (term: string) => ActionResult; setChannelListSearch: (term: string) => void;
setChannelListFilters: (filters: ChannelSearchOpts) => ActionResult; setChannelListFilters: (filters: ChannelSearchOpts) => void;
}; };
} }

Просмотреть файл

@@ -3,7 +3,7 @@
import {connect} from 'react-redux'; import {connect} from 'react-redux';
import {bindActionCreators} from 'redux'; import {bindActionCreators} from 'redux';
import type {ActionCreatorsMapObject, Dispatch} from 'redux'; import type {Dispatch} from 'redux';
import type {Channel, ChannelSearchOpts, ChannelWithTeamData} from '@mattermost/types/channels'; import type {Channel, ChannelSearchOpts, ChannelWithTeamData} from '@mattermost/types/channels';
import type {DataRetentionCustomPolicy} from '@mattermost/types/data_retention'; import type {DataRetentionCustomPolicy} from '@mattermost/types/data_retention';
@@ -11,7 +11,6 @@ import type {DataRetentionCustomPolicy} from '@mattermost/types/data_retention';
import {getDataRetentionCustomPolicyChannels, searchDataRetentionCustomPolicyChannels as searchChannels} from 'mattermost-redux/actions/admin'; import {getDataRetentionCustomPolicyChannels, searchDataRetentionCustomPolicyChannels as searchChannels} from 'mattermost-redux/actions/admin';
import {getDataRetentionCustomPolicy} from 'mattermost-redux/selectors/entities/admin'; import {getDataRetentionCustomPolicy} from 'mattermost-redux/selectors/entities/admin';
import {filterChannelList, getChannelsInPolicy, searchChannelsInPolicy} from 'mattermost-redux/selectors/entities/channels'; import {filterChannelList, getChannelsInPolicy, searchChannelsInPolicy} from 'mattermost-redux/selectors/entities/channels';
import type {ActionFunc, ActionResult, GenericAction} from 'mattermost-redux/types/actions';
import {filterChannelsMatchingTerm, channelListToMap} from 'mattermost-redux/utils/channel_utils'; import {filterChannelsMatchingTerm, channelListToMap} from 'mattermost-redux/utils/channel_utils';
import {setChannelListSearch, setChannelListFilters} from 'actions/views/search'; import {setChannelListSearch, setChannelListFilters} from 'actions/views/search';
@@ -25,13 +24,6 @@ type OwnProps = {
channelsToAdd: Record<string, ChannelWithTeamData>; channelsToAdd: Record<string, ChannelWithTeamData>;
} }
type Actions = {
searchChannels: (id: string, term: string, opts: ChannelSearchOpts) => Promise<{ data: ChannelWithTeamData[] }>;
getDataRetentionCustomPolicyChannels: (id: string, page: number, perPage: number) => Promise<{ data: ChannelWithTeamData[] }>;
setChannelListSearch: (term: string) => ActionResult;
setChannelListFilters: (filters: ChannelSearchOpts) => ActionResult;
}
function searchChannelsToAdd(channels: Record<string, Channel>, term: string, filters: ChannelSearchOpts): Record<string, Channel> { function searchChannelsToAdd(channels: Record<string, Channel>, term: string, filters: ChannelSearchOpts): Record<string, Channel> {
let filteredTeams = filterChannelsMatchingTerm(Object.keys(channels).map((key) => channels[key]), term); let filteredTeams = filterChannelsMatchingTerm(Object.keys(channels).map((key) => channels[key]), term);
filteredTeams = filterChannelList(filteredTeams, filters); filteredTeams = filterChannelList(filteredTeams, filters);
@@ -72,7 +64,7 @@ function mapStateToProps() {
function mapDispatchToProps(dispatch: Dispatch) { function mapDispatchToProps(dispatch: Dispatch) {
return { return {
actions: bindActionCreators<ActionCreatorsMapObject<ActionFunc | GenericAction>, Actions>({ actions: bindActionCreators({
getDataRetentionCustomPolicyChannels, getDataRetentionCustomPolicyChannels,
searchChannels, searchChannels,
setChannelListSearch, setChannelListSearch,

Просмотреть файл

@@ -13,6 +13,8 @@ import type {
import type {Team} from '@mattermost/types/teams'; import type {Team} from '@mattermost/types/teams';
import type {IDMappedObjects} from '@mattermost/types/utilities'; import type {IDMappedObjects} from '@mattermost/types/utilities';
import type {ActionResult} from 'mattermost-redux/types/actions';
import BlockableLink from 'components/admin_console/blockable_link'; import BlockableLink from 'components/admin_console/blockable_link';
import ChannelList from 'components/admin_console/data_retention_settings/channel_list'; import ChannelList from 'components/admin_console/data_retention_settings/channel_list';
import {keepForeverOption, yearsOption, daysOption, FOREVER, YEARS} from 'components/admin_console/data_retention_settings/dropdown_options/dropdown_options'; import {keepForeverOption, yearsOption, daysOption, FOREVER, YEARS} from 'components/admin_console/data_retention_settings/dropdown_options/dropdown_options';
@@ -37,14 +39,14 @@ type Props = {
policy?: DataRetentionCustomPolicy | null; policy?: DataRetentionCustomPolicy | null;
teams?: Team[]; teams?: Team[];
actions: { actions: {
fetchPolicy: (id: string) => Promise<{ data: DataRetentionCustomPolicy; error?: Error }>; fetchPolicy: (id: string) => Promise<ActionResult>;
fetchPolicyTeams: (id: string, page: number, perPage: number) => Promise<{ data: Team[]; error?: Error }>; fetchPolicyTeams: (id: string, page: number, perPage: number) => Promise<ActionResult>;
createDataRetentionCustomPolicy: (policy: CreateDataRetentionCustomPolicy) => Promise<{ data: DataRetentionCustomPolicy; error?: Error }>; createDataRetentionCustomPolicy: (policy: CreateDataRetentionCustomPolicy) => Promise<ActionResult>;
updateDataRetentionCustomPolicy: (id: string, policy: PatchDataRetentionCustomPolicy) => Promise<{ data: DataRetentionCustomPolicy; error?: Error }>; updateDataRetentionCustomPolicy: (id: string, policy: PatchDataRetentionCustomPolicy) => Promise<ActionResult>;
addDataRetentionCustomPolicyTeams: (id: string, policy: string[]) => Promise<{ data?: {status: string}; error?: Error }>; addDataRetentionCustomPolicyTeams: (id: string, policy: string[]) => Promise<ActionResult>;
removeDataRetentionCustomPolicyTeams: (id: string, policy: string[]) => Promise<{ data?: {status: string}; error?: Error }>; removeDataRetentionCustomPolicyTeams: (id: string, policy: string[]) => Promise<ActionResult>;
addDataRetentionCustomPolicyChannels: (id: string, policy: string[]) => Promise<{ data?: {status: string}; error?: Error }>; addDataRetentionCustomPolicyChannels: (id: string, policy: string[]) => Promise<ActionResult>;
removeDataRetentionCustomPolicyChannels: (id: string, policy: string[]) => Promise<{ data?: {status: string}; error?: Error }>; removeDataRetentionCustomPolicyChannels: (id: string, policy: string[]) => Promise<ActionResult>;
setNavigationBlocked: (blocked: boolean) => void; setNavigationBlocked: (blocked: boolean) => void;
}; };
}; };

Просмотреть файл

@@ -3,14 +3,7 @@
import {connect} from 'react-redux'; import {connect} from 'react-redux';
import {bindActionCreators} from 'redux'; import {bindActionCreators} from 'redux';
import type {Dispatch, ActionCreatorsMapObject} from 'redux'; import type {Dispatch} from 'redux';
import type {
DataRetentionCustomPolicy,
CreateDataRetentionCustomPolicy,
PatchDataRetentionCustomPolicy,
} from '@mattermost/types/data_retention';
import type {Team} from '@mattermost/types/teams';
import { import {
getDataRetentionCustomPolicy as fetchPolicy, getDataRetentionCustomPolicy as fetchPolicy,
@@ -24,7 +17,6 @@ import {
} from 'mattermost-redux/actions/admin'; } from 'mattermost-redux/actions/admin';
import {getDataRetentionCustomPolicy} from 'mattermost-redux/selectors/entities/admin'; import {getDataRetentionCustomPolicy} from 'mattermost-redux/selectors/entities/admin';
import {getTeamsInPolicy} from 'mattermost-redux/selectors/entities/teams'; import {getTeamsInPolicy} from 'mattermost-redux/selectors/entities/teams';
import type {GenericAction, ActionFunc} from 'mattermost-redux/types/actions';
import {setNavigationBlocked} from 'actions/admin_actions.jsx'; import {setNavigationBlocked} from 'actions/admin_actions.jsx';
@@ -32,18 +24,6 @@ import type {GlobalState} from 'types/store';
import CustomPolicyForm from './custom_policy_form'; import CustomPolicyForm from './custom_policy_form';
type Actions = {
fetchPolicy: (id: string) => Promise<{ data: DataRetentionCustomPolicy }>;
fetchPolicyTeams: (id: string, page: number, perPage: number) => Promise<{ data: Team[] }>;
createDataRetentionCustomPolicy: (policy: CreateDataRetentionCustomPolicy) => Promise<{ data: DataRetentionCustomPolicy }>;
updateDataRetentionCustomPolicy: (id: string, policy: PatchDataRetentionCustomPolicy) => Promise<{ data: DataRetentionCustomPolicy }>;
addDataRetentionCustomPolicyTeams: (id: string, teams: string[]) => Promise<{ data?: {status: string}; error?: Error }>;
removeDataRetentionCustomPolicyTeams: (id: string, teams: string[]) => Promise<{ data?: {status: string}; error?: Error }>;
addDataRetentionCustomPolicyChannels: (id: string, channels: string[]) => Promise<{ data?: {status: string}; error?: Error }>;
removeDataRetentionCustomPolicyChannels: (id: string, channels: string[]) => Promise<{ data?: {status: string}; error?: Error }>;
setNavigationBlocked: (blocked: boolean) => void;
};
type OwnProps = { type OwnProps = {
match: { match: {
params: { params: {
@@ -66,9 +46,9 @@ function mapStateToProps() {
}; };
} }
function mapDispatchToProps(dispatch: Dispatch<GenericAction>) { function mapDispatchToProps(dispatch: Dispatch) {
return { return {
actions: bindActionCreators<ActionCreatorsMapObject<ActionFunc | GenericAction>, Actions>({ actions: bindActionCreators({
fetchPolicy, fetchPolicy,
fetchPolicyTeams, fetchPolicyTeams,
createDataRetentionCustomPolicy, createDataRetentionCustomPolicy,

Просмотреть файл

@@ -40,11 +40,11 @@ type Props = {
globalMessageRetentionHours: string | undefined; globalMessageRetentionHours: string | undefined;
globalFileRetentionHours: string | undefined; globalFileRetentionHours: string | undefined;
actions: { actions: {
getDataRetentionCustomPolicies: (page: number) => Promise<{ data: DataRetentionCustomPolicies }>; getDataRetentionCustomPolicies: (page: number) => Promise<ActionResult>;
createJob: (job: JobTypeBase) => Promise<{ data: any }>; createJob: (job: JobTypeBase) => Promise<ActionResult>;
getJobsByType: (job: JobType) => Promise<{ data: any}>; getJobsByType: (job: JobType) => Promise<ActionResult>;
deleteDataRetentionCustomPolicy: (id: string) => Promise<ActionResult>; deleteDataRetentionCustomPolicy: (id: string) => Promise<ActionResult>;
updateConfig: (config: Record<string, any>) => Promise<{ data: any}>; updateConfig: (config: Record<string, any>) => Promise<ActionResult>;
}; };
}; };

Просмотреть файл

@@ -5,9 +5,10 @@ import React from 'react';
import {FormattedMessage} from 'react-intl'; import {FormattedMessage} from 'react-intl';
import type {AdminConfig, EnvironmentConfig} from '@mattermost/types/config'; import type {AdminConfig, EnvironmentConfig} from '@mattermost/types/config';
import type {ServerError} from '@mattermost/types/errors';
import type {DeepPartial} from '@mattermost/types/utilities'; import type {DeepPartial} from '@mattermost/types/utilities';
import type {ActionResult} from 'mattermost-redux/types/actions';
import BlockableLink from 'components/admin_console/blockable_link'; import BlockableLink from 'components/admin_console/blockable_link';
import {keepForeverOption, yearsOption, daysOption, FOREVER, YEARS, DAYS, hoursOption} from 'components/admin_console/data_retention_settings/dropdown_options/dropdown_options'; import {keepForeverOption, yearsOption, daysOption, FOREVER, YEARS, DAYS, hoursOption} from 'components/admin_console/data_retention_settings/dropdown_options/dropdown_options';
import SetByEnv from 'components/admin_console/set_by_env'; import SetByEnv from 'components/admin_console/set_by_env';
@@ -31,7 +32,7 @@ type Props = {
fileRetentionHours: string | undefined; fileRetentionHours: string | undefined;
environmentConfig: Partial<EnvironmentConfig>; environmentConfig: Partial<EnvironmentConfig>;
actions: { actions: {
updateConfig: (config: Record<string, any>) => Promise<{ data?: AdminConfig; error?: ServerError }>; updateConfig: (config: Record<string, any>) => Promise<ActionResult>;
setNavigationBlocked: (blocked: boolean) => void; setNavigationBlocked: (blocked: boolean) => void;
}; };
}; };

Просмотреть файл

@@ -3,17 +3,13 @@
import {connect} from 'react-redux'; import {connect} from 'react-redux';
import {bindActionCreators} from 'redux'; import {bindActionCreators} from 'redux';
import type {Dispatch, ActionCreatorsMapObject} from 'redux'; import type {Dispatch} from 'redux';
import type {AdminConfig} from '@mattermost/types/config';
import type {ServerError} from '@mattermost/types/errors';
import { import {
updateConfig, updateConfig,
} from 'mattermost-redux/actions/admin'; } from 'mattermost-redux/actions/admin';
import {getEnvironmentConfig} from 'mattermost-redux/selectors/entities/admin'; import {getEnvironmentConfig} from 'mattermost-redux/selectors/entities/admin';
import {getConfig} from 'mattermost-redux/selectors/entities/general'; import {getConfig} from 'mattermost-redux/selectors/entities/general';
import type {GenericAction, ActionFunc} from 'mattermost-redux/types/actions';
import {setNavigationBlocked} from 'actions/admin_actions.jsx'; import {setNavigationBlocked} from 'actions/admin_actions.jsx';
@@ -21,11 +17,6 @@ import type {GlobalState} from 'types/store';
import GlobalPolicyForm from './global_policy_form'; import GlobalPolicyForm from './global_policy_form';
type Actions = {
updateConfig: (config: Record<string, any>) => Promise<{ data?: AdminConfig; error?: ServerError }>;
setNavigationBlocked: (blocked: boolean) => void;
};
function mapStateToProps(state: GlobalState) { function mapStateToProps(state: GlobalState) {
const messageRetentionHours = getConfig(state).DataRetentionMessageRetentionHours; const messageRetentionHours = getConfig(state).DataRetentionMessageRetentionHours;
const fileRetentionHours = getConfig(state).DataRetentionFileRetentionHours; const fileRetentionHours = getConfig(state).DataRetentionFileRetentionHours;
@@ -37,9 +28,9 @@ function mapStateToProps(state: GlobalState) {
}; };
} }
function mapDispatchToProps(dispatch: Dispatch<GenericAction>) { function mapDispatchToProps(dispatch: Dispatch) {
return { return {
actions: bindActionCreators<ActionCreatorsMapObject<ActionFunc | GenericAction>, Actions>({ actions: bindActionCreators({
updateConfig, updateConfig,
setNavigationBlocked, setNavigationBlocked,
}, dispatch), }, dispatch),

Просмотреть файл

@@ -3,29 +3,17 @@
import {connect} from 'react-redux'; import {connect} from 'react-redux';
import {bindActionCreators} from 'redux'; import {bindActionCreators} from 'redux';
import type {Dispatch, ActionCreatorsMapObject} from 'redux'; import type {Dispatch} from 'redux';
import type {DataRetentionCustomPolicies} from '@mattermost/types/data_retention';
import type {JobTypeBase, JobType} from '@mattermost/types/jobs';
import {getDataRetentionCustomPolicies as fetchDataRetentionCustomPolicies, deleteDataRetentionCustomPolicy, updateConfig} from 'mattermost-redux/actions/admin'; import {getDataRetentionCustomPolicies as fetchDataRetentionCustomPolicies, deleteDataRetentionCustomPolicy, updateConfig} from 'mattermost-redux/actions/admin';
import {createJob, getJobsByType} from 'mattermost-redux/actions/jobs'; import {createJob, getJobsByType} from 'mattermost-redux/actions/jobs';
import {getDataRetentionCustomPolicies, getDataRetentionCustomPoliciesCount} from 'mattermost-redux/selectors/entities/admin'; import {getDataRetentionCustomPolicies, getDataRetentionCustomPoliciesCount} from 'mattermost-redux/selectors/entities/admin';
import {getConfig} from 'mattermost-redux/selectors/entities/general'; import {getConfig} from 'mattermost-redux/selectors/entities/general';
import type {GenericAction, ActionFunc, ActionResult} from 'mattermost-redux/types/actions';
import type {GlobalState} from 'types/store'; import type {GlobalState} from 'types/store';
import DataRetentionSettings from './data_retention_settings'; import DataRetentionSettings from './data_retention_settings';
type Actions = {
getDataRetentionCustomPolicies: () => Promise<{ data: DataRetentionCustomPolicies}>;
deleteDataRetentionCustomPolicy: (id: string) => Promise<ActionResult>;
createJob: (job: JobTypeBase) => Promise<{ data: any}>;
getJobsByType: (job: JobType) => Promise<{ data: any}>;
updateConfig: (config: Record<string, any>) => Promise<{ data: any}>;
};
function mapStateToProps(state: GlobalState) { function mapStateToProps(state: GlobalState) {
const customPolicies = getDataRetentionCustomPolicies(state); const customPolicies = getDataRetentionCustomPolicies(state);
const customPoliciesCount = getDataRetentionCustomPoliciesCount(state); const customPoliciesCount = getDataRetentionCustomPoliciesCount(state);
@@ -40,9 +28,9 @@ function mapStateToProps(state: GlobalState) {
}; };
} }
function mapDispatchToProps(dispatch: Dispatch<GenericAction>) { function mapDispatchToProps(dispatch: Dispatch) {
return { return {
actions: bindActionCreators<ActionCreatorsMapObject<ActionFunc>, Actions>({ actions: bindActionCreators({
getDataRetentionCustomPolicies: fetchDataRetentionCustomPolicies, getDataRetentionCustomPolicies: fetchDataRetentionCustomPolicies,
createJob, createJob,
getJobsByType, getJobsByType,

Просмотреть файл

@@ -3,15 +3,14 @@
import {connect} from 'react-redux'; import {connect} from 'react-redux';
import {bindActionCreators} from 'redux'; import {bindActionCreators} from 'redux';
import type {ActionCreatorsMapObject, Dispatch} from 'redux'; import type {Dispatch} from 'redux';
import type {DataRetentionCustomPolicy} from '@mattermost/types/data_retention'; import type {DataRetentionCustomPolicy} from '@mattermost/types/data_retention';
import type {Team, TeamSearchOpts} from '@mattermost/types/teams'; import type {Team} from '@mattermost/types/teams';
import {getDataRetentionCustomPolicyTeams, searchDataRetentionCustomPolicyTeams as searchTeams} from 'mattermost-redux/actions/admin'; import {getDataRetentionCustomPolicyTeams, searchDataRetentionCustomPolicyTeams as searchTeams} from 'mattermost-redux/actions/admin';
import {getDataRetentionCustomPolicy} from 'mattermost-redux/selectors/entities/admin'; import {getDataRetentionCustomPolicy} from 'mattermost-redux/selectors/entities/admin';
import {getTeamsInPolicy, searchTeamsInPolicy} from 'mattermost-redux/selectors/entities/teams'; import {getTeamsInPolicy, searchTeamsInPolicy} from 'mattermost-redux/selectors/entities/teams';
import type {ActionFunc, ActionResult, GenericAction} from 'mattermost-redux/types/actions';
import {teamListToMap, filterTeamsStartingWithTerm} from 'mattermost-redux/utils/team_utils'; import {teamListToMap, filterTeamsStartingWithTerm} from 'mattermost-redux/utils/team_utils';
import {setTeamListSearch} from 'actions/views/search'; import {setTeamListSearch} from 'actions/views/search';
@@ -25,12 +24,6 @@ type OwnProps = {
teamsToAdd: Record<string, Team>; teamsToAdd: Record<string, Team>;
} }
type Actions = {
getDataRetentionCustomPolicyTeams: (id: string, page: number, perPage: number) => Promise<{ data: Team[] }>;
searchTeams: (id: string, term: string, opts: TeamSearchOpts) => Promise<{ data: Team[] }>;
setTeamListSearch: (term: string) => ActionResult;
}
function searchTeamsToAdd(teams: Record<string, Team>, term: string): Record<string, Team> { function searchTeamsToAdd(teams: Record<string, Team>, term: string): Record<string, Team> {
const filteredTeams = filterTeamsStartingWithTerm(Object.keys(teams).map((key) => teams[key]), term); const filteredTeams = filterTeamsStartingWithTerm(Object.keys(teams).map((key) => teams[key]), term);
return teamListToMap(filteredTeams); return teamListToMap(filteredTeams);
@@ -66,7 +59,7 @@ function mapStateToProps() {
function mapDispatchToProps(dispatch: Dispatch) { function mapDispatchToProps(dispatch: Dispatch) {
return { return {
actions: bindActionCreators<ActionCreatorsMapObject<ActionFunc | GenericAction>, Actions>({ actions: bindActionCreators({
getDataRetentionCustomPolicyTeams, getDataRetentionCustomPolicyTeams,
searchTeams, searchTeams,
setTeamListSearch, setTeamListSearch,

Просмотреть файл

@@ -31,8 +31,8 @@ type Props = {
teamsToAdd: Record<string, Team>; teamsToAdd: Record<string, Team>;
actions: { actions: {
searchTeams: (id: string, term: string, opts: TeamSearchOpts) => Promise<{ data: Team[] }>; searchTeams: (id: string, term: string, opts: TeamSearchOpts) => Promise<ActionResult>;
getDataRetentionCustomPolicyTeams: (id: string, page: number, perPage: number) => Promise<{ data: Team[] }>; getDataRetentionCustomPolicyTeams: (id: string, page: number, perPage: number) => Promise<ActionResult>;
setTeamListSearch: (term: string) => ActionResult; setTeamListSearch: (term: string) => ActionResult;
}; };
} }

Просмотреть файл

@@ -3,20 +3,15 @@
import {connect} from 'react-redux'; import {connect} from 'react-redux';
import {bindActionCreators} from 'redux'; import {bindActionCreators} from 'redux';
import type {Dispatch, ActionCreatorsMapObject} from 'redux'; import type {Dispatch} from 'redux';
import {getAppliedSchemaMigrations} from 'mattermost-redux/actions/admin'; import {getAppliedSchemaMigrations} from 'mattermost-redux/actions/admin';
import type {ActionFunc, ActionResult, GenericAction} from 'mattermost-redux/types/actions';
import MigrationsTable from './migrations_table'; import MigrationsTable from './migrations_table';
type Actions = {
getAppliedSchemaMigrations: () => Promise<ActionResult>;
}
function mapDispatchToProps(dispatch: Dispatch) { function mapDispatchToProps(dispatch: Dispatch) {
return { return {
actions: bindActionCreators<ActionCreatorsMapObject<ActionFunc | GenericAction>, Actions>({ actions: bindActionCreators({
getAppliedSchemaMigrations, getAppliedSchemaMigrations,
}, dispatch), }, dispatch),
}; };

Просмотреть файл

@@ -3,14 +3,13 @@
import {connect} from 'react-redux'; import {connect} from 'react-redux';
import {bindActionCreators} from 'redux'; import {bindActionCreators} from 'redux';
import type {Dispatch, ActionCreatorsMapObject} from 'redux'; import type {Dispatch} from 'redux';
import {getPrevTrialLicense} from 'mattermost-redux/actions/admin'; import {getPrevTrialLicense} from 'mattermost-redux/actions/admin';
import {getCloudSubscription} from 'mattermost-redux/actions/cloud'; import {getCloudSubscription} from 'mattermost-redux/actions/cloud';
import {checkHadPriorTrial, getCloudCustomer} from 'mattermost-redux/selectors/entities/cloud'; import {checkHadPriorTrial, getCloudCustomer} from 'mattermost-redux/selectors/entities/cloud';
import {getLicense} from 'mattermost-redux/selectors/entities/general'; import {getLicense} from 'mattermost-redux/selectors/entities/general';
import {deprecateCloudFree} from 'mattermost-redux/selectors/entities/preferences'; import {deprecateCloudFree} from 'mattermost-redux/selectors/entities/preferences';
import type {Action, GenericAction} from 'mattermost-redux/types/actions';
import {openModal} from 'actions/views/modals'; import {openModal} from 'actions/views/modals';
@@ -19,7 +18,6 @@ import withGetCloudSubscription from 'components/common/hocs/cloud/with_get_clou
import {LicenseSkus} from 'utils/constants'; import {LicenseSkus} from 'utils/constants';
import {isCloudLicense} from 'utils/license_utils'; import {isCloudLicense} from 'utils/license_utils';
import type {ModalData} from 'types/actions';
import type {GlobalState} from 'types/store'; import type {GlobalState} from 'types/store';
import FeatureDiscovery from './feature_discovery'; import FeatureDiscovery from './feature_discovery';
@@ -45,15 +43,9 @@ function mapStateToProps(state: GlobalState) {
}; };
} }
type Actions = { function mapDispatchToProps(dispatch: Dispatch) {
getPrevTrialLicense: () => void;
getCloudSubscription: () => void;
openModal: <P>(modalData: ModalData<P>) => void;
}
function mapDispatchToProps(dispatch: Dispatch<GenericAction>) {
return { return {
actions: bindActionCreators<ActionCreatorsMapObject<Action>, Actions>({ actions: bindActionCreators({
getPrevTrialLicense, getPrevTrialLicense,
getCloudSubscription, getCloudSubscription,
openModal, openModal,

Просмотреть файл

@@ -6,7 +6,7 @@ import {useIntl} from 'react-intl';
import type {ActionMeta, OptionsType, ValueType} from 'react-select'; import type {ActionMeta, OptionsType, ValueType} from 'react-select';
import AsyncSelect from 'react-select/async'; import AsyncSelect from 'react-select/async';
import type {Team} from '@mattermost/types/teams'; import type {PagedTeamSearchOpts, Team} from '@mattermost/types/teams';
import type {ActionResult} from 'mattermost-redux/types/actions'; import type {ActionResult} from 'mattermost-redux/types/actions';
@@ -57,7 +57,7 @@ function TeamFilterDropdown(props: Props) {
async function searchInList(term: string, callBack: (options: OptionsType<{label: string; value: string}>) => void) { async function searchInList(term: string, callBack: (options: OptionsType<{label: string; value: string}>) => void) {
try { try {
const response = await props.searchTeams(term, {page: 0, per_page: TEAMS_PER_PAGE}) as ActionResult<{teams: Team[]}>; const response = await props.searchTeams(term, {page: 0, per_page: TEAMS_PER_PAGE} as PagedTeamSearchOpts);
if (response && response.data && response.data.teams && response.data.teams.length > 0) { if (response && response.data && response.data.teams && response.data.teams.length > 0) {
const teams = response.data.teams.map((team: Team) => ({ const teams = response.data.teams.map((team: Team) => ({
value: team.id, value: team.id,

Просмотреть файл

@@ -3,7 +3,7 @@
import {connect} from 'react-redux'; import {connect} from 'react-redux';
import {bindActionCreators} from 'redux'; import {bindActionCreators} from 'redux';
import type {ActionCreatorsMapObject, Dispatch} from 'redux'; import type {Dispatch} from 'redux';
import type {GlobalState} from '@mattermost/types/store'; import type {GlobalState} from '@mattermost/types/store';
@@ -24,12 +24,10 @@ import {
getGroupTeams, getGroupTeams,
} from 'mattermost-redux/selectors/entities/groups'; } from 'mattermost-redux/selectors/entities/groups';
import {getProfilesInGroup as selectProfilesInGroup} from 'mattermost-redux/selectors/entities/users'; import {getProfilesInGroup as selectProfilesInGroup} from 'mattermost-redux/selectors/entities/users';
import type {ActionFunc, GenericAction} from 'mattermost-redux/types/actions';
import {setNavigationBlocked} from 'actions/admin_actions'; import {setNavigationBlocked} from 'actions/admin_actions';
import GroupDetails from './group_details'; import GroupDetails from './group_details';
import type {Props} from './group_details';
type OwnProps = { type OwnProps = {
match: { match: {
@@ -57,12 +55,9 @@ function mapStateToProps(state: GlobalState, props: OwnProps) {
}; };
} }
function mapDispatchToProps(dispatch: Dispatch<GenericAction>) { function mapDispatchToProps(dispatch: Dispatch) {
return { return {
actions: bindActionCreators< actions: bindActionCreators(
ActionCreatorsMapObject<ActionFunc | GenericAction>,
Props['actions']
>(
{ {
setNavigationBlocked, setNavigationBlocked,
getGroup: fetchGroup, getGroup: fetchGroup,

Просмотреть файл

@@ -6,6 +6,8 @@ import {FormattedMessage} from 'react-intl';
import type {GroupSearchOpts, MixedUnlinkedGroupRedux} from '@mattermost/types/groups'; import type {GroupSearchOpts, MixedUnlinkedGroupRedux} from '@mattermost/types/groups';
import type {ActionResult} from 'mattermost-redux/types/actions';
import GroupRow from 'components/admin_console/group_settings/group_row'; import GroupRow from 'components/admin_console/group_settings/group_row';
import CheckboxCheckedIcon from 'components/widgets/icons/checkbox_checked_icon'; import CheckboxCheckedIcon from 'components/widgets/icons/checkbox_checked_icon';
import NextIcon from 'components/widgets/icons/fa_next_icon'; import NextIcon from 'components/widgets/icons/fa_next_icon';
@@ -22,9 +24,9 @@ type Props = {
total: number; total: number;
readOnly?: boolean; readOnly?: boolean;
actions: { actions: {
getLdapGroups: (page?: number, perPage?: number, opts?: GroupSearchOpts) => Promise<any>; getLdapGroups: (page?: number, perPage?: number, opts?: GroupSearchOpts) => Promise<ActionResult>;
link: (key: string) => Promise<any>; link: (key: string) => Promise<ActionResult>;
unlink: (key: string) => Promise<any>; unlink: (key: string) => Promise<ActionResult>;
}; };
} }
@@ -445,7 +447,7 @@ export default class GroupsList extends React.PureComponent<Props, State> {
this.props.actions.getLdapGroups(this.state.page, LDAP_GROUPS_PAGE_SIZE, {q: ''}).then(this.handleGetGroupsResponse); this.props.actions.getLdapGroups(this.state.page, LDAP_GROUPS_PAGE_SIZE, {q: ''}).then(this.handleGetGroupsResponse);
}; };
handleGetGroupsResponse = (response: any) => { handleGetGroupsResponse = (response: ActionResult) => {
if (response?.error) { if (response?.error) {
this.setState({fetchError: true}); this.setState({fetchError: true});
} else { } else {

Просмотреть файл

@@ -3,14 +3,13 @@
import {connect} from 'react-redux'; import {connect} from 'react-redux';
import {bindActionCreators} from 'redux'; import {bindActionCreators} from 'redux';
import type {Dispatch, ActionCreatorsMapObject} from 'redux'; import type {Dispatch} from 'redux';
import type {GlobalState} from '@mattermost/types/store'; import type {GlobalState} from '@mattermost/types/store';
import {linkLdapGroup, unlinkLdapGroup, getLdapGroups as fetchLdapGroups} from 'mattermost-redux/actions/admin'; import {linkLdapGroup, unlinkLdapGroup, getLdapGroups as fetchLdapGroups} from 'mattermost-redux/actions/admin';
import {createSelector} from 'mattermost-redux/selectors/create_selector'; import {createSelector} from 'mattermost-redux/selectors/create_selector';
import {getLdapGroups, getLdapGroupsCount} from 'mattermost-redux/selectors/entities/admin'; import {getLdapGroups, getLdapGroupsCount} from 'mattermost-redux/selectors/entities/admin';
import type {ActionFunc} from 'mattermost-redux/types/actions';
import GroupsList from './groups_list'; import GroupsList from './groups_list';
@@ -33,7 +32,7 @@ function mapStateToProps(state: GlobalState) {
function mapDispatchToProps(dispatch: Dispatch) { function mapDispatchToProps(dispatch: Dispatch) {
return { return {
actions: bindActionCreators<ActionCreatorsMapObject<ActionFunc>, any>({ actions: bindActionCreators({
getLdapGroups: fetchLdapGroups, getLdapGroups: fetchLdapGroups,
link: linkLdapGroup, link: linkLdapGroup,
unlink: unlinkLdapGroup, unlink: unlinkLdapGroup,

Просмотреть файл

@@ -4,10 +4,7 @@
import {connect} from 'react-redux'; import {connect} from 'react-redux';
import type {ConnectedProps} from 'react-redux'; import type {ConnectedProps} from 'react-redux';
import {bindActionCreators} from 'redux'; import {bindActionCreators} from 'redux';
import type {ActionCreatorsMapObject, Dispatch} from 'redux'; import type {Dispatch} from 'redux';
import type {AdminConfig} from '@mattermost/types/config';
import type {Role} from '@mattermost/types/roles';
import {getConfig, getEnvironmentConfig, updateConfig} from 'mattermost-redux/actions/admin'; import {getConfig, getEnvironmentConfig, updateConfig} from 'mattermost-redux/actions/admin';
import {loadRolesIfNeeded, editRole} from 'mattermost-redux/actions/roles'; import {loadRolesIfNeeded, editRole} from 'mattermost-redux/actions/roles';
@@ -19,7 +16,6 @@ import {getTheme} from 'mattermost-redux/selectors/entities/preferences';
import {getRoles} from 'mattermost-redux/selectors/entities/roles'; import {getRoles} from 'mattermost-redux/selectors/entities/roles';
import {getTeam} from 'mattermost-redux/selectors/entities/teams'; import {getTeam} from 'mattermost-redux/selectors/entities/teams';
import {isCurrentUserSystemAdmin, currentUserHasAnAdminRole, getCurrentUserId} from 'mattermost-redux/selectors/entities/users'; import {isCurrentUserSystemAdmin, currentUserHasAnAdminRole, getCurrentUserId} from 'mattermost-redux/selectors/entities/users';
import type {ActionFunc, GenericAction} from 'mattermost-redux/types/actions';
import {setNavigationBlocked, deferNavigation, cancelNavigation, confirmNavigation} from 'actions/admin_actions.jsx'; import {setNavigationBlocked, deferNavigation, cancelNavigation, confirmNavigation} from 'actions/admin_actions.jsx';
import {selectLhsItem} from 'actions/views/lhs'; import {selectLhsItem} from 'actions/views/lhs';
@@ -28,7 +24,6 @@ import {showNavigationPrompt} from 'selectors/views/admin';
import LocalStorageStore from 'stores/local_storage_store'; import LocalStorageStore from 'stores/local_storage_store';
import type {GlobalState} from 'types/store'; import type {GlobalState} from 'types/store';
import type {LhsItemType} from 'types/store/lhs';
import AdminConsole from './admin_console'; import AdminConsole from './admin_console';
@@ -59,22 +54,9 @@ function mapStateToProps(state: GlobalState) {
}; };
} }
type Actions = { function mapDispatchToProps(dispatch: Dispatch) {
getConfig: () => ActionFunc;
getEnvironmentConfig: () => ActionFunc;
setNavigationBlocked: () => void;
confirmNavigation: () => void;
cancelNavigation: () => void;
loadRolesIfNeeded: (roles: Iterable<string>) => ActionFunc;
selectLhsItem: (type: LhsItemType, id?: string) => void;
selectTeam: (teamId: string) => void;
editRole: (role: Role) => void;
updateConfig?: (config: AdminConfig) => ActionFunc;
};
function mapDispatchToProps(dispatch: Dispatch<GenericAction>) {
return { return {
actions: bindActionCreators<ActionCreatorsMapObject, Actions>({ actions: bindActionCreators({
getConfig, getConfig,
getEnvironmentConfig, getEnvironmentConfig,
updateConfig, updateConfig,

Просмотреть файл

@@ -3,14 +3,11 @@
import {connect} from 'react-redux'; import {connect} from 'react-redux';
import {bindActionCreators} from 'redux'; import {bindActionCreators} from 'redux';
import type {Dispatch, ActionCreatorsMapObject} from 'redux'; import type {Dispatch} from 'redux';
import type {JobType} from '@mattermost/types/jobs';
import {getJobsByType, createJob, cancelJob} from 'mattermost-redux/actions/jobs'; import {getJobsByType, createJob, cancelJob} from 'mattermost-redux/actions/jobs';
import {getConfig} from 'mattermost-redux/selectors/entities/admin'; import {getConfig} from 'mattermost-redux/selectors/entities/admin';
import {makeGetJobsByType} from 'mattermost-redux/selectors/entities/jobs'; import {makeGetJobsByType} from 'mattermost-redux/selectors/entities/jobs';
import type {GenericAction, ActionFunc, ActionResult} from 'mattermost-redux/types/actions';
import type {GlobalState} from 'types/store'; import type {GlobalState} from 'types/store';
@@ -26,15 +23,9 @@ function mapStateToProps(state: GlobalState, ownProps: OwnProps) {
}; };
} }
type Actions = { function mapDispatchToProps(dispatch: Dispatch) {
getJobsByType: (type: JobType) => Promise<ActionResult>;
createJob: (job: {type: JobType}) => Promise<ActionResult>;
cancelJob: (id: string) => Promise<ActionResult>;
}
function mapDispatchToProps(dispatch: Dispatch<GenericAction>) {
return { return {
actions: bindActionCreators<ActionCreatorsMapObject<ActionFunc>, Actions>({ actions: bindActionCreators({
getJobsByType, getJobsByType,
createJob, createJob,
cancelJob, cancelJob,

Просмотреть файл

@@ -3,23 +3,17 @@
import {connect} from 'react-redux'; import {connect} from 'react-redux';
import {bindActionCreators} from 'redux'; import {bindActionCreators} from 'redux';
import type {ActionCreatorsMapObject, Dispatch} from 'redux'; import type {Dispatch} from 'redux';
import type {StatusOK} from '@mattermost/types/client4';
import type {ServerError} from '@mattermost/types/errors';
import type {GetFilteredUsersStatsOpts, UsersStats} from '@mattermost/types/users';
import {uploadLicense, removeLicense, getPrevTrialLicense} from 'mattermost-redux/actions/admin'; import {uploadLicense, removeLicense, getPrevTrialLicense} from 'mattermost-redux/actions/admin';
import {getLicenseConfig} from 'mattermost-redux/actions/general'; import {getLicenseConfig} from 'mattermost-redux/actions/general';
import {getFilteredUsersStats} from 'mattermost-redux/actions/users'; import {getFilteredUsersStats} from 'mattermost-redux/actions/users';
import {getConfig} from 'mattermost-redux/selectors/entities/general'; import {getConfig} from 'mattermost-redux/selectors/entities/general';
import {getFilteredUsersStats as selectFilteredUserStats} from 'mattermost-redux/selectors/entities/users'; import {getFilteredUsersStats as selectFilteredUserStats} from 'mattermost-redux/selectors/entities/users';
import type {Action, ActionResult, GenericAction} from 'mattermost-redux/types/actions';
import {requestTrialLicense, upgradeToE0Status, upgradeToE0, restartServer, ping} from 'actions/admin_actions'; import {requestTrialLicense, upgradeToE0Status, upgradeToE0, restartServer, ping} from 'actions/admin_actions';
import {openModal} from 'actions/views/modals'; import {openModal} from 'actions/views/modals';
import type {ModalData} from 'types/actions';
import type {GlobalState} from 'types/store'; import type {GlobalState} from 'types/store';
import LicenseSettings from './license_settings'; import LicenseSettings from './license_settings';
@@ -34,27 +28,9 @@ function mapStateToProps(state: GlobalState) {
}; };
} }
type StatusOKFunc = () => Promise<StatusOK>; function mapDispatchToProps(dispatch: Dispatch) {
type PromiseStatusFunc = () => Promise<{status: string}>;
type ActionCreatorTypes = Action | PromiseStatusFunc | StatusOKFunc;
type Actions = {
getLicenseConfig: () => void;
uploadLicense: (file: File) => Promise<ActionResult>;
removeLicense: () => Promise<ActionResult>;
getPrevTrialLicense: () => void;
upgradeToE0: StatusOKFunc;
upgradeToE0Status: () => Promise<{percentage: number; error: string | JSX.Element}>;
restartServer: StatusOKFunc;
ping: PromiseStatusFunc;
requestTrialLicense: (users: number, termsAccepted: boolean, receiveEmailsAccepted: boolean, featureName: string) => Promise<ActionResult>;
openModal: <P>(modalData: ModalData<P>) => void;
getFilteredUsersStats: (filters: GetFilteredUsersStatsOpts) => Promise<{ data?: UsersStats | undefined; error?: ServerError | undefined}>;
}
function mapDispatchToProps(dispatch: Dispatch<GenericAction>) {
return { return {
actions: bindActionCreators<ActionCreatorsMapObject<ActionCreatorTypes>, Actions>({ actions: bindActionCreators({
getLicenseConfig, getLicenseConfig,
uploadLicense, uploadLicense,
removeLicense, removeLicense,

Просмотреть файл

@@ -49,7 +49,7 @@ type Props = {
removeLicense: () => Promise<ActionResult>; removeLicense: () => Promise<ActionResult>;
getPrevTrialLicense: () => void; getPrevTrialLicense: () => void;
upgradeToE0: () => Promise<StatusOK>; upgradeToE0: () => Promise<StatusOK>;
upgradeToE0Status: () => Promise<{percentage: number; error: string | JSX.Element}>; upgradeToE0Status: () => Promise<{percentage: number; error: string | JSX.Element | null}>;
restartServer: () => Promise<StatusOK>; restartServer: () => Promise<StatusOK>;
ping: () => Promise<{status: string}>; ping: () => Promise<{status: string}>;
requestTrialLicense: (users: number, termsAccepted: boolean, receiveEmailsAccepted: boolean, featureName: string) => Promise<ActionResult>; requestTrialLicense: (users: number, termsAccepted: boolean, receiveEmailsAccepted: boolean, featureName: string) => Promise<ActionResult>;

Просмотреть файл

@@ -3,15 +3,14 @@
import {connect} from 'react-redux'; import {connect} from 'react-redux';
import {bindActionCreators} from 'redux'; import {bindActionCreators} from 'redux';
import type {Dispatch, ActionCreatorsMapObject} from 'redux'; import type {Dispatch} from 'redux';
import {updateUserRoles} from 'mattermost-redux/actions/users'; import {updateUserRoles} from 'mattermost-redux/actions/users';
import type {GenericAction, ActionFunc} from 'mattermost-redux/types/actions'; import type {GenericAction} from 'mattermost-redux/types/actions';
import type {GlobalState} from 'types/store'; import type {GlobalState} from 'types/store';
import ManageRolesModal from './manage_roles_modal'; import ManageRolesModal from './manage_roles_modal';
import type {Props} from './manage_roles_modal';
function mapStateToProps(state: GlobalState) { function mapStateToProps(state: GlobalState) {
return { return {
@@ -21,7 +20,7 @@ function mapStateToProps(state: GlobalState) {
function mapDispatchToProps(dispatch: Dispatch<GenericAction>) { function mapDispatchToProps(dispatch: Dispatch<GenericAction>) {
return { return {
actions: bindActionCreators<ActionCreatorsMapObject<ActionFunc>, Props['actions']>({ actions: bindActionCreators({
updateUserRoles, updateUserRoles,
}, dispatch), }, dispatch),
}; };

Просмотреть файл

@@ -3,17 +3,16 @@
import {connect} from 'react-redux'; import {connect} from 'react-redux';
import {bindActionCreators} from 'redux'; import {bindActionCreators} from 'redux';
import type {ActionCreatorsMapObject, Dispatch} from 'redux'; import type {Dispatch} from 'redux';
import {updateTeamMemberSchemeRoles, getTeamMembersForUser, getTeamsForUser, removeUserFromTeam} from 'mattermost-redux/actions/teams'; import {updateTeamMemberSchemeRoles, getTeamMembersForUser, getTeamsForUser, removeUserFromTeam} from 'mattermost-redux/actions/teams';
import type {ActionFunc, GenericAction} from 'mattermost-redux/types/actions'; import type {GenericAction} from 'mattermost-redux/types/actions';
import {getCurrentLocale} from 'selectors/i18n'; import {getCurrentLocale} from 'selectors/i18n';
import type {GlobalState} from 'types/store'; import type {GlobalState} from 'types/store';
import ManageTeamsModal from './manage_teams_modal'; import ManageTeamsModal from './manage_teams_modal';
import type {Props} from './manage_teams_modal';
function mapStateToProps(state: GlobalState) { function mapStateToProps(state: GlobalState) {
return { return {
@@ -23,7 +22,7 @@ function mapStateToProps(state: GlobalState) {
function mapDispatchToProps(dispatch: Dispatch<GenericAction>) { function mapDispatchToProps(dispatch: Dispatch<GenericAction>) {
return { return {
actions: bindActionCreators<ActionCreatorsMapObject<ActionFunc>, Props['actions']>({ actions: bindActionCreators({
getTeamMembersForUser, getTeamMembersForUser,
getTeamsForUser, getTeamsForUser,
updateTeamMemberSchemeRoles, updateTeamMemberSchemeRoles,

Просмотреть файл

@@ -3,17 +3,21 @@
import {connect} from 'react-redux'; import {connect} from 'react-redux';
import {bindActionCreators} from 'redux'; import {bindActionCreators} from 'redux';
import type {ActionCreatorsMapObject, Dispatch} from 'redux'; import type {Dispatch} from 'redux';
import type {UserProfile} from '@mattermost/types/users';
import {getUserAccessTokensForUser} from 'mattermost-redux/actions/users'; import {getUserAccessTokensForUser} from 'mattermost-redux/actions/users';
import type {ActionFunc} from 'mattermost-redux/types/actions';
import type {GlobalState} from 'types/store'; import type {GlobalState} from 'types/store';
import ManageTokensModal from './manage_tokens_modal'; import ManageTokensModal from './manage_tokens_modal';
import type {Props} from './manage_tokens_modal';
function mapStateToProps(state: GlobalState, ownProps: Props) { type OwnProps = {
user?: UserProfile;
}
function mapStateToProps(state: GlobalState, ownProps: OwnProps) {
const userId = ownProps.user ? ownProps.user.id : ''; const userId = ownProps.user ? ownProps.user.id : '';
const userAccessTokens = state.entities.admin.userAccessTokensByUser; const userAccessTokens = state.entities.admin.userAccessTokensByUser;
@@ -25,7 +29,7 @@ function mapStateToProps(state: GlobalState, ownProps: Props) {
function mapDispatchToProps(dispatch: Dispatch) { function mapDispatchToProps(dispatch: Dispatch) {
return { return {
actions: bindActionCreators<ActionCreatorsMapObject<ActionFunc>, Props['actions']>({ actions: bindActionCreators({
getUserAccessTokensForUser, getUserAccessTokensForUser,
}, dispatch), }, dispatch),
}; };

Просмотреть файл

@@ -8,7 +8,6 @@ import {FormattedMessage} from 'react-intl';
import type {UserAccessToken, UserProfile} from '@mattermost/types/users'; import type {UserAccessToken, UserProfile} from '@mattermost/types/users';
import {Client4} from 'mattermost-redux/client'; import {Client4} from 'mattermost-redux/client';
import type {ActionFunc} from 'mattermost-redux/types/actions';
import * as UserUtils from 'mattermost-redux/utils/user_utils'; import * as UserUtils from 'mattermost-redux/utils/user_utils';
import RevokeTokenButton from 'components/admin_console/revoke_token_button'; import RevokeTokenButton from 'components/admin_console/revoke_token_button';
@@ -44,7 +43,7 @@ export type Props = {
/** /**
* Function to get a user's access tokens * Function to get a user's access tokens
*/ */
getUserAccessTokensForUser: (userId: string, page: number, perPage: number) => ActionFunc; getUserAccessTokensForUser: (userId: string, page: number, perPage: number) => void;
}; };
}; };

Просмотреть файл

@@ -3,20 +3,18 @@
import {connect} from 'react-redux'; import {connect} from 'react-redux';
import {bindActionCreators} from 'redux'; import {bindActionCreators} from 'redux';
import type {Dispatch, ActionCreatorsMapObject} from 'redux'; import type {Dispatch} from 'redux';
import {getGroupStats} from 'mattermost-redux/actions/groups'; import {getGroupStats} from 'mattermost-redux/actions/groups';
import {searchProfiles, getProfilesInGroup} from 'mattermost-redux/actions/users'; import {searchProfiles, getProfilesInGroup} from 'mattermost-redux/actions/users';
import {getGroupMemberCount} from 'mattermost-redux/selectors/entities/groups'; import {getGroupMemberCount} from 'mattermost-redux/selectors/entities/groups';
import {getProfilesInGroup as selectProfiles, searchProfilesInGroup} from 'mattermost-redux/selectors/entities/users'; import {getProfilesInGroup as selectProfiles, searchProfilesInGroup} from 'mattermost-redux/selectors/entities/users';
import type {ActionFunc, GenericAction} from 'mattermost-redux/types/actions';
import {setModalSearchTerm} from 'actions/views/search'; import {setModalSearchTerm} from 'actions/views/search';
import type {GlobalState} from 'types/store'; import type {GlobalState} from 'types/store';
import MemberListGroup from './member_list_group'; import MemberListGroup from './member_list_group';
import type {Props as MemberListGroupProps} from './member_list_group';
type Props = { type Props = {
groupID: string; groupID: string;
@@ -41,7 +39,7 @@ function mapStateToProps(state: GlobalState, ownProps: Props) {
function mapDispatchToProps(dispatch: Dispatch) { function mapDispatchToProps(dispatch: Dispatch) {
return { return {
actions: bindActionCreators<ActionCreatorsMapObject<ActionFunc | GenericAction>, MemberListGroupProps['actions']>({ actions: bindActionCreators({
getProfilesInGroup, getProfilesInGroup,
searchProfiles, searchProfiles,
setModalSearchTerm, setModalSearchTerm,

Просмотреть файл

@@ -7,6 +7,8 @@ import {FormattedMessage} from 'react-intl';
import type {GroupStats} from '@mattermost/types/groups'; import type {GroupStats} from '@mattermost/types/groups';
import type {UserProfile} from '@mattermost/types/users'; import type {UserProfile} from '@mattermost/types/users';
import type {ActionResult} from 'mattermost-redux/types/actions';
import DataGrid from 'components/admin_console/data_grid/data_grid'; import DataGrid from 'components/admin_console/data_grid/data_grid';
import type {Row, Column} from 'components/admin_console/data_grid/data_grid'; import type {Row, Column} from 'components/admin_console/data_grid/data_grid';
import UserGridName from 'components/admin_console/user_grid/user_grid_name'; import UserGridName from 'components/admin_console/user_grid/user_grid_name';
@@ -23,10 +25,10 @@ export type Props = {
groupID: string; groupID: string;
total: number; total: number;
actions: { actions: {
getProfilesInGroup: (groupID: string, page: number, perPage: number) => Promise<{data: UserProfile[]}>; getProfilesInGroup: (groupID: string, page: number, perPage: number) => Promise<ActionResult<UserProfile[]>>;
getGroupStats: (groupID: string) => Promise<{data: GroupStats}>; getGroupStats: (groupID: string) => Promise<ActionResult<GroupStats>>;
searchProfiles: (term: string, options?: Record<string, unknown>) => Promise<{data: UserProfile[]}>; searchProfiles: (term: string, options?: Record<string, unknown>) => Promise<ActionResult<UserProfile[]>>;
setModalSearchTerm: (term: string) => Promise<{data: boolean}>; setModalSearchTerm: (term: string) => void;
}; };
} }

Просмотреть файл

@@ -3,22 +3,15 @@
import {connect} from 'react-redux'; import {connect} from 'react-redux';
import {bindActionCreators} from 'redux'; import {bindActionCreators} from 'redux';
import type {Dispatch, ActionCreatorsMapObject} from 'redux'; import type {Dispatch} from 'redux';
import type {AdminConfig} from '@mattermost/types/config';
import {updateConfig} from 'mattermost-redux/actions/admin'; import {updateConfig} from 'mattermost-redux/actions/admin';
import type {ActionFunc, GenericAction} from 'mattermost-redux/types/actions';
import OpenIdConvert from './openid_convert'; import OpenIdConvert from './openid_convert';
type Actions = { function mapDispatchToProps(dispatch: Dispatch) {
updateConfig: (config: AdminConfig) => ActionFunc;
}
function mapDispatchToProps(dispatch: Dispatch<GenericAction>) {
return { return {
actions: bindActionCreators<ActionCreatorsMapObject<ActionFunc>, Actions>({ actions: bindActionCreators({
updateConfig, updateConfig,
}, dispatch), }, dispatch),
}; };

Просмотреть файл

@@ -6,7 +6,7 @@ import {FormattedMessage} from 'react-intl';
import type {AdminConfig} from '@mattermost/types/config'; import type {AdminConfig} from '@mattermost/types/config';
import type {ActionFunc} from 'mattermost-redux/types/actions'; import type {ActionResult} from 'mattermost-redux/types/actions';
import type {BaseProps} from 'components/admin_console/admin_settings'; import type {BaseProps} from 'components/admin_console/admin_settings';
import ExternalLink from 'components/external_link'; import ExternalLink from 'components/external_link';
@@ -21,18 +21,13 @@ import './openid_convert.scss';
type Props = BaseProps & { type Props = BaseProps & {
disabled?: boolean; disabled?: boolean;
actions: { actions: {
updateConfig: (config: AdminConfig) => ActionFunc & Partial<{error?: ClientErrorPlaceholder}>; updateConfig: (config: AdminConfig) => Promise<ActionResult>;
}; };
}; };
type State = { type State = {
serverError?: string; serverError?: string;
} }
type ClientErrorPlaceholder = {
message: string;
server_error_id: string;
}
export default class OpenIdConvert extends React.PureComponent<Props, State> { export default class OpenIdConvert extends React.PureComponent<Props, State> {
constructor(props: Props) { constructor(props: Props) {
super(props); super(props);

Просмотреть файл

@@ -7,7 +7,7 @@ import {FormattedMessage} from 'react-intl';
import type {AdminConfig} from '@mattermost/types/config'; import type {AdminConfig} from '@mattermost/types/config';
import type {ActionFunc} from 'mattermost-redux/types/actions'; import type {ActionResult} from 'mattermost-redux/types/actions';
import FormattedMarkdownMessage from 'components/formatted_markdown_message'; import FormattedMarkdownMessage from 'components/formatted_markdown_message';
@@ -22,15 +22,10 @@ type Props ={
show: boolean; show: boolean;
onClose: () => void; onClose: () => void;
actions: { actions: {
updateConfig: (config: AdminConfig) => ActionFunc & {error?: ClientErrorPlaceholder}; updateConfig: (config: AdminConfig) => Promise<ActionResult>;
}; };
} }
type ClientErrorPlaceholder = {
message: string;
server_error_id: string;
}
export default function EditPostTimeLimitModal(props: Props) { export default function EditPostTimeLimitModal(props: Props) {
const {ServiceSettings} = props.config; const {ServiceSettings} = props.config;

Просмотреть файл

@@ -3,31 +3,24 @@
import {connect} from 'react-redux'; import {connect} from 'react-redux';
import {bindActionCreators} from 'redux'; import {bindActionCreators} from 'redux';
import type {ActionCreatorsMapObject, Dispatch} from 'redux'; import type {Dispatch} from 'redux';
import type {AdminConfig} from '@mattermost/types/config';
import {updateConfig} from 'mattermost-redux/actions/admin'; import {updateConfig} from 'mattermost-redux/actions/admin';
import {getConfig} from 'mattermost-redux/selectors/entities/admin'; import {getConfig} from 'mattermost-redux/selectors/entities/admin';
import type {ActionFunc, GenericAction} from 'mattermost-redux/types/actions';
import type {GlobalState} from 'types/store'; import type {GlobalState} from 'types/store';
import EditPostTimeLimitModal from './edit_post_time_limit_modal'; import EditPostTimeLimitModal from './edit_post_time_limit_modal';
type Actions = {
updateConfig: (config: AdminConfig) => ActionFunc;
}
function mapStateToProps(state: GlobalState) { function mapStateToProps(state: GlobalState) {
return { return {
config: getConfig(state), config: getConfig(state),
}; };
} }
function mapDispatchToProps(dispatch: Dispatch<GenericAction>) { function mapDispatchToProps(dispatch: Dispatch) {
return { return {
actions: bindActionCreators<ActionCreatorsMapObject<ActionFunc>, Actions>({updateConfig}, dispatch), actions: bindActionCreators({updateConfig}, dispatch),
}; };
} }

Просмотреть файл

@@ -3,17 +3,15 @@
import {connect} from 'react-redux'; import {connect} from 'react-redux';
import {bindActionCreators} from 'redux'; import {bindActionCreators} from 'redux';
import type {ActionCreatorsMapObject, Dispatch} from 'redux'; import type {Dispatch} from 'redux';
import {getSchemeTeams as loadSchemeTeams, getSchemes as loadSchemes} from 'mattermost-redux/actions/schemes'; import {getSchemeTeams as loadSchemeTeams, getSchemes as loadSchemes} from 'mattermost-redux/actions/schemes';
import {getConfig} from 'mattermost-redux/selectors/entities/general'; import {getConfig} from 'mattermost-redux/selectors/entities/general';
import {getSchemes} from 'mattermost-redux/selectors/entities/schemes'; import {getSchemes} from 'mattermost-redux/selectors/entities/schemes';
import type {ActionFunc, GenericAction} from 'mattermost-redux/types/actions';
import type {GlobalState} from 'types/store'; import type {GlobalState} from 'types/store';
import PermissionSchemesSettings from './permission_schemes_settings'; import PermissionSchemesSettings from './permission_schemes_settings';
import type {Props} from './permission_schemes_settings';
function mapStateToProps(state: GlobalState) { function mapStateToProps(state: GlobalState) {
const schemes = getSchemes(state); const schemes = getSchemes(state);
@@ -26,9 +24,9 @@ function mapStateToProps(state: GlobalState) {
}; };
} }
function mapDispatchToProps(dispatch: Dispatch<GenericAction>) { function mapDispatchToProps(dispatch: Dispatch) {
return { return {
actions: bindActionCreators<ActionCreatorsMapObject<ActionFunc | GenericAction>, Props['actions']>({ actions: bindActionCreators({
loadSchemes, loadSchemes,
loadSchemeTeams, loadSchemeTeams,
}, dispatch), }, dispatch),

Просмотреть файл

@@ -3,15 +3,13 @@
import {connect} from 'react-redux'; import {connect} from 'react-redux';
import {bindActionCreators} from 'redux'; import {bindActionCreators} from 'redux';
import type {ActionCreatorsMapObject, Dispatch} from 'redux'; import type {Dispatch} from 'redux';
import type {Role} from '@mattermost/types/roles';
import type {GlobalState} from '@mattermost/types/store'; import type {GlobalState} from '@mattermost/types/store';
import {loadRolesIfNeeded, editRole} from 'mattermost-redux/actions/roles'; import {loadRolesIfNeeded, editRole} from 'mattermost-redux/actions/roles';
import {getLicense, getConfig} from 'mattermost-redux/selectors/entities/general'; import {getLicense, getConfig} from 'mattermost-redux/selectors/entities/general';
import {getRoles} from 'mattermost-redux/selectors/entities/roles'; import {getRoles} from 'mattermost-redux/selectors/entities/roles';
import type {ActionFunc, ActionResult, GenericAction} from 'mattermost-redux/types/actions.js';
import {setNavigationBlocked} from 'actions/admin_actions.jsx'; import {setNavigationBlocked} from 'actions/admin_actions.jsx';
@@ -24,15 +22,10 @@ function mapStateToProps(state: GlobalState) {
roles: getRoles(state), roles: getRoles(state),
}; };
} }
type Actions = {
loadRolesIfNeeded: (roles: Iterable<string>) => void;
editRole: (role: Partial<Role>) => Promise<ActionResult>;
setNavigationBlocked: (blocked: boolean) => void;
};
function mapDispatchToProps(dispatch: Dispatch<GenericAction>) { function mapDispatchToProps(dispatch: Dispatch) {
return { return {
actions: bindActionCreators<ActionCreatorsMapObject<ActionFunc | GenericAction>, Actions>({ actions: bindActionCreators({
loadRolesIfNeeded, loadRolesIfNeeded,
editRole, editRole,
setNavigationBlocked, setNavigationBlocked,

Просмотреть файл

@@ -33,7 +33,7 @@ type Props = {
license: ClientLicense; license: ClientLicense;
isDisabled?: boolean; isDisabled?: boolean;
actions: { actions: {
loadRolesIfNeeded: (roles: Iterable<string>) => void; loadRolesIfNeeded: (roles: string[]) => void;
editRole: (role: Partial<Role>) => Promise<ActionResult>; editRole: (role: Partial<Role>) => Promise<ActionResult>;
setNavigationBlocked: (blocked: boolean) => void; setNavigationBlocked: (blocked: boolean) => void;
}; };

Просмотреть файл

@@ -3,11 +3,8 @@
import {connect} from 'react-redux'; import {connect} from 'react-redux';
import {bindActionCreators} from 'redux'; import {bindActionCreators} from 'redux';
import type {ActionCreatorsMapObject, Dispatch} from 'redux'; import type {Dispatch} from 'redux';
import type {ServerError} from '@mattermost/types/errors';
import type {Role} from '@mattermost/types/roles';
import type {Scheme, SchemePatch} from '@mattermost/types/schemes';
import type {GlobalState} from '@mattermost/types/store'; import type {GlobalState} from '@mattermost/types/store';
import {loadRolesIfNeeded, editRole} from 'mattermost-redux/actions/roles'; import {loadRolesIfNeeded, editRole} from 'mattermost-redux/actions/roles';
@@ -16,12 +13,10 @@ import {updateTeamScheme} from 'mattermost-redux/actions/teams';
import {getLicense, getConfig} from 'mattermost-redux/selectors/entities/general'; import {getLicense, getConfig} from 'mattermost-redux/selectors/entities/general';
import {getRoles} from 'mattermost-redux/selectors/entities/roles'; import {getRoles} from 'mattermost-redux/selectors/entities/roles';
import {getScheme, makeGetSchemeTeams} from 'mattermost-redux/selectors/entities/schemes'; import {getScheme, makeGetSchemeTeams} from 'mattermost-redux/selectors/entities/schemes';
import type {ActionFunc, ActionResult, GenericAction} from 'mattermost-redux/types/actions';
import {setNavigationBlocked} from 'actions/admin_actions'; import {setNavigationBlocked} from 'actions/admin_actions';
import PermissionTeamSchemeSettings from './permission_team_scheme_settings'; import PermissionTeamSchemeSettings from './permission_team_scheme_settings';
import type {Props} from './permission_team_scheme_settings';
type OwnProps = { type OwnProps = {
match: { match: {
@@ -47,20 +42,9 @@ function makeMapStateToProps() {
}; };
} }
type Actions = { function mapDispatchToProps(dispatch: Dispatch) {
loadRolesIfNeeded: (roles: Iterable<string>) => ActionFunc;
loadScheme: (schemeId: string) => Promise<ActionResult>;
loadSchemeTeams: (schemeId: string, page?: number, perPage?: number) => ActionFunc;
editRole: (role: Role) => Promise<{error: ServerError}>;
patchScheme: (schemeId: string, scheme: SchemePatch) => ActionFunc;
updateTeamScheme: (teamId: string, schemeId: string) => Promise<{error: ServerError; data: Scheme}>;
createScheme: (scheme: Scheme) => Promise<{error: ServerError; data: Scheme}>;
setNavigationBlocked: (blocked: boolean) => void;
};
function mapDispatchToProps(dispatch: Dispatch<GenericAction>): Props {
return { return {
actions: bindActionCreators<ActionCreatorsMapObject<ActionFunc | GenericAction>, Actions>({ actions: bindActionCreators({
loadRolesIfNeeded, loadRolesIfNeeded,
loadScheme, loadScheme,
loadSchemeTeams, loadSchemeTeams,
@@ -70,7 +54,7 @@ function mapDispatchToProps(dispatch: Dispatch<GenericAction>): Props {
createScheme, createScheme,
setNavigationBlocked, setNavigationBlocked,
}, dispatch), }, dispatch),
} as Props; };
} }
export default connect(makeMapStateToProps, mapDispatchToProps)(PermissionTeamSchemeSettings); export default connect(makeMapStateToProps, mapDispatchToProps)(PermissionTeamSchemeSettings);

Просмотреть файл

@@ -6,13 +6,12 @@ import {FormattedMessage, injectIntl, type IntlShape} from 'react-intl';
import type {RouteComponentProps} from 'react-router-dom'; import type {RouteComponentProps} from 'react-router-dom';
import type {ClientConfig, ClientLicense} from '@mattermost/types/config'; import type {ClientConfig, ClientLicense} from '@mattermost/types/config';
import type {ServerError} from '@mattermost/types/errors';
import type {Role} from '@mattermost/types/roles'; import type {Role} from '@mattermost/types/roles';
import type {Scheme, SchemePatch} from '@mattermost/types/schemes'; import type {Scheme, SchemePatch} from '@mattermost/types/schemes';
import type {Team} from '@mattermost/types/teams'; import type {Team} from '@mattermost/types/teams';
import GeneralConstants from 'mattermost-redux/constants/general'; import GeneralConstants from 'mattermost-redux/constants/general';
import type {ActionFunc, ActionResult} from 'mattermost-redux/types/actions'; import type {ActionResult} from 'mattermost-redux/types/actions';
import BlockableLink from 'components/admin_console/blockable_link'; import BlockableLink from 'components/admin_console/blockable_link';
import ExternalLink from 'components/external_link'; import ExternalLink from 'components/external_link';
@@ -44,18 +43,18 @@ export type Props = {
scheme: Scheme | null; scheme: Scheme | null;
roles: RolesMap; roles: RolesMap;
license: ClientLicense; license: ClientLicense;
teams: Team[]; teams: Team[] | null;
isDisabled: boolean; isDisabled: boolean;
config: Partial<ClientConfig>; config: Partial<ClientConfig>;
intl: IntlShape; intl: IntlShape;
actions: { actions: {
loadRolesIfNeeded: (roles: Iterable<string>) => ActionFunc; loadRolesIfNeeded: (roles: Iterable<string>) => Promise<ActionResult>;
loadScheme: (schemeId: string) => Promise<ActionResult>; loadScheme: (schemeId: string) => Promise<ActionResult>;
loadSchemeTeams: (schemeId: string, page?: number, perPage?: number) => ActionFunc; loadSchemeTeams: (schemeId: string, page?: number, perPage?: number) => Promise<ActionResult>;
editRole: (role: Role) => Promise<{error: ServerError}>; editRole: (role: Role) => Promise<ActionResult>;
patchScheme: (schemeId: string, scheme: SchemePatch) => ActionFunc; patchScheme: (schemeId: string, scheme: SchemePatch) => Promise<ActionResult>;
updateTeamScheme: (teamId: string, schemeId: string) => Promise<{error: ServerError; data: Scheme}>; updateTeamScheme: (teamId: string, schemeId: string) => Promise<ActionResult>;
createScheme: (scheme: Scheme) => Promise<{error: ServerError; data: Scheme}>; createScheme: (scheme: Scheme) => Promise<ActionResult>;
setNavigationBlocked: (blocked: boolean) => void; setNavigationBlocked: (blocked: boolean) => void;
}; };
} }
@@ -548,7 +547,7 @@ export class PermissionTeamSchemeSettings extends React.PureComponent<Props & Ro
}; };
removeTeam = (teamId: string) => { removeTeam = (teamId: string) => {
const teams = (this.state.teams || this.props.teams).filter((team) => team.id !== teamId); const teams = (this.state.teams || this.props.teams)?.filter((team) => team.id !== teamId) ?? null;
this.setState({teams, saveNeeded: true}); this.setState({teams, saveNeeded: true});
this.props.actions.setNavigationBlocked(true); this.props.actions.setNavigationBlocked(true);
}; };

Просмотреть файл

@@ -4,13 +4,12 @@
import {connect} from 'react-redux'; import {connect} from 'react-redux';
import type {RouteComponentProps} from 'react-router-dom'; import type {RouteComponentProps} from 'react-router-dom';
import {bindActionCreators} from 'redux'; import {bindActionCreators} from 'redux';
import type {ActionCreatorsMapObject, Dispatch} from 'redux'; import type {Dispatch} from 'redux';
import type {GlobalState} from '@mattermost/types/store'; import type {GlobalState} from '@mattermost/types/store';
import {deleteScheme} from 'mattermost-redux/actions/schemes'; import {deleteScheme} from 'mattermost-redux/actions/schemes';
import {makeGetSchemeTeams} from 'mattermost-redux/selectors/entities/schemes'; import {makeGetSchemeTeams} from 'mattermost-redux/selectors/entities/schemes';
import type {ActionFunc, ActionResult, GenericAction} from 'mattermost-redux/types/actions';
import PermissionsSchemeSummary from './permissions_scheme_summary'; import PermissionsSchemeSummary from './permissions_scheme_summary';
import type {Props} from './permissions_scheme_summary'; import type {Props} from './permissions_scheme_summary';
@@ -25,13 +24,9 @@ function makeMapStateToProps() {
}; };
} }
type Actions = { function mapDispatchToProps(dispatch: Dispatch) {
deleteScheme: (schemeId: string) => Promise<ActionResult>;
};
function mapDispatchToProps(dispatch: Dispatch<GenericAction>) {
return { return {
actions: bindActionCreators<ActionCreatorsMapObject<ActionFunc>, Actions>({ actions: bindActionCreators({
deleteScheme, deleteScheme,
}, dispatch), }, dispatch),
}; };

Просмотреть файл

@@ -3,22 +3,15 @@
import {connect} from 'react-redux'; import {connect} from 'react-redux';
import {bindActionCreators} from 'redux'; import {bindActionCreators} from 'redux';
import type {Dispatch, ActionCreatorsMapObject} from 'redux'; import type {Dispatch} from 'redux';
import type {UserProfile} from '@mattermost/types/users';
import {patchUser} from 'mattermost-redux/actions/users'; import {patchUser} from 'mattermost-redux/actions/users';
import {getCurrentUserId} from 'mattermost-redux/selectors/entities/common'; import {getCurrentUserId} from 'mattermost-redux/selectors/entities/common';
import type {ActionFunc, ActionResult} from 'mattermost-redux/types/actions';
import type {GlobalState} from 'types/store'; import type {GlobalState} from 'types/store';
import ResetEmailModal from './reset_email_modal'; import ResetEmailModal from './reset_email_modal';
type Actions = {
patchUser: (user: UserProfile) => ActionResult;
}
function mapStateToProps(state: GlobalState) { function mapStateToProps(state: GlobalState) {
return { return {
currentUserId: getCurrentUserId(state), currentUserId: getCurrentUserId(state),
@@ -27,7 +20,7 @@ function mapStateToProps(state: GlobalState) {
function mapDispatchToProps(dispatch: Dispatch) { function mapDispatchToProps(dispatch: Dispatch) {
return { return {
actions: bindActionCreators<ActionCreatorsMapObject<ActionFunc>, Actions>({ actions: bindActionCreators({
patchUser, patchUser,
}, dispatch), }, dispatch),
}; };

Просмотреть файл

@@ -20,7 +20,7 @@ describe('components/admin_console/reset_email_modal/reset_email_modal.tsx', ()
}); });
const baseProps = { const baseProps = {
actions: {patchUser: jest.fn(() => ({data: ''}))}, actions: {patchUser: jest.fn(() => Promise.resolve({}))},
user, user,
currentUserId: 'random_user_id', currentUserId: 'random_user_id',
show: true, show: true,
@@ -46,14 +46,12 @@ describe('components/admin_console/reset_email_modal/reset_email_modal.tsx', ()
}); });
test('should not update email since the email is empty', () => { test('should not update email since the email is empty', () => {
const patchUser = jest.fn(() => ({data: ''})); const wrapper = mountWithIntl(<ResetEmailModal {...baseProps}/>);
const props = {...baseProps, actions: {patchUser}};
const wrapper = mountWithIntl(<ResetEmailModal {...props}/>);
(wrapper.find('input[type=\'email\']').first().instance() as unknown as HTMLInputElement).value = ''; (wrapper.find('input[type=\'email\']').first().instance() as unknown as HTMLInputElement).value = '';
wrapper.find('button[type=\'submit\']').first().simulate('click', {preventDefault: jest.fn()}); wrapper.find('button[type=\'submit\']').first().simulate('click', {preventDefault: jest.fn()});
expect(patchUser.mock.calls.length).toBe(0); expect(baseProps.actions.patchUser.mock.calls.length).toBe(0);
expect(wrapper.state('error')).toStrictEqual( expect(wrapper.state('error')).toStrictEqual(
<FormattedMessage <FormattedMessage
id='user.settings.general.validEmail' id='user.settings.general.validEmail'
@@ -63,14 +61,12 @@ describe('components/admin_console/reset_email_modal/reset_email_modal.tsx', ()
}); });
test('should not update email since the email is invalid', () => { test('should not update email since the email is invalid', () => {
const patchUser = jest.fn(() => ({data: ''})); const wrapper = mountWithIntl(<ResetEmailModal {...baseProps}/>);
const props = {...baseProps, actions: {patchUser}};
const wrapper = mountWithIntl(<ResetEmailModal {...props}/>);
(wrapper.find('input[type=\'email\']').first().instance() as unknown as HTMLInputElement).value = 'invalid-email'; (wrapper.find('input[type=\'email\']').first().instance() as unknown as HTMLInputElement).value = 'invalid-email';
wrapper.find('button[type=\'submit\']').first().simulate('click', {preventDefault: jest.fn()}); wrapper.find('button[type=\'submit\']').first().simulate('click', {preventDefault: jest.fn()});
expect(patchUser.mock.calls.length).toBe(0); expect(baseProps.actions.patchUser.mock.calls.length).toBe(0);
expect(wrapper.state('error')).toStrictEqual( expect(wrapper.state('error')).toStrictEqual(
<FormattedMessage <FormattedMessage
id='user.settings.general.validEmail' id='user.settings.general.validEmail'
@@ -80,14 +76,13 @@ describe('components/admin_console/reset_email_modal/reset_email_modal.tsx', ()
}); });
test('should require password when updating email of the current user', () => { test('should require password when updating email of the current user', () => {
const patchUser = jest.fn(() => ({data: ''})); const props = {...baseProps, currentUserId: user.id};
const props = {...baseProps, actions: {patchUser}, currentUserId: user.id};
const wrapper = mountWithIntl(<ResetEmailModal {...props}/>); const wrapper = mountWithIntl(<ResetEmailModal {...props}/>);
(wrapper.find('input[type=\'email\']').first().instance() as unknown as HTMLInputElement).value = 'currentUser@test.com'; (wrapper.find('input[type=\'email\']').first().instance() as unknown as HTMLInputElement).value = 'currentUser@test.com';
wrapper.find('button[type=\'submit\']').first().simulate('click', {preventDefault: jest.fn()}); wrapper.find('button[type=\'submit\']').first().simulate('click', {preventDefault: jest.fn()});
expect(patchUser.mock.calls.length).toBe(0); expect(baseProps.actions.patchUser.mock.calls.length).toBe(0);
expect(wrapper.state('error')).toStrictEqual( expect(wrapper.state('error')).toStrictEqual(
<FormattedMessage <FormattedMessage
id='admin.reset_email.missing_current_password' id='admin.reset_email.missing_current_password'
@@ -97,27 +92,24 @@ describe('components/admin_console/reset_email_modal/reset_email_modal.tsx', ()
}); });
test('should update email since the email is valid of the another user', () => { test('should update email since the email is valid of the another user', () => {
const patchUser = jest.fn(() => ({data: ''})); const wrapper = mountWithIntl(<ResetEmailModal {...baseProps}/>);
const props = {...baseProps, actions: {patchUser}};
const wrapper = mountWithIntl(<ResetEmailModal {...props}/>);
(wrapper.find('input[type=\'email\']').first().instance() as unknown as HTMLInputElement).value = 'user@test.com'; (wrapper.find('input[type=\'email\']').first().instance() as unknown as HTMLInputElement).value = 'user@test.com';
wrapper.find('button[type=\'submit\']').first().simulate('click', {preventDefault: jest.fn()}); wrapper.find('button[type=\'submit\']').first().simulate('click', {preventDefault: jest.fn()});
expect(patchUser.mock.calls.length).toBe(1); expect(baseProps.actions.patchUser.mock.calls.length).toBe(1);
expect(wrapper.state('error')).toBeNull(); expect(wrapper.state('error')).toBeNull();
}); });
test('should update email since the email is valid of the current user', () => { test('should update email since the email is valid of the current user', () => {
const patchUser = jest.fn(() => ({data: ''})); const props = {...baseProps, currentUserId: user.id};
const props = {...baseProps, actions: {patchUser}, currentUserId: user.id};
const wrapper = mountWithIntl(<ResetEmailModal {...props}/>); const wrapper = mountWithIntl(<ResetEmailModal {...props}/>);
(wrapper.find('input[type=\'email\']').first().instance() as unknown as HTMLInputElement).value = 'currentUser@test.com'; (wrapper.find('input[type=\'email\']').first().instance() as unknown as HTMLInputElement).value = 'currentUser@test.com';
(wrapper.find('input[type=\'password\']').first().instance() as unknown as HTMLInputElement).value = 'password'; (wrapper.find('input[type=\'password\']').first().instance() as unknown as HTMLInputElement).value = 'password';
wrapper.find('button[type=\'submit\']').first().simulate('click', {preventDefault: jest.fn()}); wrapper.find('button[type=\'submit\']').first().simulate('click', {preventDefault: jest.fn()});
expect(patchUser.mock.calls.length).toBe(1); expect(baseProps.actions.patchUser.mock.calls.length).toBe(1);
expect(wrapper.state('error')).toBeNull(); expect(wrapper.state('error')).toBeNull();
}); });
}); });

Просмотреть файл

@@ -23,7 +23,7 @@ type Props = {
onModalSubmit: (user?: UserProfile) => void; onModalSubmit: (user?: UserProfile) => void;
onModalDismissed: () => void; onModalDismissed: () => void;
actions: { actions: {
patchUser: (user: UserProfile) => ActionResult; patchUser: (user: UserProfile) => Promise<ActionResult>;
}; };
} }

Просмотреть файл

@@ -3,12 +3,11 @@
import {connect} from 'react-redux'; import {connect} from 'react-redux';
import {bindActionCreators} from 'redux'; import {bindActionCreators} from 'redux';
import type {Dispatch, ActionCreatorsMapObject} from 'redux'; import type {Dispatch} from 'redux';
import {updateUserPassword} from 'mattermost-redux/actions/users'; import {updateUserPassword} from 'mattermost-redux/actions/users';
import {getConfig} from 'mattermost-redux/selectors/entities/general'; import {getConfig} from 'mattermost-redux/selectors/entities/general';
import {getCurrentUserId} from 'mattermost-redux/selectors/entities/users'; import {getCurrentUserId} from 'mattermost-redux/selectors/entities/users';
import type {ActionFunc, ActionResult} from 'mattermost-redux/types/actions';
import {getPasswordConfig} from 'utils/utils'; import {getPasswordConfig} from 'utils/utils';
@@ -16,10 +15,6 @@ import type {GlobalState} from 'types/store';
import ResetPasswordModal from './reset_password_modal'; import ResetPasswordModal from './reset_password_modal';
type Actions = {
updateUserPassword: (userId: string, currentPassword: string, password: string) => ActionResult;
}
function mapStateToProps(state: GlobalState) { function mapStateToProps(state: GlobalState) {
const config = getConfig(state); const config = getConfig(state);
@@ -31,7 +26,7 @@ function mapStateToProps(state: GlobalState) {
function mapDispatchToProps(dispatch: Dispatch) { function mapDispatchToProps(dispatch: Dispatch) {
return { return {
actions: bindActionCreators<ActionCreatorsMapObject<ActionFunc>, Actions>({ actions: bindActionCreators({
updateUserPassword, updateUserPassword,
}, dispatch), }, dispatch),
}; };

Просмотреть файл

@@ -7,8 +7,6 @@ import {FormattedMessage} from 'react-intl';
import type {UserNotifyProps, UserProfile} from '@mattermost/types/users'; import type {UserNotifyProps, UserProfile} from '@mattermost/types/users';
import type {ActionResult} from 'mattermost-redux/types/actions';
import {mountWithIntl} from 'tests/helpers/intl-test-helper'; import {mountWithIntl} from 'tests/helpers/intl-test-helper';
import {TestHelper} from 'utils/test_helper'; import {TestHelper} from 'utils/test_helper';
@@ -36,8 +34,7 @@ describe('components/admin_console/reset_password_modal/reset_password_modal.tsx
}); });
const baseProps = { const baseProps = {
// eslint-disable-next-line @typescript-eslint/ban-types actions: {updateUserPassword: jest.fn(() => Promise.resolve({data: ''}))},
actions: {updateUserPassword: jest.fn<ActionResult, Array<{}>>(() => ({data: ''}))},
currentUserId: user.id, currentUserId: user.id,
user, user,
show: true, show: true,
@@ -68,8 +65,7 @@ describe('components/admin_console/reset_password_modal/reset_password_modal.tsx
}); });
test('should call updateUserPassword', () => { test('should call updateUserPassword', () => {
// eslint-disable-next-line @typescript-eslint/ban-types const updateUserPassword = jest.fn(() => Promise.resolve({data: ''}));
const updateUserPassword = jest.fn<ActionResult, Array<{}>>(() => ({data: ''}));
const oldPassword = 'oldPassword123!'; const oldPassword = 'oldPassword123!';
const newPassword = 'newPassword123!'; const newPassword = 'newPassword123!';
const props = {...baseProps, actions: {updateUserPassword}}; const props = {...baseProps, actions: {updateUserPassword}};
@@ -85,8 +81,7 @@ describe('components/admin_console/reset_password_modal/reset_password_modal.tsx
}); });
test('should not call updateUserPassword when the old password is not provided', () => { test('should not call updateUserPassword when the old password is not provided', () => {
// eslint-disable-next-line @typescript-eslint/ban-types const updateUserPassword = jest.fn(() => Promise.resolve({data: ''}));
const updateUserPassword = jest.fn<ActionResult, Array<{}>>(() => ({data: ''}));
const newPassword = 'newPassword123!'; const newPassword = 'newPassword123!';
const props = {...baseProps, actions: {updateUserPassword}}; const props = {...baseProps, actions: {updateUserPassword}};
const wrapper = mountWithIntl(<ResetPasswordModal {...props}/>); const wrapper = mountWithIntl(<ResetPasswordModal {...props}/>);
@@ -104,8 +99,7 @@ describe('components/admin_console/reset_password_modal/reset_password_modal.tsx
}); });
test('should call updateUserPassword', () => { test('should call updateUserPassword', () => {
// eslint-disable-next-line @typescript-eslint/ban-types const updateUserPassword = jest.fn(() => Promise.resolve({data: ''}));
const updateUserPassword = jest.fn<ActionResult, Array<{}>>(() => ({data: ''}));
const password = 'Password123!'; const password = 'Password123!';
const props = {...baseProps, currentUserId: '2', actions: {updateUserPassword}}; const props = {...baseProps, currentUserId: '2', actions: {updateUserPassword}};

Просмотреть файл

@@ -24,7 +24,7 @@ type State = {
serverErrorCurrentPass: React.ReactNode; serverErrorCurrentPass: React.ReactNode;
} }
type Props = { export type Props = {
user?: UserProfile; user?: UserProfile;
currentUserId: string; currentUserId: string;
show: boolean; show: boolean;
@@ -32,7 +32,7 @@ type Props = {
onModalDismissed: () => void; onModalDismissed: () => void;
passwordConfig: PasswordConfig; passwordConfig: PasswordConfig;
actions: { actions: {
updateUserPassword: (userId: string, currentPassword: string, password: string) => ActionResult; updateUserPassword: (userId: string, currentPassword: string, password: string) => Promise<ActionResult>;
}; };
} }

Просмотреть файл

@@ -4,15 +4,15 @@
import React from 'react'; import React from 'react';
import {FormattedMessage} from 'react-intl'; import {FormattedMessage} from 'react-intl';
import type {ActionFunc, ActionResult} from 'mattermost-redux/types/actions'; import type {ActionResult} from 'mattermost-redux/types/actions';
import {trackEvent} from 'actions/telemetry_actions.jsx'; import {trackEvent} from 'actions/telemetry_actions.jsx';
interface RevokeTokenButtonProps { export interface RevokeTokenButtonProps {
actions: { actions: {
revokeUserAccessToken: ( revokeUserAccessToken: (
tokenId: string tokenId: string
) => Promise<ActionFunc | ActionResult> | ActionFunc | ActionResult; ) => Promise<ActionResult>;
}; };
tokenId: string; tokenId: string;
onError: (errorMessage: string) => void; onError: (errorMessage: string) => void;

Просмотреть файл

@@ -12,8 +12,6 @@ import type {
LogServerNames, LogServerNames,
} from '@mattermost/types/admin'; } from '@mattermost/types/admin';
import type {ActionFunc} from 'mattermost-redux/types/actions';
import AdminHeader from 'components/widgets/admin_console/admin_header'; import AdminHeader from 'components/widgets/admin_console/admin_header';
import LogList from './log_list'; import LogList from './log_list';
@@ -24,11 +22,11 @@ type Props = {
plainLogs: string[]; plainLogs: string[];
isPlainLogs: boolean; isPlainLogs: boolean;
actions: { actions: {
getLogs: (logFilter: LogFilter) => ActionFunc; getLogs: (logFilter: LogFilter) => Promise<unknown>;
getPlainLogs: ( getPlainLogs: (
page?: number | undefined, page?: number | undefined,
perPage?: number | undefined perPage?: number | undefined
) => ActionFunc; ) => Promise<unknown>;
}; };
}; };

Просмотреть файл

@@ -11,6 +11,7 @@ import type {UserProfile} from '@mattermost/types/users';
import {Client4} from 'mattermost-redux/client'; import {Client4} from 'mattermost-redux/client';
import {filterProfiles} from 'mattermost-redux/selectors/entities/users'; import {filterProfiles} from 'mattermost-redux/selectors/entities/users';
import type {ActionResult} from 'mattermost-redux/types/actions';
import {filterProfilesStartingWithTerm, profileListToMap, isGuest} from 'mattermost-redux/utils/user_utils'; import {filterProfilesStartingWithTerm, profileListToMap, isGuest} from 'mattermost-redux/utils/user_utils';
import MultiSelect from 'components/multiselect/multiselect'; import MultiSelect from 'components/multiselect/multiselect';
@@ -36,8 +37,8 @@ export type Props = {
onExited: () => void; onExited: () => void;
actions: { actions: {
getProfiles: (page: number, perPage?: number, options?: Record<string, any>) => Promise<{ data: UserProfile[] }>; getProfiles: (page: number, perPage?: number, options?: Record<string, any>) => Promise<ActionResult<UserProfile[]>>;
searchProfiles: (term: string, options?: Record<string, any>) => Promise<{ data: UserProfile[] }>; searchProfiles: (term: string, options?: Record<string, any>) => Promise<ActionResult<UserProfile[]>>;
}; };
} }
@@ -87,7 +88,7 @@ export class AddUsersToRoleModal extends React.PureComponent<Props, State> {
const search = term !== ''; const search = term !== '';
if (search) { if (search) {
const {data} = await this.props.actions.searchProfiles(term, {replace: true}); const {data} = await this.props.actions.searchProfiles(term, {replace: true});
data.forEach((user) => { data!.forEach((user) => {
if (!user.is_bot) { if (!user.is_bot) {
searchResults.push(user); searchResults.push(user);
} }

Просмотреть файл

@@ -3,14 +3,13 @@
import {connect} from 'react-redux'; import {connect} from 'react-redux';
import {bindActionCreators} from 'redux'; import {bindActionCreators} from 'redux';
import type {Dispatch, ActionCreatorsMapObject} from 'redux'; import type {Dispatch} from 'redux';
import type {GlobalState} from '@mattermost/types/store'; import type {GlobalState} from '@mattermost/types/store';
import type {UserProfile} from '@mattermost/types/users'; import type {UserProfile} from '@mattermost/types/users';
import {getProfiles, searchProfiles} from 'mattermost-redux/actions/users'; import {getProfiles, searchProfiles} from 'mattermost-redux/actions/users';
import {getProfiles as selectProfiles} from 'mattermost-redux/selectors/entities/users'; import {getProfiles as selectProfiles} from 'mattermost-redux/selectors/entities/users';
import type {GenericAction, ActionFunc} from 'mattermost-redux/types/actions';
import AddUsersToRoleModal from './add_users_to_role_modal'; import AddUsersToRoleModal from './add_users_to_role_modal';
import type {Props} from './add_users_to_role_modal'; import type {Props} from './add_users_to_role_modal';
@@ -24,9 +23,9 @@ function mapStateToProps(state: GlobalState, props: Props) {
}; };
} }
function mapDispatchToProps(dispatch: Dispatch<GenericAction>) { function mapDispatchToProps(dispatch: Dispatch) {
return { return {
actions: bindActionCreators<ActionCreatorsMapObject<ActionFunc>, Props['actions']>({ actions: bindActionCreators({
getProfiles, getProfiles,
searchProfiles, searchProfiles,
}, dispatch), }, dispatch),

Просмотреть файл

@@ -3,15 +3,12 @@
import {connect} from 'react-redux'; import {connect} from 'react-redux';
import {bindActionCreators} from 'redux'; import {bindActionCreators} from 'redux';
import type {Dispatch, ActionCreatorsMapObject} from 'redux'; import type {Dispatch} from 'redux';
import type {Role} from '@mattermost/types/roles';
import {editRole} from 'mattermost-redux/actions/roles'; import {editRole} from 'mattermost-redux/actions/roles';
import {updateUserRoles} from 'mattermost-redux/actions/users'; import {updateUserRoles} from 'mattermost-redux/actions/users';
import {getLicense} from 'mattermost-redux/selectors/entities/general'; import {getLicense} from 'mattermost-redux/selectors/entities/general';
import {getRolesById} from 'mattermost-redux/selectors/entities/roles'; import {getRolesById} from 'mattermost-redux/selectors/entities/roles';
import type {GenericAction, ActionFunc, ActionResult} from 'mattermost-redux/types/actions';
import {setNavigationBlocked} from 'actions/admin_actions.jsx'; import {setNavigationBlocked} from 'actions/admin_actions.jsx';
@@ -27,12 +24,6 @@ type Props = {
}; };
} }
type Actions = {
editRole(role: Role): Promise<ActionResult>;
updateUserRoles(userId: string, roles: string): Promise<ActionResult>;
setNavigationBlocked: (blocked: boolean) => void;
}
function mapStateToProps(state: GlobalState, props: Props) { function mapStateToProps(state: GlobalState, props: Props) {
const role = getRolesById(state)[props.match.params.role_id]; const role = getRolesById(state)[props.match.params.role_id];
const license = getLicense(state); const license = getLicense(state);
@@ -44,9 +35,9 @@ function mapStateToProps(state: GlobalState, props: Props) {
}; };
} }
function mapDispatchToProps(dispatch: Dispatch<GenericAction>) { function mapDispatchToProps(dispatch: Dispatch) {
return { return {
actions: bindActionCreators<ActionCreatorsMapObject<ActionFunc | GenericAction>, Actions>({ actions: bindActionCreators({
editRole, editRole,
updateUserRoles, updateUserRoles,
setNavigationBlocked, setNavigationBlocked,

Просмотреть файл

@@ -3,14 +3,13 @@
import {connect} from 'react-redux'; import {connect} from 'react-redux';
import {bindActionCreators} from 'redux'; import {bindActionCreators} from 'redux';
import type {Dispatch, ActionCreatorsMapObject} from 'redux'; import type {Dispatch} from 'redux';
import type {UserProfile} from '@mattermost/types/users'; import type {UserProfile} from '@mattermost/types/users';
import {getFilteredUsersStats, getProfiles, searchProfiles} from 'mattermost-redux/actions/users'; import {getFilteredUsersStats, getProfiles, searchProfiles} from 'mattermost-redux/actions/users';
import {getRoles} from 'mattermost-redux/selectors/entities/roles_helpers'; import {getRoles} from 'mattermost-redux/selectors/entities/roles_helpers';
import {getProfiles as selectProfiles, getFilteredUsersStats as selectFilteredUserStats, makeSearchProfilesStartingWithTerm, filterProfiles} from 'mattermost-redux/selectors/entities/users'; import {getProfiles as selectProfiles, getFilteredUsersStats as selectFilteredUserStats, makeSearchProfilesStartingWithTerm, filterProfiles} from 'mattermost-redux/selectors/entities/users';
import type {GenericAction, ActionFunc} from 'mattermost-redux/types/actions';
import {filterProfilesStartingWithTerm, profileListToMap} from 'mattermost-redux/utils/user_utils'; import {filterProfilesStartingWithTerm, profileListToMap} from 'mattermost-redux/utils/user_utils';
import {setUserGridSearch} from 'actions/views/search'; import {setUserGridSearch} from 'actions/views/search';
@@ -18,7 +17,6 @@ import {setUserGridSearch} from 'actions/views/search';
import type {GlobalState} from 'types/store'; import type {GlobalState} from 'types/store';
import SystemRoleUsers from './system_role_users'; import SystemRoleUsers from './system_role_users';
import type {Props} from './system_role_users';
type OwnProps = { type OwnProps = {
roleName: string; roleName: string;
@@ -57,9 +55,9 @@ function mapStateToProps(state: GlobalState, props: OwnProps) {
}; };
} }
function mapDispatchToProps(dispatch: Dispatch<GenericAction>) { function mapDispatchToProps(dispatch: Dispatch) {
return { return {
actions: bindActionCreators<ActionCreatorsMapObject<ActionFunc | GenericAction>, Props['actions']>({ actions: bindActionCreators({
getProfiles, getProfiles,
getFilteredUsersStats, getFilteredUsersStats,
searchProfiles, searchProfiles,

Просмотреть файл

@@ -4,10 +4,11 @@
import React from 'react'; import React from 'react';
import {FormattedMessage} from 'react-intl'; import {FormattedMessage} from 'react-intl';
import type {ServerError} from '@mattermost/types/errors';
import type {Role} from '@mattermost/types/roles'; import type {Role} from '@mattermost/types/roles';
import type {UserProfile, UsersStats, GetFilteredUsersStatsOpts} from '@mattermost/types/users'; import type {UserProfile, UsersStats, GetFilteredUsersStatsOpts} from '@mattermost/types/users';
import type {ActionResult} from 'mattermost-redux/types/actions';
import DataGrid from 'components/admin_console/data_grid/data_grid'; import DataGrid from 'components/admin_console/data_grid/data_grid';
import UserGridName from 'components/admin_console/user_grid/user_grid_name'; import UserGridName from 'components/admin_console/user_grid/user_grid_name';
import UserGridRemove from 'components/admin_console/user_grid/user_grid_remove'; import UserGridRemove from 'components/admin_console/user_grid/user_grid_remove';
@@ -30,13 +31,10 @@ export type Props = {
onAddCallback: (users: UserProfile[]) => void; onAddCallback: (users: UserProfile[]) => void;
onRemoveCallback: (user: UserProfile) => void; onRemoveCallback: (user: UserProfile) => void;
actions: { actions: {
getFilteredUsersStats: (filters: GetFilteredUsersStatsOpts) => Promise<{ getFilteredUsersStats: (filters: GetFilteredUsersStatsOpts) => Promise<ActionResult<UsersStats>>;
data?: UsersStats; getProfiles: (page?: number | undefined, perPage?: number | undefined, options?: any) => Promise<ActionResult>;
error?: ServerError; searchProfiles: (term: string, options: any) => Promise<ActionResult>;
}>; setUserGridSearch: (term: string) => void;
getProfiles: (page?: number | undefined, perPage?: number | undefined, options?: any) => Promise<any>;
searchProfiles: (term: string, options: any) => Promise<any>;
setUserGridSearch: (term: string) => Promise<any>;
}; };
readOnly?: boolean; readOnly?: boolean;
} }

Просмотреть файл

@@ -3,17 +3,15 @@
import {connect} from 'react-redux'; import {connect} from 'react-redux';
import {bindActionCreators} from 'redux'; import {bindActionCreators} from 'redux';
import type {ActionCreatorsMapObject, Dispatch} from 'redux'; import type {Dispatch} from 'redux';
import type {ServerError} from '@mattermost/types/errors';
import type {GlobalState} from '@mattermost/types/store'; import type {GlobalState} from '@mattermost/types/store';
import type {TeamMembership} from '@mattermost/types/teams';
import {addUserToTeam} from 'mattermost-redux/actions/teams'; import {addUserToTeam} from 'mattermost-redux/actions/teams';
import {updateUserActive} from 'mattermost-redux/actions/users'; import {updateUserActive} from 'mattermost-redux/actions/users';
import {getConfig} from 'mattermost-redux/selectors/entities/general'; import {getConfig} from 'mattermost-redux/selectors/entities/general';
import {getUser} from 'mattermost-redux/selectors/entities/users'; import {getUser} from 'mattermost-redux/selectors/entities/users';
import type {ActionFunc, GenericAction} from 'mattermost-redux/types/actions'; import type {GenericAction} from 'mattermost-redux/types/actions';
import {setNavigationBlocked} from 'actions/admin_actions.jsx'; import {setNavigationBlocked} from 'actions/admin_actions.jsx';
@@ -33,14 +31,8 @@ function mapStateToProps(state: GlobalState, ownProps: OwnProps) {
}; };
} }
type Actions = {
updateUserActive: (userId: string, active: boolean) => Promise<{error: ServerError}>;
setNavigationBlocked: (blocked: boolean) => void;
addUserToTeam: (teamId: string, userId?: string) => Promise<{data: TeamMembership; error?: any}>;
}
function mapDispatchToProps(dispatch: Dispatch<GenericAction>) { function mapDispatchToProps(dispatch: Dispatch<GenericAction>) {
const apiActions = bindActionCreators<ActionCreatorsMapObject<ActionFunc>, Actions>({ const apiActions = bindActionCreators({
updateUserActive, updateUserActive,
addUserToTeam, addUserToTeam,
}, dispatch); }, dispatch);

Просмотреть файл

@@ -11,6 +11,7 @@ import type {ServerError} from '@mattermost/types/errors';
import type {Team, TeamMembership} from '@mattermost/types/teams'; import type {Team, TeamMembership} from '@mattermost/types/teams';
import type {UserProfile} from '@mattermost/types/users'; import type {UserProfile} from '@mattermost/types/users';
import type {ActionResult} from 'mattermost-redux/types/actions';
import {isEmail} from 'mattermost-redux/utils/helpers'; import {isEmail} from 'mattermost-redux/utils/helpers';
import {adminResetMfa, adminResetEmail} from 'actions/admin_actions.jsx'; import {adminResetMfa, adminResetEmail} from 'actions/admin_actions.jsx';
@@ -42,9 +43,9 @@ export type Props = {
mfaEnabled: boolean; mfaEnabled: boolean;
isDisabled?: boolean; isDisabled?: boolean;
actions: { actions: {
updateUserActive: (userId: string, active: boolean) => Promise<{error: ServerError}>; updateUserActive: (userId: string, active: boolean) => Promise<ActionResult>;
setNavigationBlocked: (blocked: boolean) => void; setNavigationBlocked: (blocked: boolean) => void;
addUserToTeam: (teamId: string, userId?: string) => Promise<{data: TeamMembership; error?: any}>; addUserToTeam: (teamId: string, userId: string) => Promise<unknown>;
}; };
} }

Просмотреть файл

@@ -6,6 +6,8 @@ import {FormattedMessage} from 'react-intl';
import type {Team} from '@mattermost/types/teams'; import type {Team} from '@mattermost/types/teams';
import type {ActionResult} from 'mattermost-redux/types/actions';
import NextIcon from 'components/widgets/icons/fa_next_icon'; import NextIcon from 'components/widgets/icons/fa_next_icon';
import PreviousIcon from 'components/widgets/icons/fa_previous_icon'; import PreviousIcon from 'components/widgets/icons/fa_previous_icon';
@@ -25,7 +27,7 @@ type Props = {
emptyListTextId: string; emptyListTextId: string;
emptyListTextDefaultMessage: string; emptyListTextDefaultMessage: string;
actions: { actions: {
getTeamsData: (userId: string) => Promise<{data: Team[]}>; getTeamsData: (userId: string) => Promise<ActionResult<Team[]>>;
removeGroup?: () => void; removeGroup?: () => void;
}; };
} }

Просмотреть файл

@@ -3,9 +3,7 @@
import {connect} from 'react-redux'; import {connect} from 'react-redux';
import {bindActionCreators} from 'redux'; import {bindActionCreators} from 'redux';
import type {ActionCreatorsMapObject, Dispatch} from 'redux'; import type {Dispatch} from 'redux';
import type {Team, TeamMembership} from '@mattermost/types/teams';
import { import {
getTeamsForUser, getTeamsForUser,
@@ -13,7 +11,7 @@ import {
removeUserFromTeam, removeUserFromTeam,
updateTeamMemberSchemeRoles, updateTeamMemberSchemeRoles,
} from 'mattermost-redux/actions/teams'; } from 'mattermost-redux/actions/teams';
import type {ActionFunc, ActionResult, GenericAction} from 'mattermost-redux/types/actions'; import type {GenericAction} from 'mattermost-redux/types/actions';
import {getCurrentLocale} from 'selectors/i18n'; import {getCurrentLocale} from 'selectors/i18n';
@@ -21,13 +19,6 @@ import type {GlobalState} from 'types/store';
import TeamList from './team_list'; import TeamList from './team_list';
type Actions = {
getTeamsData: (userId: string) => Promise<{data: Team[]}>;
getTeamMembersForUser: (userId: string) => Promise<{data: TeamMembership[]}>;
removeUserFromTeam: (userId: string, teamId: string) => Promise<ActionResult>;
updateTeamMemberSchemeRoles: (userId: string, teamId: string, isSchemeUser: boolean, isSchemeAdmin: boolean) => Promise<ActionResult>;
}
function mapStateToProps(state: GlobalState) { function mapStateToProps(state: GlobalState) {
return { return {
locale: getCurrentLocale(state), locale: getCurrentLocale(state),
@@ -36,7 +27,7 @@ function mapStateToProps(state: GlobalState) {
function mapDispatchToProps(dispatch: Dispatch<GenericAction>) { function mapDispatchToProps(dispatch: Dispatch<GenericAction>) {
return { return {
actions: bindActionCreators<ActionCreatorsMapObject<ActionFunc>, Actions>({ actions: bindActionCreators({
getTeamsData: getTeamsForUser, getTeamsData: getTeamsForUser,
getTeamMembersForUser, getTeamMembersForUser,
removeUserFromTeam, removeUserFromTeam,

Просмотреть файл

@@ -51,8 +51,8 @@ type Props = {
emptyListTextId: string; emptyListTextId: string;
emptyListTextDefaultMessage: string; emptyListTextDefaultMessage: string;
actions: { actions: {
getTeamsData: (userId: string) => Promise<{data: Team[]}>; getTeamsData: (userId: string) => Promise<ActionResult<Team[]>>;
getTeamMembersForUser: (userId: string) => Promise<{data: TeamMembership[]}>; getTeamMembersForUser: (userId: string) => Promise<ActionResult<TeamMembership[]>>;
removeUserFromTeam: (teamId: string, userId: string) => Promise<ActionResult>; removeUserFromTeam: (teamId: string, userId: string) => Promise<ActionResult>;
updateTeamMemberSchemeRoles: (teamId: string, userId: string, isSchemeUser: boolean, isSchemeAdmin: boolean) => Promise<ActionResult>; updateTeamMemberSchemeRoles: (teamId: string, userId: string, isSchemeUser: boolean, isSchemeAdmin: boolean) => Promise<ActionResult>;
}; };
@@ -103,11 +103,11 @@ export default class TeamList extends React.PureComponent<Props, State> {
}; };
// check this out // check this out
private mergeTeamsWithMemberships = (data: [{data: Team[]}, {data: TeamMembership[]}]): TeamWithMembership[] => { private mergeTeamsWithMemberships = (data: [ActionResult<Team[]>, ActionResult<TeamMembership[]>]): TeamWithMembership[] => {
const teams = data[0].data; const teams = data[0].data;
const memberships = data[1].data; const memberships = data[1].data;
let teamsWithMemberships = teams.map((object: Team) => { let teamsWithMemberships = teams!.map((object: Team) => {
const results = memberships.filter((team: TeamMembership) => team.team_id === object.id); const results = memberships!.filter((team: TeamMembership) => team.team_id === object.id);
const team = {...object, ...results[0]}; const team = {...object, ...results[0]};
return team; return team;
}); });

Просмотреть файл

@@ -3,11 +3,7 @@
import {connect} from 'react-redux'; import {connect} from 'react-redux';
import {bindActionCreators} from 'redux'; import {bindActionCreators} from 'redux';
import type {ActionCreatorsMapObject, Dispatch} from 'redux'; import type {Dispatch} from 'redux';
import type {StatusOK} from '@mattermost/types/client4';
import type {ServerError} from '@mattermost/types/errors';
import type {GetFilteredUsersStatsOpts, UsersStats} from '@mattermost/types/users';
import {logError} from 'mattermost-redux/actions/errors'; import {logError} from 'mattermost-redux/actions/errors';
import {getTeams, getTeamStats} from 'mattermost-redux/actions/teams'; import {getTeams, getTeamStats} from 'mattermost-redux/actions/teams';
@@ -21,7 +17,6 @@ import {
import {getConfig} from 'mattermost-redux/selectors/entities/general'; import {getConfig} from 'mattermost-redux/selectors/entities/general';
import {getTeamsList} from 'mattermost-redux/selectors/entities/teams'; import {getTeamsList} from 'mattermost-redux/selectors/entities/teams';
import {getFilteredUsersStats as selectFilteredUserStats, getUsers} from 'mattermost-redux/selectors/entities/users'; import {getFilteredUsersStats as selectFilteredUserStats, getUsers} from 'mattermost-redux/selectors/entities/users';
import type {Action, ActionFunc, GenericAction} from 'mattermost-redux/types/actions';
import {loadProfilesAndTeamMembers, loadProfilesWithoutTeam} from 'actions/user_actions'; import {loadProfilesAndTeamMembers, loadProfilesWithoutTeam} from 'actions/user_actions';
import {setSystemUsersSearch} from 'actions/views/search'; import {setSystemUsersSearch} from 'actions/views/search';
@@ -74,28 +69,9 @@ function mapStateToProps(state: GlobalState) {
}; };
} }
type StatusOKFunc = () => Promise<StatusOK>; function mapDispatchToProps(dispatch: Dispatch) {
type PromiseStatusFunc = () => Promise<{status: string}>;
type ActionCreatorTypes = Action | PromiseStatusFunc | StatusOKFunc;
type Actions = {
getTeams: (startInde: number, endIndex: number) => void;
getTeamStats: (teamId: string) => ActionFunc<any, any>;
getUser: (id: string) => ActionFunc<any, any>;
getUserAccessToken: (tokenId: string) => Promise<any> | ActionFunc;
loadProfilesAndTeamMembers: (page: number, maxItemsPerPage: number, teamId: string, options: Record<string, string | boolean>) => void;
loadProfilesWithoutTeam: (page: number, maxItemsPerPage: number, options: Record<string, string | boolean>) => void;
getProfiles: (page: number, maxItemsPerPage: number, options: Record<string, string | boolean>) => void;
setSystemUsersSearch: (searchTerm: string, teamId: string, filter: string) => void;
searchProfiles: (term: string, options?: any) => Promise<any> | ActionFunc;
revokeSessionsForAllUsers: () => any;
logError: (error: {type: string; message: string}) => void;
getFilteredUsersStats: (filters: GetFilteredUsersStatsOpts) => Promise<{ data?: UsersStats | undefined; error?: ServerError | undefined}>;
}
function mapDispatchToProps(dispatch: Dispatch<GenericAction>) {
return { return {
actions: bindActionCreators<ActionCreatorsMapObject<ActionCreatorTypes>, Actions>({ actions: bindActionCreators({
getTeams, getTeams,
getTeamStats, getTeamStats,
getUser, getUser,

Просмотреть файл

@@ -7,10 +7,10 @@ import {FormattedMessage} from 'react-intl';
import type {ServerError} from '@mattermost/types/errors'; import type {ServerError} from '@mattermost/types/errors';
import type {Team} from '@mattermost/types/teams'; import type {Team} from '@mattermost/types/teams';
import type {GetFilteredUsersStatsOpts, UserProfile, UsersStats} from '@mattermost/types/users'; import type {GetFilteredUsersStatsOpts, UserAccessToken, UserProfile, UsersStats} from '@mattermost/types/users';
import {debounce} from 'mattermost-redux/actions/helpers'; import {debounce} from 'mattermost-redux/actions/helpers';
import type {ActionFunc} from 'mattermost-redux/types/actions'; import type {ActionResult} from 'mattermost-redux/types/actions';
import AdminHeader from 'components/widgets/admin_console/admin_header'; import AdminHeader from 'components/widgets/admin_console/admin_header';
@@ -68,22 +68,22 @@ type Props = {
/** /**
* Function to get statistics for a team * Function to get statistics for a team
*/ */
getTeamStats: (teamId: string) => ActionFunc; getTeamStats: (teamId: string) => Promise<ActionResult>;
/** /**
* Function to get a user * Function to get a user
*/ */
getUser: (id: string) => ActionFunc; getUser: (id: string) => Promise<ActionResult>;
/** /**
* Function to get a user access token * Function to get a user access token
*/ */
getUserAccessToken: (tokenId: string) => Promise<any> | ActionFunc; getUserAccessToken: (tokenId: string) => Promise<ActionResult<UserAccessToken>>;
loadProfilesAndTeamMembers: (page: number, maxItemsPerPage: number, teamId: string, options: Record<string, string | boolean>) => void; loadProfilesAndTeamMembers: (page: number, maxItemsPerPage: number, teamId: string, options: Record<string, string | boolean>) => void;
loadProfilesWithoutTeam: (page: number, maxItemsPerPage: number, options: Record<string, string | boolean>) => void; loadProfilesWithoutTeam: (page: number, maxItemsPerPage: number, options: Record<string, string | boolean>) => void;
getProfiles: (page: number, maxItemsPerPage: number, options: Record<string, string | boolean>) => void; getProfiles: (page: number, maxItemsPerPage: number, options: Record<string, string | boolean>) => void;
setSystemUsersSearch: (searchTerm: string, teamId: string, filter: string) => void; setSystemUsersSearch: (searchTerm: string, teamId: string, filter: string) => void;
searchProfiles: (term: string, options?: any) => Promise<any> | ActionFunc; searchProfiles: (term: string, options?: any) => Promise<ActionResult<UserProfile[]>>;
/** /**
* Function to log errors * Function to log errors
@@ -213,7 +213,7 @@ export class SystemUsers extends React.PureComponent<Props, State> {
}; };
const {data: profiles} = await this.props.actions.searchProfiles(term, options); const {data: profiles} = await this.props.actions.searchProfiles(term, options);
if (profiles.length === 0 && term.length === USER_ID_LENGTH) { if (profiles!.length === 0 && term.length === USER_ID_LENGTH) {
await this.getUserByTokenOrId(term); await this.getUserByTokenOrId(term);
} }
@@ -267,7 +267,7 @@ export class SystemUsers extends React.PureComponent<Props, State> {
}; };
const {data: profiles} = await this.props.actions.searchProfiles(term, options); const {data: profiles} = await this.props.actions.searchProfiles(term, options);
if (profiles.length === 0 && term.length === USER_ID_LENGTH) { if (profiles!.length === 0 && term.length === USER_ID_LENGTH) {
await this.getUserByTokenOrId(term); await this.getUserByTokenOrId(term);
} }

Просмотреть файл

@@ -3,7 +3,7 @@
import {connect} from 'react-redux'; import {connect} from 'react-redux';
import {bindActionCreators} from 'redux'; import {bindActionCreators} from 'redux';
import type {Dispatch, ActionCreatorsMapObject} from 'redux'; import type {Dispatch} from 'redux';
import {loadBots} from 'mattermost-redux/actions/bots'; import {loadBots} from 'mattermost-redux/actions/bots';
import {createGroupTeamsAndChannels} from 'mattermost-redux/actions/groups'; import {createGroupTeamsAndChannels} from 'mattermost-redux/actions/groups';
@@ -12,12 +12,10 @@ import * as Selectors from 'mattermost-redux/selectors/entities/admin';
import {getExternalBotAccounts} from 'mattermost-redux/selectors/entities/bots'; import {getExternalBotAccounts} from 'mattermost-redux/selectors/entities/bots';
import {getLicense} from 'mattermost-redux/selectors/entities/general'; import {getLicense} from 'mattermost-redux/selectors/entities/general';
import {getCurrentUser} from 'mattermost-redux/selectors/entities/users'; import {getCurrentUser} from 'mattermost-redux/selectors/entities/users';
import type {ActionFunc} from 'mattermost-redux/types/actions';
import type {GlobalState} from 'types/store'; import type {GlobalState} from 'types/store';
import SystemUsersDropdown from './system_users_dropdown'; import SystemUsersDropdown from './system_users_dropdown';
import type {Props} from './system_users_dropdown';
function mapStateToProps(state: GlobalState) { function mapStateToProps(state: GlobalState) {
const bots = getExternalBotAccounts(state); const bots = getExternalBotAccounts(state);
@@ -32,7 +30,7 @@ function mapStateToProps(state: GlobalState) {
function mapDispatchToProps(dispatch: Dispatch) { function mapDispatchToProps(dispatch: Dispatch) {
return { return {
actions: bindActionCreators<ActionCreatorsMapObject<ActionFunc>, Props['actions']>({ actions: bindActionCreators({
updateUserActive, updateUserActive,
revokeAllSessionsForUser, revokeAllSessionsForUser,
promoteGuestToUser, promoteGuestToUser,

Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше