* 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 удалений

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

@@ -82,6 +82,7 @@ import {
CustomGroupPatch,
GetGroupsParams,
GetGroupsForUserParams,
GroupStats,
} from '@mattermost/types/groups';
import {PostActionResponse} from '@mattermost/types/integration_actions';
import {
@@ -123,6 +124,8 @@ import {
TeamsWithCount,
TeamUnread,
TeamSearchOpts,
PagedTeamSearchOpts,
NotPagedTeamSearchOpts,
} from '@mattermost/types/teams';
import {TermsOfService} from '@mattermost/types/terms_of_service';
import {
@@ -1272,7 +1275,9 @@ export default class Client4 {
);
};
searchTeams = (term: string, opts: TeamSearchOpts) => {
searchTeams(term: string, opts: PagedTeamSearchOpts): Promise<Team[]>;
searchTeams(term: string, opts: NotPagedTeamSearchOpts): Promise<TeamsWithCount>;
searchTeams (term: string, opts: TeamSearchOpts): Promise<Team[] | TeamsWithCount> {
this.trackEvent('api', 'api_search_teams');
return this.doFetch<Team[] | TeamsWithCount>(
@@ -1325,7 +1330,7 @@ export default class Client4 {
);
};
getTeamMembers = (teamId: string, page = 0, perPage = PER_PAGE_DEFAULT, options: GetTeamMembersOpts) => {
getTeamMembers = (teamId: string, page = 0, perPage = PER_PAGE_DEFAULT, options?: GetTeamMembersOpts) => {
return this.doFetch<TeamMembership[]>(
`${this.getTeamMembersRoute(teamId)}${buildQueryString({page, per_page: perPage, ...options})}`,
{method: 'get'},
@@ -1482,7 +1487,7 @@ export default class Client4 {
sendEmailInvitesToTeamGracefully = (teamId: string, emails: string[]) => {
this.trackEvent('api', 'api_teams_invite_members', {team_id: teamId});
return this.doFetch<TeamInviteWithError>(
return this.doFetch<TeamInviteWithError[]>(
`${this.getTeamRoute(teamId)}/invite/email?graceful=true`,
{method: 'post', body: JSON.stringify(emails)},
);
@@ -1496,7 +1501,7 @@ export default class Client4 {
) => {
this.trackEvent('api', 'api_teams_invite_members_to_channels', {team_id: teamId, channel_len: channelIds.length});
return this.doFetch<TeamInviteWithError>(
return this.doFetch<TeamInviteWithError[]>(
`${this.getTeamRoute(teamId)}/invite/email?graceful=true`,
{method: 'post', body: JSON.stringify({emails, channelIds, message})},
);
@@ -1556,7 +1561,25 @@ export default class Client4 {
// Channel Routes
getAllChannels = (page = 0, perPage = PER_PAGE_DEFAULT, notAssociatedToGroup = '', excludeDefaultChannels = false, includeTotalCount = false, includeDeleted = false, excludePolicyConstrained = false) => {
getAllChannels(
page: number | undefined,
perPage: number | undefined,
notAssociatedToGroup: string | undefined,
excludeDefaultChannels: boolean | undefined,
includeTotalCount: false | undefined,
includeDeleted: boolean | undefined,
excludePolicyConstrained: boolean | undefined
): Promise<ChannelWithTeamData[]>;
getAllChannels(
page: number | undefined,
perPage: number | undefined,
notAssociatedToGroup: string | undefined,
excludeDefaultChannels: boolean | undefined,
includeTotalCount: true,
includeDeleted: boolean | undefined,
excludePolicyConstrained: boolean | undefined
): Promise<ChannelsWithTotalCount>;
getAllChannels(page = 0, perPage = PER_PAGE_DEFAULT, notAssociatedToGroup = '', excludeDefaultChannels = false, includeTotalCount = false, includeDeleted = false, excludePolicyConstrained = false) {
const queryData = {
page,
per_page: perPage,
@@ -1867,7 +1890,9 @@ export default class Client4 {
);
};
searchAllChannels = (term: string, opts: ChannelSearchOpts = {}) => {
searchAllChannels(term: string, opts: {page: number; per_page: number} & ChannelSearchOpts): Promise<ChannelsWithTotalCount>;
searchAllChannels(term: string, opts: Omit<ChannelSearchOpts, 'page' | 'per_page'> | undefined): Promise<ChannelWithTeamData[]>;
searchAllChannels(term: string, opts: ChannelSearchOpts = {}) {
const body = {
term,
...opts,
@@ -1879,7 +1904,7 @@ export default class Client4 {
queryParams = {system_console: false};
delete body.nonAdminSearch;
}
return this.doFetch<Channel[] | ChannelsWithTotalCount>(
return this.doFetch<ChannelWithTeamData[] | ChannelsWithTotalCount>(
`${this.getChannelsRoute()}/search${buildQueryString(queryParams)}`,
{method: 'post', body: JSON.stringify(body)},
);
@@ -3520,7 +3545,7 @@ export default class Client4 {
};
// Groups
linkGroupSyncable = (groupID: string, syncableID: string, syncableType: string, patch: SyncablePatch) => {
linkGroupSyncable = (groupID: string, syncableID: string, syncableType: string, patch: Partial<SyncablePatch>) => {
return this.doFetch<GroupSyncable>(
`${this.getGroupRoute(groupID)}/${syncableType}s/${syncableID}/link`,
{method: 'post', body: JSON.stringify(patch)},
@@ -3549,7 +3574,7 @@ export default class Client4 {
};
getGroupStats = (groupID: string) => {
return this.doFetch<Group>(
return this.doFetch<GroupStats>(
`${this.getGroupRoute(groupID)}/stats`,
{method: 'get'},
);
@@ -3697,7 +3722,7 @@ export default class Client4 {
);
};
patchGroupSyncable = (groupID: string, syncableID: string, syncableType: string, patch: SyncablePatch) => {
patchGroupSyncable = (groupID: string, syncableID: string, syncableType: string, patch: Partial<SyncablePatch>) => {
return this.doFetch<GroupSyncable>(
`${this.getGroupRoute(groupID)}/${syncableType}s/${syncableID}/patch`,
{method: 'put', body: JSON.stringify(patch)},
@@ -3741,7 +3766,7 @@ export default class Client4 {
);
}
patchBot = (botUserId: string, botPatch: BotPatch) => {
patchBot = (botUserId: string, botPatch: Partial<BotPatch>) => {
return this.doFetch<Bot>(
`${this.getBotRoute(botUserId)}`,
{method: 'put', body: JSON.stringify(botPatch)},