Improve Redux types part 4 (#26003)
* Fix return type of addUsersToChannel * Fix type of TeamInviteWithError.error * Change Constants.Integrations.PAGE_SIZE into a number"
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
8a869b0623
Коммит
e98aa55ad7
@@ -159,7 +159,9 @@ export function addUsersToChannel(channelId: Channel['id'], userIds: Array<UserP
|
|||||||
try {
|
try {
|
||||||
const requests = userIds.map((uId) => dispatch(ChannelActions.addChannelMember(channelId, uId)));
|
const requests = userIds.map((uId) => dispatch(ChannelActions.addChannelMember(channelId, uId)));
|
||||||
|
|
||||||
return await Promise.all(requests) as any; // HARRISONTODO This incorrectly returns an ActionResult[]
|
await Promise.all(requests);
|
||||||
|
|
||||||
|
return {data: true};
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return {error};
|
return {error};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ export function sendMembersInvites(teamId: string, users: UserProfile[], emails:
|
|||||||
data: emails.map((email) => ({
|
data: emails.map((email) => ({
|
||||||
email,
|
email,
|
||||||
error: {error: localizeMessage('invite.members.unable-to-add-the-user-to-the-team', 'Unable to add the user to the team.')},
|
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
|
})) as unknown as TeamInviteWithError[],
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
const invitesWithErrors = response.data || [];
|
const invitesWithErrors = response.data || [];
|
||||||
@@ -184,8 +184,8 @@ export function sendGuestsInvites(
|
|||||||
data: emails.map((email) => ({
|
data: emails.map((email) => ({
|
||||||
email,
|
email,
|
||||||
error: {error: localizeMessage('invite.guests.unable-to-add-the-user-to-the-channels', 'Unable to add the guest to the channels.')},
|
error: {error: localizeMessage('invite.guests.unable-to-add-the-user-to-the-channels', 'Unable to add the guest to the channels.')},
|
||||||
})),
|
})) as unknown as TeamInviteWithError[],
|
||||||
} as any; // HARRISONTODO These error handling cases return slightly different types
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (response.error) {
|
if (response.error) {
|
||||||
@@ -281,7 +281,7 @@ export function sendMembersInvitesToChannels(
|
|||||||
data: emails.map((email) => ({
|
data: emails.map((email) => ({
|
||||||
email,
|
email,
|
||||||
error: {error: localizeMessage('invite.members.unable-to-add-the-user-to-the-team', 'Unable to add the user to the team.')},
|
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
|
})) as unknown as TeamInviteWithError[],
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
const invitesWithErrors = response.data || [];
|
const invitesWithErrors = response.data || [];
|
||||||
|
|||||||
@@ -135,7 +135,7 @@ export default class SystemUsersDropdown extends React.PureComponent<Props, Stat
|
|||||||
if (this.shouldDisableBotsWhenOwnerIsDeactivated()) {
|
if (this.shouldDisableBotsWhenOwnerIsDeactivated()) {
|
||||||
await this.props.actions.loadBots(
|
await this.props.actions.loadBots(
|
||||||
Constants.Integrations.START_PAGE_NUM,
|
Constants.Integrations.START_PAGE_NUM,
|
||||||
parseInt(Constants.Integrations.PAGE_SIZE, 10),
|
Constants.Integrations.PAGE_SIZE,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
this.setState({showDeactivateMemberModal: true});
|
this.setState({showDeactivateMemberModal: true});
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ export type Props = {
|
|||||||
groups: Group[];
|
groups: Group[];
|
||||||
isGroupsEnabled: boolean;
|
isGroupsEnabled: boolean;
|
||||||
actions: {
|
actions: {
|
||||||
addUsersToChannel: (channelId: string, userIds: string[]) => Promise<any>;
|
addUsersToChannel: (channelId: string, userIds: string[]) => Promise<ActionResult>;
|
||||||
getProfilesNotInChannel: (teamId: string, channelId: string, groupConstrained: boolean, page: number, perPage?: number) => Promise<ActionResult>;
|
getProfilesNotInChannel: (teamId: string, channelId: string, groupConstrained: boolean, page: number, perPage?: number) => Promise<ActionResult>;
|
||||||
getProfilesInChannel: (channelId: string, page: number, perPage: number, sort: string, options: {active?: boolean}) => Promise<ActionResult>;
|
getProfilesInChannel: (channelId: string, page: number, perPage: number, sort: string, options: {active?: boolean}) => Promise<ActionResult>;
|
||||||
getTeamStats: (teamId: string) => void;
|
getTeamStats: (teamId: string) => void;
|
||||||
@@ -305,7 +305,7 @@ export class ChannelInviteModal extends React.PureComponent<Props, State> {
|
|||||||
|
|
||||||
this.setState({saving: true});
|
this.setState({saving: true});
|
||||||
|
|
||||||
actions.addUsersToChannel(channel.id, userIds).then((result: any) => {
|
actions.addUsersToChannel(channel.id, userIds).then((result) => {
|
||||||
if (result.error) {
|
if (result.error) {
|
||||||
this.handleInviteError(result.error);
|
this.handleInviteError(result.error);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -118,7 +118,7 @@ export default class Bots extends React.PureComponent<Props, State> {
|
|||||||
public componentDidMount(): void {
|
public componentDidMount(): void {
|
||||||
this.props.actions.loadBots(
|
this.props.actions.loadBots(
|
||||||
Constants.Integrations.START_PAGE_NUM,
|
Constants.Integrations.START_PAGE_NUM,
|
||||||
parseInt(Constants.Integrations.PAGE_SIZE, 10),
|
Constants.Integrations.PAGE_SIZE,
|
||||||
).then(
|
).then(
|
||||||
(result) => {
|
(result) => {
|
||||||
if (result.data) {
|
if (result.data) {
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ export default class InstalledIncomingWebhooks extends React.PureComponent<Props
|
|||||||
this.props.actions.loadIncomingHooksAndProfilesForTeam(
|
this.props.actions.loadIncomingHooksAndProfilesForTeam(
|
||||||
this.props.team.id,
|
this.props.team.id,
|
||||||
Constants.Integrations.START_PAGE_NUM,
|
Constants.Integrations.START_PAGE_NUM,
|
||||||
Constants.Integrations.PAGE_SIZE as any, // HARRISONTODO PAGE_SIZE doesn't seem like it should be a string
|
Constants.Integrations.PAGE_SIZE,
|
||||||
).then(
|
).then(
|
||||||
() => this.setState({loading: false}),
|
() => this.setState({loading: false}),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ export default class InstalledOutgoingWebhooks extends React.PureComponent<Props
|
|||||||
this.props.actions.loadOutgoingHooksAndProfilesForTeam(
|
this.props.actions.loadOutgoingHooksAndProfilesForTeam(
|
||||||
this.props.teamId,
|
this.props.teamId,
|
||||||
Constants.Integrations.START_PAGE_NUM,
|
Constants.Integrations.START_PAGE_NUM,
|
||||||
parseInt(Constants.Integrations.PAGE_SIZE, 10),
|
Constants.Integrations.PAGE_SIZE,
|
||||||
).then(
|
).then(
|
||||||
() => this.setState({loading: false}),
|
() => this.setState({loading: false}),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1931,7 +1931,7 @@ export const Constants = {
|
|||||||
},
|
},
|
||||||
Integrations: {
|
Integrations: {
|
||||||
COMMAND: 'commands',
|
COMMAND: 'commands',
|
||||||
PAGE_SIZE: '10000',
|
PAGE_SIZE: 10000,
|
||||||
START_PAGE_NUM: 0,
|
START_PAGE_NUM: 0,
|
||||||
INCOMING_WEBHOOK: 'incoming_webhooks',
|
INCOMING_WEBHOOK: 'incoming_webhooks',
|
||||||
OUTGOING_WEBHOOK: 'outgoing_webhooks',
|
OUTGOING_WEBHOOK: 'outgoing_webhooks',
|
||||||
|
|||||||
@@ -1535,7 +1535,7 @@ export default class Client4 {
|
|||||||
sendEmailGuestInvitesToChannelsGracefully = async (teamId: string, channelIds: string[], emails: string[], message: string) => {
|
sendEmailGuestInvitesToChannelsGracefully = async (teamId: string, channelIds: string[], emails: string[], message: string) => {
|
||||||
this.trackEvent('api', 'api_teams_invite_guests', {team_id: teamId, channel_ids: channelIds});
|
this.trackEvent('api', 'api_teams_invite_guests', {team_id: teamId, channel_ids: channelIds});
|
||||||
|
|
||||||
return this.doFetch<TeamInviteWithError>(
|
return this.doFetch<TeamInviteWithError[]>(
|
||||||
`${this.getTeamRoute(teamId)}/invite-guests/email?graceful=true`,
|
`${this.getTeamRoute(teamId)}/invite-guests/email?graceful=true`,
|
||||||
{method: 'post', body: JSON.stringify({emails, channels: channelIds, message})},
|
{method: 'post', body: JSON.stringify({emails, channels: channelIds, message})},
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -109,5 +109,10 @@ export type NotPagedTeamSearchOpts = {
|
|||||||
|
|
||||||
export type TeamInviteWithError = {
|
export type TeamInviteWithError = {
|
||||||
email: string;
|
email: string;
|
||||||
error: ServerError;
|
|
||||||
|
// Unlike ServerError, error uses field names directly from model.AppError on the server
|
||||||
|
error: {
|
||||||
|
id: string;
|
||||||
|
message: string;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user