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
@@ -25,7 +25,7 @@ export type Props = {
|
||||
/**
|
||||
* The function to call to add new command
|
||||
*/
|
||||
addCommand: (command: Command) => Promise<ActionResult>;
|
||||
addCommand: (command: Command) => Promise<ActionResult<Command>>;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -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 {addCommand} from 'mattermost-redux/actions/integrations';
|
||||
import type {ActionFunc} from 'mattermost-redux/types/actions';
|
||||
|
||||
import AddCommand from './add_command';
|
||||
import type {Props} from './add_command';
|
||||
|
||||
function mapDispatchToProps(dispatch: Dispatch) {
|
||||
return {
|
||||
actions: bindActionCreators<ActionCreatorsMapObject<ActionFunc>, Props['actions']>({
|
||||
actions: bindActionCreators({
|
||||
addCommand,
|
||||
}, dispatch),
|
||||
};
|
||||
|
||||
@@ -6,6 +6,8 @@ import React from 'react';
|
||||
import type {IncomingWebhook} from '@mattermost/types/integrations';
|
||||
import type {Team} from '@mattermost/types/teams';
|
||||
|
||||
import type {ActionResult} from 'mattermost-redux/types/actions';
|
||||
|
||||
import AbstractIncomingWebhook from 'components/integrations/abstract_incoming_webhook';
|
||||
|
||||
import {getHistory} from 'utils/browser_history';
|
||||
@@ -37,7 +39,7 @@ type Props = {
|
||||
/**
|
||||
* The function to call to add a new incoming webhook
|
||||
*/
|
||||
createIncomingHook: (hook: IncomingWebhook) => Promise<{ data?: IncomingWebhook; error?: Error }>;
|
||||
createIncomingHook: (hook: IncomingWebhook) => Promise<ActionResult<IncomingWebhook>>;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -3,14 +3,12 @@
|
||||
|
||||
import {connect} from 'react-redux';
|
||||
import {bindActionCreators} from 'redux';
|
||||
import type {ActionCreatorsMapObject, Dispatch} from 'redux';
|
||||
import type {Dispatch} from 'redux';
|
||||
|
||||
import type {IncomingWebhook} from '@mattermost/types/integrations';
|
||||
import type {GlobalState} from '@mattermost/types/store';
|
||||
|
||||
import {createIncomingHook} from 'mattermost-redux/actions/integrations';
|
||||
import {getConfig} from 'mattermost-redux/selectors/entities/general';
|
||||
import type {Action, GenericAction} from 'mattermost-redux/types/actions';
|
||||
|
||||
import AddIncomingWebhook from './add_incoming_webhook';
|
||||
|
||||
@@ -25,13 +23,9 @@ function mapStateToProps(state: GlobalState) {
|
||||
};
|
||||
}
|
||||
|
||||
type Actions = {
|
||||
createIncomingHook: (hook: IncomingWebhook) => Promise<{ data?: IncomingWebhook; error?: Error }>;
|
||||
}
|
||||
|
||||
function mapDispatchToProps(dispatch: Dispatch<GenericAction>) {
|
||||
function mapDispatchToProps(dispatch: Dispatch) {
|
||||
return {
|
||||
actions: bindActionCreators<ActionCreatorsMapObject<Action>, Actions>({
|
||||
actions: bindActionCreators({
|
||||
createIncomingHook,
|
||||
}, dispatch),
|
||||
};
|
||||
|
||||
@@ -29,7 +29,7 @@ export type Props = {
|
||||
/**
|
||||
* The function to call to add new OAuthApp
|
||||
*/
|
||||
addOAuthApp: (app: OAuthApp) => Promise<ActionResult>;
|
||||
addOAuthApp: (app: OAuthApp) => Promise<ActionResult<OAuthApp>>;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -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 {addOAuthApp} from 'mattermost-redux/actions/integrations';
|
||||
import type {ActionFunc} from 'mattermost-redux/types/actions';
|
||||
|
||||
import AddOAuthApp from './add_oauth_app';
|
||||
import type {Props} from './add_oauth_app';
|
||||
|
||||
function mapDispatchToProps(dispatch: Dispatch) {
|
||||
return {
|
||||
actions: bindActionCreators<ActionCreatorsMapObject<ActionFunc>, Props['actions']>({
|
||||
actions: bindActionCreators({
|
||||
addOAuthApp,
|
||||
}, dispatch),
|
||||
};
|
||||
|
||||
@@ -29,7 +29,7 @@ export type Props = {
|
||||
/**
|
||||
* The function to call to add a new outgoing webhook
|
||||
*/
|
||||
createOutgoingHook: (hook: OutgoingWebhook) => Promise<ActionResult>;
|
||||
createOutgoingHook: (hook: OutgoingWebhook) => Promise<ActionResult<OutgoingWebhook>>;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -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 {createOutgoingHook} from 'mattermost-redux/actions/integrations';
|
||||
import {getConfig} from 'mattermost-redux/selectors/entities/general';
|
||||
import type {ActionFunc} from 'mattermost-redux/types/actions';
|
||||
|
||||
import type {GlobalState} from 'types/store';
|
||||
|
||||
import AddOutgoingWebhook from './add_outgoing_webhook';
|
||||
import type {Props} from './add_outgoing_webhook';
|
||||
|
||||
function mapStateToProps(state: GlobalState) {
|
||||
const config = getConfig(state);
|
||||
@@ -26,7 +24,7 @@ function mapStateToProps(state: GlobalState) {
|
||||
|
||||
function mapDispatchToProps(dispatch: Dispatch) {
|
||||
return {
|
||||
actions: bindActionCreators<ActionCreatorsMapObject<ActionFunc>, Props['actions']>({
|
||||
actions: bindActionCreators({
|
||||
createOutgoingHook,
|
||||
}, dispatch),
|
||||
};
|
||||
|
||||
@@ -8,7 +8,7 @@ import {Link} from 'react-router-dom';
|
||||
|
||||
import type {Bot, BotPatch} from '@mattermost/types/bots';
|
||||
import type {Team} from '@mattermost/types/teams';
|
||||
import type {UserProfile} from '@mattermost/types/users';
|
||||
import type {UserAccessToken, UserProfile} from '@mattermost/types/users';
|
||||
|
||||
import {General} from 'mattermost-redux/constants';
|
||||
import type {ActionResult} from 'mattermost-redux/types/actions';
|
||||
@@ -70,32 +70,32 @@ export type Props = {
|
||||
/**
|
||||
* Creates a new bot account.
|
||||
*/
|
||||
createBot: (bot: Partial<Bot>) => ActionResult;
|
||||
createBot: (bot: Partial<Bot>) => Promise<ActionResult<Bot>>;
|
||||
|
||||
/**
|
||||
* Patches an existing bot account.
|
||||
*/
|
||||
patchBot: (botUserId: string, botPatch: Partial<BotPatch>) => ActionResult;
|
||||
patchBot: (botUserId: string, botPatch: Partial<BotPatch>) => Promise<ActionResult<Bot>>;
|
||||
|
||||
/**
|
||||
* Uploads a user profile image
|
||||
*/
|
||||
uploadProfileImage: (userId: string, image: File | string) => ActionResult;
|
||||
uploadProfileImage: (userId: string, image: File | string) => Promise<ActionResult>;
|
||||
|
||||
/**
|
||||
* Set profile image to default
|
||||
*/
|
||||
setDefaultProfileImage: (userId: string) => ActionResult;
|
||||
setDefaultProfileImage: (userId: string) => Promise<ActionResult>;
|
||||
|
||||
/**
|
||||
* For creating default access token
|
||||
*/
|
||||
createUserAccessToken: (userId: string, description: string) => ActionResult;
|
||||
createUserAccessToken: (userId: string, description: string) => Promise<ActionResult<UserAccessToken>>;
|
||||
|
||||
/**
|
||||
* For creating setting bot to system admin or special posting permissions
|
||||
*/
|
||||
updateUserRoles: (userId: string, roles: string) => ActionResult;
|
||||
updateUserRoles: (userId: string, roles: string) => Promise<ActionResult>;
|
||||
};
|
||||
};
|
||||
|
||||
@@ -355,7 +355,7 @@ export default class AddBot extends React.PureComponent<Props, State> {
|
||||
return;
|
||||
}
|
||||
|
||||
token = tokenResult.data.token;
|
||||
token = tokenResult.data!.token!;
|
||||
}
|
||||
|
||||
if (!error && data) {
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
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 {createBot, patchBot} from 'mattermost-redux/actions/bots';
|
||||
import {updateUserRoles, uploadProfileImage, setDefaultProfileImage, createUserAccessToken} from 'mattermost-redux/actions/users';
|
||||
@@ -13,12 +13,10 @@ import {getBotAccounts} from 'mattermost-redux/selectors/entities/bots';
|
||||
import {getConfig} from 'mattermost-redux/selectors/entities/general';
|
||||
import {haveISystemPermission} from 'mattermost-redux/selectors/entities/roles';
|
||||
import {getUser} from 'mattermost-redux/selectors/entities/users';
|
||||
import type {ActionFunc} from 'mattermost-redux/types/actions';
|
||||
|
||||
import type {GlobalState} from 'types/store';
|
||||
|
||||
import AddBot from './add_bot';
|
||||
import type {Props} from './add_bot';
|
||||
|
||||
type OwnProps = {
|
||||
|
||||
@@ -46,7 +44,7 @@ function mapStateToProps(state: GlobalState, ownProps: OwnProps) {
|
||||
|
||||
function mapDispatchToProps(dispatch: Dispatch) {
|
||||
return {
|
||||
actions: bindActionCreators<ActionCreatorsMapObject<ActionFunc>, Props['actions']>({
|
||||
actions: bindActionCreators({
|
||||
createBot,
|
||||
patchBot,
|
||||
uploadProfileImage,
|
||||
|
||||
@@ -84,14 +84,11 @@ type Props = {
|
||||
/**
|
||||
* Access token managment
|
||||
*/
|
||||
createUserAccessToken: (userId: string, description: string) => Promise<{
|
||||
data: {token: string; description: string; id: string; is_active: boolean} | null;
|
||||
error?: Error;
|
||||
}>;
|
||||
createUserAccessToken: (userId: string, description: string) => Promise<ActionResult<UserAccessToken>>;
|
||||
|
||||
revokeUserAccessToken: (tokenId: string) => Promise<{data: string; error?: Error}>;
|
||||
enableUserAccessToken: (tokenId: string) => Promise<{data: string; error?: Error}>;
|
||||
disableUserAccessToken: (tokenId: string) => Promise<{data: string; error?: Error}>;
|
||||
revokeUserAccessToken: (tokenId: string) => Promise<ActionResult>;
|
||||
enableUserAccessToken: (tokenId: string) => Promise<ActionResult>;
|
||||
disableUserAccessToken: (tokenId: string) => Promise<ActionResult>;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -59,7 +59,7 @@ type Props = {
|
||||
/**
|
||||
* Ensure we have bot accounts
|
||||
*/
|
||||
loadBots: (page?: number, perPage?: number) => Promise<{data: BotType[]; error?: Error}>;
|
||||
loadBots: (page?: number, perPage?: number) => Promise<ActionResult<BotType[]>>;
|
||||
|
||||
/**
|
||||
* Load access tokens for bot accounts
|
||||
@@ -69,14 +69,11 @@ type Props = {
|
||||
/**
|
||||
* Access token managment
|
||||
*/
|
||||
createUserAccessToken: (userId: string, description: string) => Promise<{
|
||||
data: {token: string; description: string; id: string; is_active: boolean} | null;
|
||||
error?: Error;
|
||||
}>;
|
||||
createUserAccessToken: (userId: string, description: string) => Promise<ActionResult<UserAccessToken>>;
|
||||
|
||||
revokeUserAccessToken: (tokenId: string) => Promise<{data: string; error?: Error}>;
|
||||
enableUserAccessToken: (tokenId: string) => Promise<{data: string; error?: Error}>;
|
||||
disableUserAccessToken: (tokenId: string) => Promise<{data: string; error?: Error}>;
|
||||
revokeUserAccessToken: (tokenId: string) => Promise<ActionResult>;
|
||||
enableUserAccessToken: (tokenId: string) => Promise<ActionResult>;
|
||||
disableUserAccessToken: (tokenId: string) => Promise<ActionResult>;
|
||||
|
||||
/**
|
||||
* Load owner of bot account
|
||||
|
||||
@@ -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 {Bot as BotType} from '@mattermost/types/bots';
|
||||
import type {GlobalState} from '@mattermost/types/store';
|
||||
@@ -17,7 +17,7 @@ import {getExternalBotAccounts} from 'mattermost-redux/selectors/entities/bots';
|
||||
import {getConfig} from 'mattermost-redux/selectors/entities/general';
|
||||
import {getAppsBotIDs} from 'mattermost-redux/selectors/entities/integrations';
|
||||
import * as UserSelectors from 'mattermost-redux/selectors/entities/users';
|
||||
import type {GenericAction, ActionResult, ActionFunc} from 'mattermost-redux/types/actions';
|
||||
import type {GenericAction} from 'mattermost-redux/types/actions';
|
||||
|
||||
import Bots from './bots';
|
||||
|
||||
@@ -48,25 +48,9 @@ function mapStateToProps(state: GlobalState) {
|
||||
};
|
||||
}
|
||||
|
||||
type Actions = {
|
||||
fetchAppsBotIDs: () => Promise<{data: string[]}>;
|
||||
loadBots: (page?: number, perPage?: number) => Promise<{data: BotType[]; error?: Error}>;
|
||||
getUserAccessTokensForUser: (userId: string, page?: number, perPage?: number) => void;
|
||||
createUserAccessToken: (userId: string, description: string) => Promise<{
|
||||
data: {token: string; description: string; id: string; is_active: boolean} | null;
|
||||
error?: Error;
|
||||
}>;
|
||||
revokeUserAccessToken: (tokenId: string) => Promise<{data: string; error?: Error}>;
|
||||
enableUserAccessToken: (tokenId: string) => Promise<{data: string; error?: Error}>;
|
||||
disableUserAccessToken: (tokenId: string) => Promise<{data: string; error?: Error}>;
|
||||
getUser: (userId: string) => void;
|
||||
disableBot: (userId: string) => Promise<ActionResult>;
|
||||
enableBot: (userId: string) => Promise<ActionResult>;
|
||||
}
|
||||
|
||||
function mapDispatchToProps(dispatch: Dispatch<GenericAction>) {
|
||||
return {
|
||||
actions: bindActionCreators<ActionCreatorsMapObject<ActionFunc>, Actions>({
|
||||
actions: bindActionCreators({
|
||||
fetchAppsBotIDs,
|
||||
loadBots,
|
||||
getUserAccessTokensForUser,
|
||||
|
||||
@@ -7,6 +7,8 @@ import React from 'react';
|
||||
import type {Command} from '@mattermost/types/integrations';
|
||||
import type {Team} from '@mattermost/types/teams';
|
||||
|
||||
import type {ActionResult} from 'mattermost-redux/types/actions';
|
||||
|
||||
import EditCommand from 'components/integrations/edit_command/edit_command';
|
||||
|
||||
import {TestHelper} from 'utils/test_helper';
|
||||
@@ -14,8 +16,8 @@ import {TestHelper} from 'utils/test_helper';
|
||||
describe('components/integrations/EditCommand', () => {
|
||||
const getCustomTeamCommands = jest.fn(
|
||||
() => {
|
||||
return new Promise<Command[]>((resolve) => {
|
||||
process.nextTick(() => resolve([]));
|
||||
return new Promise<ActionResult<Command[]>>((resolve) => {
|
||||
process.nextTick(() => resolve({data: []}));
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
@@ -8,6 +8,8 @@ import type {Command} from '@mattermost/types/integrations';
|
||||
import type {Team} from '@mattermost/types/teams';
|
||||
import type {RelationOneToOne} from '@mattermost/types/utilities';
|
||||
|
||||
import type {ActionResult} from 'mattermost-redux/types/actions';
|
||||
|
||||
import ConfirmModal from 'components/confirm_modal';
|
||||
import LoadingScreen from 'components/loading_screen';
|
||||
|
||||
@@ -41,12 +43,12 @@ type Props = {
|
||||
/**
|
||||
* The function to call to fetch team commands
|
||||
*/
|
||||
getCustomTeamCommands: (teamId: string) => Promise<Command[]>;
|
||||
getCustomTeamCommands: (teamId: string) => Promise<ActionResult>;
|
||||
|
||||
/**
|
||||
* The function to call to edit command
|
||||
*/
|
||||
editCommand: (command?: Command) => Promise<{data?: Command; error?: Error}>;
|
||||
editCommand: (command: Command) => Promise<ActionResult>;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -59,7 +61,6 @@ type State = {
|
||||
originalCommand: Command | null;
|
||||
showConfirmModal: boolean;
|
||||
serverError: string;
|
||||
|
||||
}
|
||||
|
||||
export default class EditCommand extends React.PureComponent<Props, State> {
|
||||
@@ -115,7 +116,7 @@ export default class EditCommand extends React.PureComponent<Props, State> {
|
||||
public submitCommand = async (): Promise<void> => {
|
||||
this.setState({serverError: ''});
|
||||
|
||||
const {data, error} = await this.props.actions.editCommand(this.newCommand);
|
||||
const {data, error} = await this.props.actions.editCommand(this.newCommand!);
|
||||
|
||||
if (data) {
|
||||
getHistory().push(`/${this.props.team.name}/integrations/commands`);
|
||||
|
||||
@@ -3,15 +3,13 @@
|
||||
|
||||
import {connect} from 'react-redux';
|
||||
import {bindActionCreators} from 'redux';
|
||||
import type {Dispatch, ActionCreatorsMapObject} from 'redux';
|
||||
import type {Dispatch} from 'redux';
|
||||
|
||||
import type {Command} from '@mattermost/types/integrations';
|
||||
import type {GlobalState} from '@mattermost/types/store';
|
||||
|
||||
import {editCommand, getCustomTeamCommands} from 'mattermost-redux/actions/integrations';
|
||||
import {getConfig} from 'mattermost-redux/selectors/entities/general';
|
||||
import {getCommands} from 'mattermost-redux/selectors/entities/integrations';
|
||||
import type {GenericAction, ActionFunc} from 'mattermost-redux/types/actions';
|
||||
|
||||
import EditCommand from './edit_command';
|
||||
|
||||
@@ -19,11 +17,6 @@ type Props = {
|
||||
location: Location;
|
||||
}
|
||||
|
||||
type Actions = {
|
||||
getCustomTeamCommands: (teamId: string) => Promise<Command[]>;
|
||||
editCommand: (command?: Command) => Promise<{data?: Command; error?: Error}>;
|
||||
}
|
||||
|
||||
function mapStateToProps(state: GlobalState, ownProps: Props) {
|
||||
const config = getConfig(state);
|
||||
const commandId = (new URLSearchParams(ownProps.location.search)).get('id');
|
||||
@@ -36,9 +29,9 @@ function mapStateToProps(state: GlobalState, ownProps: Props) {
|
||||
};
|
||||
}
|
||||
|
||||
function mapDispatchToProps(dispatch: Dispatch<GenericAction>) {
|
||||
function mapDispatchToProps(dispatch: Dispatch) {
|
||||
return {
|
||||
actions: bindActionCreators<ActionCreatorsMapObject<ActionFunc>, Actions>({
|
||||
actions: bindActionCreators({
|
||||
getCustomTeamCommands,
|
||||
editCommand,
|
||||
}, dispatch),
|
||||
|
||||
@@ -3,14 +3,12 @@
|
||||
|
||||
import {connect} from 'react-redux';
|
||||
import {bindActionCreators} from 'redux';
|
||||
import type {ActionCreatorsMapObject, Dispatch} from 'redux';
|
||||
import type {Dispatch} from 'redux';
|
||||
|
||||
import type {IncomingWebhook} from '@mattermost/types/integrations';
|
||||
import type {GlobalState} from '@mattermost/types/store';
|
||||
|
||||
import {getIncomingHook, updateIncomingHook} from 'mattermost-redux/actions/integrations';
|
||||
import {getConfig} from 'mattermost-redux/selectors/entities/general';
|
||||
import type {ActionFunc, ActionResult, GenericAction} from 'mattermost-redux/types/actions';
|
||||
|
||||
import EditIncomingWebhook from './edit_incoming_webhook';
|
||||
|
||||
@@ -18,11 +16,6 @@ type Props = {
|
||||
location: Location;
|
||||
}
|
||||
|
||||
type Actions = {
|
||||
updateIncomingHook: (hook: IncomingWebhook) => Promise<ActionResult>;
|
||||
getIncomingHook: (hookId: string) => Promise<ActionResult>;
|
||||
}
|
||||
|
||||
function mapStateToProps(state: GlobalState, ownProps: Props) {
|
||||
const config = getConfig(state);
|
||||
const enableIncomingWebhooks = config.EnableIncomingWebhooks === 'true';
|
||||
@@ -39,9 +32,9 @@ function mapStateToProps(state: GlobalState, ownProps: Props) {
|
||||
};
|
||||
}
|
||||
|
||||
function mapDispatchToProps(dispatch: Dispatch<GenericAction>) {
|
||||
function mapDispatchToProps(dispatch: Dispatch) {
|
||||
return {
|
||||
actions: bindActionCreators<ActionCreatorsMapObject<ActionFunc>, Actions>({
|
||||
actions: bindActionCreators({
|
||||
updateIncomingHook,
|
||||
getIncomingHook,
|
||||
}, dispatch),
|
||||
|
||||
@@ -21,7 +21,7 @@ const FOOTER = {id: 'update_incoming_webhook.update', defaultMessage: 'Update'};
|
||||
const LOADING = {id: 'update_incoming_webhook.updating', defaultMessage: 'Updating...'};
|
||||
|
||||
type Actions = {
|
||||
getOAuthApp: (id: string) => OAuthApp;
|
||||
getOAuthApp: (id: string) => void;
|
||||
editOAuthApp: (app: OAuthApp) => Promise<ActionResult>;
|
||||
};
|
||||
|
||||
|
||||
@@ -6,22 +6,15 @@
|
||||
|
||||
import {connect} from 'react-redux';
|
||||
import {bindActionCreators} from 'redux';
|
||||
import type {Dispatch, ActionCreatorsMapObject} from 'redux';
|
||||
import type {Dispatch} from 'redux';
|
||||
|
||||
import type {OAuthApp} from '@mattermost/types/integrations';
|
||||
import type {GlobalState} from '@mattermost/types/store';
|
||||
|
||||
import {getOAuthApp, editOAuthApp} from 'mattermost-redux/actions/integrations';
|
||||
import {getConfig} from 'mattermost-redux/selectors/entities/general';
|
||||
import type {ActionFunc, ActionResult} from 'mattermost-redux/types/actions';
|
||||
|
||||
import EditOAuthApp from './edit_oauth_app';
|
||||
|
||||
type Actions = {
|
||||
getOAuthApp: (id: string) => OAuthApp;
|
||||
editOAuthApp: (app: OAuthApp) => Promise<ActionResult>;
|
||||
};
|
||||
|
||||
type Props = {
|
||||
location: Location;
|
||||
};
|
||||
@@ -40,7 +33,7 @@ function mapStateToProps(state: GlobalState, ownProps: Props) {
|
||||
|
||||
function mapDispatchToProps(dispatch: Dispatch) {
|
||||
return {
|
||||
actions: bindActionCreators<ActionCreatorsMapObject<ActionFunc>, Actions>({
|
||||
actions: bindActionCreators({
|
||||
getOAuthApp,
|
||||
editOAuthApp,
|
||||
}, dispatch),
|
||||
|
||||
@@ -4,10 +4,11 @@
|
||||
import React from 'react';
|
||||
import {FormattedMessage} from 'react-intl';
|
||||
|
||||
import type {ServerError} from '@mattermost/types/errors';
|
||||
import type {OutgoingWebhook} from '@mattermost/types/integrations';
|
||||
import type {Team} from '@mattermost/types/teams';
|
||||
|
||||
import type {ActionResult} from 'mattermost-redux/types/actions';
|
||||
|
||||
import ConfirmModal from 'components/confirm_modal';
|
||||
import AbstractOutgoingWebhook from 'components/integrations/abstract_outgoing_webhook';
|
||||
import LoadingScreen from 'components/loading_screen';
|
||||
@@ -18,7 +19,7 @@ const HEADER = {id: 'integrations.edit', defaultMessage: 'Edit'};
|
||||
const FOOTER = {id: 'update_outgoing_webhook.update', defaultMessage: 'Update'};
|
||||
const LOADING = {id: 'update_outgoing_webhook.updating', defaultMessage: 'Updating...'};
|
||||
|
||||
interface Props {
|
||||
export interface Props {
|
||||
|
||||
/**
|
||||
* The current team
|
||||
@@ -39,12 +40,12 @@ interface Props {
|
||||
/**
|
||||
* The function to call to update an outgoing webhook
|
||||
*/
|
||||
updateOutgoingHook: (hook: OutgoingWebhook) => Promise<{ data: OutgoingWebhook; error: ServerError }>;
|
||||
updateOutgoingHook: (hook: OutgoingWebhook) => Promise<ActionResult<OutgoingWebhook>>;
|
||||
|
||||
/**
|
||||
* The function to call to get an outgoing webhook
|
||||
*/
|
||||
getOutgoingHook: (hookId: string) => Promise<{ data: OutgoingWebhook; error: ServerError }>;
|
||||
getOutgoingHook: (hookId: string) => Promise<ActionResult<OutgoingWebhook>>;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -121,7 +122,7 @@ export default class EditOutgoingWebhook extends React.PureComponent<Props, Stat
|
||||
submitHook = async (): Promise<void> => {
|
||||
this.setState({serverError: ''});
|
||||
|
||||
const {data, error}: {data: OutgoingWebhook; error: ServerError} = await this.props.actions.updateOutgoingHook(this.newHook!);
|
||||
const {data, error} = await this.props.actions.updateOutgoingHook(this.newHook!);
|
||||
|
||||
if (data) {
|
||||
getHistory().push(`/${this.props.team.name}/integrations/outgoing_webhooks`);
|
||||
|
||||
@@ -3,15 +3,12 @@
|
||||
|
||||
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 {OutgoingWebhook} from '@mattermost/types/integrations';
|
||||
import type {GlobalState} from '@mattermost/types/store';
|
||||
|
||||
import {getOutgoingHook, updateOutgoingHook} from 'mattermost-redux/actions/integrations';
|
||||
import {getConfig} from 'mattermost-redux/selectors/entities/general';
|
||||
import type {ActionFunc, GenericAction} from 'mattermost-redux/types/actions';
|
||||
|
||||
import EditOutgoingWebhook from './edit_outgoing_webhook';
|
||||
|
||||
@@ -21,11 +18,6 @@ type OwnProps = {
|
||||
};
|
||||
}
|
||||
|
||||
type Actions = {
|
||||
updateOutgoingHook: (hook: OutgoingWebhook) => Promise<{ data: OutgoingWebhook; error: ServerError }>;
|
||||
getOutgoingHook: (hookId: string) => Promise<{ data: OutgoingWebhook; error: ServerError }>;
|
||||
}
|
||||
|
||||
function mapStateToProps(state: GlobalState, ownProps: OwnProps) {
|
||||
const config = getConfig(state);
|
||||
const hookId = (new URLSearchParams(ownProps.location.search)).get('id');
|
||||
@@ -42,9 +34,9 @@ function mapStateToProps(state: GlobalState, ownProps: OwnProps) {
|
||||
};
|
||||
}
|
||||
|
||||
function mapDispatchToProps(dispatch: Dispatch<GenericAction>) {
|
||||
function mapDispatchToProps(dispatch: Dispatch) {
|
||||
return {
|
||||
actions: bindActionCreators<ActionCreatorsMapObject<ActionFunc>, Actions>({
|
||||
actions: bindActionCreators({
|
||||
updateOutgoingHook,
|
||||
getOutgoingHook,
|
||||
}, 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 type {GlobalState} from '@mattermost/types/store';
|
||||
|
||||
import {deleteCommand, regenCommandToken} from 'mattermost-redux/actions/integrations';
|
||||
import {Permissions} from 'mattermost-redux/constants';
|
||||
import {haveITeamPermission} from 'mattermost-redux/selectors/entities/roles';
|
||||
import type {GenericAction, ActionResult, ActionFunc} from 'mattermost-redux/types/actions';
|
||||
|
||||
import InstalledCommands from './installed_commands';
|
||||
|
||||
@@ -20,11 +19,6 @@ type Props = {
|
||||
};
|
||||
}
|
||||
|
||||
type Actions = {
|
||||
regenCommandToken: (id: string) => Promise<ActionResult>;
|
||||
deleteCommand: (id: string) => Promise<ActionResult>;
|
||||
}
|
||||
|
||||
function mapStateToProps(state: GlobalState, ownProps: Props) {
|
||||
const canManageOthersSlashCommands = haveITeamPermission(state, ownProps.team.id, Permissions.MANAGE_OTHERS_SLASH_COMMANDS);
|
||||
|
||||
@@ -33,9 +27,9 @@ function mapStateToProps(state: GlobalState, ownProps: Props) {
|
||||
};
|
||||
}
|
||||
|
||||
function mapDispatchToProps(dispatch: Dispatch<GenericAction>) {
|
||||
function mapDispatchToProps(dispatch: Dispatch) {
|
||||
return {
|
||||
actions: bindActionCreators<ActionCreatorsMapObject<ActionFunc>, Actions>({
|
||||
actions: bindActionCreators({
|
||||
regenCommandToken,
|
||||
deleteCommand,
|
||||
}, dispatch),
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -15,17 +15,11 @@ import {getIncomingHooks} from 'mattermost-redux/selectors/entities/integrations
|
||||
import {haveITeamPermission} from 'mattermost-redux/selectors/entities/roles';
|
||||
import {getCurrentTeamId} from 'mattermost-redux/selectors/entities/teams';
|
||||
import {getUsers} from 'mattermost-redux/selectors/entities/users';
|
||||
import type {ActionResult, GenericAction} from 'mattermost-redux/types/actions';
|
||||
|
||||
import {loadIncomingHooksAndProfilesForTeam} from 'actions/integration_actions';
|
||||
|
||||
import InstalledIncomingWebhooks from './installed_incoming_webhooks';
|
||||
|
||||
type Actions = {
|
||||
removeIncomingHook: (hookId: string) => Promise<ActionResult>;
|
||||
loadIncomingHooksAndProfilesForTeam: (teamId: string, startPageNumber: number, pageSize: string) => Promise<ActionResult>;
|
||||
}
|
||||
|
||||
function mapStateToProps(state: GlobalState) {
|
||||
const config = getConfig(state);
|
||||
const teamId = getCurrentTeamId(state);
|
||||
@@ -45,9 +39,9 @@ function mapStateToProps(state: GlobalState) {
|
||||
};
|
||||
}
|
||||
|
||||
function mapDispatchToProps(dispatch: Dispatch<GenericAction>) {
|
||||
function mapDispatchToProps(dispatch: Dispatch) {
|
||||
return {
|
||||
actions: bindActionCreators<ActionCreatorsMapObject<any>, Actions>({
|
||||
actions: bindActionCreators({
|
||||
loadIncomingHooksAndProfilesForTeam,
|
||||
removeIncomingHook,
|
||||
}, dispatch),
|
||||
|
||||
@@ -31,7 +31,7 @@ type Props = {
|
||||
actions: {
|
||||
removeIncomingHook: (hookId: string) => Promise<ActionResult>;
|
||||
loadIncomingHooksAndProfilesForTeam: (teamId: string, startPageNumber: number,
|
||||
pageSize: string) => Promise<ActionResult>;
|
||||
pageSize: number) => Promise<ActionResult>;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ export default class InstalledIncomingWebhooks extends React.PureComponent<Props
|
||||
this.props.actions.loadIncomingHooksAndProfilesForTeam(
|
||||
this.props.team.id,
|
||||
Constants.Integrations.START_PAGE_NUM,
|
||||
Constants.Integrations.PAGE_SIZE,
|
||||
Constants.Integrations.PAGE_SIZE as any, // HARRISONTODO PAGE_SIZE doesn't seem like it should be a string
|
||||
).then(
|
||||
() => this.setState({loading: false}),
|
||||
);
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -13,7 +13,6 @@ import {getConfig} from 'mattermost-redux/selectors/entities/general';
|
||||
import {getAppsOAuthAppIDs, getOAuthApps} from 'mattermost-redux/selectors/entities/integrations';
|
||||
import {haveISystemPermission} from 'mattermost-redux/selectors/entities/roles';
|
||||
import {getCurrentTeam} from 'mattermost-redux/selectors/entities/teams';
|
||||
import type {GenericAction} from 'mattermost-redux/types/actions';
|
||||
|
||||
import {loadOAuthAppsAndProfiles} from 'actions/integration_actions';
|
||||
|
||||
@@ -32,15 +31,9 @@ function mapStateToProps(state: GlobalState) {
|
||||
};
|
||||
}
|
||||
|
||||
type Actions = {
|
||||
loadOAuthAppsAndProfiles: (page?: number, perPage?: number) => Promise<void>;
|
||||
regenOAuthAppSecret: (appId: string) => Promise<{ error?: Error }>;
|
||||
deleteOAuthApp: (appId: string) => Promise<void>;
|
||||
}
|
||||
|
||||
function mapDispatchToProps(dispatch: Dispatch<GenericAction>) {
|
||||
function mapDispatchToProps(dispatch: Dispatch) {
|
||||
return {
|
||||
actions: bindActionCreators<ActionCreatorsMapObject, Actions>({
|
||||
actions: bindActionCreators({
|
||||
loadOAuthAppsAndProfiles,
|
||||
regenOAuthAppSecret,
|
||||
deleteOAuthApp,
|
||||
|
||||
@@ -6,6 +6,8 @@ import {FormattedMessage} from 'react-intl';
|
||||
|
||||
import type {OAuthApp} from '@mattermost/types/integrations';
|
||||
|
||||
import type {ActionResult} from 'mattermost-redux/types/actions';
|
||||
|
||||
import BackstageList from 'components/backstage/components/backstage_list';
|
||||
import ExternalLink from 'components/external_link';
|
||||
import FormattedMarkdownMessage from 'components/formatted_markdown_message';
|
||||
@@ -50,17 +52,17 @@ type Props = {
|
||||
/**
|
||||
* The function to call to fetch OAuth apps
|
||||
*/
|
||||
loadOAuthAppsAndProfiles: (page?: number, perPage?: number) => Promise<void>;
|
||||
loadOAuthAppsAndProfiles: (page?: number, perPage?: number) => Promise<ActionResult>;
|
||||
|
||||
/**
|
||||
* The function to call when Regenerate Secret link is clicked
|
||||
*/
|
||||
regenOAuthAppSecret: (appId: string) => Promise<{ error?: Error }>;
|
||||
regenOAuthAppSecret: (appId: string) => Promise<ActionResult>;
|
||||
|
||||
/**
|
||||
* The function to call when Delete link is clicked
|
||||
*/
|
||||
deleteOAuthApp: (appId: string) => Promise<void>;
|
||||
deleteOAuthApp: (appId: string) => Promise<ActionResult>;
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -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 * as Actions from 'mattermost-redux/actions/integrations';
|
||||
import {Permissions} from 'mattermost-redux/constants';
|
||||
@@ -19,7 +19,6 @@ import {loadOutgoingHooksAndProfilesForTeam} from 'actions/integration_actions';
|
||||
import type {GlobalState} from 'types/store';
|
||||
|
||||
import InstalledOutgoingWebhook from './installed_outgoing_webhooks';
|
||||
import type {Props} from './installed_outgoing_webhooks';
|
||||
|
||||
function mapStateToProps(state: GlobalState) {
|
||||
const config = getConfig(state);
|
||||
@@ -43,7 +42,7 @@ function mapStateToProps(state: GlobalState) {
|
||||
|
||||
function mapDispatchToProps(dispatch: Dispatch) {
|
||||
return {
|
||||
actions: bindActionCreators<ActionCreatorsMapObject<any>, Props['actions']>({
|
||||
actions: bindActionCreators({
|
||||
loadOutgoingHooksAndProfilesForTeam,
|
||||
removeOutgoingHook: Actions.removeOutgoingHook,
|
||||
regenOutgoingHookToken: Actions.regenOutgoingHookToken,
|
||||
|
||||
@@ -10,6 +10,8 @@ import type {Team} from '@mattermost/types/teams';
|
||||
import type {UserProfile} from '@mattermost/types/users';
|
||||
import type {IDMappedObjects} from '@mattermost/types/utilities';
|
||||
|
||||
import type {ActionResult} from 'mattermost-redux/types/actions';
|
||||
|
||||
import BackstageList from 'components/backstage/components/backstage_list';
|
||||
import ExternalLink from 'components/external_link';
|
||||
import FormattedMarkdownMessage from 'components/formatted_markdown_message';
|
||||
@@ -60,17 +62,17 @@ export type Props = {
|
||||
/**
|
||||
* The function to call for removing outgoingWebhook
|
||||
*/
|
||||
removeOutgoingHook: (hookId: string) => Promise<void>;
|
||||
removeOutgoingHook: (hookId: string) => Promise<ActionResult>;
|
||||
|
||||
/**
|
||||
* The function to call for outgoingWebhook List and for the status of api
|
||||
*/
|
||||
loadOutgoingHooksAndProfilesForTeam: (teamId: string, page: number, perPage: number) => Promise<void>;
|
||||
loadOutgoingHooksAndProfilesForTeam: (teamId: string, page: number, perPage: number) => Promise<ActionResult>;
|
||||
|
||||
/**
|
||||
* The function to call for regeneration of webhook token
|
||||
*/
|
||||
regenOutgoingHookToken: (hookId: string) => Promise<void>;
|
||||
regenOutgoingHookToken: (hookId: string) => Promise<ActionResult>;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Ссылка в новой задаче
Block a user