From 5f2e4dd8ea9ecd22e9ab72393052f52264c601ca Mon Sep 17 00:00:00 2001 From: Pawan Kumar Date: Fri, 21 Mar 2025 10:58:19 +0530 Subject: [PATCH 1/3] add ce files --- .../components/UQIEditor/FormRender.tsx | 7 ++- .../formControls/DatasourceLinkControl.tsx | 63 +++++++++++++++++++ .../components/FunctionCallingConfigForm.tsx | 1 + .../utils/formControl/FormControlRegistry.tsx | 14 +++++ .../src/utils/formControl/formControlTypes.ts | 1 + 5 files changed, 85 insertions(+), 1 deletion(-) create mode 100644 app/client/src/components/formControls/DatasourceLinkControl.tsx diff --git a/app/client/src/PluginActionEditor/components/PluginActionForm/components/UQIEditor/FormRender.tsx b/app/client/src/PluginActionEditor/components/PluginActionForm/components/UQIEditor/FormRender.tsx index 644c090f73a8..eb42337a0d11 100644 --- a/app/client/src/PluginActionEditor/components/PluginActionForm/components/UQIEditor/FormRender.tsx +++ b/app/client/src/PluginActionEditor/components/PluginActionForm/components/UQIEditor/FormRender.tsx @@ -183,6 +183,7 @@ const FormRender = (props: Props) => { @@ -221,7 +222,11 @@ const FormRender = (props: Props) => { ? "single_column" : "double_column"; - return {children}; + return ( + + {children} + + ); } default: return children; diff --git a/app/client/src/components/formControls/DatasourceLinkControl.tsx b/app/client/src/components/formControls/DatasourceLinkControl.tsx new file mode 100644 index 000000000000..a102fe954415 --- /dev/null +++ b/app/client/src/components/formControls/DatasourceLinkControl.tsx @@ -0,0 +1,63 @@ +import React, { useCallback } from "react"; +import omit from "lodash/omit"; +import history from "utils/history"; +import { Button, type ButtonProps } from "@appsmith/ads"; +import type { ControlType } from "constants/PropertyControlConstants"; + +import BaseControl from "./BaseControl"; +import type { ControlProps } from "./BaseControl"; +import { useParentEntityInfo } from "ee/IDE/hooks/useParentEntityInfo"; +import { getIDETypeByUrl } from "ee/entities/IDE/utils"; +import { datasourcesEditorIdURL } from "ee/RouteBuilder"; +import { getQueryParams } from "utils/URLUtils"; + +export interface DatasourceLinkControlProps extends ControlProps { + href: string; + text: string; + size?: ButtonProps["size"]; + kind?: ButtonProps["kind"]; + icon?: ButtonProps["startIcon"]; +} + +class DatasourceLinkControl extends BaseControl { + getControlType(): ControlType { + return "DATASOURCE_LINK"; + } + render() { + return ; + } +} + +function DatasourceLink(props: DatasourceLinkControlProps) { + const { icon, kind = "secondary", size = "sm", text } = props; + const ideType = getIDETypeByUrl(location.pathname); + const { parentEntityId } = useParentEntityInfo(ideType); + + const onPress = useCallback(() => { + const url = datasourcesEditorIdURL({ + baseParentEntityId: parentEntityId, + datasourceId: props.datasourceId as string, + params: { ...omit(getQueryParams(), "viewMode"), viewMode: false }, + }); + + history.push(url); + }, [parentEntityId, props.datasourceId]); + + return ( + + ); +} + +export interface CheckboxControlProps extends ControlProps { + info?: string; +} + +export { DatasourceLinkControl }; diff --git a/app/client/src/components/formControls/FunctionCallingConfigControl/components/FunctionCallingConfigForm.tsx b/app/client/src/components/formControls/FunctionCallingConfigControl/components/FunctionCallingConfigForm.tsx index 26a7cf0e05d7..20054d4c3a88 100644 --- a/app/client/src/components/formControls/FunctionCallingConfigControl/components/FunctionCallingConfigForm.tsx +++ b/app/client/src/components/formControls/FunctionCallingConfigControl/components/FunctionCallingConfigForm.tsx @@ -59,6 +59,7 @@ export const FunctionCallingConfigForm = ({