* Remove mattermost-redux * Move mm-redux files into app/redux * Add @redux path to tsconfig.json * Fix imports * Install missing dependencies * Fix tsc errors * Fix i18n_utils test * Fix more imports * Remove redux websocket * Fix tests * Rename @redux * Apply changes from mattermost-redux PR 1103 * Remove mattermost-redux mention in template * Add missing imports * Rename app/redux/ to app/mm-redux/ * Remove test file * Fix fetching Sidebar GM profiles Co-authored-by: Elias Nahum <nahumhbl@gmail.com>
84 lines
2.1 KiB
TypeScript
84 lines
2.1 KiB
TypeScript
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
import {Client4} from '@mm-redux/client';
|
|
import {BotTypes} from '@mm-redux/action_types';
|
|
import {bindClientFunc} from './helpers';
|
|
|
|
import {ActionFunc} from '@mm-redux/types/actions';
|
|
import {Bot, BotPatch} from '@mm-redux/types/bots';
|
|
|
|
const BOTS_PER_PAGE_DEFAULT = 20;
|
|
|
|
export function createBot(bot: Bot): ActionFunc {
|
|
return bindClientFunc({
|
|
clientFunc: Client4.createBot,
|
|
onSuccess: BotTypes.RECEIVED_BOT_ACCOUNT,
|
|
params: [
|
|
bot,
|
|
],
|
|
});
|
|
}
|
|
|
|
export function patchBot(botUserId: string, botPatch: BotPatch): ActionFunc {
|
|
return bindClientFunc({
|
|
clientFunc: Client4.patchBot,
|
|
onSuccess: BotTypes.RECEIVED_BOT_ACCOUNT,
|
|
params: [
|
|
botUserId,
|
|
botPatch,
|
|
],
|
|
});
|
|
}
|
|
|
|
export function loadBot(botUserId: string): ActionFunc {
|
|
return bindClientFunc({
|
|
clientFunc: Client4.getBot,
|
|
onSuccess: BotTypes.RECEIVED_BOT_ACCOUNT,
|
|
params: [
|
|
botUserId,
|
|
],
|
|
});
|
|
}
|
|
|
|
export function loadBots(page = 0, perPage = BOTS_PER_PAGE_DEFAULT): ActionFunc {
|
|
return bindClientFunc({
|
|
clientFunc: Client4.getBotsIncludeDeleted,
|
|
onSuccess: BotTypes.RECEIVED_BOT_ACCOUNTS,
|
|
params: [
|
|
page,
|
|
perPage,
|
|
],
|
|
});
|
|
}
|
|
|
|
export function disableBot(botUserId: string): ActionFunc {
|
|
return bindClientFunc({
|
|
clientFunc: Client4.disableBot,
|
|
onSuccess: BotTypes.RECEIVED_BOT_ACCOUNT,
|
|
params: [
|
|
botUserId,
|
|
],
|
|
});
|
|
}
|
|
|
|
export function enableBot(botUserId: string): ActionFunc {
|
|
return bindClientFunc({
|
|
clientFunc: Client4.enableBot,
|
|
onSuccess: BotTypes.RECEIVED_BOT_ACCOUNT,
|
|
params: [
|
|
botUserId,
|
|
],
|
|
});
|
|
}
|
|
|
|
export function assignBot(botUserId: string, newOwnerId: string): ActionFunc {
|
|
return bindClientFunc({
|
|
clientFunc: Client4.assignBot,
|
|
onSuccess: BotTypes.RECEIVED_BOT_ACCOUNT,
|
|
params: [
|
|
botUserId,
|
|
newOwnerId,
|
|
],
|
|
});
|
|
}
|