* Always dispatch thunk actions instead of calling them

* Properly dispatch actions in SwitchChannelProvider

* Fix tests relying on bad types

* Properly pass actions into ManageTokens

* Make other logic changes to support new types

* Do the big type migrations without any logic changes

* Revert "Properly dispatch actions in SwitchChannelProvider"

This reverts commit 28c8c7af2ef324c6814087a81baca66c60477daa.

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

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

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

@@ -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),