Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: [Plugin Action Editor] Query forms in Plugin Action Form #36684

Merged
merged 1 commit into from
Oct 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,24 @@ import { useChangeActionCall } from "./hooks/useChangeActionCall";
import { usePluginActionContext } from "../../PluginActionContext";
import { UIComponentTypes } from "api/PluginApi";
import GraphQLEditorForm from "./components/GraphQLEditor/GraphQLEditorForm";
import UQIEditorForm from "./components/UQIEditorForm";

const PluginActionForm = () => {
useChangeActionCall();
const { plugin } = usePluginActionContext();

return (
<Flex p="spaces-2" w="100%">
<Flex flex="1" overflow="hidden" p="spaces-2" w="100%">
{plugin.uiComponent === UIComponentTypes.ApiEditorForm && (
<APIEditorForm />
)}
{plugin.uiComponent === UIComponentTypes.GraphQLEditorForm && (
<GraphQLEditorForm />
)}
{plugin.uiComponent === UIComponentTypes.DbEditorForm ||
(plugin.uiComponent === UIComponentTypes.UQIDbEditorForm && (
<UQIEditorForm />
))}
</Flex>
);
};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import React from "react";
import FormRender from "pages/Editor/QueryEditor/FormRender";
import { usePluginActionContext } from "../../../PluginActionContext";
import { QUERY_EDITOR_FORM_NAME } from "ee/constants/forms";
import { getFormValues, reduxForm } from "redux-form";
import type { QueryAction, SaaSAction } from "entities/Action";
import { useSelector } from "react-redux";
import { getFormEvaluationState } from "selectors/formSelectors";
import { Flex } from "@appsmith/ads";

const UQIEditorForm = () => {
const { editorConfig, plugin } = usePluginActionContext();

const formData = useSelector(getFormValues(QUERY_EDITOR_FORM_NAME)) as
| QueryAction
| SaaSAction;

const formEvaluation = useSelector(getFormEvaluationState);

let formEvaluationState = {};

// Fetching evaluations state only once the formData is populated
if (!!formData) {
formEvaluationState = formEvaluation[formData.id];
}

return (
<Flex flexDirection="column" overflowY="scroll" w="100%">
<FormRender
editorConfig={editorConfig}
formData={formData}
formEvaluationState={formEvaluationState}
formName={QUERY_EDITOR_FORM_NAME}
uiComponent={plugin.uiComponent}
/>
</Flex>
);
};

export default reduxForm({
form: QUERY_EDITOR_FORM_NAME,
enableReinitialize: true,
})(UQIEditorForm);
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,22 @@ import { noop } from "lodash";
import { EditorTheme } from "components/editorComponents/CodeEditor/EditorConfig";
import { getErrorCount } from "selectors/debuggerSelectors";
import { getApiPaneDebuggerState } from "selectors/apiPaneSelectors";
import { doesPluginRequireDatasource } from "ee/entities/Engine/actionHelpers";
import useShowSchema from "components/editorComponents/ActionRightPane/useShowSchema";
import Schema from "components/editorComponents/Debugger/Schema";
import QueryResponseTab from "pages/Editor/QueryEditor/QueryResponseTab";
import type { SourceEntity } from "entities/AppsmithConsole";
import { ENTITY_TYPE as SOURCE_ENTITY_TYPE } from "ee/entities/AppsmithConsole/utils";

function usePluginActionResponseTabs() {
const { action, actionResponse, plugin } = usePluginActionContext();
const { action, actionResponse, datasource, plugin } =
usePluginActionContext();

const IDEViewMode = useSelector(getIDEViewMode);
const errorCount = useSelector(getErrorCount);
const pluginRequireDatasource = doesPluginRequireDatasource(plugin);

const showSchema = useShowSchema(plugin.id) && pluginRequireDatasource;

const { responseTabHeight } = useSelector(getApiPaneDebuggerState);

Expand Down Expand Up @@ -81,6 +91,55 @@ function usePluginActionResponseTabs() {
]);
}

if (
[
PluginType.DB,
PluginType.AI,
PluginType.REMOTE,
PluginType.SAAS,
PluginType.INTERNAL,
].includes(plugin.type)
) {
const newTabs = [];

const actionSource: SourceEntity = {
type: SOURCE_ENTITY_TYPE.ACTION,
name: action.name,
id: action.id,
};

if (showSchema) {
newTabs.push({
key: "schema",
title: "Schema",
panelComponent: (
<Schema
currentActionId={action.id}
datasourceId={datasource?.id || ""}
datasourceName={datasource?.name || ""}
/>
),
});
}

newTabs.push({
key: "response",
title: createMessage(DEBUGGER_RESPONSE),
panelComponent: (
<QueryResponseTab
actionName={action.name}
actionSource={actionSource}
currentActionConfig={action}
isRunning={false}
onRunClick={noop}
runErrorMessage={""} // TODO
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Let's address the TODO: Implement runErrorMessage

There's a // TODO comment indicating that runErrorMessage needs implementation. Completing this will ensure users receive accurate error feedback.

Would you like assistance in providing this implementation?

/>
),
});

return tabs.concat(newTabs);
}

return tabs;
}

Expand Down
Loading