## Description Response Pane stuff - Move Api Response into its own component and sub components - Move Api Headers response into its own component and sub components - A lot of these are also used by queries and js so maybe we will create a common folder for that - Add a logic to render the bottom tabs in the module. Allows for extension via hook Fixes #36155 ## Automation /ok-to-test tags="@tag.Datasource" ### 🔍 Cypress test results <!-- This is an auto-generated comment: Cypress test results --> > [!TIP] > 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉 > Workflow run: <https://github.com/appsmithorg/appsmith/actions/runs/11026260058> > Commit: c3b5b4b8f0e0668ff43adae1b22d320a5e6d347d > <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=11026260058&attempt=1" target="_blank">Cypress dashboard</a>. > Tags: `@tag.Datasource` > Spec: > <hr>Wed, 25 Sep 2024 05:04:24 UTC <!-- end of auto-generated comment: Cypress test results --> ## Communication Should the DevRel and Marketing teams inform users about this change? - [ ] Yes - [x] No <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Introduced new components for displaying API responses, including `ApiFormatSegmentedResponse` and `ApiResponseHeaders`. - Enhanced user interaction with a segmented control for switching between different API response formats. - **Improvements** - Added utility functions for improved handling and validation of API response headers and HTML content. - **Bug Fixes** - Improved error handling for API response states to ensure accurate feedback during user interactions. - **Chores** - Added tests for new utility functions to validate their functionality and ensure reliability. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
94 lines
2.6 KiB
TypeScript
94 lines
2.6 KiB
TypeScript
import React from "react";
|
|
import { useLocation } from "react-router";
|
|
import { identifyEntityFromPath } from "../navigation/FocusEntity";
|
|
import { useSelector } from "react-redux";
|
|
import {
|
|
getActionByBaseId,
|
|
getActionResponses,
|
|
getDatasource,
|
|
getEditorConfig,
|
|
getPlugin,
|
|
} from "ee/selectors/entitiesSelector";
|
|
import { PluginActionContextProvider } from "./PluginActionContext";
|
|
import { get } from "lodash";
|
|
import EntityNotFoundPane from "pages/Editor/EntityNotFoundPane";
|
|
import Spinner from "components/editorComponents/Spinner";
|
|
import CenteredWrapper from "components/designSystems/appsmith/CenteredWrapper";
|
|
import { Text } from "@appsmith/ads";
|
|
import { useIsEditorInitialised } from "IDE/hooks";
|
|
import { useActionSettingsConfig } from "./hooks";
|
|
|
|
interface ChildrenProps {
|
|
children: React.ReactNode | React.ReactNode[];
|
|
}
|
|
|
|
const PluginActionEditor = (props: ChildrenProps) => {
|
|
const { pathname } = useLocation();
|
|
|
|
const isEditorInitialized = useIsEditorInitialised();
|
|
|
|
const entity = identifyEntityFromPath(pathname);
|
|
const action = useSelector((state) => getActionByBaseId(state, entity.id));
|
|
|
|
const pluginId = get(action, "pluginId", "");
|
|
const plugin = useSelector((state) => getPlugin(state, pluginId));
|
|
|
|
const datasourceId = get(action, "datasource.id", "");
|
|
const datasource = useSelector((state) => getDatasource(state, datasourceId));
|
|
|
|
const settingsConfig = useActionSettingsConfig(action);
|
|
|
|
const editorConfig = useSelector((state) => getEditorConfig(state, pluginId));
|
|
|
|
const actionResponses = useSelector(getActionResponses);
|
|
|
|
if (!isEditorInitialized) {
|
|
return (
|
|
<CenteredWrapper>
|
|
<Spinner size={30} />
|
|
</CenteredWrapper>
|
|
);
|
|
}
|
|
|
|
if (!action) {
|
|
return <EntityNotFoundPane />;
|
|
}
|
|
|
|
if (!plugin) {
|
|
return (
|
|
<CenteredWrapper>
|
|
<Text color="var(--ads-v2-color-fg-error)" kind="heading-m">
|
|
Plugin not installed!
|
|
</Text>
|
|
</CenteredWrapper>
|
|
);
|
|
}
|
|
|
|
if (!settingsConfig || !editorConfig) {
|
|
return (
|
|
<CenteredWrapper>
|
|
<Text color="var(--ads-v2-color-fg-error)" kind="heading-m">
|
|
Editor config not found!
|
|
</Text>
|
|
</CenteredWrapper>
|
|
);
|
|
}
|
|
|
|
const actionResponse = actionResponses[action.id];
|
|
|
|
return (
|
|
<PluginActionContextProvider
|
|
action={action}
|
|
actionResponse={actionResponse}
|
|
datasource={datasource}
|
|
editorConfig={editorConfig}
|
|
plugin={plugin}
|
|
settingsConfig={settingsConfig}
|
|
>
|
|
{props.children}
|
|
</PluginActionContextProvider>
|
|
);
|
|
};
|
|
|
|
export default PluginActionEditor;
|