Chore: Migrate REST API - getCommandPreview to Typescript (#3894)
This commit is contained in:
parent
6d543c28d9
commit
8a1f81d707
|
@ -638,12 +638,12 @@ class MessageBox extends Component<IMessageBoxProps, IMessageBoxState> {
|
||||||
}, 1000);
|
}, 1000);
|
||||||
};
|
};
|
||||||
|
|
||||||
setCommandPreview = async (command: any, name: string, params: any) => {
|
setCommandPreview = async (command: any, name: string, params: string) => {
|
||||||
const { rid } = this.props;
|
const { rid } = this.props;
|
||||||
try {
|
try {
|
||||||
const { success, preview } = await RocketChat.getCommandPreview(name, rid, params);
|
const response = await RocketChat.getCommandPreview(name, rid, params);
|
||||||
if (success) {
|
if (response.success) {
|
||||||
return this.setState({ commandPreview: preview?.items, showCommandPreview: true, command });
|
return this.setState({ commandPreview: response.preview?.items, showCommandPreview: true, command });
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
log(e);
|
log(e);
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
export type CommandsEndpoints = {
|
||||||
|
'commands.preview': {
|
||||||
|
GET: (params: { command: string; roomId: string; params: string }) => {
|
||||||
|
preview: {
|
||||||
|
i18nTitle: string;
|
||||||
|
items: any;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
|
@ -16,6 +16,7 @@ import { TeamsEndpoints } from './teams';
|
||||||
import { E2eEndpoints } from './e2e';
|
import { E2eEndpoints } from './e2e';
|
||||||
import { SubscriptionsEndpoints } from './subscriptions';
|
import { SubscriptionsEndpoints } from './subscriptions';
|
||||||
import { VideoConferenceEndpoints } from './videoConference';
|
import { VideoConferenceEndpoints } from './videoConference';
|
||||||
|
import { CommandsEndpoints } from './commands';
|
||||||
|
|
||||||
export type Endpoints = ChannelsEndpoints &
|
export type Endpoints = ChannelsEndpoints &
|
||||||
ChatEndpoints &
|
ChatEndpoints &
|
||||||
|
@ -34,4 +35,5 @@ export type Endpoints = ChannelsEndpoints &
|
||||||
TeamsEndpoints &
|
TeamsEndpoints &
|
||||||
E2eEndpoints &
|
E2eEndpoints &
|
||||||
SubscriptionsEndpoints &
|
SubscriptionsEndpoints &
|
||||||
VideoConferenceEndpoints;
|
VideoConferenceEndpoints &
|
||||||
|
CommandsEndpoints;
|
||||||
|
|
|
@ -686,10 +686,8 @@ export const runSlashCommand = (command: string, roomId: string, params: any, tr
|
||||||
tmid
|
tmid
|
||||||
});
|
});
|
||||||
|
|
||||||
export const getCommandPreview = (command: string, roomId: string, params: any): any =>
|
export const getCommandPreview = (command: string, roomId: string, params: string) =>
|
||||||
// RC 0.65.0
|
// RC 0.65.0
|
||||||
// TODO: missing definitions from server
|
|
||||||
// @ts-ignore
|
|
||||||
sdk.get('commands.preview', {
|
sdk.get('commands.preview', {
|
||||||
command,
|
command,
|
||||||
roomId,
|
roomId,
|
||||||
|
|
Loading…
Reference in New Issue