Improve Redux types part 1 (#25872)
* 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.
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
0a4e9eeb92
Коммит
978f335925
@@ -15,7 +15,6 @@ import store from 'stores/redux_store';
|
||||
import {ActionTypes} from 'utils/constants';
|
||||
|
||||
const dispatch = store.dispatch;
|
||||
const getState = store.getState;
|
||||
|
||||
export async function reloadConfig(success, error) {
|
||||
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) {
|
||||
const {data, error: err} = await UserActions.updateUserMfa(userId, false)(dispatch, getState);
|
||||
const {data, error: err} = await dispatch(UserActions.updateUserMfa(userId, false));
|
||||
if (data && success) {
|
||||
success(data);
|
||||
} else if (err && error) {
|
||||
@@ -38,7 +37,7 @@ export async function adminResetMfa(userId, 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) {
|
||||
success(data);
|
||||
} else if (err && error) {
|
||||
@@ -47,7 +46,7 @@ export async function getClusterStatus(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) {
|
||||
success(data);
|
||||
} else if (err && error) {
|
||||
@@ -56,7 +55,7 @@ export async function ldapTest(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) {
|
||||
success(data);
|
||||
} else if (err && error) {
|
||||
@@ -65,7 +64,7 @@ export async function invalidateAllCaches(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) {
|
||||
success(data);
|
||||
} else if (err && error) {
|
||||
@@ -74,7 +73,7 @@ export async function recycleDatabaseConnection(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) {
|
||||
success(data);
|
||||
} else if (err && error) {
|
||||
@@ -83,7 +82,7 @@ export async function adminResetEmail(user, 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) {
|
||||
success(data);
|
||||
} else if (err && error) {
|
||||
@@ -92,7 +91,7 @@ export async function samlCertificateStatus(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) {
|
||||
success(data);
|
||||
} else if (err && error) {
|
||||
@@ -101,7 +100,7 @@ export async function getIPFilters(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) {
|
||||
success(data);
|
||||
} else if (err && error) {
|
||||
@@ -110,7 +109,7 @@ export async function getCurrentIP(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) {
|
||||
success(data);
|
||||
} 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) {
|
||||
return bindClientFunc({
|
||||
clientFunc: Client4.getOAuthAppInfo,
|
||||
@@ -125,6 +128,10 @@ export function getOAuthAppInfo(clientId) {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {*}
|
||||
* @returns {ActionResult<{redirect: string}>}
|
||||
*/
|
||||
export function allowOAuth2({responseType, clientId, redirectUri, state, scope}) {
|
||||
return bindClientFunc({
|
||||
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) {
|
||||
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) {
|
||||
success(data);
|
||||
} 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) {
|
||||
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) {
|
||||
success(data);
|
||||
} 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) {
|
||||
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.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) {
|
||||
const {data, error: err} = await AdminActions.uploadBrandImage(brandImage)(dispatch, getState);
|
||||
const {data, error: err} = await dispatch(AdminActions.uploadBrandImage(brandImage));
|
||||
if (data && success) {
|
||||
success(data);
|
||||
} else if (err && error) {
|
||||
@@ -174,7 +181,7 @@ export async function uploadBrandImage(brandImage, 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) {
|
||||
success(data);
|
||||
} else if (err && error) {
|
||||
@@ -183,7 +190,7 @@ export async function deleteBrandImage(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) {
|
||||
success('saml-public.crt');
|
||||
} else if (err && error) {
|
||||
@@ -192,7 +199,7 @@ export async function uploadPublicSamlCertificate(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) {
|
||||
success('saml-private.key');
|
||||
} else if (err && error) {
|
||||
@@ -201,7 +208,7 @@ export async function uploadPrivateSamlCertificate(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) {
|
||||
success('ldap-public.crt');
|
||||
} else if (err && error) {
|
||||
@@ -209,7 +216,7 @@ export async function uploadPublicLdapCertificate(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) {
|
||||
success('ldap-private.key');
|
||||
} else if (err && error) {
|
||||
@@ -218,7 +225,7 @@ export async function uploadPrivateLdapCertificate(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) {
|
||||
success('saml-idp.crt');
|
||||
} else if (err && error) {
|
||||
@@ -227,7 +234,7 @@ export async function uploadIdpSamlCertificate(file, 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) {
|
||||
success(data);
|
||||
} else if (err && error) {
|
||||
@@ -236,7 +243,7 @@ export async function removePublicSamlCertificate(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) {
|
||||
success(data);
|
||||
} else if (err && error) {
|
||||
@@ -245,7 +252,7 @@ export async function removePrivateSamlCertificate(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) {
|
||||
success(data);
|
||||
} else if (err && error) {
|
||||
@@ -254,7 +261,7 @@ export async function removePublicLdapCertificate(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) {
|
||||
success(data);
|
||||
} else if (err && error) {
|
||||
@@ -263,7 +270,7 @@ export async function removePrivateLdapCertificate(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) {
|
||||
success(data);
|
||||
} else if (err && error) {
|
||||
@@ -272,27 +279,27 @@ export async function removeIdpSamlCertificate(success, error) {
|
||||
}
|
||||
|
||||
export async function getStandardAnalytics(teamId) {
|
||||
await AdminActions.getStandardAnalytics(teamId)(dispatch, getState);
|
||||
await dispatch(AdminActions.getStandardAnalytics(teamId));
|
||||
}
|
||||
|
||||
export async function getAdvancedAnalytics(teamId) {
|
||||
await AdminActions.getAdvancedAnalytics(teamId)(dispatch, getState);
|
||||
await dispatch(AdminActions.getAdvancedAnalytics(teamId));
|
||||
}
|
||||
|
||||
export async function getBotPostsPerDayAnalytics(teamId) {
|
||||
await AdminActions.getBotPostsPerDayAnalytics(teamId)(dispatch, getState);
|
||||
await dispatch(AdminActions.getBotPostsPerDayAnalytics(teamId));
|
||||
}
|
||||
|
||||
export async function getPostsPerDayAnalytics(teamId) {
|
||||
await AdminActions.getPostsPerDayAnalytics(teamId)(dispatch, getState);
|
||||
await dispatch(AdminActions.getPostsPerDayAnalytics(teamId));
|
||||
}
|
||||
|
||||
export async function getUsersPerDayAnalytics(teamId) {
|
||||
await AdminActions.getUsersPerDayAnalytics(teamId)(dispatch, getState);
|
||||
await dispatch(AdminActions.getUsersPerDayAnalytics(teamId));
|
||||
}
|
||||
|
||||
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) {
|
||||
success(data);
|
||||
} else if (err && error) {
|
||||
@@ -301,7 +308,7 @@ export async function elasticsearchTest(config, 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) {
|
||||
success(data);
|
||||
} else if (err && error) {
|
||||
@@ -310,7 +317,7 @@ export async function testS3Connection(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) {
|
||||
success(data);
|
||||
} else if (err && error) {
|
||||
@@ -441,7 +448,7 @@ export async function getSamlMetadataFromIdp(success, error, samlMetadataURL) {
|
||||
}
|
||||
|
||||
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) {
|
||||
success('saml-idp.crt');
|
||||
} else if (err && error) {
|
||||
|
||||
@@ -1,13 +1,16 @@
|
||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||
// 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 {CommandArgs} from '@mattermost/types/integrations';
|
||||
import type {Post} from '@mattermost/types/posts';
|
||||
|
||||
import {Client4} from 'mattermost-redux/client';
|
||||
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 {openModal} from 'actions/views/modals';
|
||||
@@ -19,10 +22,15 @@ import {getHistory} from 'utils/browser_history';
|
||||
import {ModalIdentifiers} from 'utils/constants';
|
||||
import {getSiteURL, shouldOpenInNewTab} from 'utils/url';
|
||||
|
||||
import type {DoAppCallResult} from 'types/apps';
|
||||
import type {GlobalState} from 'types/store';
|
||||
|
||||
import {sendEphemeralPost} from './global_actions';
|
||||
|
||||
export function handleBindingClick<Res=unknown>(binding: AppBinding, context: AppContext, intl: any): ActionFunc {
|
||||
return async (dispatch: DispatchFunc) => {
|
||||
export type AppsActionFunc<Res = unknown> = ThunkAction<Promise<Res>, GlobalState, unknown, ReduxAction>;
|
||||
|
||||
export function handleBindingClick<Res=unknown>(binding: AppBinding, context: AppContext, intl: any): AppsActionFunc<DoAppCallResult<Res>> {
|
||||
return async (dispatch) => {
|
||||
// Fetch form
|
||||
let form = binding.form;
|
||||
if (form?.source) {
|
||||
@@ -31,7 +39,7 @@ export function handleBindingClick<Res=unknown>(binding: AppBinding, context: Ap
|
||||
if (res.error) {
|
||||
return res;
|
||||
}
|
||||
form = res.data.form;
|
||||
form = res.data!.form;
|
||||
}
|
||||
|
||||
// Open form
|
||||
@@ -45,7 +53,7 @@ export function handleBindingClick<Res=unknown>(binding: AppBinding, context: Ap
|
||||
return {error: makeCallErrorResponse(errMsg)};
|
||||
}
|
||||
|
||||
const res: AppCallResponse = {
|
||||
const res: AppCallResponse<Res> = {
|
||||
type: AppCallResponseTypes.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 () => {
|
||||
try {
|
||||
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 () => {
|
||||
try {
|
||||
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 () => {
|
||||
try {
|
||||
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 {
|
||||
return (channelId: string, teamId: string): ActionFunc => {
|
||||
export function makeFetchBindings(location: string): (channelId: string, teamId: string) => NewActionFuncAsync<AppBinding[]> {
|
||||
return (channelId: string, teamId: string): NewActionFuncAsync<AppBinding[]> => {
|
||||
return async () => {
|
||||
try {
|
||||
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({
|
||||
modalId: ModalIdentifiers.APPS_MODAL,
|
||||
dialogType: AppsForm,
|
||||
|
||||
@@ -14,7 +14,7 @@ import {getChannelByName, getUnreadChannelIds, getChannel} from 'mattermost-redu
|
||||
import {getMyChannelMemberships} from 'mattermost-redux/selectors/entities/common';
|
||||
import {getCurrentTeamUrl, getCurrentTeamId} from 'mattermost-redux/selectors/entities/teams';
|
||||
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 {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 {getDirectChannelName} from 'utils/utils';
|
||||
|
||||
export function openDirectChannelToUserId(userId: UserProfile['id']): ActionFunc {
|
||||
export function openDirectChannelToUserId(userId: UserProfile['id']): NewActionFuncAsync<Channel> {
|
||||
return async (dispatch, getState) => {
|
||||
const state = getState();
|
||||
const currentUserId = getCurrentUserId(state);
|
||||
@@ -31,7 +31,7 @@ export function openDirectChannelToUserId(userId: UserProfile['id']): ActionFunc
|
||||
const channel = getChannelByName(state, channelName);
|
||||
|
||||
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');
|
||||
@@ -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) => {
|
||||
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) => {
|
||||
const state = getState();
|
||||
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) => {
|
||||
const state = getState();
|
||||
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) => {
|
||||
try {
|
||||
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) {
|
||||
return {error};
|
||||
}
|
||||
|
||||
@@ -272,7 +272,7 @@ export function retryFailedCloudFetches() {
|
||||
}
|
||||
|
||||
if (errors.limits) {
|
||||
getCloudLimits()(dispatch, getState);
|
||||
dispatch(getCloudLimits());
|
||||
}
|
||||
|
||||
return {data: true};
|
||||
|
||||
@@ -15,7 +15,7 @@ import {isMarketplaceEnabled} from 'mattermost-redux/selectors/entities/general'
|
||||
import {haveICurrentTeamPermission} from 'mattermost-redux/selectors/entities/roles';
|
||||
import {getCurrentRelativeTeamUrl, getCurrentTeamId} from 'mattermost-redux/selectors/entities/teams';
|
||||
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 PostActions from 'actions/post_actions';
|
||||
@@ -34,14 +34,13 @@ import {isUrlSafe, getSiteURL} from 'utils/url';
|
||||
import * as UserAgent from 'utils/user_agent';
|
||||
import {localizeMessage, getUserIdFromChannelName} from 'utils/utils';
|
||||
|
||||
import type {DoAppCallResult} from 'types/apps';
|
||||
import type {GlobalState} from 'types/store';
|
||||
|
||||
import {doAppSubmit, openAppsModal, postEphemeralCallResponseForCommandArgs} from './apps';
|
||||
import {trackEvent} from './telemetry_actions';
|
||||
|
||||
export function executeCommand(message: string, args: CommandArgs): ActionFunc {
|
||||
return async (dispatch: DispatchFunc, getState: GetStateFunc) => {
|
||||
export function executeCommand(message: string, args: CommandArgs): NewActionFuncAsync<boolean, GlobalState> {
|
||||
return async (dispatch, getState) => {
|
||||
const state = getState() as GlobalState;
|
||||
|
||||
let msg = message;
|
||||
@@ -155,7 +154,7 @@ export function executeCommand(message: string, args: CommandArgs): ActionFunc {
|
||||
return createErrorMessage(errorMessage!);
|
||||
}
|
||||
|
||||
const res = await dispatch(doAppSubmit(creq, intlShim)) as DoAppCallResult;
|
||||
const res = await dispatch(doAppSubmit(creq, intlShim));
|
||||
|
||||
if (res.error) {
|
||||
const errorResponse = res.error;
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
/**
|
||||
* @param {Post} originalPost
|
||||
* @returns {NewActionFuncAsync<Post>}
|
||||
*/
|
||||
export function runMessageWillBePostedHooks(originalPost) {
|
||||
return async (dispatch, getState) => {
|
||||
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 {appsEnabled} from 'mattermost-redux/selectors/entities/apps';
|
||||
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;
|
||||
|
||||
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) => {
|
||||
const {data} = await dispatch(IntegrationActions.getIncomingHooks(teamId, page, perPage));
|
||||
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) => {
|
||||
const {data} = await dispatch(IntegrationActions.getOutgoingHooks('', teamId, page, perPage));
|
||||
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) => {
|
||||
if (appsEnabled(getState())) {
|
||||
dispatch(IntegrationActions.getAppsOAuthAppIDs());
|
||||
|
||||
@@ -4,8 +4,6 @@
|
||||
import type {Channel} from '@mattermost/types/channels';
|
||||
import type {UserProfile} from '@mattermost/types/users';
|
||||
|
||||
import type {DispatchFunc, GetStateFunc} from 'mattermost-redux/types/actions';
|
||||
|
||||
import {sendMembersInvites, sendGuestsInvites} from 'actions/invite_actions';
|
||||
|
||||
import mockStore from 'tests/test_store';
|
||||
@@ -124,7 +122,7 @@ describe('actions/invite_actions', () => {
|
||||
|
||||
describe('sendMembersInvites', () => {
|
||||
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({
|
||||
data: {
|
||||
sent: [],
|
||||
@@ -135,7 +133,7 @@ describe('actions/invite_actions', () => {
|
||||
|
||||
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 response = await sendMembersInvites('correct', [], emails)(store.dispatch as DispatchFunc, store.getState as GetStateFunc);
|
||||
const response = await store.dispatch(sendMembersInvites('correct', [], emails));
|
||||
expect(response).toEqual({
|
||||
data: {
|
||||
notSent: [],
|
||||
@@ -159,7 +157,7 @@ describe('actions/invite_actions', () => {
|
||||
|
||||
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 response = await sendMembersInvites('error', [], emails)(store.dispatch as DispatchFunc, store.getState as GetStateFunc);
|
||||
const response = await store.dispatch(sendMembersInvites('error', [], emails));
|
||||
expect(response).toEqual({
|
||||
data: {
|
||||
sent: [],
|
||||
@@ -188,7 +186,7 @@ describe('actions/invite_actions', () => {
|
||||
{id: 'other-user', roles: 'system_user'},
|
||||
{id: 'other-guest', roles: 'system_guest'},
|
||||
] 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({
|
||||
data: {
|
||||
sent: [
|
||||
@@ -234,7 +232,7 @@ describe('actions/invite_actions', () => {
|
||||
{id: 'other-user', roles: 'system_user'},
|
||||
{id: 'other-guest', roles: 'system_guest'},
|
||||
] 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({
|
||||
data: {
|
||||
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.',
|
||||
});
|
||||
}
|
||||
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({
|
||||
data: {
|
||||
notSent: expectedNotSent,
|
||||
@@ -286,7 +284,7 @@ describe('actions/invite_actions', () => {
|
||||
|
||||
it('should generate a failure for smtp config', async () => {
|
||||
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({
|
||||
data: {
|
||||
notSent: [
|
||||
@@ -306,7 +304,7 @@ describe('actions/invite_actions', () => {
|
||||
|
||||
describe('sendGuestsInvites', () => {
|
||||
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({
|
||||
data: {
|
||||
sent: [],
|
||||
@@ -318,7 +316,7 @@ describe('actions/invite_actions', () => {
|
||||
it('should generate list of success for emails', async () => {
|
||||
const channels = [{id: 'correct'}] as Channel[];
|
||||
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({
|
||||
data: {
|
||||
notSent: [],
|
||||
@@ -343,7 +341,7 @@ describe('actions/invite_actions', () => {
|
||||
it('should generate list of failures for emails on invite fails', async () => {
|
||||
const channels = [{id: 'correct'}] as Channel[];
|
||||
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({
|
||||
data: {
|
||||
sent: [],
|
||||
@@ -373,7 +371,7 @@ describe('actions/invite_actions', () => {
|
||||
{id: 'other-user', roles: 'system_user'},
|
||||
{id: 'other-guest', roles: 'system_guest'},
|
||||
] 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({
|
||||
data: {
|
||||
sent: [
|
||||
@@ -425,7 +423,7 @@ describe('actions/invite_actions', () => {
|
||||
{id: 'guest2', roles: 'system_guest'},
|
||||
{id: 'guest3', roles: 'system_guest'},
|
||||
] 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({
|
||||
data: {
|
||||
sent: [],
|
||||
@@ -456,7 +454,7 @@ describe('actions/invite_actions', () => {
|
||||
{id: 'other-user', roles: 'system_user'},
|
||||
{id: 'other-guest', roles: 'system_guest'},
|
||||
] 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({
|
||||
data: {
|
||||
@@ -515,7 +513,7 @@ describe('actions/invite_actions', () => {
|
||||
{id: 'other-user', roles: 'system_user'},
|
||||
{id: 'other-guest', roles: 'system_guest'},
|
||||
] 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({
|
||||
data: {
|
||||
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({
|
||||
data: {
|
||||
notSent: expectedNotSent,
|
||||
@@ -575,7 +573,7 @@ describe('actions/invite_actions', () => {
|
||||
|
||||
it('should generate a failure for smtp config', async () => {
|
||||
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({
|
||||
data: {
|
||||
notSent: [
|
||||
|
||||
@@ -11,17 +11,19 @@ import * as TeamActions from 'mattermost-redux/actions/teams';
|
||||
import {getChannelMembersInChannels} from 'mattermost-redux/selectors/entities/channels';
|
||||
import {getTeamMember} from 'mattermost-redux/selectors/entities/teams';
|
||||
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 {addUsersToTeam} from 'actions/team_actions';
|
||||
|
||||
import type {InviteResults} from 'components/invitation_modal/result_view';
|
||||
|
||||
import {ConsolePages} from 'utils/constants';
|
||||
import {t} from 'utils/i18n';
|
||||
import {localizeMessage} from 'utils/utils';
|
||||
|
||||
export function sendMembersInvites(teamId: string, users: UserProfile[], emails: string[]): ActionFunc {
|
||||
return async (dispatch: DispatchFunc, getState: GetStateFunc) => {
|
||||
export function sendMembersInvites(teamId: string, users: UserProfile[], emails: string[]): NewActionFuncAsync<InviteResults> {
|
||||
return async (dispatch, getState) => {
|
||||
if (users.length > 0) {
|
||||
await dispatch(TeamActions.getTeamMembersByIds(teamId, users.map((u) => u.id)));
|
||||
}
|
||||
@@ -62,7 +64,12 @@ export function sendMembersInvites(teamId: string, users: UserProfile[], emails:
|
||||
try {
|
||||
response = await dispatch(TeamActions.sendEmailInvitesToTeamGracefully(teamId, emails));
|
||||
} 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 || [];
|
||||
if (response.error) {
|
||||
@@ -151,8 +158,8 @@ export function sendGuestsInvites(
|
||||
users: UserProfile[],
|
||||
emails: string[],
|
||||
message: string,
|
||||
): ActionFunc {
|
||||
return async (dispatch: DispatchFunc, getState: GetStateFunc) => {
|
||||
): NewActionFuncAsync<InviteResults> {
|
||||
return async (dispatch, getState) => {
|
||||
const state = getState();
|
||||
const sent = [];
|
||||
const notSent = [];
|
||||
@@ -173,7 +180,12 @@ export function sendGuestsInvites(
|
||||
try {
|
||||
response = await dispatch(TeamActions.sendEmailGuestInvitesToChannelsGracefully(teamId, channels.map((x) => x.id), emails, message));
|
||||
} 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) {
|
||||
@@ -214,8 +226,8 @@ export function sendMembersInvitesToChannels(
|
||||
users: UserProfile[],
|
||||
emails: string[],
|
||||
message: string,
|
||||
): ActionFunc {
|
||||
return async (dispatch: DispatchFunc, getState: GetStateFunc) => {
|
||||
): NewActionFuncAsync<InviteResults> {
|
||||
return async (dispatch, getState) => {
|
||||
if (users.length > 0) {
|
||||
// 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.
|
||||
@@ -265,7 +277,12 @@ export function sendMembersInvitesToChannels(
|
||||
),
|
||||
);
|
||||
} 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 || [];
|
||||
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 {getCurrentTeamId} from 'mattermost-redux/selectors/entities/teams';
|
||||
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 {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) {
|
||||
return (dispatch: DispatchFunc, getState: GetStateFunc) => {
|
||||
export function submitReaction(postId: string, action: string, emojiName: string): NewActionFuncOldVariantDoNotUse {
|
||||
return (dispatch, getState) => {
|
||||
const state = getState() as GlobalState;
|
||||
const getIsReactionAlreadyAddedToPost = makeGetIsReactionAlreadyAddedToPost();
|
||||
|
||||
@@ -162,8 +162,8 @@ export function submitReaction(postId: string, action: string, emojiName: string
|
||||
};
|
||||
}
|
||||
|
||||
export function toggleReaction(postId: string, emojiName: string) {
|
||||
return (dispatch: DispatchFunc, getState: GetStateFunc) => {
|
||||
export function toggleReaction(postId: string, emojiName: string): NewActionFuncOldVariantDoNotUse {
|
||||
return (dispatch, getState) => {
|
||||
const state = getState() as GlobalState;
|
||||
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();
|
||||
return (dispatch: DispatchFunc, getState: GetStateFunc) => {
|
||||
return (dispatch, getState) => {
|
||||
const state = getState() as GlobalState;
|
||||
const config = getConfig(state);
|
||||
const uniqueEmojiNames = getUniqueEmojiNameReactionsForPost(state, postId) ?? [];
|
||||
@@ -277,8 +277,8 @@ export function unpinPost(postId: string) {
|
||||
};
|
||||
}
|
||||
|
||||
export function setEditingPost(postId = '', refocusId = '', title = '', isRHS = false) {
|
||||
return async (dispatch: DispatchFunc, getState: GetStateFunc) => {
|
||||
export function setEditingPost(postId = '', refocusId = '', title = '', isRHS = false): NewActionFunc<boolean> {
|
||||
return (dispatch, getState) => {
|
||||
const state = getState();
|
||||
const post = PostSelectors.getPost(state, postId);
|
||||
|
||||
@@ -316,8 +316,8 @@ export function unsetEditingPost() {
|
||||
};
|
||||
}
|
||||
|
||||
export function markPostAsUnread(post: Post, location: string) {
|
||||
return async (dispatch: DispatchFunc, getState: GetStateFunc) => {
|
||||
export function markPostAsUnread(post: Post, location?: string): NewActionFuncAsync {
|
||||
return async (dispatch, getState) => {
|
||||
const state = getState();
|
||||
const userId = getCurrentUserId(state);
|
||||
const currentTeamId = getCurrentTeamId(state);
|
||||
@@ -355,8 +355,8 @@ export function markMostRecentPostInChannelAsUnread(channelId: string) {
|
||||
}
|
||||
|
||||
// Action called by DeletePostModal when the post is deleted
|
||||
export function deleteAndRemovePost(post: Post) {
|
||||
return async (dispatch: DispatchFunc, getState: GetStateFunc) => {
|
||||
export function deleteAndRemovePost(post: Post): NewActionFuncAsync<boolean> {
|
||||
return async (dispatch, getState) => {
|
||||
const {error} = await dispatch(PostActions.deletePost(post));
|
||||
if (error) {
|
||||
return {error};
|
||||
@@ -425,7 +425,7 @@ export function resetInlineImageVisibility() {
|
||||
*
|
||||
* @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 {
|
||||
type: ActionTypes.EMITTED_SHORTCUT_REACT_TO_LAST_POST,
|
||||
payload: emittedFrom,
|
||||
|
||||
@@ -8,7 +8,7 @@ import {getCurrentChannelId} from 'mattermost-redux/selectors/entities/channels'
|
||||
import {getPostsInCurrentChannel} from 'mattermost-redux/selectors/entities/posts';
|
||||
import {getDirectShowPreferences} from 'mattermost-redux/selectors/entities/preferences';
|
||||
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';
|
||||
|
||||
@@ -49,8 +49,8 @@ export function loadStatusesForChannelAndSidebar(): ActionFunc {
|
||||
};
|
||||
}
|
||||
|
||||
export function loadStatusesForProfilesList(users: UserProfile[] | null) {
|
||||
return (dispatch: DispatchFunc) => {
|
||||
export function loadStatusesForProfilesList(users: UserProfile[] | null): NewActionFunc<boolean> {
|
||||
return (dispatch) => {
|
||||
if (users == null) {
|
||||
return {data: false};
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
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 {TeamTypes} from 'mattermost-redux/action_types';
|
||||
@@ -15,12 +15,12 @@ import {getUser} from 'mattermost-redux/actions/users';
|
||||
import {Client4} from 'mattermost-redux/client';
|
||||
import {getCurrentChannelId} from 'mattermost-redux/selectors/entities/channels';
|
||||
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 {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) => {
|
||||
const response = await dispatch(TeamActions.removeUserFromTeam(teamId, 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) => {
|
||||
const {data: member, error} = await dispatch(TeamActions.addUserToTeamFromInvite(token, inviteId));
|
||||
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) => {
|
||||
const {data: member, error} = await dispatch(TeamActions.addUserToTeam(teamId, userId));
|
||||
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) => {
|
||||
const {data, error} = await dispatch(TeamActions.addUsersToTeamGracefully(teamId, userIds));
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ import {
|
||||
import {getBool, isCollapsedThreadsEnabled} from 'mattermost-redux/selectors/entities/preferences';
|
||||
import {getCurrentTeamId, getTeamMember} from 'mattermost-redux/selectors/entities/teams';
|
||||
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 {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>) {
|
||||
return async (doDispatch: DispatchFunc, doGetState: GetStateFunc) => {
|
||||
export function loadProfilesAndTeamMembers(page: number, perPage: number, teamId: string, options?: Record<string, any>): NewActionFuncAsync {
|
||||
return async (doDispatch, doGetState) => {
|
||||
const newTeamId = teamId || getCurrentTeamId(doGetState());
|
||||
const {data} = await doDispatch(UserActions.getProfilesInTeam(newTeamId, page, perPage, '', options));
|
||||
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}) {
|
||||
return async (doDispatch: DispatchFunc, doGetState: GetStateFunc) => {
|
||||
export function loadProfilesAndTeamMembersAndChannelMembers(page: number, perPage: number, teamId: string, channelId: string, options?: {active?: boolean}): NewActionFuncAsync {
|
||||
return async (doDispatch, doGetState) => {
|
||||
const state = doGetState();
|
||||
const teamIdParam = teamId || getCurrentTeamId(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);
|
||||
if (pref === false) {
|
||||
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_CHANNEL_OPEN_TIME, name: channelId, value: now.toString()},
|
||||
])(doDispatch);
|
||||
]));
|
||||
loadProfilesForDM();
|
||||
return {data: true};
|
||||
}
|
||||
@@ -243,7 +243,7 @@ export function loadNewDMIfNeeded(channelId: string) {
|
||||
if (channel) {
|
||||
result = checkPreference(channel);
|
||||
} else {
|
||||
result = await getChannelAndMyMember(channelId)(doDispatch, doGetState) as ActionResult;
|
||||
result = await doDispatch(getChannelAndMyMember(channelId));
|
||||
if (result.data) {
|
||||
result = checkPreference(result.data.channel);
|
||||
}
|
||||
@@ -269,7 +269,7 @@ export function loadNewGMIfNeeded(channelId: string) {
|
||||
|
||||
const channel = getChannel(state, channelId);
|
||||
if (!channel) {
|
||||
await getChannelAndMyMember(channelId)(doDispatch, doGetState);
|
||||
await doDispatch(getChannelAndMyMember(channelId));
|
||||
}
|
||||
return checkPreference();
|
||||
};
|
||||
@@ -406,13 +406,13 @@ export async function loadProfilesForDM() {
|
||||
}
|
||||
|
||||
if (newPreferences.length > 0) {
|
||||
savePreferences(currentUserId, newPreferences)(dispatch);
|
||||
dispatch(savePreferences(currentUserId, newPreferences));
|
||||
}
|
||||
|
||||
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) {
|
||||
@@ -431,9 +431,9 @@ export function autocompleteUsers(username: string) {
|
||||
}
|
||||
|
||||
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 {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) {
|
||||
return {data: userStatus};
|
||||
@@ -442,7 +442,7 @@ export function autoResetStatus() {
|
||||
const autoReset = getBool(getState(), PreferencesRedux.CATEGORY_AUTO_RESET_MANUAL_STATUS, currentUserId, false);
|
||||
|
||||
if (autoReset) {
|
||||
UserActions.setStatus({user_id: currentUserId, status: 'online'})(doDispatch, doGetState);
|
||||
doDispatch(UserActions.setStatus({user_id: currentUserId, status: 'online'}));
|
||||
return {data: userStatus};
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
import type {GenericAction} from 'mattermost-redux/types/actions';
|
||||
|
||||
import {Constants, ActionTypes, WindowSizes} from 'utils/constants';
|
||||
|
||||
export function emitBrowserWindowResized(windowSize?: string): GenericAction {
|
||||
export function emitBrowserWindowResized(windowSize?: string) {
|
||||
let newWindowSize = windowSize;
|
||||
if (!windowSize) {
|
||||
const width = window.innerWidth;
|
||||
|
||||
@@ -41,7 +41,7 @@ import {
|
||||
} from 'mattermost-redux/selectors/entities/teams';
|
||||
import {getCurrentUserId, getUserByUsername} from 'mattermost-redux/selectors/entities/users';
|
||||
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 EventEmitter from 'mattermost-redux/utils/event_emitter';
|
||||
|
||||
@@ -98,8 +98,8 @@ export function loadIfNecessaryAndSwitchToChannelById(channelId: string) {
|
||||
};
|
||||
}
|
||||
|
||||
export function switchToChannel(channel: Channel & {userId?: string}) {
|
||||
return async (dispatch: DispatchFunc, getState: GetStateFunc) => {
|
||||
export function switchToChannel(channel: Channel & {userId?: string}): NewActionFuncAsync {
|
||||
return async (dispatch, getState) => {
|
||||
const state = getState();
|
||||
const selectedTeamId = channel.team_id;
|
||||
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) {
|
||||
return async (dispatch: DispatchFunc) => {
|
||||
export function loadUnreads(channelId: string, prefetch = false): NewActionFuncAsync<{atLatestMessage: boolean; atOldestMessage: boolean}> {
|
||||
return async (dispatch) => {
|
||||
const time = Date.now();
|
||||
if (prefetch) {
|
||||
dispatch({
|
||||
@@ -259,13 +259,13 @@ export function loadUnreads(channelId: string, prefetch = false) {
|
||||
atOldestmessage: false,
|
||||
};
|
||||
}
|
||||
dispatch(loadCustomStatusEmojisForPostList(data.posts));
|
||||
dispatch(loadCustomStatusEmojisForPostList(data!.posts));
|
||||
|
||||
const actions = [];
|
||||
actions.push({
|
||||
type: ActionTypes.INCREASE_POST_VISIBILITY,
|
||||
data: channelId,
|
||||
amount: data.order.length,
|
||||
amount: data!.order.length,
|
||||
});
|
||||
|
||||
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({
|
||||
type: ActionTypes.RECEIVED_POSTS_FOR_CHANNEL_AT_TIME,
|
||||
channelId,
|
||||
@@ -286,8 +286,8 @@ export function loadUnreads(channelId: string, prefetch = false) {
|
||||
|
||||
dispatch(batchActions(actions));
|
||||
return {
|
||||
atLatestMessage: data.next_post_id === '',
|
||||
atOldestmessage: data.prev_post_id === '',
|
||||
atLatestMessage: data!.next_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) {
|
||||
return async (dispatch: DispatchFunc, getState: GetStateFunc) => {
|
||||
export function prefetchChannelPosts(channelId: string, jitter?: number): NewActionFuncAsync {
|
||||
return async (dispatch, getState) => {
|
||||
const state = getState();
|
||||
const recentPostIdInChannel = getMostRecentPostIdInChannel(state, channelId);
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import {General} from 'mattermost-redux/constants';
|
||||
import {CategoryTypes} from 'mattermost-redux/constants/channel_categories';
|
||||
import {getCategory, makeGetChannelIdsForCategory} from 'mattermost-redux/selectors/entities/channel_categories';
|
||||
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 {getCategoriesForCurrentTeam, getChannelsInCategoryOrder, getDisplayedChannels} from 'selectors/views/channel_sidebar';
|
||||
@@ -33,8 +33,8 @@ export function stopDragging() {
|
||||
return {type: ActionTypes.SIDEBAR_DRAGGING_STOP};
|
||||
}
|
||||
|
||||
export function createCategory(teamId: string, displayName: string, channelIds?: string[]) {
|
||||
return async (dispatch: DispatchFunc, getState: GetStateFunc) => {
|
||||
export function createCategory(teamId: string, displayName: string, channelIds?: string[]): NewActionFuncAsync {
|
||||
return async (dispatch, getState) => {
|
||||
if (channelIds) {
|
||||
const state = getState() as GlobalState;
|
||||
const multiSelectedChannelIds = state.views.channelSidebar.multiSelectedChannelIds;
|
||||
|
||||
@@ -18,7 +18,7 @@ import {
|
||||
} from 'mattermost-redux/selectors/entities/posts';
|
||||
import {getCurrentTeamId} from 'mattermost-redux/selectors/entities/teams';
|
||||
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 {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) {
|
||||
return (draft: PostDraft, options: {ignoreSlash?: boolean} = {}) => async (dispatch: DispatchFunc, getState: () => GlobalState) => {
|
||||
export function makeOnSubmit(channelId: string, rootId: string, latestPostId: string): (draft: PostDraft, options?: {ignoreSlash?: boolean}) => NewActionFuncAsync {
|
||||
return (draft, options = {}) => async (dispatch, getState) => {
|
||||
const {message} = draft;
|
||||
|
||||
dispatch(addMessageIntoHistory(message));
|
||||
@@ -218,10 +218,10 @@ function makeGetCurrentUsersLatestReply() {
|
||||
);
|
||||
}
|
||||
|
||||
export function makeOnEditLatestPost(rootId: string) {
|
||||
export function makeOnEditLatestPost(rootId: string): () => NewActionFunc<boolean> {
|
||||
const getCurrentUsersLatestPost = makeGetCurrentUsersLatestReply();
|
||||
|
||||
return () => (dispatch: DispatchFunc, getState: GetStateFunc) => {
|
||||
return () => (dispatch, getState) => {
|
||||
const state = getState();
|
||||
|
||||
const lastPost = getCurrentUsersLatestPost(state, rootId);
|
||||
|
||||
@@ -19,7 +19,7 @@ export type CloseModalType = {
|
||||
modalId: string;
|
||||
}
|
||||
|
||||
export function closeModal(modalId: string): CloseModalType {
|
||||
export function closeModal(modalId: string) {
|
||||
return {
|
||||
type: ActionTypes.MODAL_CLOSE,
|
||||
modalId,
|
||||
|
||||
@@ -21,8 +21,8 @@ import {getTimestamp} from 'utils/utils';
|
||||
import {runMessageWillBePostedHooks} from '../hooks';
|
||||
|
||||
export function editPost(post) {
|
||||
return async (dispatch, getState) => {
|
||||
const result = await PostActions.editPost(post)(dispatch, getState);
|
||||
return async (dispatch) => {
|
||||
const result = await dispatch(PostActions.editPost(post));
|
||||
|
||||
// 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') {
|
||||
|
||||
@@ -3,10 +3,10 @@
|
||||
|
||||
import {getChannelMember} from 'mattermost-redux/actions/channels';
|
||||
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) {
|
||||
return (dispatch: DispatchFunc) => {
|
||||
export function getMembershipForEntities(teamId: string, userId: string, channelId?: string): NewActionFuncOldVariantDoNotUse {
|
||||
return (dispatch) => {
|
||||
return Promise.all([
|
||||
dispatch(getTeamMember(teamId, 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 {getCurrentTimezone} from 'mattermost-redux/selectors/entities/timezone';
|
||||
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 {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) {
|
||||
return (dispatch: DispatchFunc, getState: GetStateFunc) => {
|
||||
const action = {
|
||||
const action: AnyAction = {
|
||||
type: ActionTypes.UPDATE_RHS_STATE,
|
||||
state: rhsState,
|
||||
} as GenericAction;
|
||||
};
|
||||
|
||||
if ([
|
||||
RHSStates.PIN,
|
||||
@@ -130,7 +130,7 @@ export function selectPostCardFromRightHandSideSearch(post: Post) {
|
||||
export function selectPostFromRightHandSideSearchByPostId(postId: string) {
|
||||
return async (dispatch: DispatchFunc, getState: GetStateFunc) => {
|
||||
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) {
|
||||
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 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
|
||||
return (dispatch: DispatchFunc, getState: GetStateFunc) => {
|
||||
if (!previous) {
|
||||
return openRHSSearch()(dispatch);
|
||||
return dispatch(openRHSSearch());
|
||||
}
|
||||
|
||||
if (previous.isChannelInfo) {
|
||||
const currentChannelId = getCurrentChannelId(getState());
|
||||
return showChannelInfo(currentChannelId)(dispatch);
|
||||
return dispatch(showChannelInfo(currentChannelId));
|
||||
}
|
||||
if (previous.isChannelMembers) {
|
||||
const currentChannelId = getCurrentChannelId(getState());
|
||||
return showChannelMembers(currentChannelId)(dispatch, getState);
|
||||
return dispatch(showChannelMembers(currentChannelId));
|
||||
}
|
||||
if (previous.isMentionSearch) {
|
||||
return showMentions()(dispatch, getState);
|
||||
return dispatch(showMentions());
|
||||
}
|
||||
if (previous.isPinnedPosts) {
|
||||
return showPinnedPosts()(dispatch, getState);
|
||||
return dispatch(showPinnedPosts());
|
||||
}
|
||||
if (previous.isFlaggedPosts) {
|
||||
return showFlaggedPosts()(dispatch, getState);
|
||||
return dispatch(showFlaggedPosts());
|
||||
}
|
||||
if (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) {
|
||||
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) {
|
||||
return showSearchResults()(dispatch, getState);
|
||||
return dispatch(showSearchResults());
|
||||
}
|
||||
|
||||
return openRHSSearch()(dispatch);
|
||||
return dispatch(openRHSSearch());
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -1278,7 +1278,7 @@ function handleStatusChangedEvent(msg) {
|
||||
}
|
||||
|
||||
function handleHelloEvent(msg) {
|
||||
setServerVersion(msg.data.server_version)(dispatch, getState);
|
||||
dispatch(setServerVersion(msg.data.server_version));
|
||||
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 Permissions from 'mattermost-redux/constants/permissions';
|
||||
import type {ActionResult} from 'mattermost-redux/types/actions';
|
||||
|
||||
import FormattedMarkdownMessage from 'components/formatted_markdown_message';
|
||||
import OverlayTrigger from 'components/overlay_trigger';
|
||||
@@ -83,7 +84,7 @@ export type Props = {
|
||||
/**
|
||||
* 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
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
import type {ComponentProps} from 'react';
|
||||
import {connect} from 'react-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 {Post} from '@mattermost/types/posts';
|
||||
@@ -25,8 +25,6 @@ import {makeFetchBindings, postEphemeralCallResponseForPost, handleBindingClick,
|
||||
import {openModal} from 'actions/views/modals';
|
||||
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 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>) {
|
||||
return {
|
||||
actions: bindActionCreators<ActionCreatorsMapObject<any>, Actions>({
|
||||
actions: bindActionCreators({
|
||||
handleBindingClick,
|
||||
fetchBindings,
|
||||
openModal,
|
||||
|
||||
@@ -7,7 +7,7 @@ import {FormattedMessage} from 'react-intl';
|
||||
|
||||
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';
|
||||
|
||||
@@ -38,12 +38,12 @@ export type Props = {
|
||||
/**
|
||||
* Function to refresh sessions from server
|
||||
*/
|
||||
getSessions: (userId: string) => ActionFunc;
|
||||
getSessions: (userId: string) => void;
|
||||
|
||||
/**
|
||||
* 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 {bindActionCreators} from 'redux';
|
||||
import type {ActionCreatorsMapObject, Dispatch} from 'redux';
|
||||
import type {Dispatch} from 'redux';
|
||||
|
||||
import {getSessions, revokeSession} from 'mattermost-redux/actions/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 type {GlobalState} from 'types/store';
|
||||
|
||||
import ActivityLogModal from './activity_log_modal';
|
||||
import type {Props} from './activity_log_modal';
|
||||
|
||||
function mapStateToProps(state: GlobalState) {
|
||||
return {
|
||||
@@ -24,9 +22,9 @@ function mapStateToProps(state: GlobalState) {
|
||||
};
|
||||
}
|
||||
|
||||
function mapDispatchToProps(dispatch: Dispatch<GenericAction>) {
|
||||
function mapDispatchToProps(dispatch: Dispatch) {
|
||||
return {
|
||||
actions: bindActionCreators<ActionCreatorsMapObject<ActionFunc| GenericAction>, Props['actions']>({
|
||||
actions: bindActionCreators({
|
||||
getSessions,
|
||||
revokeSession,
|
||||
}, dispatch),
|
||||
|
||||
@@ -10,7 +10,7 @@ import type {ServerError} from '@mattermost/types/errors';
|
||||
import type {Group, SyncablePatch} 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 type {Value} from 'components/multiselect/multiselect';
|
||||
@@ -38,12 +38,12 @@ export type Props = {
|
||||
onAddCallback?: (groupIDs: string[]) => void;
|
||||
|
||||
actions: {
|
||||
getGroupsNotAssociatedToChannel: (channelID: string, q?: string, page?: number | null, perPage?: number | null, filterParentTeamPermitted?: boolean) => Promise<ActionFunc>;
|
||||
setModalSearchTerm: (term: string) => { type: string; data: string};
|
||||
linkGroupSyncable: (groupID: string, syncableID: string, syncableType: string, patch: Partial<SyncablePatch>) => Promise<{error?: ServerError; data?: null}>;
|
||||
getAllGroupsAssociatedToChannel: (channelID: string, filterAllowReference: boolean, includeMemberCount: boolean) => ActionFunc;
|
||||
getTeam: (teamId: string) => ActionFunc;
|
||||
getAllGroupsAssociatedToTeam: (teamID: string, filterAllowReference: boolean, includeMemberCount: boolean) => ActionFunc;
|
||||
getGroupsNotAssociatedToChannel: (channelID: string, q?: string, page?: number, perPage?: number, filterParentTeamPermitted?: boolean) => Promise<ActionResult>;
|
||||
setModalSearchTerm: (term: string) => void;
|
||||
linkGroupSyncable: (groupID: string, syncableID: string, syncableType: SyncableType, patch: Partial<SyncablePatch>) => Promise<ActionResult>;
|
||||
getAllGroupsAssociatedToChannel: (channelID: string, filterAllowReference: boolean, includeMemberCount: boolean) => Promise<ActionResult>;
|
||||
getTeam: (teamId: string) => Promise<ActionResult>;
|
||||
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(
|
||||
async () => {
|
||||
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);
|
||||
},
|
||||
Constants.SEARCH_TIMEOUT_MILLISECONDS,
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
import {connect} from 'react-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 {Group} from '@mattermost/types/groups';
|
||||
@@ -12,14 +12,12 @@ import {getGroupsNotAssociatedToChannel, linkGroupSyncable, getAllGroupsAssociat
|
||||
import {getTeam} from 'mattermost-redux/actions/teams';
|
||||
import {getCurrentChannel} from 'mattermost-redux/selectors/entities/channels';
|
||||
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 type {GlobalState} from 'types/store';
|
||||
|
||||
import AddGroupsToChannelModal from './add_groups_to_channel_modal';
|
||||
import type {Props} from './add_groups_to_channel_modal';
|
||||
|
||||
type OwnProps = {
|
||||
channel: Channel;
|
||||
@@ -51,9 +49,9 @@ function mapStateToProps(state: GlobalState, ownProps: OwnProps) {
|
||||
};
|
||||
}
|
||||
|
||||
function mapDispatchToProps(dispatch: Dispatch<GenericAction>) {
|
||||
function mapDispatchToProps(dispatch: Dispatch) {
|
||||
return {
|
||||
actions: bindActionCreators<ActionCreatorsMapObject<ActionFunc| GenericAction>, Props['actions']>({
|
||||
actions: bindActionCreators({
|
||||
getGroupsNotAssociatedToChannel,
|
||||
setModalSearchTerm,
|
||||
linkGroupSyncable,
|
||||
|
||||
@@ -7,9 +7,11 @@ import {Modal} from 'react-bootstrap';
|
||||
import type {IntlShape} 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 type {ActionResult} from 'mattermost-redux/types/actions';
|
||||
|
||||
import Nbsp from 'components/html_entities/nbsp';
|
||||
import MultiSelect from 'components/multiselect/multiselect';
|
||||
import type {Value} from 'components/multiselect/multiselect';
|
||||
@@ -40,10 +42,10 @@ type Props = {
|
||||
}
|
||||
|
||||
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;
|
||||
linkGroupSyncable: (groupID: string, syncableID: string, syncableType: SyncableType, patch: SyncablePatch) => Promise<{ data?: boolean; error?: Error }>;
|
||||
getAllGroupsAssociatedToTeam: (teamID: string, filterAllowReference: boolean, includeMemberCount: boolean) => Promise<{ data: GroupsWithCount } | { error: Error }>;
|
||||
linkGroupSyncable: (groupID: string, syncableID: string, syncableType: SyncableType, patch: SyncablePatch) => Promise<ActionResult>;
|
||||
getAllGroupsAssociatedToTeam: (teamID: string, filterAllowReference: boolean, includeMemberCount: boolean) => Promise<ActionResult>;
|
||||
};
|
||||
|
||||
type State = {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
import {connect} from 'react-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 {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 as selectGroupsNotAssociatedToTeam} from 'mattermost-redux/selectors/entities/groups';
|
||||
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 type {GlobalState} from 'types/store';
|
||||
|
||||
import AddGroupsToTeamModal from './add_groups_to_team_modal';
|
||||
import type {Actions} from './add_groups_to_team_modal';
|
||||
|
||||
type Props = {
|
||||
team?: Team;
|
||||
@@ -51,7 +50,7 @@ function mapStateToProps(state: GlobalState, ownProps: Props) {
|
||||
|
||||
function mapDispatchToProps(dispatch: Dispatch<GenericAction>) {
|
||||
return {
|
||||
actions: bindActionCreators<ActionCreatorsMapObject<ActionFunc|GenericAction>, Actions>({
|
||||
actions: bindActionCreators({
|
||||
getGroupsNotAssociatedToTeam,
|
||||
setModalSearchTerm,
|
||||
linkGroupSyncable,
|
||||
|
||||
@@ -3,16 +3,14 @@
|
||||
|
||||
import {connect} from 'react-redux';
|
||||
import {bindActionCreators} from 'redux';
|
||||
import type {ActionCreatorsMapObject, Dispatch} from 'redux';
|
||||
import type {Dispatch} from 'redux';
|
||||
|
||||
import type {GlobalState} from '@mattermost/types/store';
|
||||
|
||||
import {addChannelMember, getChannelMember, autocompleteChannelsForSearch} from 'mattermost-redux/actions/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 type {Props} from './add_user_to_channel_modal';
|
||||
|
||||
function mapStateToProps(state: GlobalState) {
|
||||
const channelMembers = getChannelMembersInChannels(state) || {};
|
||||
@@ -23,7 +21,7 @@ function mapStateToProps(state: GlobalState) {
|
||||
|
||||
function mapDispatchToProps(dispatch: Dispatch) {
|
||||
return {
|
||||
actions: bindActionCreators<ActionCreatorsMapObject<ActionFunc>, Props['actions']>({
|
||||
actions: bindActionCreators({
|
||||
addChannelMember,
|
||||
getChannelMember,
|
||||
autocompleteChannelsForSearch,
|
||||
|
||||
@@ -3,13 +3,12 @@
|
||||
|
||||
import {connect} from 'react-redux';
|
||||
import {bindActionCreators} from 'redux';
|
||||
import type {ActionCreatorsMapObject, Dispatch} from 'redux';
|
||||
import type {Dispatch} from 'redux';
|
||||
|
||||
import type {UserProfile} from '@mattermost/types/users';
|
||||
|
||||
import {getProfilesNotInGroup, searchProfiles, getProfiles} from 'mattermost-redux/actions/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';
|
||||
|
||||
@@ -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) {
|
||||
return {
|
||||
actions: bindActionCreators<ActionCreatorsMapObject<Action>, Actions>({
|
||||
actions: bindActionCreators({
|
||||
getProfiles,
|
||||
getProfilesNotInGroup,
|
||||
loadStatusesForProfilesList,
|
||||
|
||||
@@ -3,24 +3,17 @@
|
||||
|
||||
import {connect} from 'react-redux';
|
||||
import {bindActionCreators} from 'redux';
|
||||
import type {ActionCreatorsMapObject, Dispatch} from 'redux';
|
||||
import type {Dispatch} from 'redux';
|
||||
|
||||
import {addUsersToGroup} from 'mattermost-redux/actions/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 type {ModalData} from 'types/actions';
|
||||
import type {GlobalState} from 'types/store';
|
||||
|
||||
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 = {
|
||||
groupId: string;
|
||||
}
|
||||
@@ -35,7 +28,7 @@ function mapStateToProps(state: GlobalState, props: OwnProps) {
|
||||
|
||||
function mapDispatchToProps(dispatch: Dispatch) {
|
||||
return {
|
||||
actions: bindActionCreators<ActionCreatorsMapObject<Action>, Actions>({
|
||||
actions: bindActionCreators({
|
||||
addUsersToGroup,
|
||||
openModal,
|
||||
}, dispatch),
|
||||
|
||||
@@ -10,6 +10,7 @@ import type {Team} from '@mattermost/types/teams';
|
||||
import type {UserProfile} from '@mattermost/types/users';
|
||||
|
||||
import {Client4} from 'mattermost-redux/client';
|
||||
import type {ActionResult} from 'mattermost-redux/types/actions';
|
||||
import {isGuest} from 'mattermost-redux/utils/user_utils';
|
||||
|
||||
import MultiSelect from 'components/multiselect/multiselect';
|
||||
@@ -36,8 +37,8 @@ type Props = {
|
||||
onExited?: () => void;
|
||||
|
||||
actions: {
|
||||
getProfilesNotInTeam: (teamId: string, groupConstrained: boolean, page: number, perPage?: number, options?: Record<string, any>) => Promise<{ data: UserProfile[] }>;
|
||||
searchProfiles: (term: string, 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<ActionResult<UserProfile[]>>;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -91,7 +92,7 @@ export class AddUsersToTeamModal extends React.PureComponent<Props, State> {
|
||||
const search = term !== '';
|
||||
if (search) {
|
||||
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 {
|
||||
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 {bindActionCreators} from 'redux';
|
||||
import type {Dispatch, ActionCreatorsMapObject} from 'redux';
|
||||
import type {Dispatch} from 'redux';
|
||||
|
||||
import type {GlobalState} from '@mattermost/types/store';
|
||||
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 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';
|
||||
|
||||
@@ -20,11 +19,6 @@ type Props = {
|
||||
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) {
|
||||
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 {
|
||||
actions: bindActionCreators<ActionCreatorsMapObject<ActionFunc>, Actions>({
|
||||
actions: bindActionCreators({
|
||||
getProfilesNotInTeam,
|
||||
searchProfiles,
|
||||
}, dispatch),
|
||||
|
||||
@@ -10,7 +10,7 @@ import type {AdminConfig, EnvironmentConfig} from '@mattermost/types/config';
|
||||
import type {Role} from '@mattermost/types/roles';
|
||||
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 AnnouncementBarController from 'components/announcement_bar';
|
||||
@@ -45,7 +45,7 @@ type ExtraProps = {
|
||||
setNavigationBlocked?: () => void;
|
||||
roles?: Record<string, Role>;
|
||||
editRole?: (role: Role) => void;
|
||||
updateConfig?: (config: AdminConfig) => ActionFunc;
|
||||
updateConfig?: (config: AdminConfig) => Promise<ActionResult>;
|
||||
cloud: CloudState;
|
||||
isCurrentUserSystemAdmin: boolean;
|
||||
}
|
||||
|
||||
@@ -4,16 +4,13 @@
|
||||
import {connect} from 'react-redux';
|
||||
import type {ConnectedProps} from 'react-redux';
|
||||
import {bindActionCreators} from 'redux';
|
||||
import type {ActionCreatorsMapObject, Dispatch} from 'redux';
|
||||
|
||||
import type {PluginsResponse} from '@mattermost/types/plugins';
|
||||
import type {Dispatch} from 'redux';
|
||||
|
||||
import {getPlugins} from 'mattermost-redux/actions/admin';
|
||||
import {getSubscriptionProduct} from 'mattermost-redux/selectors/entities/cloud';
|
||||
import {getConfig, getLicense} from 'mattermost-redux/selectors/entities/general';
|
||||
import {getBool} from 'mattermost-redux/selectors/entities/preferences';
|
||||
import {isFirstAdmin} from 'mattermost-redux/selectors/entities/users';
|
||||
import type {ActionFunc} from 'mattermost-redux/types/actions';
|
||||
|
||||
import {getAdminDefinition, getConsoleAccess} from 'selectors/admin_console';
|
||||
import {getNavigationBlocked} from 'selectors/views/admin';
|
||||
@@ -53,13 +50,9 @@ function mapStateToProps(state: GlobalState) {
|
||||
};
|
||||
}
|
||||
|
||||
type Actions = {
|
||||
getPlugins: () => Promise<{data: PluginsResponse}>;
|
||||
}
|
||||
|
||||
function mapDispatchToProps(dispatch: Dispatch) {
|
||||
return {
|
||||
actions: bindActionCreators<ActionCreatorsMapObject<ActionFunc>, Actions>({
|
||||
actions: bindActionCreators({
|
||||
getPlugins,
|
||||
}, dispatch),
|
||||
};
|
||||
|
||||
@@ -7,6 +7,8 @@ import {FormattedMessage} from 'react-intl';
|
||||
|
||||
import type {Audit} from '@mattermost/types/audits';
|
||||
|
||||
import type {ActionResult} from 'mattermost-redux/types/actions';
|
||||
|
||||
import ComplianceReports from 'components/admin_console/compliance_reports';
|
||||
import AuditTable from 'components/audit_table';
|
||||
import LoadingScreen from 'components/loading_screen';
|
||||
@@ -17,7 +19,7 @@ type Props = {
|
||||
audits: Audit[];
|
||||
isDisabled?: boolean;
|
||||
actions: {
|
||||
getAudits: () => Promise<{data: Audit[]}>;
|
||||
getAudits: () => Promise<ActionResult<Audit[]>>;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -3,23 +3,16 @@
|
||||
|
||||
import {connect} from 'react-redux';
|
||||
import {bindActionCreators} from 'redux';
|
||||
import type {Dispatch, ActionCreatorsMapObject} from 'redux';
|
||||
|
||||
import type {Audit} from '@mattermost/types/audits';
|
||||
import type {Dispatch} from 'redux';
|
||||
|
||||
import {getAudits} from 'mattermost-redux/actions/admin';
|
||||
import * as Selectors from 'mattermost-redux/selectors/entities/admin';
|
||||
import {getLicense} from 'mattermost-redux/selectors/entities/general';
|
||||
import type {ActionFunc, GenericAction} from 'mattermost-redux/types/actions';
|
||||
|
||||
import type {GlobalState} from 'types/store';
|
||||
|
||||
import Audits from './audits';
|
||||
|
||||
type Actions = {
|
||||
getAudits: () => Promise<{data: Audit[]}>;
|
||||
}
|
||||
|
||||
function mapStateToProps(state: GlobalState) {
|
||||
const license = getLicense(state);
|
||||
const isLicensed = license.Compliance === 'true';
|
||||
@@ -30,9 +23,9 @@ function mapStateToProps(state: GlobalState) {
|
||||
};
|
||||
}
|
||||
|
||||
function mapDispatchToProps(dispatch: Dispatch<GenericAction>) {
|
||||
function mapDispatchToProps(dispatch: Dispatch) {
|
||||
return {
|
||||
actions: bindActionCreators<ActionCreatorsMapObject<ActionFunc>, Actions>({
|
||||
actions: bindActionCreators({
|
||||
getAudits,
|
||||
}, dispatch),
|
||||
};
|
||||
|
||||
@@ -8,6 +8,7 @@ import type {Compliance} from '@mattermost/types/compliance';
|
||||
import type {UserProfile} from '@mattermost/types/users';
|
||||
|
||||
import {Client4} from 'mattermost-redux/client';
|
||||
import type {ActionResult} from 'mattermost-redux/types/actions';
|
||||
|
||||
import LoadingScreen from 'components/loading_screen';
|
||||
import ReloadIcon from 'components/widgets/icons/fa_reload_icon';
|
||||
@@ -44,12 +45,12 @@ type Props = {
|
||||
/*
|
||||
* Function to get compliance reports
|
||||
*/
|
||||
getComplianceReports: () => Promise<{data: Compliance[]}>;
|
||||
getComplianceReports: () => Promise<ActionResult<Compliance[]>>;
|
||||
|
||||
/*
|
||||
* 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 {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 {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 {getComplianceReports as selectComplianceReports, getConfig} from 'mattermost-redux/selectors/entities/admin';
|
||||
import {getLicense} from 'mattermost-redux/selectors/entities/general';
|
||||
import type {ActionFunc, GenericAction} from 'mattermost-redux/types/actions';
|
||||
|
||||
import ComplianceReports from './compliance_reports';
|
||||
|
||||
type Actions = {
|
||||
getComplianceReports: () => Promise<{data: Compliance[]}>;
|
||||
createComplianceReport: (job: Partial<Compliance>) => Promise<{data: Compliance; error?: Error}>;
|
||||
}
|
||||
|
||||
const getUsersForReports = createSelector(
|
||||
'getUsersForReports',
|
||||
(state: GlobalState) => state.entities.users.profiles,
|
||||
@@ -67,9 +60,9 @@ function mapStateToProps(state: GlobalState) {
|
||||
};
|
||||
}
|
||||
|
||||
function mapDispatchToProps(dispatch: Dispatch<GenericAction>) {
|
||||
function mapDispatchToProps(dispatch: Dispatch) {
|
||||
return {
|
||||
actions: bindActionCreators<ActionCreatorsMapObject<ActionFunc>, Actions>({
|
||||
actions: bindActionCreators({
|
||||
getComplianceReports,
|
||||
createComplianceReport,
|
||||
}, dispatch),
|
||||
|
||||
@@ -7,6 +7,8 @@ import {FormattedMessage} from 'react-intl';
|
||||
import type {AdminConfig, ClientLicense} from '@mattermost/types/config';
|
||||
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 type {BaseProps, BaseState} from 'components/admin_console/admin_settings';
|
||||
import BooleanSetting from 'components/admin_console/boolean_setting';
|
||||
@@ -19,8 +21,8 @@ import {Constants} from 'utils/constants';
|
||||
|
||||
type Props = BaseProps & {
|
||||
actions: {
|
||||
getTermsOfService: () => Promise<{data: TermsOfService}>;
|
||||
createTermsOfService: (text: string) => Promise<{data: TermsOfService; error?: Error}>;
|
||||
getTermsOfService: () => Promise<ActionResult<TermsOfService>>;
|
||||
createTermsOfService: (text: string) => Promise<ActionResult<TermsOfService>>;
|
||||
};
|
||||
config: AdminConfig;
|
||||
license: ClientLicense;
|
||||
|
||||
@@ -3,23 +3,15 @@
|
||||
|
||||
import {connect} from 'react-redux';
|
||||
import {bindActionCreators} from 'redux';
|
||||
import type {ActionCreatorsMapObject, Dispatch} from 'redux';
|
||||
|
||||
import type {TermsOfService} from '@mattermost/types/terms_of_service';
|
||||
import type {Dispatch} from 'redux';
|
||||
|
||||
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';
|
||||
|
||||
type Actions = {
|
||||
getTermsOfService: () => Promise<{data: TermsOfService}>;
|
||||
createTermsOfService: (text: string) => Promise<{data: TermsOfService; error?: Error}>;
|
||||
};
|
||||
|
||||
function mapDispatchToProps(dispatch: Dispatch<GenericAction>) {
|
||||
function mapDispatchToProps(dispatch: Dispatch) {
|
||||
return {
|
||||
actions: bindActionCreators<ActionCreatorsMapObject<ActionFunc>, Actions>({
|
||||
actions: bindActionCreators({
|
||||
getTermsOfService,
|
||||
createTermsOfService,
|
||||
}, dispatch),
|
||||
|
||||
@@ -36,10 +36,10 @@ type Props = {
|
||||
channelsToAdd: Record<string, ChannelWithTeamData>;
|
||||
|
||||
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;
|
||||
searchChannels: (id: string, term: string, opts: ChannelSearchOpts) => Promise<ActionResult>;
|
||||
getDataRetentionCustomPolicyChannels: (id: string, page: number, perPage: number) => Promise<ActionResult>;
|
||||
setChannelListSearch: (term: string) => void;
|
||||
setChannelListFilters: (filters: ChannelSearchOpts) => void;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
import {connect} from 'react-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 {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 {getDataRetentionCustomPolicy} from 'mattermost-redux/selectors/entities/admin';
|
||||
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 {setChannelListSearch, setChannelListFilters} from 'actions/views/search';
|
||||
@@ -25,13 +24,6 @@ type OwnProps = {
|
||||
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> {
|
||||
let filteredTeams = filterChannelsMatchingTerm(Object.keys(channels).map((key) => channels[key]), term);
|
||||
filteredTeams = filterChannelList(filteredTeams, filters);
|
||||
@@ -72,7 +64,7 @@ function mapStateToProps() {
|
||||
|
||||
function mapDispatchToProps(dispatch: Dispatch) {
|
||||
return {
|
||||
actions: bindActionCreators<ActionCreatorsMapObject<ActionFunc | GenericAction>, Actions>({
|
||||
actions: bindActionCreators({
|
||||
getDataRetentionCustomPolicyChannels,
|
||||
searchChannels,
|
||||
setChannelListSearch,
|
||||
|
||||
@@ -13,6 +13,8 @@ import type {
|
||||
import type {Team} from '@mattermost/types/teams';
|
||||
import type {IDMappedObjects} from '@mattermost/types/utilities';
|
||||
|
||||
import type {ActionResult} from 'mattermost-redux/types/actions';
|
||||
|
||||
import BlockableLink from 'components/admin_console/blockable_link';
|
||||
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';
|
||||
@@ -37,14 +39,14 @@ type Props = {
|
||||
policy?: DataRetentionCustomPolicy | null;
|
||||
teams?: Team[];
|
||||
actions: {
|
||||
fetchPolicy: (id: string) => Promise<{ data: DataRetentionCustomPolicy; error?: Error }>;
|
||||
fetchPolicyTeams: (id: string, page: number, perPage: number) => Promise<{ data: Team[]; error?: Error }>;
|
||||
createDataRetentionCustomPolicy: (policy: CreateDataRetentionCustomPolicy) => Promise<{ data: DataRetentionCustomPolicy; error?: Error }>;
|
||||
updateDataRetentionCustomPolicy: (id: string, policy: PatchDataRetentionCustomPolicy) => Promise<{ data: DataRetentionCustomPolicy; error?: Error }>;
|
||||
addDataRetentionCustomPolicyTeams: (id: string, policy: string[]) => Promise<{ data?: {status: string}; error?: Error }>;
|
||||
removeDataRetentionCustomPolicyTeams: (id: string, policy: string[]) => Promise<{ data?: {status: string}; error?: Error }>;
|
||||
addDataRetentionCustomPolicyChannels: (id: string, policy: string[]) => Promise<{ data?: {status: string}; error?: Error }>;
|
||||
removeDataRetentionCustomPolicyChannels: (id: string, policy: string[]) => Promise<{ data?: {status: string}; error?: Error }>;
|
||||
fetchPolicy: (id: string) => Promise<ActionResult>;
|
||||
fetchPolicyTeams: (id: string, page: number, perPage: number) => Promise<ActionResult>;
|
||||
createDataRetentionCustomPolicy: (policy: CreateDataRetentionCustomPolicy) => Promise<ActionResult>;
|
||||
updateDataRetentionCustomPolicy: (id: string, policy: PatchDataRetentionCustomPolicy) => Promise<ActionResult>;
|
||||
addDataRetentionCustomPolicyTeams: (id: string, policy: string[]) => Promise<ActionResult>;
|
||||
removeDataRetentionCustomPolicyTeams: (id: string, policy: string[]) => Promise<ActionResult>;
|
||||
addDataRetentionCustomPolicyChannels: (id: string, policy: string[]) => Promise<ActionResult>;
|
||||
removeDataRetentionCustomPolicyChannels: (id: string, policy: string[]) => Promise<ActionResult>;
|
||||
setNavigationBlocked: (blocked: boolean) => void;
|
||||
};
|
||||
};
|
||||
|
||||
@@ -3,14 +3,7 @@
|
||||
|
||||
import {connect} from 'react-redux';
|
||||
import {bindActionCreators} from 'redux';
|
||||
import type {Dispatch, ActionCreatorsMapObject} from 'redux';
|
||||
|
||||
import type {
|
||||
DataRetentionCustomPolicy,
|
||||
CreateDataRetentionCustomPolicy,
|
||||
PatchDataRetentionCustomPolicy,
|
||||
} from '@mattermost/types/data_retention';
|
||||
import type {Team} from '@mattermost/types/teams';
|
||||
import type {Dispatch} from 'redux';
|
||||
|
||||
import {
|
||||
getDataRetentionCustomPolicy as fetchPolicy,
|
||||
@@ -24,7 +17,6 @@ import {
|
||||
} from 'mattermost-redux/actions/admin';
|
||||
import {getDataRetentionCustomPolicy} from 'mattermost-redux/selectors/entities/admin';
|
||||
import {getTeamsInPolicy} from 'mattermost-redux/selectors/entities/teams';
|
||||
import type {GenericAction, ActionFunc} from 'mattermost-redux/types/actions';
|
||||
|
||||
import {setNavigationBlocked} from 'actions/admin_actions.jsx';
|
||||
|
||||
@@ -32,18 +24,6 @@ import type {GlobalState} from 'types/store';
|
||||
|
||||
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 = {
|
||||
match: {
|
||||
params: {
|
||||
@@ -66,9 +46,9 @@ function mapStateToProps() {
|
||||
};
|
||||
}
|
||||
|
||||
function mapDispatchToProps(dispatch: Dispatch<GenericAction>) {
|
||||
function mapDispatchToProps(dispatch: Dispatch) {
|
||||
return {
|
||||
actions: bindActionCreators<ActionCreatorsMapObject<ActionFunc | GenericAction>, Actions>({
|
||||
actions: bindActionCreators({
|
||||
fetchPolicy,
|
||||
fetchPolicyTeams,
|
||||
createDataRetentionCustomPolicy,
|
||||
|
||||
@@ -40,11 +40,11 @@ type Props = {
|
||||
globalMessageRetentionHours: string | undefined;
|
||||
globalFileRetentionHours: string | undefined;
|
||||
actions: {
|
||||
getDataRetentionCustomPolicies: (page: number) => Promise<{ data: DataRetentionCustomPolicies }>;
|
||||
createJob: (job: JobTypeBase) => Promise<{ data: any }>;
|
||||
getJobsByType: (job: JobType) => Promise<{ data: any}>;
|
||||
getDataRetentionCustomPolicies: (page: number) => Promise<ActionResult>;
|
||||
createJob: (job: JobTypeBase) => Promise<ActionResult>;
|
||||
getJobsByType: (job: JobType) => 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 type {AdminConfig, EnvironmentConfig} from '@mattermost/types/config';
|
||||
import type {ServerError} from '@mattermost/types/errors';
|
||||
import type {DeepPartial} from '@mattermost/types/utilities';
|
||||
|
||||
import type {ActionResult} from 'mattermost-redux/types/actions';
|
||||
|
||||
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 SetByEnv from 'components/admin_console/set_by_env';
|
||||
@@ -31,7 +32,7 @@ type Props = {
|
||||
fileRetentionHours: string | undefined;
|
||||
environmentConfig: Partial<EnvironmentConfig>;
|
||||
actions: {
|
||||
updateConfig: (config: Record<string, any>) => Promise<{ data?: AdminConfig; error?: ServerError }>;
|
||||
updateConfig: (config: Record<string, any>) => Promise<ActionResult>;
|
||||
setNavigationBlocked: (blocked: boolean) => void;
|
||||
};
|
||||
};
|
||||
|
||||
@@ -3,17 +3,13 @@
|
||||
|
||||
import {connect} from 'react-redux';
|
||||
import {bindActionCreators} from 'redux';
|
||||
import type {Dispatch, ActionCreatorsMapObject} from 'redux';
|
||||
|
||||
import type {AdminConfig} from '@mattermost/types/config';
|
||||
import type {ServerError} from '@mattermost/types/errors';
|
||||
import type {Dispatch} from 'redux';
|
||||
|
||||
import {
|
||||
updateConfig,
|
||||
} from 'mattermost-redux/actions/admin';
|
||||
import {getEnvironmentConfig} from 'mattermost-redux/selectors/entities/admin';
|
||||
import {getConfig} from 'mattermost-redux/selectors/entities/general';
|
||||
import type {GenericAction, ActionFunc} from 'mattermost-redux/types/actions';
|
||||
|
||||
import {setNavigationBlocked} from 'actions/admin_actions.jsx';
|
||||
|
||||
@@ -21,11 +17,6 @@ import type {GlobalState} from 'types/store';
|
||||
|
||||
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) {
|
||||
const messageRetentionHours = getConfig(state).DataRetentionMessageRetentionHours;
|
||||
const fileRetentionHours = getConfig(state).DataRetentionFileRetentionHours;
|
||||
@@ -37,9 +28,9 @@ function mapStateToProps(state: GlobalState) {
|
||||
};
|
||||
}
|
||||
|
||||
function mapDispatchToProps(dispatch: Dispatch<GenericAction>) {
|
||||
function mapDispatchToProps(dispatch: Dispatch) {
|
||||
return {
|
||||
actions: bindActionCreators<ActionCreatorsMapObject<ActionFunc | GenericAction>, Actions>({
|
||||
actions: bindActionCreators({
|
||||
updateConfig,
|
||||
setNavigationBlocked,
|
||||
}, dispatch),
|
||||
|
||||
@@ -3,29 +3,17 @@
|
||||
|
||||
import {connect} from 'react-redux';
|
||||
import {bindActionCreators} from 'redux';
|
||||
import type {Dispatch, ActionCreatorsMapObject} from 'redux';
|
||||
|
||||
import type {DataRetentionCustomPolicies} from '@mattermost/types/data_retention';
|
||||
import type {JobTypeBase, JobType} from '@mattermost/types/jobs';
|
||||
import type {Dispatch} from 'redux';
|
||||
|
||||
import {getDataRetentionCustomPolicies as fetchDataRetentionCustomPolicies, deleteDataRetentionCustomPolicy, updateConfig} from 'mattermost-redux/actions/admin';
|
||||
import {createJob, getJobsByType} from 'mattermost-redux/actions/jobs';
|
||||
import {getDataRetentionCustomPolicies, getDataRetentionCustomPoliciesCount} from 'mattermost-redux/selectors/entities/admin';
|
||||
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 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) {
|
||||
const customPolicies = getDataRetentionCustomPolicies(state);
|
||||
const customPoliciesCount = getDataRetentionCustomPoliciesCount(state);
|
||||
@@ -40,9 +28,9 @@ function mapStateToProps(state: GlobalState) {
|
||||
};
|
||||
}
|
||||
|
||||
function mapDispatchToProps(dispatch: Dispatch<GenericAction>) {
|
||||
function mapDispatchToProps(dispatch: Dispatch) {
|
||||
return {
|
||||
actions: bindActionCreators<ActionCreatorsMapObject<ActionFunc>, Actions>({
|
||||
actions: bindActionCreators({
|
||||
getDataRetentionCustomPolicies: fetchDataRetentionCustomPolicies,
|
||||
createJob,
|
||||
getJobsByType,
|
||||
|
||||
@@ -3,15 +3,14 @@
|
||||
|
||||
import {connect} from 'react-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 {Team, TeamSearchOpts} from '@mattermost/types/teams';
|
||||
import type {Team} from '@mattermost/types/teams';
|
||||
|
||||
import {getDataRetentionCustomPolicyTeams, searchDataRetentionCustomPolicyTeams as searchTeams} from 'mattermost-redux/actions/admin';
|
||||
import {getDataRetentionCustomPolicy} from 'mattermost-redux/selectors/entities/admin';
|
||||
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 {setTeamListSearch} from 'actions/views/search';
|
||||
@@ -25,12 +24,6 @@ type OwnProps = {
|
||||
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> {
|
||||
const filteredTeams = filterTeamsStartingWithTerm(Object.keys(teams).map((key) => teams[key]), term);
|
||||
return teamListToMap(filteredTeams);
|
||||
@@ -66,7 +59,7 @@ function mapStateToProps() {
|
||||
|
||||
function mapDispatchToProps(dispatch: Dispatch) {
|
||||
return {
|
||||
actions: bindActionCreators<ActionCreatorsMapObject<ActionFunc | GenericAction>, Actions>({
|
||||
actions: bindActionCreators({
|
||||
getDataRetentionCustomPolicyTeams,
|
||||
searchTeams,
|
||||
setTeamListSearch,
|
||||
|
||||
@@ -31,8 +31,8 @@ type Props = {
|
||||
teamsToAdd: Record<string, Team>;
|
||||
|
||||
actions: {
|
||||
searchTeams: (id: string, term: string, opts: TeamSearchOpts) => Promise<{ data: Team[] }>;
|
||||
getDataRetentionCustomPolicyTeams: (id: string, page: number, perPage: number) => Promise<{ data: Team[] }>;
|
||||
searchTeams: (id: string, term: string, opts: TeamSearchOpts) => Promise<ActionResult>;
|
||||
getDataRetentionCustomPolicyTeams: (id: string, page: number, perPage: number) => Promise<ActionResult>;
|
||||
setTeamListSearch: (term: string) => ActionResult;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -3,20 +3,15 @@
|
||||
|
||||
import {connect} from 'react-redux';
|
||||
import {bindActionCreators} from 'redux';
|
||||
import type {Dispatch, ActionCreatorsMapObject} from 'redux';
|
||||
import type {Dispatch} from 'redux';
|
||||
|
||||
import {getAppliedSchemaMigrations} from 'mattermost-redux/actions/admin';
|
||||
import type {ActionFunc, ActionResult, GenericAction} from 'mattermost-redux/types/actions';
|
||||
|
||||
import MigrationsTable from './migrations_table';
|
||||
|
||||
type Actions = {
|
||||
getAppliedSchemaMigrations: () => Promise<ActionResult>;
|
||||
}
|
||||
|
||||
function mapDispatchToProps(dispatch: Dispatch) {
|
||||
return {
|
||||
actions: bindActionCreators<ActionCreatorsMapObject<ActionFunc | GenericAction>, Actions>({
|
||||
actions: bindActionCreators({
|
||||
getAppliedSchemaMigrations,
|
||||
}, dispatch),
|
||||
};
|
||||
|
||||
@@ -3,14 +3,13 @@
|
||||
|
||||
import {connect} from 'react-redux';
|
||||
import {bindActionCreators} from 'redux';
|
||||
import type {Dispatch, ActionCreatorsMapObject} from 'redux';
|
||||
import type {Dispatch} from 'redux';
|
||||
|
||||
import {getPrevTrialLicense} from 'mattermost-redux/actions/admin';
|
||||
import {getCloudSubscription} from 'mattermost-redux/actions/cloud';
|
||||
import {checkHadPriorTrial, getCloudCustomer} from 'mattermost-redux/selectors/entities/cloud';
|
||||
import {getLicense} from 'mattermost-redux/selectors/entities/general';
|
||||
import {deprecateCloudFree} from 'mattermost-redux/selectors/entities/preferences';
|
||||
import type {Action, GenericAction} from 'mattermost-redux/types/actions';
|
||||
|
||||
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 {isCloudLicense} from 'utils/license_utils';
|
||||
|
||||
import type {ModalData} from 'types/actions';
|
||||
import type {GlobalState} from 'types/store';
|
||||
|
||||
import FeatureDiscovery from './feature_discovery';
|
||||
@@ -45,15 +43,9 @@ function mapStateToProps(state: GlobalState) {
|
||||
};
|
||||
}
|
||||
|
||||
type Actions = {
|
||||
getPrevTrialLicense: () => void;
|
||||
getCloudSubscription: () => void;
|
||||
openModal: <P>(modalData: ModalData<P>) => void;
|
||||
}
|
||||
|
||||
function mapDispatchToProps(dispatch: Dispatch<GenericAction>) {
|
||||
function mapDispatchToProps(dispatch: Dispatch) {
|
||||
return {
|
||||
actions: bindActionCreators<ActionCreatorsMapObject<Action>, Actions>({
|
||||
actions: bindActionCreators({
|
||||
getPrevTrialLicense,
|
||||
getCloudSubscription,
|
||||
openModal,
|
||||
|
||||
@@ -6,7 +6,7 @@ import {useIntl} from 'react-intl';
|
||||
import type {ActionMeta, OptionsType, ValueType} from 'react-select';
|
||||
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';
|
||||
|
||||
@@ -57,7 +57,7 @@ function TeamFilterDropdown(props: Props) {
|
||||
|
||||
async function searchInList(term: string, callBack: (options: OptionsType<{label: string; value: string}>) => void) {
|
||||
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) {
|
||||
const teams = response.data.teams.map((team: Team) => ({
|
||||
value: team.id,
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
import {connect} from 'react-redux';
|
||||
import {bindActionCreators} from 'redux';
|
||||
import type {ActionCreatorsMapObject, Dispatch} from 'redux';
|
||||
import type {Dispatch} from 'redux';
|
||||
|
||||
import type {GlobalState} from '@mattermost/types/store';
|
||||
|
||||
@@ -24,12 +24,10 @@ import {
|
||||
getGroupTeams,
|
||||
} from 'mattermost-redux/selectors/entities/groups';
|
||||
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 GroupDetails from './group_details';
|
||||
import type {Props} from './group_details';
|
||||
|
||||
type OwnProps = {
|
||||
match: {
|
||||
@@ -57,12 +55,9 @@ function mapStateToProps(state: GlobalState, props: OwnProps) {
|
||||
};
|
||||
}
|
||||
|
||||
function mapDispatchToProps(dispatch: Dispatch<GenericAction>) {
|
||||
function mapDispatchToProps(dispatch: Dispatch) {
|
||||
return {
|
||||
actions: bindActionCreators<
|
||||
ActionCreatorsMapObject<ActionFunc | GenericAction>,
|
||||
Props['actions']
|
||||
>(
|
||||
actions: bindActionCreators(
|
||||
{
|
||||
setNavigationBlocked,
|
||||
getGroup: fetchGroup,
|
||||
|
||||
@@ -6,6 +6,8 @@ import {FormattedMessage} from 'react-intl';
|
||||
|
||||
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 CheckboxCheckedIcon from 'components/widgets/icons/checkbox_checked_icon';
|
||||
import NextIcon from 'components/widgets/icons/fa_next_icon';
|
||||
@@ -22,9 +24,9 @@ type Props = {
|
||||
total: number;
|
||||
readOnly?: boolean;
|
||||
actions: {
|
||||
getLdapGroups: (page?: number, perPage?: number, opts?: GroupSearchOpts) => Promise<any>;
|
||||
link: (key: string) => Promise<any>;
|
||||
unlink: (key: string) => Promise<any>;
|
||||
getLdapGroups: (page?: number, perPage?: number, opts?: GroupSearchOpts) => Promise<ActionResult>;
|
||||
link: (key: string) => Promise<ActionResult>;
|
||||
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);
|
||||
};
|
||||
|
||||
handleGetGroupsResponse = (response: any) => {
|
||||
handleGetGroupsResponse = (response: ActionResult) => {
|
||||
if (response?.error) {
|
||||
this.setState({fetchError: true});
|
||||
} else {
|
||||
|
||||
@@ -3,14 +3,13 @@
|
||||
|
||||
import {connect} from 'react-redux';
|
||||
import {bindActionCreators} from 'redux';
|
||||
import type {Dispatch, ActionCreatorsMapObject} from 'redux';
|
||||
import type {Dispatch} from 'redux';
|
||||
|
||||
import type {GlobalState} from '@mattermost/types/store';
|
||||
|
||||
import {linkLdapGroup, unlinkLdapGroup, getLdapGroups as fetchLdapGroups} from 'mattermost-redux/actions/admin';
|
||||
import {createSelector} from 'mattermost-redux/selectors/create_selector';
|
||||
import {getLdapGroups, getLdapGroupsCount} from 'mattermost-redux/selectors/entities/admin';
|
||||
import type {ActionFunc} from 'mattermost-redux/types/actions';
|
||||
|
||||
import GroupsList from './groups_list';
|
||||
|
||||
@@ -33,7 +32,7 @@ function mapStateToProps(state: GlobalState) {
|
||||
|
||||
function mapDispatchToProps(dispatch: Dispatch) {
|
||||
return {
|
||||
actions: bindActionCreators<ActionCreatorsMapObject<ActionFunc>, any>({
|
||||
actions: bindActionCreators({
|
||||
getLdapGroups: fetchLdapGroups,
|
||||
link: linkLdapGroup,
|
||||
unlink: unlinkLdapGroup,
|
||||
|
||||
@@ -4,10 +4,7 @@
|
||||
import {connect} from 'react-redux';
|
||||
import type {ConnectedProps} from 'react-redux';
|
||||
import {bindActionCreators} from 'redux';
|
||||
import type {ActionCreatorsMapObject, Dispatch} from 'redux';
|
||||
|
||||
import type {AdminConfig} from '@mattermost/types/config';
|
||||
import type {Role} from '@mattermost/types/roles';
|
||||
import type {Dispatch} from 'redux';
|
||||
|
||||
import {getConfig, getEnvironmentConfig, updateConfig} from 'mattermost-redux/actions/admin';
|
||||
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 {getTeam} from 'mattermost-redux/selectors/entities/teams';
|
||||
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 {selectLhsItem} from 'actions/views/lhs';
|
||||
@@ -28,7 +24,6 @@ import {showNavigationPrompt} from 'selectors/views/admin';
|
||||
import LocalStorageStore from 'stores/local_storage_store';
|
||||
|
||||
import type {GlobalState} from 'types/store';
|
||||
import type {LhsItemType} from 'types/store/lhs';
|
||||
|
||||
import AdminConsole from './admin_console';
|
||||
|
||||
@@ -59,22 +54,9 @@ function mapStateToProps(state: GlobalState) {
|
||||
};
|
||||
}
|
||||
|
||||
type Actions = {
|
||||
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>) {
|
||||
function mapDispatchToProps(dispatch: Dispatch) {
|
||||
return {
|
||||
actions: bindActionCreators<ActionCreatorsMapObject, Actions>({
|
||||
actions: bindActionCreators({
|
||||
getConfig,
|
||||
getEnvironmentConfig,
|
||||
updateConfig,
|
||||
|
||||
@@ -3,14 +3,11 @@
|
||||
|
||||
import {connect} from 'react-redux';
|
||||
import {bindActionCreators} from 'redux';
|
||||
import type {Dispatch, ActionCreatorsMapObject} from 'redux';
|
||||
|
||||
import type {JobType} from '@mattermost/types/jobs';
|
||||
import type {Dispatch} from 'redux';
|
||||
|
||||
import {getJobsByType, createJob, cancelJob} from 'mattermost-redux/actions/jobs';
|
||||
import {getConfig} from 'mattermost-redux/selectors/entities/admin';
|
||||
import {makeGetJobsByType} from 'mattermost-redux/selectors/entities/jobs';
|
||||
import type {GenericAction, ActionFunc, ActionResult} from 'mattermost-redux/types/actions';
|
||||
|
||||
import type {GlobalState} from 'types/store';
|
||||
|
||||
@@ -26,15 +23,9 @@ function mapStateToProps(state: GlobalState, ownProps: OwnProps) {
|
||||
};
|
||||
}
|
||||
|
||||
type Actions = {
|
||||
getJobsByType: (type: JobType) => Promise<ActionResult>;
|
||||
createJob: (job: {type: JobType}) => Promise<ActionResult>;
|
||||
cancelJob: (id: string) => Promise<ActionResult>;
|
||||
}
|
||||
|
||||
function mapDispatchToProps(dispatch: Dispatch<GenericAction>) {
|
||||
function mapDispatchToProps(dispatch: Dispatch) {
|
||||
return {
|
||||
actions: bindActionCreators<ActionCreatorsMapObject<ActionFunc>, Actions>({
|
||||
actions: bindActionCreators({
|
||||
getJobsByType,
|
||||
createJob,
|
||||
cancelJob,
|
||||
|
||||
@@ -3,23 +3,17 @@
|
||||
|
||||
import {connect} from 'react-redux';
|
||||
import {bindActionCreators} from 'redux';
|
||||
import type {ActionCreatorsMapObject, 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 type {Dispatch} from 'redux';
|
||||
|
||||
import {uploadLicense, removeLicense, getPrevTrialLicense} from 'mattermost-redux/actions/admin';
|
||||
import {getLicenseConfig} from 'mattermost-redux/actions/general';
|
||||
import {getFilteredUsersStats} from 'mattermost-redux/actions/users';
|
||||
import {getConfig} from 'mattermost-redux/selectors/entities/general';
|
||||
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 {openModal} from 'actions/views/modals';
|
||||
|
||||
import type {ModalData} from 'types/actions';
|
||||
import type {GlobalState} from 'types/store';
|
||||
|
||||
import LicenseSettings from './license_settings';
|
||||
@@ -34,27 +28,9 @@ function mapStateToProps(state: GlobalState) {
|
||||
};
|
||||
}
|
||||
|
||||
type StatusOKFunc = () => Promise<StatusOK>;
|
||||
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>) {
|
||||
function mapDispatchToProps(dispatch: Dispatch) {
|
||||
return {
|
||||
actions: bindActionCreators<ActionCreatorsMapObject<ActionCreatorTypes>, Actions>({
|
||||
actions: bindActionCreators({
|
||||
getLicenseConfig,
|
||||
uploadLicense,
|
||||
removeLicense,
|
||||
|
||||
@@ -49,7 +49,7 @@ type Props = {
|
||||
removeLicense: () => Promise<ActionResult>;
|
||||
getPrevTrialLicense: () => void;
|
||||
upgradeToE0: () => Promise<StatusOK>;
|
||||
upgradeToE0Status: () => Promise<{percentage: number; error: string | JSX.Element}>;
|
||||
upgradeToE0Status: () => Promise<{percentage: number; error: string | JSX.Element | null}>;
|
||||
restartServer: () => Promise<StatusOK>;
|
||||
ping: () => Promise<{status: string}>;
|
||||
requestTrialLicense: (users: number, termsAccepted: boolean, receiveEmailsAccepted: boolean, featureName: string) => Promise<ActionResult>;
|
||||
|
||||
@@ -3,15 +3,14 @@
|
||||
|
||||
import {connect} from 'react-redux';
|
||||
import {bindActionCreators} from 'redux';
|
||||
import type {Dispatch, ActionCreatorsMapObject} from 'redux';
|
||||
import type {Dispatch} from 'redux';
|
||||
|
||||
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 ManageRolesModal from './manage_roles_modal';
|
||||
import type {Props} from './manage_roles_modal';
|
||||
|
||||
function mapStateToProps(state: GlobalState) {
|
||||
return {
|
||||
@@ -21,7 +20,7 @@ function mapStateToProps(state: GlobalState) {
|
||||
|
||||
function mapDispatchToProps(dispatch: Dispatch<GenericAction>) {
|
||||
return {
|
||||
actions: bindActionCreators<ActionCreatorsMapObject<ActionFunc>, Props['actions']>({
|
||||
actions: bindActionCreators({
|
||||
updateUserRoles,
|
||||
}, dispatch),
|
||||
};
|
||||
|
||||
@@ -3,17 +3,16 @@
|
||||
|
||||
import {connect} from 'react-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 type {ActionFunc, GenericAction} from 'mattermost-redux/types/actions';
|
||||
import type {GenericAction} from 'mattermost-redux/types/actions';
|
||||
|
||||
import {getCurrentLocale} from 'selectors/i18n';
|
||||
|
||||
import type {GlobalState} from 'types/store';
|
||||
|
||||
import ManageTeamsModal from './manage_teams_modal';
|
||||
import type {Props} from './manage_teams_modal';
|
||||
|
||||
function mapStateToProps(state: GlobalState) {
|
||||
return {
|
||||
@@ -23,7 +22,7 @@ function mapStateToProps(state: GlobalState) {
|
||||
|
||||
function mapDispatchToProps(dispatch: Dispatch<GenericAction>) {
|
||||
return {
|
||||
actions: bindActionCreators<ActionCreatorsMapObject<ActionFunc>, Props['actions']>({
|
||||
actions: bindActionCreators({
|
||||
getTeamMembersForUser,
|
||||
getTeamsForUser,
|
||||
updateTeamMemberSchemeRoles,
|
||||
|
||||
@@ -3,17 +3,21 @@
|
||||
|
||||
import {connect} from 'react-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 type {ActionFunc} from 'mattermost-redux/types/actions';
|
||||
|
||||
import type {GlobalState} from 'types/store';
|
||||
|
||||
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 userAccessTokens = state.entities.admin.userAccessTokensByUser;
|
||||
@@ -25,7 +29,7 @@ function mapStateToProps(state: GlobalState, ownProps: Props) {
|
||||
|
||||
function mapDispatchToProps(dispatch: Dispatch) {
|
||||
return {
|
||||
actions: bindActionCreators<ActionCreatorsMapObject<ActionFunc>, Props['actions']>({
|
||||
actions: bindActionCreators({
|
||||
getUserAccessTokensForUser,
|
||||
}, dispatch),
|
||||
};
|
||||
|
||||
@@ -8,7 +8,6 @@ import {FormattedMessage} from 'react-intl';
|
||||
import type {UserAccessToken, UserProfile} from '@mattermost/types/users';
|
||||
|
||||
import {Client4} from 'mattermost-redux/client';
|
||||
import type {ActionFunc} from 'mattermost-redux/types/actions';
|
||||
import * as UserUtils from 'mattermost-redux/utils/user_utils';
|
||||
|
||||
import RevokeTokenButton from 'components/admin_console/revoke_token_button';
|
||||
@@ -44,7 +43,7 @@ export type Props = {
|
||||
/**
|
||||
* 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 {bindActionCreators} from 'redux';
|
||||
import type {Dispatch, ActionCreatorsMapObject} from 'redux';
|
||||
import type {Dispatch} from 'redux';
|
||||
|
||||
import {getGroupStats} from 'mattermost-redux/actions/groups';
|
||||
import {searchProfiles, getProfilesInGroup} from 'mattermost-redux/actions/users';
|
||||
import {getGroupMemberCount} from 'mattermost-redux/selectors/entities/groups';
|
||||
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 type {GlobalState} from 'types/store';
|
||||
|
||||
import MemberListGroup from './member_list_group';
|
||||
import type {Props as MemberListGroupProps} from './member_list_group';
|
||||
|
||||
type Props = {
|
||||
groupID: string;
|
||||
@@ -41,7 +39,7 @@ function mapStateToProps(state: GlobalState, ownProps: Props) {
|
||||
|
||||
function mapDispatchToProps(dispatch: Dispatch) {
|
||||
return {
|
||||
actions: bindActionCreators<ActionCreatorsMapObject<ActionFunc | GenericAction>, MemberListGroupProps['actions']>({
|
||||
actions: bindActionCreators({
|
||||
getProfilesInGroup,
|
||||
searchProfiles,
|
||||
setModalSearchTerm,
|
||||
|
||||
@@ -7,6 +7,8 @@ import {FormattedMessage} from 'react-intl';
|
||||
import type {GroupStats} from '@mattermost/types/groups';
|
||||
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 type {Row, Column} from 'components/admin_console/data_grid/data_grid';
|
||||
import UserGridName from 'components/admin_console/user_grid/user_grid_name';
|
||||
@@ -23,10 +25,10 @@ export type Props = {
|
||||
groupID: string;
|
||||
total: number;
|
||||
actions: {
|
||||
getProfilesInGroup: (groupID: string, page: number, perPage: number) => Promise<{data: UserProfile[]}>;
|
||||
getGroupStats: (groupID: string) => Promise<{data: GroupStats}>;
|
||||
searchProfiles: (term: string, options?: Record<string, unknown>) => Promise<{data: UserProfile[]}>;
|
||||
setModalSearchTerm: (term: string) => Promise<{data: boolean}>;
|
||||
getProfilesInGroup: (groupID: string, page: number, perPage: number) => Promise<ActionResult<UserProfile[]>>;
|
||||
getGroupStats: (groupID: string) => Promise<ActionResult<GroupStats>>;
|
||||
searchProfiles: (term: string, options?: Record<string, unknown>) => Promise<ActionResult<UserProfile[]>>;
|
||||
setModalSearchTerm: (term: string) => void;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -3,22 +3,15 @@
|
||||
|
||||
import {connect} from 'react-redux';
|
||||
import {bindActionCreators} from 'redux';
|
||||
import type {Dispatch, ActionCreatorsMapObject} from 'redux';
|
||||
|
||||
import type {AdminConfig} from '@mattermost/types/config';
|
||||
import type {Dispatch} from 'redux';
|
||||
|
||||
import {updateConfig} from 'mattermost-redux/actions/admin';
|
||||
import type {ActionFunc, GenericAction} from 'mattermost-redux/types/actions';
|
||||
|
||||
import OpenIdConvert from './openid_convert';
|
||||
|
||||
type Actions = {
|
||||
updateConfig: (config: AdminConfig) => ActionFunc;
|
||||
}
|
||||
|
||||
function mapDispatchToProps(dispatch: Dispatch<GenericAction>) {
|
||||
function mapDispatchToProps(dispatch: Dispatch) {
|
||||
return {
|
||||
actions: bindActionCreators<ActionCreatorsMapObject<ActionFunc>, Actions>({
|
||||
actions: bindActionCreators({
|
||||
updateConfig,
|
||||
}, dispatch),
|
||||
};
|
||||
|
||||
@@ -6,7 +6,7 @@ import {FormattedMessage} from 'react-intl';
|
||||
|
||||
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 ExternalLink from 'components/external_link';
|
||||
@@ -21,18 +21,13 @@ import './openid_convert.scss';
|
||||
type Props = BaseProps & {
|
||||
disabled?: boolean;
|
||||
actions: {
|
||||
updateConfig: (config: AdminConfig) => ActionFunc & Partial<{error?: ClientErrorPlaceholder}>;
|
||||
updateConfig: (config: AdminConfig) => Promise<ActionResult>;
|
||||
};
|
||||
};
|
||||
type State = {
|
||||
serverError?: string;
|
||||
}
|
||||
|
||||
type ClientErrorPlaceholder = {
|
||||
message: string;
|
||||
server_error_id: string;
|
||||
}
|
||||
|
||||
export default class OpenIdConvert extends React.PureComponent<Props, State> {
|
||||
constructor(props: Props) {
|
||||
super(props);
|
||||
|
||||
@@ -7,7 +7,7 @@ import {FormattedMessage} from 'react-intl';
|
||||
|
||||
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';
|
||||
|
||||
@@ -22,15 +22,10 @@ type Props ={
|
||||
show: boolean;
|
||||
onClose: () => void;
|
||||
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) {
|
||||
const {ServiceSettings} = props.config;
|
||||
|
||||
|
||||
@@ -3,31 +3,24 @@
|
||||
|
||||
import {connect} from 'react-redux';
|
||||
import {bindActionCreators} from 'redux';
|
||||
import type {ActionCreatorsMapObject, Dispatch} from 'redux';
|
||||
|
||||
import type {AdminConfig} from '@mattermost/types/config';
|
||||
import type {Dispatch} from 'redux';
|
||||
|
||||
import {updateConfig} from 'mattermost-redux/actions/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 EditPostTimeLimitModal from './edit_post_time_limit_modal';
|
||||
|
||||
type Actions = {
|
||||
updateConfig: (config: AdminConfig) => ActionFunc;
|
||||
}
|
||||
|
||||
function mapStateToProps(state: GlobalState) {
|
||||
return {
|
||||
config: getConfig(state),
|
||||
};
|
||||
}
|
||||
|
||||
function mapDispatchToProps(dispatch: Dispatch<GenericAction>) {
|
||||
function mapDispatchToProps(dispatch: Dispatch) {
|
||||
return {
|
||||
actions: bindActionCreators<ActionCreatorsMapObject<ActionFunc>, Actions>({updateConfig}, dispatch),
|
||||
actions: bindActionCreators({updateConfig}, dispatch),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -3,17 +3,15 @@
|
||||
|
||||
import {connect} from 'react-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 {getConfig} from 'mattermost-redux/selectors/entities/general';
|
||||
import {getSchemes} from 'mattermost-redux/selectors/entities/schemes';
|
||||
import type {ActionFunc, GenericAction} from 'mattermost-redux/types/actions';
|
||||
|
||||
import type {GlobalState} from 'types/store';
|
||||
|
||||
import PermissionSchemesSettings from './permission_schemes_settings';
|
||||
import type {Props} from './permission_schemes_settings';
|
||||
|
||||
function mapStateToProps(state: GlobalState) {
|
||||
const schemes = getSchemes(state);
|
||||
@@ -26,9 +24,9 @@ function mapStateToProps(state: GlobalState) {
|
||||
};
|
||||
}
|
||||
|
||||
function mapDispatchToProps(dispatch: Dispatch<GenericAction>) {
|
||||
function mapDispatchToProps(dispatch: Dispatch) {
|
||||
return {
|
||||
actions: bindActionCreators<ActionCreatorsMapObject<ActionFunc | GenericAction>, Props['actions']>({
|
||||
actions: bindActionCreators({
|
||||
loadSchemes,
|
||||
loadSchemeTeams,
|
||||
}, dispatch),
|
||||
|
||||
@@ -3,15 +3,13 @@
|
||||
|
||||
import {connect} from 'react-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 {loadRolesIfNeeded, editRole} from 'mattermost-redux/actions/roles';
|
||||
import {getLicense, getConfig} from 'mattermost-redux/selectors/entities/general';
|
||||
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';
|
||||
|
||||
@@ -24,15 +22,10 @@ function mapStateToProps(state: GlobalState) {
|
||||
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 {
|
||||
actions: bindActionCreators<ActionCreatorsMapObject<ActionFunc | GenericAction>, Actions>({
|
||||
actions: bindActionCreators({
|
||||
loadRolesIfNeeded,
|
||||
editRole,
|
||||
setNavigationBlocked,
|
||||
|
||||
@@ -33,7 +33,7 @@ type Props = {
|
||||
license: ClientLicense;
|
||||
isDisabled?: boolean;
|
||||
actions: {
|
||||
loadRolesIfNeeded: (roles: Iterable<string>) => void;
|
||||
loadRolesIfNeeded: (roles: string[]) => void;
|
||||
editRole: (role: Partial<Role>) => Promise<ActionResult>;
|
||||
setNavigationBlocked: (blocked: boolean) => void;
|
||||
};
|
||||
|
||||
@@ -3,11 +3,8 @@
|
||||
|
||||
import {connect} from 'react-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 {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 {getRoles} from 'mattermost-redux/selectors/entities/roles';
|
||||
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 PermissionTeamSchemeSettings from './permission_team_scheme_settings';
|
||||
import type {Props} from './permission_team_scheme_settings';
|
||||
|
||||
type OwnProps = {
|
||||
match: {
|
||||
@@ -47,20 +42,9 @@ function makeMapStateToProps() {
|
||||
};
|
||||
}
|
||||
|
||||
type Actions = {
|
||||
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 {
|
||||
function mapDispatchToProps(dispatch: Dispatch) {
|
||||
return {
|
||||
actions: bindActionCreators<ActionCreatorsMapObject<ActionFunc | GenericAction>, Actions>({
|
||||
actions: bindActionCreators({
|
||||
loadRolesIfNeeded,
|
||||
loadScheme,
|
||||
loadSchemeTeams,
|
||||
@@ -70,7 +54,7 @@ function mapDispatchToProps(dispatch: Dispatch<GenericAction>): Props {
|
||||
createScheme,
|
||||
setNavigationBlocked,
|
||||
}, dispatch),
|
||||
} as Props;
|
||||
};
|
||||
}
|
||||
|
||||
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 {ClientConfig, ClientLicense} from '@mattermost/types/config';
|
||||
import type {ServerError} from '@mattermost/types/errors';
|
||||
import type {Role} from '@mattermost/types/roles';
|
||||
import type {Scheme, SchemePatch} from '@mattermost/types/schemes';
|
||||
import type {Team} from '@mattermost/types/teams';
|
||||
|
||||
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 ExternalLink from 'components/external_link';
|
||||
@@ -44,18 +43,18 @@ export type Props = {
|
||||
scheme: Scheme | null;
|
||||
roles: RolesMap;
|
||||
license: ClientLicense;
|
||||
teams: Team[];
|
||||
teams: Team[] | null;
|
||||
isDisabled: boolean;
|
||||
config: Partial<ClientConfig>;
|
||||
intl: IntlShape;
|
||||
actions: {
|
||||
loadRolesIfNeeded: (roles: Iterable<string>) => ActionFunc;
|
||||
loadRolesIfNeeded: (roles: Iterable<string>) => Promise<ActionResult>;
|
||||
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}>;
|
||||
loadSchemeTeams: (schemeId: string, page?: number, perPage?: number) => Promise<ActionResult>;
|
||||
editRole: (role: Role) => Promise<ActionResult>;
|
||||
patchScheme: (schemeId: string, scheme: SchemePatch) => Promise<ActionResult>;
|
||||
updateTeamScheme: (teamId: string, schemeId: string) => Promise<ActionResult>;
|
||||
createScheme: (scheme: Scheme) => Promise<ActionResult>;
|
||||
setNavigationBlocked: (blocked: boolean) => void;
|
||||
};
|
||||
}
|
||||
@@ -548,7 +547,7 @@ export class PermissionTeamSchemeSettings extends React.PureComponent<Props & Ro
|
||||
};
|
||||
|
||||
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.props.actions.setNavigationBlocked(true);
|
||||
};
|
||||
|
||||
@@ -4,13 +4,12 @@
|
||||
import {connect} from 'react-redux';
|
||||
import type {RouteComponentProps} from 'react-router-dom';
|
||||
import {bindActionCreators} from 'redux';
|
||||
import type {ActionCreatorsMapObject, Dispatch} from 'redux';
|
||||
import type {Dispatch} from 'redux';
|
||||
|
||||
import type {GlobalState} from '@mattermost/types/store';
|
||||
|
||||
import {deleteScheme} from 'mattermost-redux/actions/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 type {Props} from './permissions_scheme_summary';
|
||||
@@ -25,13 +24,9 @@ function makeMapStateToProps() {
|
||||
};
|
||||
}
|
||||
|
||||
type Actions = {
|
||||
deleteScheme: (schemeId: string) => Promise<ActionResult>;
|
||||
};
|
||||
|
||||
function mapDispatchToProps(dispatch: Dispatch<GenericAction>) {
|
||||
function mapDispatchToProps(dispatch: Dispatch) {
|
||||
return {
|
||||
actions: bindActionCreators<ActionCreatorsMapObject<ActionFunc>, Actions>({
|
||||
actions: bindActionCreators({
|
||||
deleteScheme,
|
||||
}, dispatch),
|
||||
};
|
||||
|
||||
@@ -3,22 +3,15 @@
|
||||
|
||||
import {connect} from 'react-redux';
|
||||
import {bindActionCreators} from 'redux';
|
||||
import type {Dispatch, ActionCreatorsMapObject} from 'redux';
|
||||
|
||||
import type {UserProfile} from '@mattermost/types/users';
|
||||
import type {Dispatch} from 'redux';
|
||||
|
||||
import {patchUser} from 'mattermost-redux/actions/users';
|
||||
import {getCurrentUserId} from 'mattermost-redux/selectors/entities/common';
|
||||
import type {ActionFunc, ActionResult} from 'mattermost-redux/types/actions';
|
||||
|
||||
import type {GlobalState} from 'types/store';
|
||||
|
||||
import ResetEmailModal from './reset_email_modal';
|
||||
|
||||
type Actions = {
|
||||
patchUser: (user: UserProfile) => ActionResult;
|
||||
}
|
||||
|
||||
function mapStateToProps(state: GlobalState) {
|
||||
return {
|
||||
currentUserId: getCurrentUserId(state),
|
||||
@@ -27,7 +20,7 @@ function mapStateToProps(state: GlobalState) {
|
||||
|
||||
function mapDispatchToProps(dispatch: Dispatch) {
|
||||
return {
|
||||
actions: bindActionCreators<ActionCreatorsMapObject<ActionFunc>, Actions>({
|
||||
actions: bindActionCreators({
|
||||
patchUser,
|
||||
}, dispatch),
|
||||
};
|
||||
|
||||
@@ -20,7 +20,7 @@ describe('components/admin_console/reset_email_modal/reset_email_modal.tsx', ()
|
||||
});
|
||||
|
||||
const baseProps = {
|
||||
actions: {patchUser: jest.fn(() => ({data: ''}))},
|
||||
actions: {patchUser: jest.fn(() => Promise.resolve({}))},
|
||||
user,
|
||||
currentUserId: 'random_user_id',
|
||||
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', () => {
|
||||
const patchUser = jest.fn(() => ({data: ''}));
|
||||
const props = {...baseProps, actions: {patchUser}};
|
||||
const wrapper = mountWithIntl(<ResetEmailModal {...props}/>);
|
||||
const wrapper = mountWithIntl(<ResetEmailModal {...baseProps}/>);
|
||||
|
||||
(wrapper.find('input[type=\'email\']').first().instance() as unknown as HTMLInputElement).value = '';
|
||||
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(
|
||||
<FormattedMessage
|
||||
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', () => {
|
||||
const patchUser = jest.fn(() => ({data: ''}));
|
||||
const props = {...baseProps, actions: {patchUser}};
|
||||
const wrapper = mountWithIntl(<ResetEmailModal {...props}/>);
|
||||
const wrapper = mountWithIntl(<ResetEmailModal {...baseProps}/>);
|
||||
|
||||
(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()});
|
||||
|
||||
expect(patchUser.mock.calls.length).toBe(0);
|
||||
expect(baseProps.actions.patchUser.mock.calls.length).toBe(0);
|
||||
expect(wrapper.state('error')).toStrictEqual(
|
||||
<FormattedMessage
|
||||
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', () => {
|
||||
const patchUser = jest.fn(() => ({data: ''}));
|
||||
const props = {...baseProps, actions: {patchUser}, currentUserId: user.id};
|
||||
const props = {...baseProps, currentUserId: user.id};
|
||||
const wrapper = mountWithIntl(<ResetEmailModal {...props}/>);
|
||||
|
||||
(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()});
|
||||
|
||||
expect(patchUser.mock.calls.length).toBe(0);
|
||||
expect(baseProps.actions.patchUser.mock.calls.length).toBe(0);
|
||||
expect(wrapper.state('error')).toStrictEqual(
|
||||
<FormattedMessage
|
||||
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', () => {
|
||||
const patchUser = jest.fn(() => ({data: ''}));
|
||||
const props = {...baseProps, actions: {patchUser}};
|
||||
const wrapper = mountWithIntl(<ResetEmailModal {...props}/>);
|
||||
const wrapper = mountWithIntl(<ResetEmailModal {...baseProps}/>);
|
||||
|
||||
(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()});
|
||||
|
||||
expect(patchUser.mock.calls.length).toBe(1);
|
||||
expect(baseProps.actions.patchUser.mock.calls.length).toBe(1);
|
||||
expect(wrapper.state('error')).toBeNull();
|
||||
});
|
||||
|
||||
test('should update email since the email is valid of the current user', () => {
|
||||
const patchUser = jest.fn(() => ({data: ''}));
|
||||
const props = {...baseProps, actions: {patchUser}, currentUserId: user.id};
|
||||
const props = {...baseProps, currentUserId: user.id};
|
||||
const wrapper = mountWithIntl(<ResetEmailModal {...props}/>);
|
||||
|
||||
(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('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();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -23,7 +23,7 @@ type Props = {
|
||||
onModalSubmit: (user?: UserProfile) => void;
|
||||
onModalDismissed: () => void;
|
||||
actions: {
|
||||
patchUser: (user: UserProfile) => ActionResult;
|
||||
patchUser: (user: UserProfile) => Promise<ActionResult>;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -3,12 +3,11 @@
|
||||
|
||||
import {connect} from 'react-redux';
|
||||
import {bindActionCreators} from 'redux';
|
||||
import type {Dispatch, ActionCreatorsMapObject} from 'redux';
|
||||
import type {Dispatch} from 'redux';
|
||||
|
||||
import {updateUserPassword} from 'mattermost-redux/actions/users';
|
||||
import {getConfig} from 'mattermost-redux/selectors/entities/general';
|
||||
import {getCurrentUserId} from 'mattermost-redux/selectors/entities/users';
|
||||
import type {ActionFunc, ActionResult} from 'mattermost-redux/types/actions';
|
||||
|
||||
import {getPasswordConfig} from 'utils/utils';
|
||||
|
||||
@@ -16,10 +15,6 @@ import type {GlobalState} from 'types/store';
|
||||
|
||||
import ResetPasswordModal from './reset_password_modal';
|
||||
|
||||
type Actions = {
|
||||
updateUserPassword: (userId: string, currentPassword: string, password: string) => ActionResult;
|
||||
}
|
||||
|
||||
function mapStateToProps(state: GlobalState) {
|
||||
const config = getConfig(state);
|
||||
|
||||
@@ -31,7 +26,7 @@ function mapStateToProps(state: GlobalState) {
|
||||
|
||||
function mapDispatchToProps(dispatch: Dispatch) {
|
||||
return {
|
||||
actions: bindActionCreators<ActionCreatorsMapObject<ActionFunc>, Actions>({
|
||||
actions: bindActionCreators({
|
||||
updateUserPassword,
|
||||
}, dispatch),
|
||||
};
|
||||
|
||||
@@ -7,8 +7,6 @@ import {FormattedMessage} from 'react-intl';
|
||||
|
||||
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 {TestHelper} from 'utils/test_helper';
|
||||
|
||||
@@ -36,8 +34,7 @@ describe('components/admin_console/reset_password_modal/reset_password_modal.tsx
|
||||
});
|
||||
|
||||
const baseProps = {
|
||||
// eslint-disable-next-line @typescript-eslint/ban-types
|
||||
actions: {updateUserPassword: jest.fn<ActionResult, Array<{}>>(() => ({data: ''}))},
|
||||
actions: {updateUserPassword: jest.fn(() => Promise.resolve({data: ''}))},
|
||||
currentUserId: user.id,
|
||||
user,
|
||||
show: true,
|
||||
@@ -68,8 +65,7 @@ describe('components/admin_console/reset_password_modal/reset_password_modal.tsx
|
||||
});
|
||||
|
||||
test('should call updateUserPassword', () => {
|
||||
// eslint-disable-next-line @typescript-eslint/ban-types
|
||||
const updateUserPassword = jest.fn<ActionResult, Array<{}>>(() => ({data: ''}));
|
||||
const updateUserPassword = jest.fn(() => Promise.resolve({data: ''}));
|
||||
const oldPassword = 'oldPassword123!';
|
||||
const newPassword = 'newPassword123!';
|
||||
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', () => {
|
||||
// eslint-disable-next-line @typescript-eslint/ban-types
|
||||
const updateUserPassword = jest.fn<ActionResult, Array<{}>>(() => ({data: ''}));
|
||||
const updateUserPassword = jest.fn(() => Promise.resolve({data: ''}));
|
||||
const newPassword = 'newPassword123!';
|
||||
const props = {...baseProps, actions: {updateUserPassword}};
|
||||
const wrapper = mountWithIntl(<ResetPasswordModal {...props}/>);
|
||||
@@ -104,8 +99,7 @@ describe('components/admin_console/reset_password_modal/reset_password_modal.tsx
|
||||
});
|
||||
|
||||
test('should call updateUserPassword', () => {
|
||||
// eslint-disable-next-line @typescript-eslint/ban-types
|
||||
const updateUserPassword = jest.fn<ActionResult, Array<{}>>(() => ({data: ''}));
|
||||
const updateUserPassword = jest.fn(() => Promise.resolve({data: ''}));
|
||||
const password = 'Password123!';
|
||||
|
||||
const props = {...baseProps, currentUserId: '2', actions: {updateUserPassword}};
|
||||
|
||||
@@ -24,7 +24,7 @@ type State = {
|
||||
serverErrorCurrentPass: React.ReactNode;
|
||||
}
|
||||
|
||||
type Props = {
|
||||
export type Props = {
|
||||
user?: UserProfile;
|
||||
currentUserId: string;
|
||||
show: boolean;
|
||||
@@ -32,7 +32,7 @@ type Props = {
|
||||
onModalDismissed: () => void;
|
||||
passwordConfig: PasswordConfig;
|
||||
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 {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';
|
||||
|
||||
interface RevokeTokenButtonProps {
|
||||
export interface RevokeTokenButtonProps {
|
||||
actions: {
|
||||
revokeUserAccessToken: (
|
||||
tokenId: string
|
||||
) => Promise<ActionFunc | ActionResult> | ActionFunc | ActionResult;
|
||||
) => Promise<ActionResult>;
|
||||
};
|
||||
tokenId: string;
|
||||
onError: (errorMessage: string) => void;
|
||||
|
||||
@@ -12,8 +12,6 @@ import type {
|
||||
LogServerNames,
|
||||
} from '@mattermost/types/admin';
|
||||
|
||||
import type {ActionFunc} from 'mattermost-redux/types/actions';
|
||||
|
||||
import AdminHeader from 'components/widgets/admin_console/admin_header';
|
||||
|
||||
import LogList from './log_list';
|
||||
@@ -24,11 +22,11 @@ type Props = {
|
||||
plainLogs: string[];
|
||||
isPlainLogs: boolean;
|
||||
actions: {
|
||||
getLogs: (logFilter: LogFilter) => ActionFunc;
|
||||
getLogs: (logFilter: LogFilter) => Promise<unknown>;
|
||||
getPlainLogs: (
|
||||
page?: 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 {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 MultiSelect from 'components/multiselect/multiselect';
|
||||
@@ -36,8 +37,8 @@ export type Props = {
|
||||
onExited: () => void;
|
||||
|
||||
actions: {
|
||||
getProfiles: (page: number, perPage?: number, options?: Record<string, any>) => Promise<{ data: UserProfile[] }>;
|
||||
searchProfiles: (term: string, 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<ActionResult<UserProfile[]>>;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -87,7 +88,7 @@ export class AddUsersToRoleModal extends React.PureComponent<Props, State> {
|
||||
const search = term !== '';
|
||||
if (search) {
|
||||
const {data} = await this.props.actions.searchProfiles(term, {replace: true});
|
||||
data.forEach((user) => {
|
||||
data!.forEach((user) => {
|
||||
if (!user.is_bot) {
|
||||
searchResults.push(user);
|
||||
}
|
||||
|
||||
@@ -3,14 +3,13 @@
|
||||
|
||||
import {connect} from 'react-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 {UserProfile} from '@mattermost/types/users';
|
||||
|
||||
import {getProfiles, searchProfiles} from 'mattermost-redux/actions/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 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 {
|
||||
actions: bindActionCreators<ActionCreatorsMapObject<ActionFunc>, Props['actions']>({
|
||||
actions: bindActionCreators({
|
||||
getProfiles,
|
||||
searchProfiles,
|
||||
}, dispatch),
|
||||
|
||||
@@ -3,15 +3,12 @@
|
||||
|
||||
import {connect} from 'react-redux';
|
||||
import {bindActionCreators} from 'redux';
|
||||
import type {Dispatch, ActionCreatorsMapObject} from 'redux';
|
||||
|
||||
import type {Role} from '@mattermost/types/roles';
|
||||
import type {Dispatch} from 'redux';
|
||||
|
||||
import {editRole} from 'mattermost-redux/actions/roles';
|
||||
import {updateUserRoles} from 'mattermost-redux/actions/users';
|
||||
import {getLicense} from 'mattermost-redux/selectors/entities/general';
|
||||
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';
|
||||
|
||||
@@ -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) {
|
||||
const role = getRolesById(state)[props.match.params.role_id];
|
||||
const license = getLicense(state);
|
||||
@@ -44,9 +35,9 @@ function mapStateToProps(state: GlobalState, props: Props) {
|
||||
};
|
||||
}
|
||||
|
||||
function mapDispatchToProps(dispatch: Dispatch<GenericAction>) {
|
||||
function mapDispatchToProps(dispatch: Dispatch) {
|
||||
return {
|
||||
actions: bindActionCreators<ActionCreatorsMapObject<ActionFunc | GenericAction>, Actions>({
|
||||
actions: bindActionCreators({
|
||||
editRole,
|
||||
updateUserRoles,
|
||||
setNavigationBlocked,
|
||||
|
||||
@@ -3,14 +3,13 @@
|
||||
|
||||
import {connect} from 'react-redux';
|
||||
import {bindActionCreators} from 'redux';
|
||||
import type {Dispatch, ActionCreatorsMapObject} from 'redux';
|
||||
import type {Dispatch} from 'redux';
|
||||
|
||||
import type {UserProfile} from '@mattermost/types/users';
|
||||
|
||||
import {getFilteredUsersStats, getProfiles, searchProfiles} from 'mattermost-redux/actions/users';
|
||||
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 type {GenericAction, ActionFunc} from 'mattermost-redux/types/actions';
|
||||
import {filterProfilesStartingWithTerm, profileListToMap} from 'mattermost-redux/utils/user_utils';
|
||||
|
||||
import {setUserGridSearch} from 'actions/views/search';
|
||||
@@ -18,7 +17,6 @@ import {setUserGridSearch} from 'actions/views/search';
|
||||
import type {GlobalState} from 'types/store';
|
||||
|
||||
import SystemRoleUsers from './system_role_users';
|
||||
import type {Props} from './system_role_users';
|
||||
|
||||
type OwnProps = {
|
||||
roleName: string;
|
||||
@@ -57,9 +55,9 @@ function mapStateToProps(state: GlobalState, props: OwnProps) {
|
||||
};
|
||||
}
|
||||
|
||||
function mapDispatchToProps(dispatch: Dispatch<GenericAction>) {
|
||||
function mapDispatchToProps(dispatch: Dispatch) {
|
||||
return {
|
||||
actions: bindActionCreators<ActionCreatorsMapObject<ActionFunc | GenericAction>, Props['actions']>({
|
||||
actions: bindActionCreators({
|
||||
getProfiles,
|
||||
getFilteredUsersStats,
|
||||
searchProfiles,
|
||||
|
||||
@@ -4,10 +4,11 @@
|
||||
import React from 'react';
|
||||
import {FormattedMessage} from 'react-intl';
|
||||
|
||||
import type {ServerError} from '@mattermost/types/errors';
|
||||
import type {Role} from '@mattermost/types/roles';
|
||||
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 UserGridName from 'components/admin_console/user_grid/user_grid_name';
|
||||
import UserGridRemove from 'components/admin_console/user_grid/user_grid_remove';
|
||||
@@ -30,13 +31,10 @@ export type Props = {
|
||||
onAddCallback: (users: UserProfile[]) => void;
|
||||
onRemoveCallback: (user: UserProfile) => void;
|
||||
actions: {
|
||||
getFilteredUsersStats: (filters: GetFilteredUsersStatsOpts) => Promise<{
|
||||
data?: UsersStats;
|
||||
error?: ServerError;
|
||||
}>;
|
||||
getProfiles: (page?: number | undefined, perPage?: number | undefined, options?: any) => Promise<any>;
|
||||
searchProfiles: (term: string, options: any) => Promise<any>;
|
||||
setUserGridSearch: (term: string) => Promise<any>;
|
||||
getFilteredUsersStats: (filters: GetFilteredUsersStatsOpts) => Promise<ActionResult<UsersStats>>;
|
||||
getProfiles: (page?: number | undefined, perPage?: number | undefined, options?: any) => Promise<ActionResult>;
|
||||
searchProfiles: (term: string, options: any) => Promise<ActionResult>;
|
||||
setUserGridSearch: (term: string) => void;
|
||||
};
|
||||
readOnly?: boolean;
|
||||
}
|
||||
|
||||
@@ -3,17 +3,15 @@
|
||||
|
||||
import {connect} from 'react-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 {TeamMembership} from '@mattermost/types/teams';
|
||||
|
||||
import {addUserToTeam} from 'mattermost-redux/actions/teams';
|
||||
import {updateUserActive} from 'mattermost-redux/actions/users';
|
||||
import {getConfig} from 'mattermost-redux/selectors/entities/general';
|
||||
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';
|
||||
|
||||
@@ -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>) {
|
||||
const apiActions = bindActionCreators<ActionCreatorsMapObject<ActionFunc>, Actions>({
|
||||
const apiActions = bindActionCreators({
|
||||
updateUserActive,
|
||||
addUserToTeam,
|
||||
}, dispatch);
|
||||
|
||||
@@ -11,6 +11,7 @@ import type {ServerError} from '@mattermost/types/errors';
|
||||
import type {Team, TeamMembership} from '@mattermost/types/teams';
|
||||
import type {UserProfile} from '@mattermost/types/users';
|
||||
|
||||
import type {ActionResult} from 'mattermost-redux/types/actions';
|
||||
import {isEmail} from 'mattermost-redux/utils/helpers';
|
||||
|
||||
import {adminResetMfa, adminResetEmail} from 'actions/admin_actions.jsx';
|
||||
@@ -42,9 +43,9 @@ export type Props = {
|
||||
mfaEnabled: boolean;
|
||||
isDisabled?: boolean;
|
||||
actions: {
|
||||
updateUserActive: (userId: string, active: boolean) => Promise<{error: ServerError}>;
|
||||
updateUserActive: (userId: string, active: boolean) => Promise<ActionResult>;
|
||||
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 {ActionResult} from 'mattermost-redux/types/actions';
|
||||
|
||||
import NextIcon from 'components/widgets/icons/fa_next_icon';
|
||||
import PreviousIcon from 'components/widgets/icons/fa_previous_icon';
|
||||
|
||||
@@ -25,7 +27,7 @@ type Props = {
|
||||
emptyListTextId: string;
|
||||
emptyListTextDefaultMessage: string;
|
||||
actions: {
|
||||
getTeamsData: (userId: string) => Promise<{data: Team[]}>;
|
||||
getTeamsData: (userId: string) => Promise<ActionResult<Team[]>>;
|
||||
removeGroup?: () => void;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -3,9 +3,7 @@
|
||||
|
||||
import {connect} from 'react-redux';
|
||||
import {bindActionCreators} from 'redux';
|
||||
import type {ActionCreatorsMapObject, Dispatch} from 'redux';
|
||||
|
||||
import type {Team, TeamMembership} from '@mattermost/types/teams';
|
||||
import type {Dispatch} from 'redux';
|
||||
|
||||
import {
|
||||
getTeamsForUser,
|
||||
@@ -13,7 +11,7 @@ import {
|
||||
removeUserFromTeam,
|
||||
updateTeamMemberSchemeRoles,
|
||||
} 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';
|
||||
|
||||
@@ -21,13 +19,6 @@ import type {GlobalState} from 'types/store';
|
||||
|
||||
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) {
|
||||
return {
|
||||
locale: getCurrentLocale(state),
|
||||
@@ -36,7 +27,7 @@ function mapStateToProps(state: GlobalState) {
|
||||
|
||||
function mapDispatchToProps(dispatch: Dispatch<GenericAction>) {
|
||||
return {
|
||||
actions: bindActionCreators<ActionCreatorsMapObject<ActionFunc>, Actions>({
|
||||
actions: bindActionCreators({
|
||||
getTeamsData: getTeamsForUser,
|
||||
getTeamMembersForUser,
|
||||
removeUserFromTeam,
|
||||
|
||||
@@ -51,8 +51,8 @@ type Props = {
|
||||
emptyListTextId: string;
|
||||
emptyListTextDefaultMessage: string;
|
||||
actions: {
|
||||
getTeamsData: (userId: string) => Promise<{data: Team[]}>;
|
||||
getTeamMembersForUser: (userId: string) => Promise<{data: TeamMembership[]}>;
|
||||
getTeamsData: (userId: string) => Promise<ActionResult<Team[]>>;
|
||||
getTeamMembersForUser: (userId: string) => Promise<ActionResult<TeamMembership[]>>;
|
||||
removeUserFromTeam: (teamId: string, userId: string) => 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
|
||||
private mergeTeamsWithMemberships = (data: [{data: Team[]}, {data: TeamMembership[]}]): TeamWithMembership[] => {
|
||||
private mergeTeamsWithMemberships = (data: [ActionResult<Team[]>, ActionResult<TeamMembership[]>]): TeamWithMembership[] => {
|
||||
const teams = data[0].data;
|
||||
const memberships = data[1].data;
|
||||
let teamsWithMemberships = teams.map((object: Team) => {
|
||||
const results = memberships.filter((team: TeamMembership) => team.team_id === object.id);
|
||||
let teamsWithMemberships = teams!.map((object: Team) => {
|
||||
const results = memberships!.filter((team: TeamMembership) => team.team_id === object.id);
|
||||
const team = {...object, ...results[0]};
|
||||
return team;
|
||||
});
|
||||
|
||||
@@ -3,11 +3,7 @@
|
||||
|
||||
import {connect} from 'react-redux';
|
||||
import {bindActionCreators} from 'redux';
|
||||
import type {ActionCreatorsMapObject, 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 type {Dispatch} from 'redux';
|
||||
|
||||
import {logError} from 'mattermost-redux/actions/errors';
|
||||
import {getTeams, getTeamStats} from 'mattermost-redux/actions/teams';
|
||||
@@ -21,7 +17,6 @@ import {
|
||||
import {getConfig} from 'mattermost-redux/selectors/entities/general';
|
||||
import {getTeamsList} from 'mattermost-redux/selectors/entities/teams';
|
||||
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 {setSystemUsersSearch} from 'actions/views/search';
|
||||
@@ -74,28 +69,9 @@ function mapStateToProps(state: GlobalState) {
|
||||
};
|
||||
}
|
||||
|
||||
type StatusOKFunc = () => Promise<StatusOK>;
|
||||
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>) {
|
||||
function mapDispatchToProps(dispatch: Dispatch) {
|
||||
return {
|
||||
actions: bindActionCreators<ActionCreatorsMapObject<ActionCreatorTypes>, Actions>({
|
||||
actions: bindActionCreators({
|
||||
getTeams,
|
||||
getTeamStats,
|
||||
getUser,
|
||||
|
||||
@@ -7,10 +7,10 @@ import {FormattedMessage} from 'react-intl';
|
||||
|
||||
import type {ServerError} from '@mattermost/types/errors';
|
||||
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 type {ActionFunc} from 'mattermost-redux/types/actions';
|
||||
import type {ActionResult} from 'mattermost-redux/types/actions';
|
||||
|
||||
import AdminHeader from 'components/widgets/admin_console/admin_header';
|
||||
|
||||
@@ -68,22 +68,22 @@ type Props = {
|
||||
/**
|
||||
* Function to get statistics for a team
|
||||
*/
|
||||
getTeamStats: (teamId: string) => ActionFunc;
|
||||
getTeamStats: (teamId: string) => Promise<ActionResult>;
|
||||
|
||||
/**
|
||||
* Function to get a user
|
||||
*/
|
||||
getUser: (id: string) => ActionFunc;
|
||||
getUser: (id: string) => Promise<ActionResult>;
|
||||
|
||||
/**
|
||||
* 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;
|
||||
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;
|
||||
searchProfiles: (term: string, options?: any) => Promise<ActionResult<UserProfile[]>>;
|
||||
|
||||
/**
|
||||
* 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);
|
||||
if (profiles.length === 0 && term.length === USER_ID_LENGTH) {
|
||||
if (profiles!.length === 0 && term.length === USER_ID_LENGTH) {
|
||||
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);
|
||||
if (profiles.length === 0 && term.length === USER_ID_LENGTH) {
|
||||
if (profiles!.length === 0 && term.length === USER_ID_LENGTH) {
|
||||
await this.getUserByTokenOrId(term);
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
import {connect} from 'react-redux';
|
||||
import {bindActionCreators} from 'redux';
|
||||
import type {Dispatch, ActionCreatorsMapObject} from 'redux';
|
||||
import type {Dispatch} from 'redux';
|
||||
|
||||
import {loadBots} from 'mattermost-redux/actions/bots';
|
||||
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 {getLicense} from 'mattermost-redux/selectors/entities/general';
|
||||
import {getCurrentUser} from 'mattermost-redux/selectors/entities/users';
|
||||
import type {ActionFunc} from 'mattermost-redux/types/actions';
|
||||
|
||||
import type {GlobalState} from 'types/store';
|
||||
|
||||
import SystemUsersDropdown from './system_users_dropdown';
|
||||
import type {Props} from './system_users_dropdown';
|
||||
|
||||
function mapStateToProps(state: GlobalState) {
|
||||
const bots = getExternalBotAccounts(state);
|
||||
@@ -32,7 +30,7 @@ function mapStateToProps(state: GlobalState) {
|
||||
|
||||
function mapDispatchToProps(dispatch: Dispatch) {
|
||||
return {
|
||||
actions: bindActionCreators<ActionCreatorsMapObject<ActionFunc>, Props['actions']>({
|
||||
actions: bindActionCreators({
|
||||
updateUserActive,
|
||||
revokeAllSessionsForUser,
|
||||
promoteGuestToUser,
|
||||
|
||||
Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше
Ссылка в новой задаче
Block a user