Improve typing of bindClientFunc/Improve Redux types part 2 (#25915)

* Improve typing of bindClientFunc

* Slight logic changes

* Remove unused import
This commit is contained in:
Harrison Healey
2024-01-17 13:06:46 -05:00
committed by GitHub
parent ce8cf7e8db
commit 584c2e766c
25 changed files with 341 additions and 336 deletions

View File

@@ -182,7 +182,7 @@ export function retryFailedHostedCustomerFetches() {
};
}
export function submitTrueUpReview(): ActionFunc {
export function submitTrueUpReview() {
return bindClientFunc({
clientFunc: Client4.submitTrueUpReview,
onSuccess: [HostedCustomerTypes.RECEIVED_TRUE_UP_REVIEW_BUNDLE],
@@ -191,7 +191,7 @@ export function submitTrueUpReview(): ActionFunc {
});
}
export function getTrueUpReviewStatus(): ActionFunc {
export function getTrueUpReviewStatus() {
return bindClientFunc({
clientFunc: Client4.getTrueUpReviewStatus,
onSuccess: [HostedCustomerTypes.RECEIVED_TRUE_UP_REVIEW_STATUS],

View File

@@ -44,7 +44,7 @@ type Props = {
createJob: (job: JobTypeBase) => Promise<ActionResult>;
getJobsByType: (job: JobType) => Promise<ActionResult>;
deleteDataRetentionCustomPolicy: (id: string) => Promise<ActionResult>;
updateConfig: (config: Record<string, any>) => Promise<ActionResult>;
updateConfig: (config: AdminConfig) => Promise<ActionResult>;
};
} & WrappedComponentProps;

View File

@@ -32,7 +32,7 @@ type Props = {
fileRetentionHours: string | undefined;
environmentConfig: Partial<EnvironmentConfig>;
actions: {
updateConfig: (config: Record<string, any>) => Promise<ActionResult>;
updateConfig: (config: AdminConfig) => Promise<ActionResult>;
setNavigationBlocked: (blocked: boolean) => void;
};
};

View File

@@ -33,7 +33,7 @@ type Props = {
isDisabled?: boolean;
actions: {
loadRolesIfNeeded: (roles: string[]) => void;
editRole: (role: Partial<Role>) => Promise<ActionResult>;
editRole: (role: Partial<Role> & {id: string}) => Promise<ActionResult>;
setNavigationBlocked: (blocked: boolean) => void;
};
location: Location;
@@ -45,12 +45,24 @@ type State = {
saving: boolean;
saveNeeded: boolean;
serverError: null;
roles: Record<string, Partial<Role>>;
roles: RolesState;
selectedPermission?: string;
openRoles: Record<string, boolean>;
urlParams: URLSearchParams;
}
type RolesState = {
system_admin: Role;
team_admin: Role;
channel_admin: Role;
playbook_admin: Role;
playbook_member: Role;
run_admin: Role;
run_member: Role;
all_users: {name: string; display_name: string; permissions: Role['permissions']};
guests: {name: string; display_name: string; permissions: Role['permissions']};
}
class PermissionSystemSchemeSettings extends React.PureComponent<Props, State> {
private rolesNeeded: string[];
@@ -62,7 +74,7 @@ class PermissionSystemSchemeSettings extends React.PureComponent<Props, State> {
saving: false,
saveNeeded: false,
serverError: null,
roles: {},
roles: {} as RolesState,
openRoles: {
guests: true,
all_users: true,
@@ -173,7 +185,7 @@ class PermissionSystemSchemeSettings extends React.PureComponent<Props, State> {
});
}
deriveRolesFromAllUsers = (role: Partial<Role>): Record<string, Partial<Role>> => {
deriveRolesFromAllUsers = (role: RolesState['all_users']): Record<string, Role> => {
return {
system_user: {
...this.props.roles.system_user,
@@ -198,7 +210,7 @@ class PermissionSystemSchemeSettings extends React.PureComponent<Props, State> {
};
};
deriveRolesFromGuests = (role: Partial<Role>): Record<string, Partial<Role>> => {
deriveRolesFromGuests = (role: RolesState['guests']): Record<string, Role> => {
return {
system_guest: {
...this.props.roles.system_guest,
@@ -215,7 +227,7 @@ class PermissionSystemSchemeSettings extends React.PureComponent<Props, State> {
};
};
restoreExcludedPermissions = (roles: Record<string, Partial<Role>>) => {
restoreExcludedPermissions = (roles: Record<string, Role>) => {
for (const permission of this.props.roles.system_user.permissions) {
if (EXCLUDED_PERMISSIONS.includes(permission)) {
roles.system_user.permissions?.push(permission);
@@ -239,7 +251,7 @@ class PermissionSystemSchemeSettings extends React.PureComponent<Props, State> {
return roles;
};
restoreGuestPermissions = (roles: Record<string, Partial<Role>>) => {
restoreGuestPermissions = (roles: Record<string, Role>) => {
for (const permission of this.props.roles.system_guest.permissions) {
if (!GUEST_INCLUDED_PERMISSIONS.includes(permission)) {
roles.system_guest.permissions?.push(permission);
@@ -314,7 +326,7 @@ class PermissionSystemSchemeSettings extends React.PureComponent<Props, State> {
togglePermission = (roleId: string, permissions: Iterable<string>) => {
const roles = {...this.state.roles};
const role = {...roles[roleId]};
const role = {...roles[roleId as keyof RolesState]} as Role;
const newPermissions = [...role.permissions!];
for (const permission of permissions) {
if (newPermissions.indexOf(permission) === -1) {
@@ -324,7 +336,7 @@ class PermissionSystemSchemeSettings extends React.PureComponent<Props, State> {
}
}
role.permissions = newPermissions;
roles[roleId] = role;
roles[roleId as keyof RolesState] = role;
this.setState({roles, saveNeeded: true});
this.props.actions.setNavigationBlocked(true);

View File

@@ -5,6 +5,7 @@ import fs from 'fs';
import nock from 'nock';
import type {AdminConfig} from '@mattermost/types/config';
import type {CreateDataRetentionCustomPolicy} from '@mattermost/types/data_retention';
import * as Actions from 'mattermost-redux/actions/admin';
@@ -567,7 +568,7 @@ describe('Actions.Admin', () => {
post('/elasticsearch/test').
reply(200, OK_RESPONSE);
await store.dispatch(Actions.testElasticsearch({}));
await store.dispatch(Actions.testElasticsearch({} as AdminConfig));
expect(nock.isDone()).toBe(true);
});

View File

@@ -3,14 +3,13 @@
import {batchActions} from 'redux-batched-actions';
import type {LogFilter, SchemaMigration} from '@mattermost/types/admin';
import type {Audit} from '@mattermost/types/audits';
import type {LogFilter} from '@mattermost/types/admin';
import type {
Channel,
ChannelSearchOpts,
} from '@mattermost/types/channels';
import type {Compliance} from '@mattermost/types/compliance';
import type {AdminConfig, AllowedIPRange, License} from '@mattermost/types/config';
import type {AdminConfig, AllowedIPRange} from '@mattermost/types/config';
import type {
CreateDataRetentionCustomPolicy,
DataRetentionCustomPolicies,
@@ -18,8 +17,7 @@ import type {
PatchDataRetentionCustomPolicy,
} from '@mattermost/types/data_retention';
import type {ServerError} from '@mattermost/types/errors';
import type {GroupSearchOpts, MixedUnlinkedGroup} from '@mattermost/types/groups';
import type {SamlMetadataResponse} from '@mattermost/types/saml';
import type {GroupSearchOpts} from '@mattermost/types/groups';
import type {CompleteOnboardingRequest} from '@mattermost/types/setup';
import type {
Team,
@@ -36,7 +34,7 @@ import {bindClientFunc, forceLogoutIfNecessary} from './helpers';
import {General} from '../constants';
export function getLogs({serverNames = [], logLevels = [], dateFrom, dateTo}: LogFilter): NewActionFuncAsync<string[]> {
export function getLogs({serverNames = [], logLevels = [], dateFrom, dateTo}: LogFilter) {
const logFilter = {
server_names: serverNames,
log_levels: logLevels,
@@ -49,10 +47,10 @@ export function getLogs({serverNames = [], logLevels = [], dateFrom, dateTo}: Lo
params: [
logFilter,
],
}) as any; // HARRISONTODO Type bindClientFunc
});
}
export function getPlainLogs(page = 0, perPage: number = General.LOGS_PAGE_SIZE_DEFAULT): NewActionFuncAsync<string[]> {
export function getPlainLogs(page = 0, perPage: number = General.LOGS_PAGE_SIZE_DEFAULT) {
return bindClientFunc({
clientFunc: Client4.getPlainLogs,
onSuccess: [AdminTypes.RECEIVED_PLAIN_LOGS],
@@ -60,10 +58,10 @@ export function getPlainLogs(page = 0, perPage: number = General.LOGS_PAGE_SIZE_
page,
perPage,
],
}) as any; // HARRISONTODO Type bindClientFunc
});
}
export function getAudits(page = 0, perPage: number = General.PAGE_SIZE_DEFAULT): NewActionFuncAsync<Audit[]> {
export function getAudits(page = 0, perPage: number = General.PAGE_SIZE_DEFAULT) {
return bindClientFunc({
clientFunc: Client4.getAudits,
onSuccess: [AdminTypes.RECEIVED_AUDITS],
@@ -71,40 +69,40 @@ export function getAudits(page = 0, perPage: number = General.PAGE_SIZE_DEFAULT)
page,
perPage,
],
}) as any; // HARRISONTODO Type bindClientFunc
});
}
export function getConfig(): ActionFunc {
export function getConfig() {
return bindClientFunc({
clientFunc: Client4.getConfig,
onSuccess: [AdminTypes.RECEIVED_CONFIG],
});
}
export function updateConfig(config: Record<string, unknown>): NewActionFuncAsync<Partial<AdminConfig>> {
export function updateConfig(config: AdminConfig) {
return bindClientFunc({
clientFunc: Client4.updateConfig,
onSuccess: [AdminTypes.RECEIVED_CONFIG],
params: [
config,
],
}) as any; // HARRISONTODO Type bindClientFunc
});
}
export function reloadConfig(): ActionFunc {
export function reloadConfig() {
return bindClientFunc({
clientFunc: Client4.reloadConfig,
});
}
export function getEnvironmentConfig(): ActionFunc {
export function getEnvironmentConfig() {
return bindClientFunc({
clientFunc: Client4.getEnvironmentConfig,
onSuccess: [AdminTypes.RECEIVED_ENVIRONMENT_CONFIG],
});
}
export function testEmail(config: unknown): ActionFunc {
export function testEmail(config?: AdminConfig) {
return bindClientFunc({
clientFunc: Client4.testEmail,
params: [
@@ -113,7 +111,7 @@ export function testEmail(config: unknown): ActionFunc {
});
}
export function testSiteURL(siteURL: string): ActionFunc {
export function testSiteURL(siteURL: string) {
return bindClientFunc({
clientFunc: Client4.testSiteURL,
params: [
@@ -122,7 +120,7 @@ export function testSiteURL(siteURL: string): ActionFunc {
});
}
export function testS3Connection(config: unknown): ActionFunc {
export function testS3Connection(config?: AdminConfig) {
return bindClientFunc({
clientFunc: Client4.testS3Connection,
params: [
@@ -131,19 +129,19 @@ export function testS3Connection(config: unknown): ActionFunc {
});
}
export function invalidateCaches(): ActionFunc {
export function invalidateCaches() {
return bindClientFunc({
clientFunc: Client4.invalidateCaches,
});
}
export function recycleDatabase(): ActionFunc {
export function recycleDatabase() {
return bindClientFunc({
clientFunc: Client4.recycleDatabase,
});
}
export function createComplianceReport(job: Partial<Compliance>): NewActionFuncAsync<Compliance> {
export function createComplianceReport(job: Partial<Compliance>) {
return bindClientFunc({
clientFunc: Client4.createComplianceReport,
onRequest: AdminTypes.CREATE_COMPLIANCE_REQUEST,
@@ -152,10 +150,10 @@ export function createComplianceReport(job: Partial<Compliance>): NewActionFuncA
params: [
job,
],
}) as any; // HARRISONTODO Type bindClientFunc
});
}
export function getComplianceReport(reportId: string): ActionFunc {
export function getComplianceReport(reportId: string) {
return bindClientFunc({
clientFunc: Client4.getComplianceReport,
onSuccess: [AdminTypes.RECEIVED_COMPLIANCE_REPORT],
@@ -165,7 +163,7 @@ export function getComplianceReport(reportId: string): ActionFunc {
});
}
export function getComplianceReports(page = 0, perPage: number = General.PAGE_SIZE_DEFAULT): NewActionFuncAsync<Compliance[]> {
export function getComplianceReports(page = 0, perPage: number = General.PAGE_SIZE_DEFAULT) {
return bindClientFunc({
clientFunc: Client4.getComplianceReports,
onSuccess: [AdminTypes.RECEIVED_COMPLIANCE_REPORTS],
@@ -173,10 +171,10 @@ export function getComplianceReports(page = 0, perPage: number = General.PAGE_SI
page,
perPage,
],
}) as any; // HARRISONTODO Type bindClientFunc
});
}
export function uploadBrandImage(imageData: File): ActionFunc {
export function uploadBrandImage(imageData: File) {
return bindClientFunc({
clientFunc: Client4.uploadBrandImage,
params: [
@@ -185,32 +183,32 @@ export function uploadBrandImage(imageData: File): ActionFunc {
});
}
export function deleteBrandImage(): ActionFunc {
export function deleteBrandImage() {
return bindClientFunc({
clientFunc: Client4.deleteBrandImage,
});
}
export function getClusterStatus(): ActionFunc {
export function getClusterStatus() {
return bindClientFunc({
clientFunc: Client4.getClusterStatus,
onSuccess: [AdminTypes.RECEIVED_CLUSTER_STATUS],
});
}
export function testLdap(): ActionFunc {
export function testLdap() {
return bindClientFunc({
clientFunc: Client4.testLdap,
});
}
export function syncLdap(): ActionFunc {
export function syncLdap() {
return bindClientFunc({
clientFunc: Client4.syncLdap,
});
}
export function getLdapGroups(page = 0, perPage: number = General.PAGE_SIZE_MAXIMUM, opts: GroupSearchOpts = {q: ''}): NewActionFuncAsync<{count: number; groups: MixedUnlinkedGroup[]}> {
export function getLdapGroups(page = 0, perPage: number = General.PAGE_SIZE_MAXIMUM, opts: GroupSearchOpts = {q: ''}) {
return bindClientFunc({
clientFunc: Client4.getLdapGroups,
onSuccess: [AdminTypes.RECEIVED_LDAP_GROUPS],
@@ -219,7 +217,7 @@ export function getLdapGroups(page = 0, perPage: number = General.PAGE_SIZE_MAXI
perPage,
opts,
],
}) as any; // HARRISONTODO Type bindClientFunc
});
}
export function linkLdapGroup(key: string): NewActionFuncAsync {
@@ -268,14 +266,14 @@ export function unlinkLdapGroup(key: string): NewActionFuncAsync {
};
}
export function getSamlCertificateStatus(): ActionFunc {
export function getSamlCertificateStatus() {
return bindClientFunc({
clientFunc: Client4.getSamlCertificateStatus,
onSuccess: [AdminTypes.RECEIVED_SAML_CERT_STATUS],
});
}
export function uploadPublicSamlCertificate(fileData: File): ActionFunc {
export function uploadPublicSamlCertificate(fileData: File) {
return bindClientFunc({
clientFunc: Client4.uploadPublicSamlCertificate,
params: [
@@ -284,7 +282,7 @@ export function uploadPublicSamlCertificate(fileData: File): ActionFunc {
});
}
export function uploadPrivateSamlCertificate(fileData: File): ActionFunc {
export function uploadPrivateSamlCertificate(fileData: File) {
return bindClientFunc({
clientFunc: Client4.uploadPrivateSamlCertificate,
params: [
@@ -293,7 +291,7 @@ export function uploadPrivateSamlCertificate(fileData: File): ActionFunc {
});
}
export function uploadPublicLdapCertificate(fileData: File): ActionFunc {
export function uploadPublicLdapCertificate(fileData: File) {
return bindClientFunc({
clientFunc: Client4.uploadPublicLdapCertificate,
params: [
@@ -302,7 +300,7 @@ export function uploadPublicLdapCertificate(fileData: File): ActionFunc {
});
}
export function uploadPrivateLdapCertificate(fileData: File): ActionFunc {
export function uploadPrivateLdapCertificate(fileData: File) {
return bindClientFunc({
clientFunc: Client4.uploadPrivateLdapCertificate,
params: [
@@ -311,7 +309,7 @@ export function uploadPrivateLdapCertificate(fileData: File): ActionFunc {
});
}
export function uploadIdpSamlCertificate(fileData: File): ActionFunc {
export function uploadIdpSamlCertificate(fileData: File) {
return bindClientFunc({
clientFunc: Client4.uploadIdpSamlCertificate,
params: [
@@ -320,37 +318,37 @@ export function uploadIdpSamlCertificate(fileData: File): ActionFunc {
});
}
export function removePublicSamlCertificate(): ActionFunc {
export function removePublicSamlCertificate() {
return bindClientFunc({
clientFunc: Client4.deletePublicSamlCertificate,
});
}
export function removePrivateSamlCertificate(): ActionFunc {
export function removePrivateSamlCertificate() {
return bindClientFunc({
clientFunc: Client4.deletePrivateSamlCertificate,
});
}
export function removePublicLdapCertificate(): ActionFunc {
export function removePublicLdapCertificate() {
return bindClientFunc({
clientFunc: Client4.deletePublicLdapCertificate,
});
}
export function removePrivateLdapCertificate(): ActionFunc {
export function removePrivateLdapCertificate() {
return bindClientFunc({
clientFunc: Client4.deletePrivateLdapCertificate,
});
}
export function removeIdpSamlCertificate(): ActionFunc {
export function removeIdpSamlCertificate() {
return bindClientFunc({
clientFunc: Client4.deleteIdpSamlCertificate,
});
}
export function testElasticsearch(config: unknown): ActionFunc {
export function testElasticsearch(config?: AdminConfig) {
return bindClientFunc({
clientFunc: Client4.testElasticsearch,
params: [
@@ -359,19 +357,19 @@ export function testElasticsearch(config: unknown): ActionFunc {
});
}
export function purgeElasticsearchIndexes(): ActionFunc {
export function purgeElasticsearchIndexes() {
return bindClientFunc({
clientFunc: Client4.purgeElasticsearchIndexes,
});
}
export function uploadLicense(fileData: File): NewActionFuncAsync<License> {
export function uploadLicense(fileData: File) {
return bindClientFunc({
clientFunc: Client4.uploadLicense,
params: [
fileData,
],
}) as any; // HARRISONTODO Type bindClientFunc
});
}
export function removeLicense(): NewActionFuncAsync<boolean> {
@@ -476,14 +474,14 @@ export function installPluginFromUrl(url: string, force = false): ActionFunc {
};
}
export function getPlugins(): ActionFunc {
export function getPlugins() {
return bindClientFunc({
clientFunc: Client4.getPlugins,
onSuccess: [AdminTypes.RECEIVED_PLUGINS],
});
}
export function getPluginStatuses(): ActionFunc {
export function getPluginStatuses() {
return bindClientFunc({
clientFunc: Client4.getPluginStatuses,
onSuccess: [AdminTypes.RECEIVED_PLUGIN_STATUSES],
@@ -543,23 +541,23 @@ export function disablePlugin(pluginId: string): NewActionFuncAsync {
};
}
export function getSamlMetadataFromIdp(samlMetadataURL: string): NewActionFuncAsync<SamlMetadataResponse> {
export function getSamlMetadataFromIdp(samlMetadataURL: string) {
return bindClientFunc({
clientFunc: Client4.getSamlMetadataFromIdp,
onSuccess: AdminTypes.RECEIVED_SAML_METADATA_RESPONSE,
params: [
samlMetadataURL,
],
}) as any; // HARRISONTODO Type bindClientFunc
});
}
export function setSamlIdpCertificateFromMetadata(certData: string): NewActionFuncAsync {
export function setSamlIdpCertificateFromMetadata(certData: string) {
return bindClientFunc({
clientFunc: Client4.setSamlIdpCertificateFromMetadata,
params: [
certData,
],
}) as any; // HARRISONTODO Type bindClientFunc
});
}
export function sendWarnMetricAck(warnMetricId: string, forceAck: boolean): NewActionFuncAsync {
@@ -780,7 +778,7 @@ export function updateDataRetentionCustomPolicy(id: string, policy: PatchDataRet
};
}
export function addDataRetentionCustomPolicyTeams(id: string, teams: string[]): NewActionFuncAsync<DataRetentionCustomPolicies> {
export function addDataRetentionCustomPolicyTeams(id: string, teams: string[]) {
return bindClientFunc({
clientFunc: Client4.addDataRetentionPolicyTeams,
onSuccess: AdminTypes.ADD_DATA_RETENTION_CUSTOM_POLICY_TEAMS_SUCCESS,
@@ -788,7 +786,7 @@ export function addDataRetentionCustomPolicyTeams(id: string, teams: string[]):
id,
teams,
],
}) as any; // HARRISONTODO Type bindClientFunc
});
}
export function removeDataRetentionCustomPolicyTeams(id: string, teams: string[]): NewActionFuncAsync<{teams: string[]}> {
@@ -816,7 +814,7 @@ export function removeDataRetentionCustomPolicyTeams(id: string, teams: string[]
};
}
export function addDataRetentionCustomPolicyChannels(id: string, channels: string[]): NewActionFuncAsync<DataRetentionCustomPolicies> {
export function addDataRetentionCustomPolicyChannels(id: string, channels: string[]) {
return bindClientFunc({
clientFunc: Client4.addDataRetentionPolicyChannels,
onSuccess: AdminTypes.ADD_DATA_RETENTION_CUSTOM_POLICY_CHANNELS_SUCCESS,
@@ -824,7 +822,7 @@ export function addDataRetentionCustomPolicyChannels(id: string, channels: strin
id,
channels,
],
}) as any; // HARRISONTODO Type bindClientFunc
});
}
export function removeDataRetentionCustomPolicyChannels(id: string, channels: string[]): NewActionFuncAsync<{channels: string[]}> {
@@ -852,17 +850,17 @@ export function removeDataRetentionCustomPolicyChannels(id: string, channels: st
};
}
export function completeSetup(completeSetup: CompleteOnboardingRequest): ActionFunc {
export function completeSetup(completeSetup: CompleteOnboardingRequest) {
return bindClientFunc({
clientFunc: Client4.completeSetup,
params: [completeSetup],
});
}
export function getAppliedSchemaMigrations(): NewActionFuncAsync<SchemaMigration[]> {
export function getAppliedSchemaMigrations() {
return bindClientFunc({
clientFunc: Client4.getAppliedSchemaMigrations,
}) as any; // HARRISONTODO Type bindClientFunc
});
}
export function getIPFilters() {

View File

@@ -1,16 +1,18 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import type {AppBinding} from '@mattermost/types/apps';
import {AppsTypes} from 'mattermost-redux/action_types';
import {Client4} from 'mattermost-redux/client';
import {getChannel, getCurrentChannelId} from 'mattermost-redux/selectors/entities/channels';
import {getCurrentTeamId} from 'mattermost-redux/selectors/entities/teams';
import type {ActionFunc, DispatchFunc, GetStateFunc} from 'mattermost-redux/types/actions';
import type {NewActionFuncAsync} from 'mattermost-redux/types/actions';
import {bindClientFunc} from './helpers';
export function fetchAppBindings(channelID: string): ActionFunc {
return async (dispatch: DispatchFunc, getState: GetStateFunc) => {
export function fetchAppBindings(channelID: string): NewActionFuncAsync<true | AppBinding[]> {
return async (dispatch, getState) => {
if (!channelID) {
return {data: true};
}
@@ -27,8 +29,8 @@ export function fetchAppBindings(channelID: string): ActionFunc {
};
}
export function fetchRHSAppsBindings(channelID: string): ActionFunc {
return async (dispatch: DispatchFunc, getState: GetStateFunc) => {
export function fetchRHSAppsBindings(channelID: string): NewActionFuncAsync {
return async (dispatch, getState) => {
const state = getState();
const currentChannelID = getCurrentChannelId(state);

View File

@@ -5,23 +5,22 @@ import type {Bot, BotPatch} from '@mattermost/types/bots';
import {BotTypes} from 'mattermost-redux/action_types';
import {Client4} from 'mattermost-redux/client';
import type {ActionFunc, NewActionFuncAsync} from 'mattermost-redux/types/actions';
import {bindClientFunc} from './helpers';
const BOTS_PER_PAGE_DEFAULT = 20;
export function createBot(bot: Partial<Bot>): NewActionFuncAsync<Bot> {
export function createBot(bot: Partial<Bot>) {
return bindClientFunc({
clientFunc: Client4.createBot,
onSuccess: BotTypes.RECEIVED_BOT_ACCOUNT,
params: [
bot,
],
}) as any; // HARRISONTODO Type bindClientFunc
});
}
export function patchBot(botUserId: string, botPatch: Partial<BotPatch>): NewActionFuncAsync<Bot> {
export function patchBot(botUserId: string, botPatch: Partial<BotPatch>) {
return bindClientFunc({
clientFunc: Client4.patchBot,
onSuccess: BotTypes.RECEIVED_BOT_ACCOUNT,
@@ -29,10 +28,10 @@ export function patchBot(botUserId: string, botPatch: Partial<BotPatch>): NewAct
botUserId,
botPatch,
],
}) as any; // HARRISONTODO Type bindClientFunc
});
}
export function loadBot(botUserId: string): ActionFunc {
export function loadBot(botUserId: string) {
return bindClientFunc({
clientFunc: Client4.getBot,
onSuccess: BotTypes.RECEIVED_BOT_ACCOUNT,
@@ -42,7 +41,7 @@ export function loadBot(botUserId: string): ActionFunc {
});
}
export function loadBots(page = 0, perPage = BOTS_PER_PAGE_DEFAULT): NewActionFuncAsync<Bot[]> {
export function loadBots(page = 0, perPage = BOTS_PER_PAGE_DEFAULT) {
return bindClientFunc({
clientFunc: Client4.getBotsIncludeDeleted,
onSuccess: BotTypes.RECEIVED_BOT_ACCOUNTS,
@@ -50,30 +49,30 @@ export function loadBots(page = 0, perPage = BOTS_PER_PAGE_DEFAULT): NewActionFu
page,
perPage,
],
}) as any; // HARRISONTODO Type bindClientFunc
});
}
export function disableBot(botUserId: string): NewActionFuncAsync<Bot> {
export function disableBot(botUserId: string) {
return bindClientFunc({
clientFunc: Client4.disableBot,
onSuccess: BotTypes.RECEIVED_BOT_ACCOUNT,
params: [
botUserId,
],
}) as any; // HARRISONTODO Type bindClientFunc
});
}
export function enableBot(botUserId: string): NewActionFuncAsync<Bot> {
export function enableBot(botUserId: string) {
return bindClientFunc({
clientFunc: Client4.enableBot,
onSuccess: BotTypes.RECEIVED_BOT_ACCOUNT,
params: [
botUserId,
],
}) as any; // HARRISONTODO Type bindClientFunc
});
}
export function assignBot(botUserId: string, newOwnerId: string): ActionFunc {
export function assignBot(botUserId: string, newOwnerId: string) {
return bindClientFunc({
clientFunc: Client4.assignBot,
onSuccess: BotTypes.RECEIVED_BOT_ACCOUNT,

View File

@@ -12,12 +12,10 @@ import type {
ChannelsWithTotalCount,
ChannelSearchOpts,
ServerChannel,
ChannelModeration,
ChannelStats,
ChannelWithTeamData,
} from '@mattermost/types/channels';
import type {ServerError} from '@mattermost/types/errors';
import type {UsersWithGroupsAndCount} from '@mattermost/types/groups';
import type {PreferenceType} from '@mattermost/types/preferences';
import {ChannelTypes, PreferenceTypes, UserTypes} from 'mattermost-redux/action_types';
@@ -1028,11 +1026,11 @@ export function searchAllChannels(term: string, opts: ChannelSearchOpts = {}): N
};
}
export function searchGroupChannels(term: string): NewActionFuncAsync<Channel[]> {
export function searchGroupChannels(term: string) {
return bindClientFunc({
clientFunc: Client4.searchGroupChannels,
params: [term],
}) as any; // HARRISONTODO Type bindClientFunc
});
}
export function getChannelStats(channelId: string, includeFileCount?: boolean): NewActionFuncAsync<ChannelStats> {
@@ -1359,7 +1357,7 @@ export function getChannelMembersByIds(channelId: string, userIds: string[]) {
});
}
export function getChannelMember(channelId: string, userId: string): NewActionFuncAsync<ChannelMembership> {
export function getChannelMember(channelId: string, userId: string) {
return bindClientFunc({
clientFunc: Client4.getChannelMember,
onSuccess: ChannelTypes.RECEIVED_CHANNEL_MEMBER,
@@ -1367,7 +1365,7 @@ export function getChannelMember(channelId: string, userId: string): NewActionFu
channelId,
userId,
],
}) as any; // HARRISONTODO Type bindClientFunc
});
}
export function getMyChannelMember(channelId: string) {
@@ -1439,17 +1437,17 @@ export function updateChannelScheme(channelId: string, schemeId: string) {
});
}
export function updateChannelMemberSchemeRoles(channelId: string, userId: string, isSchemeUser: boolean, isSchemeAdmin: boolean): NewActionFuncAsync {
export function updateChannelMemberSchemeRoles(channelId: string, userId: string, isSchemeUser: boolean, isSchemeAdmin: boolean) {
return bindClientFunc({
clientFunc: async () => {
await Client4.updateChannelMemberSchemeRoles(channelId, userId, isSchemeUser, isSchemeAdmin);
return {channelId, userId, isSchemeUser, isSchemeAdmin};
},
onSuccess: ChannelTypes.UPDATED_CHANNEL_MEMBER_SCHEME_ROLES,
}) as any; // HARRISONTODO Type bindClientFunc
});
}
export function membersMinusGroupMembers(channelID: string, groupIDs: string[], page = 0, perPage: number = General.PROFILE_CHUNK_SIZE): NewActionFuncAsync<UsersWithGroupsAndCount> {
export function membersMinusGroupMembers(channelID: string, groupIDs: string[], page = 0, perPage: number = General.PROFILE_CHUNK_SIZE) {
return bindClientFunc({
clientFunc: Client4.channelMembersMinusGroupMembers,
onSuccess: ChannelTypes.RECEIVED_CHANNEL_MEMBERS_MINUS_GROUP_MEMBERS,
@@ -1459,45 +1457,36 @@ export function membersMinusGroupMembers(channelID: string, groupIDs: string[],
page,
perPage,
],
}) as any; // HARRISONTODO Type bindClientFunc
});
}
export function getChannelModerations(channelId: string): NewActionFuncAsync<ChannelModeration[]> {
export function getChannelModerations(channelId: string) {
return bindClientFunc({
clientFunc: async () => {
const moderations = await Client4.getChannelModerations(channelId);
return {channelId, moderations};
},
onSuccess: ChannelTypes.RECEIVED_CHANNEL_MODERATIONS,
params: [
channelId,
],
}) as any; // HARRISONTODO Type bindClientFunc
});
}
export function patchChannelModerations(channelId: string, patch: ChannelModerationPatch[]): NewActionFuncAsync<ChannelModeration[]> {
export function patchChannelModerations(channelId: string, patch: ChannelModerationPatch[]) {
return bindClientFunc({
clientFunc: async () => {
const moderations = await Client4.patchChannelModerations(channelId, patch);
return {channelId, moderations};
},
onSuccess: ChannelTypes.RECEIVED_CHANNEL_MODERATIONS,
params: [
channelId,
],
}) as any; // HARRISONTODO Type bindClientFunc
});
}
export function getChannelMemberCountsByGroup(channelId: string): ActionFunc {
export function getChannelMemberCountsByGroup(channelId: string) {
return bindClientFunc({
clientFunc: async () => {
const channelMemberCountsByGroup = await Client4.getChannelMemberCountsByGroup(channelId, true);
return {channelId, memberCounts: channelMemberCountsByGroup};
},
onSuccess: ChannelTypes.RECEIVED_CHANNEL_MEMBER_COUNTS_BY_GROUP,
params: [
channelId,
],
});
}

View File

@@ -5,11 +5,10 @@ import type {Address, CloudCustomerPatch} from '@mattermost/types/cloud';
import {CloudTypes} from 'mattermost-redux/action_types';
import {Client4} from 'mattermost-redux/client';
import type {ActionFunc} from 'mattermost-redux/types/actions';
import {bindClientFunc} from './helpers';
export function getCloudSubscription(): ActionFunc {
export function getCloudSubscription() {
return bindClientFunc({
clientFunc: Client4.getSubscription,
onSuccess: [CloudTypes.RECEIVED_CLOUD_SUBSCRIPTION],
@@ -18,7 +17,7 @@ export function getCloudSubscription(): ActionFunc {
});
}
export function getCloudProducts(includeLegacyProducts?: boolean): ActionFunc {
export function getCloudProducts(includeLegacyProducts?: boolean) {
return bindClientFunc({
clientFunc: Client4.getCloudProducts,
onSuccess: [CloudTypes.RECEIVED_CLOUD_PRODUCTS],
@@ -28,7 +27,7 @@ export function getCloudProducts(includeLegacyProducts?: boolean): ActionFunc {
});
}
export function getCloudCustomer(): ActionFunc {
export function getCloudCustomer() {
return bindClientFunc({
clientFunc: Client4.getCloudCustomer,
onSuccess: [CloudTypes.RECEIVED_CLOUD_CUSTOMER],
@@ -37,7 +36,7 @@ export function getCloudCustomer(): ActionFunc {
});
}
export function getLicenseSelfServeStatus(): ActionFunc {
export function getLicenseSelfServeStatus() {
return bindClientFunc({
clientFunc: Client4.getLicenseSelfServeStatus,
onRequest: CloudTypes.LICENSE_SELF_SERVE_STATS_REQUEST,
@@ -46,7 +45,7 @@ export function getLicenseSelfServeStatus(): ActionFunc {
});
}
export function getInvoices(): ActionFunc {
export function getInvoices() {
return bindClientFunc({
clientFunc: Client4.getInvoices,
onSuccess: [CloudTypes.RECEIVED_CLOUD_INVOICES],
@@ -55,7 +54,7 @@ export function getInvoices(): ActionFunc {
});
}
export function updateCloudCustomer(customerPatch: CloudCustomerPatch): ActionFunc {
export function updateCloudCustomer(customerPatch: CloudCustomerPatch) {
return bindClientFunc({
clientFunc: Client4.updateCloudCustomer,
onSuccess: [CloudTypes.RECEIVED_CLOUD_CUSTOMER],
@@ -63,7 +62,7 @@ export function updateCloudCustomer(customerPatch: CloudCustomerPatch): ActionFu
});
}
export function updateCloudCustomerAddress(address: Address): ActionFunc {
export function updateCloudCustomerAddress(address: Address) {
return bindClientFunc({
clientFunc: Client4.updateCloudCustomerAddress,
onSuccess: [CloudTypes.RECEIVED_CLOUD_CUSTOMER],

View File

@@ -24,7 +24,7 @@ export function setSystemEmojis(emojis: Set<string>) {
systemEmojis = emojis;
}
export function createCustomEmoji(emoji: any, image: any): NewActionFuncAsync<CustomEmoji> {
export function createCustomEmoji(emoji: any, image: any) {
return bindClientFunc({
clientFunc: Client4.createCustomEmoji,
onSuccess: EmojiTypes.RECEIVED_CUSTOM_EMOJI,
@@ -32,10 +32,10 @@ export function createCustomEmoji(emoji: any, image: any): NewActionFuncAsync<Cu
emoji,
image,
],
}) as any; // HARRISONTODO Type bindClientFunc
});
}
export function getCustomEmoji(emojiId: string): ActionFunc {
export function getCustomEmoji(emojiId: string) {
return bindClientFunc({
clientFunc: Client4.getCustomEmoji,
onSuccess: EmojiTypes.RECEIVED_CUSTOM_EMOJI,

View File

@@ -6,7 +6,7 @@ import type {Post} from '@mattermost/types/posts';
import {FileTypes} from 'mattermost-redux/action_types';
import {Client4} from 'mattermost-redux/client';
import type {DispatchFunc, GetStateFunc, ActionFunc, NewActionFuncAsync} from 'mattermost-redux/types/actions';
import type {DispatchFunc, GetStateFunc, ActionFunc} from 'mattermost-redux/types/actions';
import {logError} from './errors';
import {bindClientFunc, forceLogoutIfNecessary} from './helpers';
@@ -63,12 +63,12 @@ export function getFilesForPost(postId: string): ActionFunc {
};
}
export function getFilePublicLink(fileId: string): NewActionFuncAsync<{link: string}> {
export function getFilePublicLink(fileId: string) {
return bindClientFunc({
clientFunc: Client4.getFilePublicLink,
onSuccess: FileTypes.RECEIVED_FILE_PUBLIC_LINK,
params: [
fileId,
],
}) as any; // HARRISONTODO Type bindClientFunc
});
}

View File

@@ -56,7 +56,7 @@ export function getDataRetentionPolicy(): ActionFunc {
};
}
export function getLicenseConfig(): ActionFunc {
export function getLicenseConfig() {
return bindClientFunc({
clientFunc: Client4.getClientLicenseOld,
onSuccess: [GeneralTypes.CLIENT_LICENSE_RECEIVED],

View File

@@ -4,14 +4,14 @@
import type {AnyAction} from 'redux';
import {batchActions} from 'redux-batched-actions';
import type {GroupPatch, SyncablePatch, GroupCreateWithUserIds, CustomGroupPatch, GroupSearchParams, GetGroupsParams, GetGroupsForUserParams, Group, GroupsWithCount, GroupStats} from '@mattermost/types/groups';
import type {GroupPatch, SyncablePatch, GroupCreateWithUserIds, CustomGroupPatch, GroupSearchParams, GetGroupsParams, GetGroupsForUserParams, Group} from '@mattermost/types/groups';
import {SyncableType, GroupSource} from '@mattermost/types/groups';
import type {UserProfile} from '@mattermost/types/users';
import {ChannelTypes, GroupTypes, UserTypes} from 'mattermost-redux/action_types';
import {Client4} from 'mattermost-redux/client';
import {General} from 'mattermost-redux/constants';
import type {ActionFunc, NewActionFuncAsync} from 'mattermost-redux/types/actions';
import type {NewActionFuncAsync} from 'mattermost-redux/types/actions';
import {logError} from './errors';
import {bindClientFunc, forceLogoutIfNecessary} from './helpers';
@@ -147,7 +147,7 @@ export function patchGroupSyncable(groupID: string, syncableID: string, syncable
};
}
export function getGroup(id: string, includeMemberCount = false): NewActionFuncAsync<Group> {
export function getGroup(id: string, includeMemberCount = false) {
return bindClientFunc({
clientFunc: Client4.getGroup,
onSuccess: [GroupTypes.RECEIVED_GROUP],
@@ -155,10 +155,10 @@ export function getGroup(id: string, includeMemberCount = false): NewActionFuncA
id,
includeMemberCount,
],
}) as any; // HARRISONTODO Type bindClientFunc
});
}
export function getGroups(opts: GetGroupsParams): NewActionFuncAsync<Group[]> {
export function getGroups(opts: GetGroupsParams) {
return bindClientFunc({
clientFunc: async (opts) => {
const result = await Client4.getGroups(opts);
@@ -168,10 +168,10 @@ export function getGroups(opts: GetGroupsParams): NewActionFuncAsync<Group[]> {
params: [
opts,
],
}) as any; // HARRISONTODO Type bindClientFunc
});
}
export function getGroupsNotAssociatedToTeam(teamID: string, q = '', page = 0, perPage: number = General.PAGE_SIZE_DEFAULT, source = GroupSource.Ldap): NewActionFuncAsync<Group[]> {
export function getGroupsNotAssociatedToTeam(teamID: string, q = '', page = 0, perPage: number = General.PAGE_SIZE_DEFAULT, source = GroupSource.Ldap) {
return bindClientFunc({
clientFunc: Client4.getGroupsNotAssociatedToTeam,
onSuccess: [GroupTypes.RECEIVED_GROUPS],
@@ -182,10 +182,10 @@ export function getGroupsNotAssociatedToTeam(teamID: string, q = '', page = 0, p
perPage,
source,
],
}) as any; // HARRISONTODO Type bindClientFunc
});
}
export function getGroupsNotAssociatedToChannel(channelID: string, q = '', page = 0, perPage: number = General.PAGE_SIZE_DEFAULT, filterParentTeamPermitted = false, source = GroupSource.Ldap): NewActionFuncAsync<Group[]> {
export function getGroupsNotAssociatedToChannel(channelID: string, q = '', page = 0, perPage: number = General.PAGE_SIZE_DEFAULT, filterParentTeamPermitted = false, source = GroupSource.Ldap) {
return bindClientFunc({
clientFunc: Client4.getGroupsNotAssociatedToChannel,
onSuccess: [GroupTypes.RECEIVED_GROUPS],
@@ -197,10 +197,10 @@ export function getGroupsNotAssociatedToChannel(channelID: string, q = '', page
filterParentTeamPermitted,
source,
],
}) as any; // HARRISONTODO Type bindClientFunc
});
}
export function getAllGroupsAssociatedToTeam(teamID: string, filterAllowReference = false, includeMemberCount = false): NewActionFuncAsync<GroupsWithCount> {
export function getAllGroupsAssociatedToTeam(teamID: string, filterAllowReference = false, includeMemberCount = false) {
return bindClientFunc({
clientFunc: async (param1, param2, param3) => {
const result = await Client4.getAllGroupsAssociatedToTeam(param1, param2, param3);
@@ -213,10 +213,10 @@ export function getAllGroupsAssociatedToTeam(teamID: string, filterAllowReferenc
filterAllowReference,
includeMemberCount,
],
}) as any; // HARRISONTODO Type bindClientFunc
});
}
export function getAllGroupsAssociatedToChannelsInTeam(teamID: string, filterAllowReference = false): ActionFunc {
export function getAllGroupsAssociatedToChannelsInTeam(teamID: string, filterAllowReference = false) {
return bindClientFunc({
clientFunc: async (param1, param2) => {
const result = await Client4.getAllGroupsAssociatedToChannelsInTeam(param1, param2);
@@ -230,7 +230,7 @@ export function getAllGroupsAssociatedToChannelsInTeam(teamID: string, filterAll
});
}
export function getAllGroupsAssociatedToChannel(channelID: string, filterAllowReference = false, includeMemberCount = false): NewActionFuncAsync<GroupsWithCount> {
export function getAllGroupsAssociatedToChannel(channelID: string, filterAllowReference = false, includeMemberCount = false) {
return bindClientFunc({
clientFunc: async (param1, param2, param3) => {
const result = await Client4.getAllGroupsAssociatedToChannel(param1, param2, param3);
@@ -243,10 +243,10 @@ export function getAllGroupsAssociatedToChannel(channelID: string, filterAllowRe
filterAllowReference,
includeMemberCount,
],
}) as any; // HARRISONTODO Type bindClientFunc
});
}
export function getGroupsAssociatedToTeam(teamID: string, q = '', page = 0, perPage: number = General.PAGE_SIZE_DEFAULT, filterAllowReference = false): NewActionFuncAsync<{groups: Group[]; totalGroupCount: number}> {
export function getGroupsAssociatedToTeam(teamID: string, q = '', page = 0, perPage: number = General.PAGE_SIZE_DEFAULT, filterAllowReference = false) {
return bindClientFunc({
clientFunc: async (param1, param2, param3, param4, param5) => {
const result = await Client4.getGroupsAssociatedToTeam(param1, param2, param3, param4, param5);
@@ -260,10 +260,10 @@ export function getGroupsAssociatedToTeam(teamID: string, q = '', page = 0, perP
perPage,
filterAllowReference,
],
}) as any; // HARRISONTODO Type bindClientFunc
});
}
export function getGroupsAssociatedToChannel(channelID: string, q = '', page = 0, perPage: number = General.PAGE_SIZE_DEFAULT, filterAllowReference = false): NewActionFuncAsync<{groups: Group[]; totalGroupCount: number}> {
export function getGroupsAssociatedToChannel(channelID: string, q = '', page = 0, perPage: number = General.PAGE_SIZE_DEFAULT, filterAllowReference = false) {
return bindClientFunc({
clientFunc: async (param1, param2, param3, param4, param5) => {
const result = await Client4.getGroupsAssociatedToChannel(param1, param2, param3, param4, param5);
@@ -277,10 +277,10 @@ export function getGroupsAssociatedToChannel(channelID: string, q = '', page = 0
perPage,
filterAllowReference,
],
}) as any; // HARRISONTODO Type bindClientFunc
});
}
export function patchGroup(groupID: string, patch: GroupPatch | CustomGroupPatch): NewActionFuncAsync<Group> {
export function patchGroup(groupID: string, patch: GroupPatch | CustomGroupPatch) {
return bindClientFunc({
clientFunc: Client4.patchGroup,
onSuccess: [GroupTypes.PATCHED_GROUP],
@@ -288,10 +288,10 @@ export function patchGroup(groupID: string, patch: GroupPatch | CustomGroupPatch
groupID,
patch,
],
}) as any; // HARRISONTODO Type bindClientFunc
});
}
export function getGroupsByUserId(userID: string): ActionFunc {
export function getGroupsByUserId(userID: string) {
return bindClientFunc({
clientFunc: Client4.getGroupsByUserId,
onSuccess: [GroupTypes.RECEIVED_MY_GROUPS],
@@ -301,7 +301,7 @@ export function getGroupsByUserId(userID: string): ActionFunc {
});
}
export function getGroupsByUserIdPaginated(opts: GetGroupsForUserParams): NewActionFuncAsync<Group[]> {
export function getGroupsByUserIdPaginated(opts: GetGroupsForUserParams) {
return bindClientFunc({
clientFunc: async (opts) => {
const result = await Client4.getGroups(opts);
@@ -311,17 +311,17 @@ export function getGroupsByUserIdPaginated(opts: GetGroupsForUserParams): NewAct
params: [
opts,
],
}) as any; // HARRISONTODO Type bindClientFunc
});
}
export function getGroupStats(groupID: string): NewActionFuncAsync<GroupStats> {
export function getGroupStats(groupID: string) {
return bindClientFunc({
clientFunc: Client4.getGroupStats,
onSuccess: [GroupTypes.RECEIVED_GROUP_STATS],
params: [
groupID,
],
}) as any; // HARRISONTODO Type bindClientFunc
});
}
export function createGroupWithUserIds(group: GroupCreateWithUserIds): NewActionFuncAsync<Group> {

View File

@@ -5,7 +5,7 @@ import type {ServerError} from '@mattermost/types/errors';
import {UserTypes} from 'mattermost-redux/action_types';
import {Client4} from 'mattermost-redux/client';
import type {ActionFunc, GenericAction, DispatchFunc, GetStateFunc} from 'mattermost-redux/types/actions';
import type {GenericAction, DispatchFunc, GetStateFunc, NewActionFuncAsync} from 'mattermost-redux/types/actions';
import {logError} from './errors';
@@ -63,27 +63,31 @@ export function requestFailure(type: ActionType, error: ServerError): any {
* @returns {ActionFunc} ActionFunc
*/
export function bindClientFunc({
export function bindClientFunc<Func extends(...args: any[]) => Promise<any>>({
clientFunc,
onRequest,
onSuccess,
onFailure,
params = [],
params,
}: {
clientFunc: (...args: any[]) => Promise<any>;
clientFunc: Func;
onRequest?: ActionType;
onSuccess?: ActionType | ActionType[];
onFailure?: ActionType;
params?: any[];
}): ActionFunc {
return async (dispatch: DispatchFunc, getState: GetStateFunc) => {
params?: Parameters<Func>;
}): NewActionFuncAsync<Awaited<ReturnType<Func>>> {
return async (dispatch, getState) => {
if (onRequest) {
dispatch(requestData(onRequest));
}
let data: any = null;
let data: Awaited<ReturnType<Func>>;
try {
data = await clientFunc(...params);
if (params) {
data = await clientFunc(...params);
} else {
data = await clientFunc();
}
} catch (error) {
forceLogoutIfNecessary(error, dispatch, getState);
if (onFailure) {

View File

@@ -17,27 +17,27 @@ import {bindClientFunc, forceLogoutIfNecessary} from './helpers';
import {General} from '../constants';
export function createIncomingHook(hook: IncomingWebhook): NewActionFuncAsync<IncomingWebhook> {
export function createIncomingHook(hook: IncomingWebhook) {
return bindClientFunc({
clientFunc: Client4.createIncomingWebhook,
onSuccess: [IntegrationTypes.RECEIVED_INCOMING_HOOK],
params: [
hook,
],
}) as any; // HARRISONTODO Type bindClientFunc
});
}
export function getIncomingHook(hookId: string): NewActionFuncAsync<IncomingWebhook> {
export function getIncomingHook(hookId: string) {
return bindClientFunc({
clientFunc: Client4.getIncomingWebhook,
onSuccess: [IntegrationTypes.RECEIVED_INCOMING_HOOK],
params: [
hookId,
],
}) as any; // HARRISONTODO Type bindClientFunc
});
}
export function getIncomingHooks(teamId = '', page = 0, perPage: number = General.PAGE_SIZE_DEFAULT): NewActionFuncAsync<IncomingWebhook[]> {
export function getIncomingHooks(teamId = '', page = 0, perPage: number = General.PAGE_SIZE_DEFAULT) {
return bindClientFunc({
clientFunc: Client4.getIncomingWebhooks,
onSuccess: [IntegrationTypes.RECEIVED_INCOMING_HOOKS],
@@ -46,7 +46,7 @@ export function getIncomingHooks(teamId = '', page = 0, perPage: number = Genera
page,
perPage,
],
}) as any; // HARRISONTODO Type bindClientFunc
});
}
export function removeIncomingHook(hookId: string): NewActionFuncAsync {
@@ -71,37 +71,37 @@ export function removeIncomingHook(hookId: string): NewActionFuncAsync {
};
}
export function updateIncomingHook(hook: IncomingWebhook): NewActionFuncAsync<IncomingWebhook> {
export function updateIncomingHook(hook: IncomingWebhook) {
return bindClientFunc({
clientFunc: Client4.updateIncomingWebhook,
onSuccess: [IntegrationTypes.RECEIVED_INCOMING_HOOK],
params: [
hook,
],
}) as any; // HARRISONTODO Type bindClientFunc
});
}
export function createOutgoingHook(hook: OutgoingWebhook): NewActionFuncAsync<OutgoingWebhook> {
export function createOutgoingHook(hook: OutgoingWebhook) {
return bindClientFunc({
clientFunc: Client4.createOutgoingWebhook,
onSuccess: [IntegrationTypes.RECEIVED_OUTGOING_HOOK],
params: [
hook,
],
}) as any; // HARRISONTODO Type bindClientFunc
});
}
export function getOutgoingHook(hookId: string): NewActionFuncAsync<OutgoingWebhook> {
export function getOutgoingHook(hookId: string) {
return bindClientFunc({
clientFunc: Client4.getOutgoingWebhook,
onSuccess: [IntegrationTypes.RECEIVED_OUTGOING_HOOK],
params: [
hookId,
],
}) as any; // HARRISONTODO Type bindClientFunc
});
}
export function getOutgoingHooks(channelId = '', teamId = '', page = 0, perPage: number = General.PAGE_SIZE_DEFAULT): NewActionFuncAsync<OutgoingWebhook[]> {
export function getOutgoingHooks(channelId = '', teamId = '', page = 0, perPage: number = General.PAGE_SIZE_DEFAULT) {
return bindClientFunc({
clientFunc: Client4.getOutgoingWebhooks,
onSuccess: [IntegrationTypes.RECEIVED_OUTGOING_HOOKS],
@@ -111,7 +111,7 @@ export function getOutgoingHooks(channelId = '', teamId = '', page = 0, perPage:
page,
perPage,
],
}) as any; // HARRISONTODO Type bindClientFunc
});
}
export function removeOutgoingHook(hookId: string): NewActionFuncAsync {
@@ -136,27 +136,27 @@ export function removeOutgoingHook(hookId: string): NewActionFuncAsync {
};
}
export function updateOutgoingHook(hook: OutgoingWebhook): NewActionFuncAsync<OutgoingWebhook> {
export function updateOutgoingHook(hook: OutgoingWebhook) {
return bindClientFunc({
clientFunc: Client4.updateOutgoingWebhook,
onSuccess: [IntegrationTypes.RECEIVED_OUTGOING_HOOK],
params: [
hook,
],
}) as any; // HARRISONTODO Type bindClientFunc
});
}
export function regenOutgoingHookToken(hookId: string): NewActionFuncAsync<OutgoingWebhook> {
export function regenOutgoingHookToken(hookId: string) {
return bindClientFunc({
clientFunc: Client4.regenOutgoingHookToken,
onSuccess: [IntegrationTypes.RECEIVED_OUTGOING_HOOK],
params: [
hookId,
],
}) as any; // HARRISONTODO Type bindClientFunc
});
}
export function getCommands(teamId: string): ActionFunc {
export function getCommands(teamId: string) {
return bindClientFunc({
clientFunc: Client4.getCommandsList,
onSuccess: [IntegrationTypes.RECEIVED_COMMANDS],
@@ -166,7 +166,7 @@ export function getCommands(teamId: string): ActionFunc {
});
}
export function getAutocompleteCommands(teamId: string, page = 0, perPage: number = General.PAGE_SIZE_DEFAULT): ActionFunc {
export function getAutocompleteCommands(teamId: string, page = 0, perPage: number = General.PAGE_SIZE_DEFAULT) {
return bindClientFunc({
clientFunc: Client4.getAutocompleteCommandsList,
onSuccess: [IntegrationTypes.RECEIVED_COMMANDS],
@@ -178,37 +178,37 @@ export function getAutocompleteCommands(teamId: string, page = 0, perPage: numbe
});
}
export function getCustomTeamCommands(teamId: string): NewActionFuncAsync<Command[]> {
export function getCustomTeamCommands(teamId: string) {
return bindClientFunc({
clientFunc: Client4.getCustomTeamCommands,
onSuccess: [IntegrationTypes.RECEIVED_CUSTOM_TEAM_COMMANDS],
params: [
teamId,
],
}) as any; // HARRISONTODO Type bindClientFunc
});
}
export function addCommand(command: Command): NewActionFuncAsync<Command> {
export function addCommand(command: Command) {
return bindClientFunc({
clientFunc: Client4.addCommand,
onSuccess: [IntegrationTypes.RECEIVED_COMMAND],
params: [
command,
],
}) as any; // HARRISONTODO Type bindClientFunc
});
}
export function editCommand(command: Command): NewActionFuncAsync<Command> {
export function editCommand(command: Command) {
return bindClientFunc({
clientFunc: Client4.editCommand,
onSuccess: [IntegrationTypes.RECEIVED_COMMAND],
params: [
command,
],
}) as any; // HARRISONTODO Type bindClientFunc
});
}
export function executeCommand(command: string, args: CommandArgs): ActionFunc {
export function executeCommand(command: string, args: CommandArgs) {
return bindClientFunc({
clientFunc: Client4.executeCommand,
params: [
@@ -266,27 +266,27 @@ export function deleteCommand(id: string): NewActionFuncAsync {
};
}
export function addOAuthApp(app: OAuthApp): NewActionFuncAsync<OAuthApp> {
export function addOAuthApp(app: OAuthApp) {
return bindClientFunc({
clientFunc: Client4.createOAuthApp,
onSuccess: [IntegrationTypes.RECEIVED_OAUTH_APP],
params: [
app,
],
}) as any; // HARRISONTODO Type bindClientFunc
});
}
export function editOAuthApp(app: OAuthApp): NewActionFuncAsync<OAuthApp> {
export function editOAuthApp(app: OAuthApp) {
return bindClientFunc({
clientFunc: Client4.editOAuthApp,
onSuccess: IntegrationTypes.RECEIVED_OAUTH_APP,
params: [
app,
],
}) as any; // HARRISONTODO Type bindClientFunc
});
}
export function getOAuthApps(page = 0, perPage: number = General.PAGE_SIZE_DEFAULT): NewActionFuncAsync<OAuthApp[]> {
export function getOAuthApps(page = 0, perPage: number = General.PAGE_SIZE_DEFAULT) {
return bindClientFunc({
clientFunc: Client4.getOAuthApps,
onSuccess: [IntegrationTypes.RECEIVED_OAUTH_APPS],
@@ -294,31 +294,31 @@ export function getOAuthApps(page = 0, perPage: number = General.PAGE_SIZE_DEFAU
page,
perPage,
],
}) as any; // HARRISONTODO Type bindClientFunc
});
}
export function getAppsOAuthAppIDs(): ActionFunc {
export function getAppsOAuthAppIDs() {
return bindClientFunc({
clientFunc: Client4.getAppsOAuthAppIDs,
onSuccess: [IntegrationTypes.RECEIVED_APPS_OAUTH_APP_IDS],
});
}
export function getAppsBotIDs(): NewActionFuncAsync<string[]> {
export function getAppsBotIDs() {
return bindClientFunc({
clientFunc: Client4.getAppsBotIDs,
onSuccess: [IntegrationTypes.RECEIVED_APPS_BOT_IDS],
}) as any; // HARRISONTODO Type bindClientFunc
});
}
export function getOAuthApp(appId: string): NewActionFuncAsync<OAuthApp> {
export function getOAuthApp(appId: string) {
return bindClientFunc({
clientFunc: Client4.getOAuthApp,
onSuccess: [IntegrationTypes.RECEIVED_OAUTH_APP],
params: [
appId,
],
}) as any; // HARRISONTODO Type bindClientFunc
});
}
export function getAuthorizedOAuthApps(): NewActionFuncAsync<OAuthApp[]> {
@@ -341,11 +341,11 @@ export function getAuthorizedOAuthApps(): NewActionFuncAsync<OAuthApp[]> {
};
}
export function deauthorizeOAuthApp(clientId: string): NewActionFuncAsync {
export function deauthorizeOAuthApp(clientId: string) {
return bindClientFunc({
clientFunc: Client4.deauthorizeOAuthApp,
params: [clientId],
}) as any; // HARRISONTODO Type bindClientFunc
});
}
export function deleteOAuthApp(id: string): NewActionFuncAsync {
@@ -370,14 +370,14 @@ export function deleteOAuthApp(id: string): NewActionFuncAsync {
};
}
export function regenOAuthAppSecret(appId: string): NewActionFuncAsync<OAuthApp> {
export function regenOAuthAppSecret(appId: string) {
return bindClientFunc({
clientFunc: Client4.regenOAuthAppSecret,
onSuccess: [IntegrationTypes.RECEIVED_OAUTH_APP],
params: [
appId,
],
}) as any; // HARRISONTODO Type bindClientFunc
});
}
export function submitInteractiveDialog(submission: DialogSubmission): ActionFunc {

View File

@@ -1,37 +1,36 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import type {JobType, Job, JobTypeBase} from '@mattermost/types/jobs';
import type {JobType, JobTypeBase} from '@mattermost/types/jobs';
import {JobTypes} from 'mattermost-redux/action_types';
import {Client4} from 'mattermost-redux/client';
import type {NewActionFuncAsync} from 'mattermost-redux/types/actions';
import {bindClientFunc} from './helpers';
import {General} from '../constants';
export function createJob(job: JobTypeBase): NewActionFuncAsync<Job> {
export function createJob(job: JobTypeBase) {
return bindClientFunc({
clientFunc: Client4.createJob,
onSuccess: JobTypes.RECEIVED_JOB,
params: [
job,
],
}) as any; // HARRISONTODO Type bindClientFunc
});
}
export function getJob(id: string): NewActionFuncAsync<Job> {
export function getJob(id: string) {
return bindClientFunc({
clientFunc: Client4.getJob,
onSuccess: JobTypes.RECEIVED_JOB,
params: [
id,
],
}) as any; // HARRISONTODO Type bindClientFunc
});
}
export function getJobs(page = 0, perPage: number = General.JOBS_CHUNK_SIZE): NewActionFuncAsync<Job[]> {
export function getJobs(page = 0, perPage: number = General.JOBS_CHUNK_SIZE) {
return bindClientFunc({
clientFunc: Client4.getJobs,
onSuccess: JobTypes.RECEIVED_JOBS,
@@ -39,10 +38,10 @@ export function getJobs(page = 0, perPage: number = General.JOBS_CHUNK_SIZE): Ne
page,
perPage,
],
}) as any; // HARRISONTODO Type bindClientFunc
});
}
export function getJobsByType(type: JobType, page = 0, perPage: number = General.JOBS_CHUNK_SIZE): NewActionFuncAsync<Job> {
export function getJobsByType(type: JobType, page = 0, perPage: number = General.JOBS_CHUNK_SIZE) {
return bindClientFunc({
clientFunc: Client4.getJobsByType,
onSuccess: [JobTypes.RECEIVED_JOBS, JobTypes.RECEIVED_JOBS_BY_TYPE],
@@ -51,14 +50,14 @@ export function getJobsByType(type: JobType, page = 0, perPage: number = General
page,
perPage,
],
}) as any; // HARRISONTODO Type bindClientFunc
});
}
export function cancelJob(job: string): NewActionFuncAsync {
export function cancelJob(job: string) {
return bindClientFunc({
clientFunc: Client4.cancelJob,
params: [
job,
],
}) as any; // HARRISONTODO Type bindClientFunc
});
}

View File

@@ -31,7 +31,7 @@ import {getAllGroupsByName} from 'mattermost-redux/selectors/entities/groups';
import * as PostSelectors from 'mattermost-redux/selectors/entities/posts';
import {getUnreadScrollPositionPreference, isCollapsedThreadsEnabled} from 'mattermost-redux/selectors/entities/preferences';
import {getCurrentUserId, getUsersByUsername} from 'mattermost-redux/selectors/entities/users';
import type {ActionResult, DispatchFunc, GetStateFunc, NewActionFuncAsync} from 'mattermost-redux/types/actions';
import type {ActionResult, DispatchFunc, GetStateFunc, NewActionFunc, NewActionFuncAsync} from 'mattermost-redux/types/actions';
import {isCombinedUserActivityPost} from 'mattermost-redux/utils/post_list';
import {logError} from './errors';
@@ -1229,15 +1229,15 @@ export function getNeededAtMentionedUsernamesAndGroups(state: GlobalState, posts
export type ExtendedPost = Post & { system_post_ids?: string[] };
export function removePost(post: ExtendedPost) {
return (dispatch: DispatchFunc, getState: GetStateFunc) => {
export function removePost(post: ExtendedPost): NewActionFunc {
return (dispatch, getState) => {
if (post.type === Posts.POST_TYPES.COMBINED_USER_ACTIVITY && post.system_post_ids) {
const state = getState();
for (const systemPostId of post.system_post_ids) {
const systemPost = PostSelectors.getPost(state, systemPostId);
if (systemPost) {
dispatch(removePost(systemPost as any) as any);
dispatch(removePost(systemPost));
}
}
} else {

View File

@@ -43,7 +43,7 @@ export function deletePreferences(userId: string, preferences: PreferenceType[])
};
}
export function getMyPreferences(): ActionFunc {
export function getMyPreferences() {
return bindClientFunc({
clientFunc: Client4.getMyPreferences,
onSuccess: PreferenceTypes.RECEIVED_ALL_PREFERENCES,

View File

@@ -48,7 +48,7 @@ export function getRole(roleId: string) {
});
}
export function editRole(role: Partial<Role>): NewActionFuncAsync<Role> {
export function editRole(role: Partial<Role> & {id: string}) {
return bindClientFunc({
clientFunc: Client4.patchRole,
onRequest: RoleTypes.EDIT_ROLE_REQUEST,
@@ -58,7 +58,7 @@ export function editRole(role: Partial<Role>): NewActionFuncAsync<Role> {
role.id,
role,
],
}) as any; // HARRISONTODO Type bindClientFunc
});
}
export function setPendingRoles(roles: string[]) {

View File

@@ -1,9 +1,7 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import type {Channel} from '@mattermost/types/channels';
import type {Scheme, SchemeScope, SchemePatch} from '@mattermost/types/schemes';
import type {Team} from '@mattermost/types/teams';
import {SchemeTypes} from 'mattermost-redux/action_types';
import {Client4} from 'mattermost-redux/client';
@@ -14,17 +12,17 @@ import {bindClientFunc, forceLogoutIfNecessary} from './helpers';
import {General} from '../constants';
export function getScheme(schemeId: string): NewActionFuncAsync<Scheme> {
export function getScheme(schemeId: string) {
return bindClientFunc({
clientFunc: Client4.getScheme,
onSuccess: [SchemeTypes.RECEIVED_SCHEME],
params: [
schemeId,
],
}) as any; // HARRISONTODO Type bindClientFunc
});
}
export function getSchemes(scope: SchemeScope, page = 0, perPage: number = General.PAGE_SIZE_DEFAULT): NewActionFuncAsync<Scheme[]> {
export function getSchemes(scope: SchemeScope, page = 0, perPage: number = General.PAGE_SIZE_DEFAULT) {
return bindClientFunc({
clientFunc: Client4.getSchemes,
onSuccess: [SchemeTypes.RECEIVED_SCHEMES],
@@ -33,17 +31,17 @@ export function getSchemes(scope: SchemeScope, page = 0, perPage: number = Gener
page,
perPage,
],
}) as any; // HARRISONTODO Type bindClientFunc
});
}
export function createScheme(scheme: Scheme): NewActionFuncAsync<Scheme> {
export function createScheme(scheme: Scheme) {
return bindClientFunc({
clientFunc: Client4.createScheme,
onSuccess: [SchemeTypes.CREATED_SCHEME],
params: [
scheme,
],
}) as any; // HARRISONTODO Type bindClientFunc
});
}
export function deleteScheme(schemeId: string): NewActionFuncAsync {
@@ -63,7 +61,7 @@ export function deleteScheme(schemeId: string): NewActionFuncAsync {
};
}
export function patchScheme(schemeId: string, scheme: SchemePatch): NewActionFuncAsync<Scheme> {
export function patchScheme(schemeId: string, scheme: SchemePatch) {
return bindClientFunc({
clientFunc: Client4.patchScheme,
onSuccess: [SchemeTypes.PATCHED_SCHEME],
@@ -71,10 +69,10 @@ export function patchScheme(schemeId: string, scheme: SchemePatch): NewActionFun
schemeId,
scheme,
],
}) as any; // HARRISONTODO Type bindClientFunc
});
}
export function getSchemeTeams(schemeId: string, page = 0, perPage: number = General.PAGE_SIZE_DEFAULT): NewActionFuncAsync<Team[]> {
export function getSchemeTeams(schemeId: string, page = 0, perPage: number = General.PAGE_SIZE_DEFAULT) {
return bindClientFunc({
clientFunc: Client4.getSchemeTeams,
onSuccess: [SchemeTypes.RECEIVED_SCHEME_TEAMS],
@@ -83,10 +81,10 @@ export function getSchemeTeams(schemeId: string, page = 0, perPage: number = Gen
page,
perPage,
],
}) as any; // HARRISONTODO Type bindClientFunc
});
}
export function getSchemeChannels(schemeId: string, page = 0, perPage: number = General.PAGE_SIZE_DEFAULT): NewActionFuncAsync<Channel[]> {
export function getSchemeChannels(schemeId: string, page = 0, perPage: number = General.PAGE_SIZE_DEFAULT) {
return bindClientFunc({
clientFunc: Client4.getSchemeChannels,
onSuccess: [SchemeTypes.RECEIVED_SCHEME_CHANNELS],
@@ -95,5 +93,5 @@ export function getSchemeChannels(schemeId: string, page = 0, perPage: number =
page,
perPage,
],
}) as any; // HARRISONTODO Type bindClientFunc
});
}

View File

@@ -5,9 +5,7 @@ import type {AnyAction} from 'redux';
import {batchActions} from 'redux-batched-actions';
import type {ServerError} from '@mattermost/types/errors';
import type {UsersWithGroupsAndCount} from '@mattermost/types/groups';
import type {ProductNotices} from '@mattermost/types/product_notices';
import type {Team, TeamMembership, TeamMemberWithError, GetTeamMembersOpts, TeamsWithCount, TeamSearchOpts, TeamStats, TeamInviteWithError, NotPagedTeamSearchOpts, PagedTeamSearchOpts} from '@mattermost/types/teams';
import type {Team, TeamMembership, TeamMemberWithError, GetTeamMembersOpts, TeamsWithCount, TeamSearchOpts, NotPagedTeamSearchOpts, PagedTeamSearchOpts} from '@mattermost/types/teams';
import type {UserProfile} from '@mattermost/types/users';
import {ChannelTypes, TeamTypes, UserTypes} from 'mattermost-redux/action_types';
@@ -63,7 +61,7 @@ export function selectTeam(team: Team | Team['id']) {
};
}
export function getMyTeams(): ActionFunc {
export function getMyTeams() {
return bindClientFunc({
clientFunc: Client4.getMyTeams,
onRequest: TeamTypes.MY_TEAMS_REQUEST,
@@ -107,17 +105,17 @@ export function getMyTeamUnreads(collapsedThreads: boolean, skipCurrentTeam = fa
};
}
export function getTeam(teamId: string): NewActionFuncAsync<Team> {
export function getTeam(teamId: string) {
return bindClientFunc({
clientFunc: Client4.getTeam,
onSuccess: TeamTypes.RECEIVED_TEAM,
params: [
teamId,
],
}) as any; // HARRISONTODO Type bindClientFunc
});
}
export function getTeamByName(teamName: string): ActionFunc<Team, ServerError> {
export function getTeamByName(teamName: string) {
return bindClientFunc({
clientFunc: Client4.getTeamByName,
onSuccess: TeamTypes.RECEIVED_TEAM,
@@ -297,43 +295,43 @@ export function unarchiveTeam(teamId: string): NewActionFuncAsync {
};
}
export function updateTeam(team: Team): NewActionFuncAsync<Team> {
export function updateTeam(team: Team) {
return bindClientFunc({
clientFunc: Client4.updateTeam,
onSuccess: TeamTypes.UPDATED_TEAM,
params: [
team,
],
}) as any; // HARRISONTODO Type bindClientFunc
});
}
export function patchTeam(team: Partial<Team> & {id: string}): NewActionFuncAsync<Team> {
export function patchTeam(team: Partial<Team> & {id: string}) {
return bindClientFunc({
clientFunc: Client4.patchTeam,
onSuccess: TeamTypes.PATCHED_TEAM,
params: [
team,
],
}) as any; // HARRISONTODO Type bindClientFunc
});
}
export function regenerateTeamInviteId(teamId: string): NewActionFuncAsync<Team> {
export function regenerateTeamInviteId(teamId: string) {
return bindClientFunc({
clientFunc: Client4.regenerateTeamInviteId,
onSuccess: TeamTypes.REGENERATED_TEAM_INVITE_ID,
params: [
teamId,
],
}) as any; // HARRISONTODO Type bindClientFunc
});
}
export function getMyTeamMembers(): ActionFunc {
return async (dispatch: DispatchFunc, getState: GetStateFunc) => {
export function getMyTeamMembers(): NewActionFuncAsync<TeamMembership[]> {
return async (dispatch) => {
const getMyTeamMembersFunc = bindClientFunc({
clientFunc: Client4.getMyTeamMembers,
onSuccess: TeamTypes.RECEIVED_MY_TEAM_MEMBERS,
});
const teamMembers = (await getMyTeamMembersFunc(dispatch, getState)) as ActionResult;
const teamMembers = await dispatch(getMyTeamMembersFunc);
if ('data' in teamMembers && teamMembers.data) {
const roles = new Set<string>();
@@ -352,7 +350,7 @@ export function getMyTeamMembers(): ActionFunc {
};
}
export function getTeamMembers(teamId: string, page = 0, perPage: number = General.TEAMS_CHUNK_SIZE, options?: GetTeamMembersOpts): NewActionFuncAsync<TeamMembership[]> {
export function getTeamMembers(teamId: string, page = 0, perPage: number = General.TEAMS_CHUNK_SIZE, options?: GetTeamMembersOpts) {
return bindClientFunc({
clientFunc: Client4.getTeamMembers,
onRequest: TeamTypes.GET_TEAM_MEMBERS_REQUEST,
@@ -364,7 +362,7 @@ export function getTeamMembers(teamId: string, page = 0, perPage: number = Gener
perPage,
options,
],
}) as any; // HARRISONTODO Type bindClientFunc
});
}
export function getTeamMember(teamId: string, userId: string): ActionFunc {
@@ -415,7 +413,7 @@ export function getTeamMembersByIds(teamId: string, userIds: string[]): NewActio
};
}
export function getTeamsForUser(userId: string): NewActionFuncAsync<Team[]> {
export function getTeamsForUser(userId: string) {
return bindClientFunc({
clientFunc: Client4.getTeamsForUser,
onRequest: TeamTypes.GET_TEAMS_REQUEST,
@@ -424,30 +422,30 @@ export function getTeamsForUser(userId: string): NewActionFuncAsync<Team[]> {
params: [
userId,
],
}) as any; // HARRISONTODO Type bindClientFunc
});
}
export function getTeamMembersForUser(userId: string): NewActionFuncAsync<TeamMembership[]> {
export function getTeamMembersForUser(userId: string) {
return bindClientFunc({
clientFunc: Client4.getTeamMembersForUser,
onSuccess: TeamTypes.RECEIVED_TEAM_MEMBERS,
params: [
userId,
],
}) as any; // HARRISONTODO Type bindClientFunc
});
}
export function getTeamStats(teamId: string): NewActionFuncAsync<TeamStats> {
export function getTeamStats(teamId: string) {
return bindClientFunc({
clientFunc: Client4.getTeamStats,
onSuccess: TeamTypes.RECEIVED_TEAM_STATS,
params: [
teamId,
],
}) as any; // HARRISONTODO Type bindClientFunc
});
}
export function addUserToTeamFromInvite(token: string, inviteId: string): NewActionFuncAsync<TeamMembership> {
export function addUserToTeamFromInvite(token: string, inviteId: string) {
return bindClientFunc({
clientFunc: Client4.addToTeamFromInvite,
onRequest: TeamTypes.ADD_TO_TEAM_FROM_INVITE_REQUEST,
@@ -457,7 +455,7 @@ export function addUserToTeamFromInvite(token: string, inviteId: string): NewAct
token,
inviteId,
],
}) as any; // HARRISONTODO Type bindClientFunc
});
}
export function addUserToTeam(teamId: string, userId: string): NewActionFuncAsync<TeamMembership> {
@@ -622,7 +620,7 @@ export function updateTeamMemberRoles(teamId: string, userId: string, roles: str
};
}
export function sendEmailInvitesToTeam(teamId: string, emails: string[]): ActionFunc {
export function sendEmailInvitesToTeam(teamId: string, emails: string[]) {
return bindClientFunc({
clientFunc: Client4.sendEmailInvitesToTeam,
params: [
@@ -632,7 +630,7 @@ export function sendEmailInvitesToTeam(teamId: string, emails: string[]): Action
});
}
export function sendEmailGuestInvitesToChannels(teamId: string, channelIds: string[], emails: string[], message: string): ActionFunc {
export function sendEmailGuestInvitesToChannels(teamId: string, channelIds: string[], emails: string[], message: string) {
return bindClientFunc({
clientFunc: Client4.sendEmailGuestInvitesToChannels,
params: [
@@ -643,17 +641,17 @@ export function sendEmailGuestInvitesToChannels(teamId: string, channelIds: stri
],
});
}
export function sendEmailInvitesToTeamGracefully(teamId: string, emails: string[]): NewActionFuncAsync<TeamInviteWithError[]> {
export function sendEmailInvitesToTeamGracefully(teamId: string, emails: string[]) {
return bindClientFunc({
clientFunc: Client4.sendEmailInvitesToTeamGracefully,
params: [
teamId,
emails,
],
}) as any; // HARRISONTODO Type bindClientFunc
});
}
export function sendEmailGuestInvitesToChannelsGracefully(teamId: string, channelIds: string[], emails: string[], message: string): ActionFunc {
export function sendEmailGuestInvitesToChannelsGracefully(teamId: string, channelIds: string[], emails: string[], message: string) {
return bindClientFunc({
clientFunc: Client4.sendEmailGuestInvitesToChannelsGracefully,
params: [
@@ -670,7 +668,7 @@ export function sendEmailInvitesToTeamAndChannelsGracefully(
channelIds: string[],
emails: string[],
message: string,
): NewActionFuncAsync<TeamInviteWithError[]> {
) {
return bindClientFunc({
clientFunc: Client4.sendEmailInvitesToTeamAndChannelsGracefully,
params: [
@@ -679,10 +677,10 @@ export function sendEmailInvitesToTeamAndChannelsGracefully(
emails,
message,
],
}) as any; // HARRISONTODO Type bindClientFunc
});
}
export function getTeamInviteInfo(inviteId: string): ActionFunc {
export function getTeamInviteInfo(inviteId: string) {
return bindClientFunc({
clientFunc: Client4.getTeamInviteInfo,
onRequest: TeamTypes.TEAM_INVITE_INFO_REQUEST,
@@ -771,7 +769,7 @@ export function updateTeamScheme(teamId: string, schemeId: string): NewActionFun
return {teamId, schemeId};
},
onSuccess: TeamTypes.UPDATED_TEAM_SCHEME,
}) as any; // HARRISONTODO Type bindClientFunc
});
}
export function updateTeamMemberSchemeRoles(
@@ -786,16 +784,16 @@ export function updateTeamMemberSchemeRoles(
return {teamId, userId, isSchemeUser, isSchemeAdmin};
},
onSuccess: TeamTypes.UPDATED_TEAM_MEMBER_SCHEME_ROLES,
}) as any; // HARRISONTODO Type bindClientFunc
});
}
export function invalidateAllEmailInvites(): ActionFunc {
export function invalidateAllEmailInvites() {
return bindClientFunc({
clientFunc: Client4.invalidateAllEmailInvites,
});
}
export function membersMinusGroupMembers(teamID: string, groupIDs: string[], page = 0, perPage: number = General.PROFILE_CHUNK_SIZE): NewActionFuncAsync<UsersWithGroupsAndCount> {
export function membersMinusGroupMembers(teamID: string, groupIDs: string[], page = 0, perPage: number = General.PROFILE_CHUNK_SIZE) {
return bindClientFunc({
clientFunc: Client4.teamMembersMinusGroupMembers,
onSuccess: TeamTypes.RECEIVED_TEAM_MEMBERS_MINUS_GROUP_MEMBERS,
@@ -805,10 +803,10 @@ export function membersMinusGroupMembers(teamID: string, groupIDs: string[], pag
page,
perPage,
],
}) as any; // HARRISONTODO Type bindClientFunc
});
}
export function getInProductNotices(teamId: string, client: string, clientVersion: string): NewActionFuncAsync<ProductNotices> {
export function getInProductNotices(teamId: string, client: string, clientVersion: string) {
return bindClientFunc({
clientFunc: Client4.getInProductNotices,
params: [
@@ -816,10 +814,10 @@ export function getInProductNotices(teamId: string, client: string, clientVersio
client,
clientVersion,
],
}) as any; // HARRISONTODO Type bindClientFunc
});
}
export function updateNoticesAsViewed(noticeIds: string[]): ActionFunc {
export function updateNoticesAsViewed(noticeIds: string[]) {
return bindClientFunc({
clientFunc: Client4.updateNoticesAsViewed,
params: [

View File

@@ -6,8 +6,7 @@ import {batchActions} from 'redux-batched-actions';
import type {UserAutocomplete} from '@mattermost/types/autocomplete';
import type {ServerError} from '@mattermost/types/errors';
import type {TermsOfService} from '@mattermost/types/terms_of_service';
import type {UserProfile, UserStatus, GetFilteredUsersStatsOpts, UsersStats, UserCustomStatus, UserAccessToken, AuthChangeResponse} from '@mattermost/types/users';
import type {UserProfile, UserStatus, GetFilteredUsersStatsOpts, UsersStats, UserCustomStatus, UserAccessToken} from '@mattermost/types/users';
import {UserTypes, AdminTypes} from 'mattermost-redux/action_types';
import {logError} from 'mattermost-redux/actions/errors';
@@ -25,7 +24,7 @@ import {getCurrentUserId, getUsers} from 'mattermost-redux/selectors/entities/us
import type {ActionFunc, DispatchFunc, GetStateFunc, NewActionFuncAsync} from 'mattermost-redux/types/actions';
import {isMinimumServerVersion} from 'mattermost-redux/utils/helpers';
export function generateMfaSecret(userId: string): ActionFunc {
export function generateMfaSecret(userId: string) {
return bindClientFunc({
clientFunc: Client4.generateMfaSecret,
params: [
@@ -102,7 +101,7 @@ export function logout(): ActionFunc {
};
}
export function getTotalUsersStats(): ActionFunc {
export function getTotalUsersStats() {
return bindClientFunc({
clientFunc: Client4.getTotalUsersStats,
onSuccess: UserTypes.RECEIVED_USER_STATS,
@@ -419,19 +418,19 @@ export function getProfilesNotInChannel(teamId: string, channelId: string, group
};
}
export function getMe(): ActionFunc {
return async (dispatch: DispatchFunc, getState: GetStateFunc) => {
export function getMe(): NewActionFuncAsync<UserProfile> {
return async (dispatch) => {
const getMeFunc = bindClientFunc({
clientFunc: Client4.getMe,
onSuccess: UserTypes.RECEIVED_ME,
});
const me = await getMeFunc(dispatch, getState);
const me = await dispatch(getMeFunc);
if ('error' in me) {
return me;
}
if ('data' in me) {
dispatch(loadRolesIfNeeded(me.data.roles.split(' ')));
dispatch(loadRolesIfNeeded(me.data!.roles.split(' ')));
}
return me;
};
@@ -445,7 +444,7 @@ export function updateMyTermsOfServiceStatus(termsOfServiceId: string, accepted:
termsOfServiceId,
accepted,
],
})) as any; // HARRISONTODO Type bindClientFunc
}));
if ('data' in response) {
if (accepted) {
@@ -526,46 +525,46 @@ export function getProfilesNotInGroup(groupId: string, page = 0, perPage: number
};
}
export function getTermsOfService(): NewActionFuncAsync<TermsOfService> {
export function getTermsOfService() {
return bindClientFunc({
clientFunc: Client4.getTermsOfService,
}) as any; // HARRISONTODO Type bindClientFunc
});
}
export function promoteGuestToUser(userId: string): NewActionFuncAsync {
export function promoteGuestToUser(userId: string) {
return bindClientFunc({
clientFunc: Client4.promoteGuestToUser,
params: [userId],
}) as any; // HARRISONTODO Type bindClientFunc
});
}
export function demoteUserToGuest(userId: string): NewActionFuncAsync {
export function demoteUserToGuest(userId: string) {
return bindClientFunc({
clientFunc: Client4.demoteUserToGuest,
params: [userId],
}) as any; // HARRISONTODO Type bindClientFunc
});
}
export function createTermsOfService(text: string): NewActionFuncAsync<TermsOfService> {
export function createTermsOfService(text: string) {
return bindClientFunc({
clientFunc: Client4.createTermsOfService,
params: [
text,
],
}) as any; // HARRISONTODO Type bindClientFunc
});
}
export function getUser(id: string): NewActionFuncAsync<UserProfile> {
export function getUser(id: string) {
return bindClientFunc({
clientFunc: Client4.getUser,
onSuccess: UserTypes.RECEIVED_PROFILE,
params: [
id,
],
}) as any; // HARRISONTODO Type bindClientFunc
});
}
export function getUserByUsername(username: string): ActionFunc {
export function getUserByUsername(username: string) {
return bindClientFunc({
clientFunc: Client4.getUserByUsername,
onSuccess: UserTypes.RECEIVED_PROFILE,
@@ -575,7 +574,7 @@ export function getUserByUsername(username: string): ActionFunc {
});
}
export function getUserByEmail(email: string): ActionFunc {
export function getUserByEmail(email: string) {
return bindClientFunc({
clientFunc: Client4.getUserByEmail,
onSuccess: UserTypes.RECEIVED_PROFILE,
@@ -602,7 +601,7 @@ export function getStatusesByIdsBatchedDebounced(id: string) {
return debouncedGetStatusesByIds;
}
export function getStatusesByIds(userIds: string[]): ActionFunc {
export function getStatusesByIds(userIds: string[]) {
return bindClientFunc({
clientFunc: Client4.getStatusesByIds,
onSuccess: UserTypes.RECEIVED_STATUSES,
@@ -612,7 +611,7 @@ export function getStatusesByIds(userIds: string[]): ActionFunc {
});
}
export function getStatus(userId: string): ActionFunc {
export function getStatus(userId: string) {
return bindClientFunc({
clientFunc: Client4.getStatus,
onSuccess: UserTypes.RECEIVED_STATUS,
@@ -641,7 +640,7 @@ export function setStatus(status: UserStatus): ActionFunc {
};
}
export function setCustomStatus(customStatus: UserCustomStatus): ActionFunc {
export function setCustomStatus(customStatus: UserCustomStatus) {
return bindClientFunc({
clientFunc: Client4.updateCustomStatus,
params: [
@@ -650,13 +649,13 @@ export function setCustomStatus(customStatus: UserCustomStatus): ActionFunc {
});
}
export function unsetCustomStatus(): ActionFunc {
export function unsetCustomStatus() {
return bindClientFunc({
clientFunc: Client4.unsetCustomStatus,
});
}
export function removeRecentCustomStatus(customStatus: UserCustomStatus): ActionFunc {
export function removeRecentCustomStatus(customStatus: UserCustomStatus) {
return bindClientFunc({
clientFunc: Client4.removeRecentCustomStatus,
params: [
@@ -665,7 +664,7 @@ export function removeRecentCustomStatus(customStatus: UserCustomStatus): Action
});
}
export function getSessions(userId: string): ActionFunc {
export function getSessions(userId: string) {
return bindClientFunc({
clientFunc: Client4.getSessions,
onSuccess: UserTypes.RECEIVED_SESSIONS,
@@ -735,7 +734,7 @@ export function revokeSessionsForAllUsers(): ActionFunc<boolean, ServerError> {
};
}
export function getUserAudits(userId: string, page = 0, perPage: number = General.AUDITS_CHUNK_SIZE): ActionFunc {
export function getUserAudits(userId: string, page = 0, perPage: number = General.AUDITS_CHUNK_SIZE) {
return bindClientFunc({
clientFunc: Client4.getUserAudits,
onSuccess: UserTypes.RECEIVED_AUDITS,
@@ -874,8 +873,8 @@ export function searchProfiles(term: string, options: any = {}): NewActionFuncAs
}
let statusIntervalId: NodeJS.Timeout|null;
export function startPeriodicStatusUpdates(): ActionFunc {
return async (dispatch: DispatchFunc, getState: GetStateFunc) => {
export function startPeriodicStatusUpdates(): NewActionFuncAsync { // HARRISONTODO unused
return async (dispatch, getState) => {
if (statusIntervalId) {
clearInterval(statusIntervalId);
}
@@ -902,7 +901,7 @@ export function startPeriodicStatusUpdates(): ActionFunc {
};
}
export function stopPeriodicStatusUpdates(): ActionFunc {
export function stopPeriodicStatusUpdates(): NewActionFuncAsync { // HARRISONTODO unused
return async () => {
if (statusIntervalId) {
clearInterval(statusIntervalId);
@@ -1023,7 +1022,7 @@ export function updateUserActive(userId: string, active: boolean): NewActionFunc
};
}
export function verifyUserEmail(token: string): ActionFunc {
export function verifyUserEmail(token: string) {
return bindClientFunc({
clientFunc: Client4.verifyUserEmail,
params: [
@@ -1032,32 +1031,32 @@ export function verifyUserEmail(token: string): ActionFunc {
});
}
export function sendVerificationEmail(email: string): NewActionFuncAsync {
export function sendVerificationEmail(email: string) {
return bindClientFunc({
clientFunc: Client4.sendVerificationEmail,
params: [
email,
],
}) as any; // HARRISONTODO Type bindClientFunc
});
}
export function resetUserPassword(token: string, newPassword: string): NewActionFuncAsync {
export function resetUserPassword(token: string, newPassword: string) {
return bindClientFunc({
clientFunc: Client4.resetUserPassword,
params: [
token,
newPassword,
],
}) as any; // HARRISONTODO Type bindClientFunc
});
}
export function sendPasswordResetEmail(email: string): NewActionFuncAsync {
export function sendPasswordResetEmail(email: string) {
return bindClientFunc({
clientFunc: Client4.sendPasswordResetEmail,
params: [
email,
],
}) as any; // HARRISONTODO Type bindClientFunc
});
}
export function setDefaultProfileImage(userId: string): NewActionFuncAsync {
@@ -1095,7 +1094,7 @@ export function uploadProfileImage(userId: string, imageData: any): NewActionFun
};
}
export function switchEmailToOAuth(service: string, email: string, password: string, mfaCode = ''): ActionFunc {
export function switchEmailToOAuth(service: string, email: string, password: string, mfaCode = '') {
return bindClientFunc({
clientFunc: Client4.switchEmailToOAuth,
params: [
@@ -1107,7 +1106,7 @@ export function switchEmailToOAuth(service: string, email: string, password: str
});
}
export function switchOAuthToEmail(currentService: string, email: string, password: string): ActionFunc {
export function switchOAuthToEmail(currentService: string, email: string, password: string) {
return bindClientFunc({
clientFunc: Client4.switchOAuthToEmail,
params: [
@@ -1118,7 +1117,7 @@ export function switchOAuthToEmail(currentService: string, email: string, passwo
});
}
export function switchEmailToLdap(email: string, emailPassword: string, ldapId: string, ldapPassword: string, mfaCode = ''): ActionFunc {
export function switchEmailToLdap(email: string, emailPassword: string, ldapId: string, ldapPassword: string, mfaCode = '') {
return bindClientFunc({
clientFunc: Client4.switchEmailToLdap,
params: [
@@ -1131,7 +1130,7 @@ export function switchEmailToLdap(email: string, emailPassword: string, ldapId:
});
}
export function switchLdapToEmail(ldapPassword: string, email: string, emailPassword: string, mfaCode = ''): NewActionFuncAsync<AuthChangeResponse> {
export function switchLdapToEmail(ldapPassword: string, email: string, emailPassword: string, mfaCode = '') {
return bindClientFunc({
clientFunc: Client4.switchLdapToEmail,
params: [
@@ -1140,7 +1139,7 @@ export function switchLdapToEmail(ldapPassword: string, email: string, emailPass
emailPassword,
mfaCode,
],
}) as any; // HARRISONTODO Type bindClientFunc
});
}
export function createUserAccessToken(userId: string, description: string): NewActionFuncAsync<UserAccessToken> {
@@ -1321,7 +1320,7 @@ export function enableUserAccessToken(tokenId: string): NewActionFuncAsync {
};
}
export function getKnownUsers(): ActionFunc {
export function getKnownUsers() {
return bindClientFunc({
clientFunc: Client4.getKnownUsers,
});

View File

@@ -7,7 +7,7 @@ import FormData from 'form-data';
import {PreferenceType} from '@mattermost/types/preferences';
import {SystemSetting} from '@mattermost/types/general';
import {ClusterInfo, AnalyticsRow, SchemaMigration, LogFilter} from '@mattermost/types/admin';
import {ClusterInfo, AnalyticsRow, SchemaMigration, LogFilterQuery} from '@mattermost/types/admin';
import type {AppBinding, AppCallRequest, AppCallResponse} from '@mattermost/types/apps';
import {Audit} from '@mattermost/types/audits';
import {UserAutocomplete, AutocompleteSuggestion} from '@mattermost/types/autocomplete';
@@ -95,7 +95,7 @@ import {
OutgoingWebhook,
SubmitDialogResponse,
} from '@mattermost/types/integrations';
import {Job} from '@mattermost/types/jobs';
import {Job, JobTypeBase} from '@mattermost/types/jobs';
import {MfaSecret} from '@mattermost/types/mfa';
import {
ClientPluginManifest,
@@ -3001,7 +3001,7 @@ export default class Client4 {
);
};
createJob = (job: Job) => {
createJob = (job: JobTypeBase) => {
return this.doFetch<Job>(
`${this.getJobsRoute()}`,
{method: 'post', body: JSON.stringify(job)},
@@ -3017,7 +3017,7 @@ export default class Client4 {
// Admin Routes
getLogs = (logFilter: LogFilter) => {
getLogs = (logFilter: LogFilterQuery) => {
return this.doFetch<string[]>(
`${this.getBaseRoute()}/logs/query`,
{method: 'post', body: JSON.stringify(logFilter)},
@@ -3073,7 +3073,7 @@ export default class Client4 {
);
};
testEmail = (config: AdminConfig) => {
testEmail = (config?: AdminConfig) => {
return this.doFetch<StatusOK>(
`${this.getBaseRoute()}/email/test`,
{method: 'post', body: JSON.stringify(config)},
@@ -3087,7 +3087,7 @@ export default class Client4 {
);
};
testS3Connection = (config: ClientConfig) => {
testS3Connection = (config?: AdminConfig) => {
return this.doFetch<StatusOK>(
`${this.getBaseRoute()}/file/s3_test`,
{method: 'post', body: JSON.stringify(config)},
@@ -3303,7 +3303,7 @@ export default class Client4 {
);
};
testElasticsearch = (config: ClientConfig) => {
testElasticsearch = (config?: AdminConfig) => {
return this.doFetch<StatusOK>(
`${this.getBaseRoute()}/elasticsearch/test`,
{method: 'post', body: JSON.stringify(config)},
@@ -3776,7 +3776,7 @@ export default class Client4 {
// Bot Routes
createBot = (bot: Bot) => {
createBot = (bot: Partial<Bot>) => {
return this.doFetch<Bot>(
`${this.getBotsRoute()}`,
{method: 'post', body: JSON.stringify(bot)},

View File

@@ -41,6 +41,13 @@ export type LogFilter = {
dateTo: LogDateTo;
}
export type LogFilterQuery = {
server_names: LogServerNames;
log_levels: LogLevels;
date_from: LogDateFrom;
date_to: LogDateTo;
}
export type AdminState = {
logs: LogObject[];
plainLogs: string[];