PromucFlow_constructor/app/client/src/api/PluginApi.ts
Ayush Pahwa 16ad07fa68
feat: 5701 dynamic value fetch for forms (#10324)
* Added new condition type

* Added new variables to cater to enable/disable conditionals

* Adding functionality to disable the drop down control

* Added ability to enable/disable to dynamic input text fields

* Updated input text control to have enabled/disabled feature

* Added enable/disable functionality to FixedKeyInputControl

* Added enable/disable func to switch control and stanrdasied var name

* Added disable functionality for file picker

* Added enable/disable functionality to QUER_DYNAMIC_TEXT

* Added new state and object for evaluating conditionals

* Connected the output to the final source

* Updating loading state on the final component

* Tied fetched data to the options of dropdown component

* Added declaration to make API call

* Added loading state for dropdown

* Updated types in reducer

* Added implementation to extract API calls from the response and setting the output

* Removed extra variables

* Moved all calculation logic to the class component

* Refactors and added comments

* Added flag to store when the value fetch fails

* Reduced usage of spread operators
2022-01-13 13:37:30 +05:30

69 lines
1.9 KiB
TypeScript

import Api from "api/Api";
import { AxiosPromise } from "axios";
import { GenericApiResponse } from "api/ApiResponses";
import { PluginType } from "entities/Action";
import { DependencyMap } from "utils/DynamicBindingUtils";
import { DropdownOption } from "components/ads/Dropdown";
export type PluginId = string;
export type PluginPackageName = string;
export type GenerateCRUDEnabledPluginMap = Record<PluginId, PluginPackageName>;
export enum UIComponentTypes {
DbEditorForm = "DbEditorForm",
UQIDbEditorForm = "UQIDbEditorForm",
ApiEditorForm = "ApiEditorForm",
RapidApiEditorForm = "RapidApiEditorForm",
JsEditorForm = "JsEditorForm",
}
export enum DatasourceComponentTypes {
RestAPIDatasourceForm = "RestAPIDatasourceForm",
AutoForm = "AutoForm",
}
export interface Plugin {
id: string;
name: string;
type: PluginType;
packageName: string;
iconLocation?: string;
uiComponent: UIComponentTypes;
datasourceComponent: DatasourceComponentTypes;
allowUserDatasources?: boolean;
templates: Record<string, string>;
responseType?: "TABLE" | "JSON";
documentationLink?: string;
generateCRUDPageComponent?: string;
}
export interface PluginFormPayload {
form: any[];
editor: any[];
setting: any[];
dependencies: DependencyMap;
}
class PluginsApi extends Api {
static url = "v1/plugins";
static fetchPlugins(
orgId: string,
): AxiosPromise<GenericApiResponse<Plugin[]>> {
return Api.get(PluginsApi.url, { organizationId: orgId });
}
static fetchFormConfig(
id: string,
): AxiosPromise<GenericApiResponse<PluginFormPayload>> {
return Api.get(PluginsApi.url + `/${id}/form`);
}
// Definition to fetch the dynamic data via the URL passed in the config
static fetchDynamicFormValues(
url: string,
): AxiosPromise<GenericApiResponse<DropdownOption[]>> {
return Api.get(url);
}
}
export default PluginsApi;