Chore: Update Action interface (#93248)

Co-authored-by: Ryan McKinley <ryantxu@gmail.com>
This commit is contained in:
Adela Almasan
2024-09-23 10:41:05 -05:00
committed by GitHub
co-authored by Ryan McKinley
parent 026748a5ab
commit d630e9bcb3
5 changed files with 51 additions and 41 deletions
+12 -8
View File
@@ -3,10 +3,18 @@ import { DataFrame, Field, ValueLinkConfig } from './dataFrame';
import { InterpolateFunction } from './panel';
import { SelectableValue } from './select';
export interface Action<T = ActionType.Fetch, TOptions = FetchOptions> {
type: T;
export enum ActionType {
Fetch = 'fetch',
}
export interface Action {
type: ActionType;
title: string;
options: TOptions;
// Options for the selected type
// Currently this is required because there is only one valid type (fetch)
// once multiple types are valid, usage of this will need to be optional
[ActionType.Fetch]: FetchOptions;
}
/**
@@ -25,10 +33,6 @@ interface FetchOptions {
headers?: Array<[string, string]>;
}
export enum ActionType {
Fetch = 'fetch',
}
export enum HttpRequestMethod {
POST = 'POST',
PUT = 'PUT',
@@ -51,7 +55,7 @@ export const contentTypeOptions: SelectableValue[] = [
export const defaultActionConfig: Action = {
type: ActionType.Fetch,
title: '',
options: {
fetch: {
url: '',
method: HttpRequestMethod.POST,
body: '{}',