Skip to content

Commit

Permalink
chore: Opening response pane by default on query creation and for pag…
Browse files Browse the repository at this point in the history
…e load queries (#37245)

## Description

Opening response pane by default on query creation and for page load
queries

Fixes [#37216](#37216)

## Automation

/ok-to-test tags="@tag.Sanity"

### 🔍 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/11723600626>
> Commit: 98db89c
> <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=11723600626&attempt=1"
target="_blank">Cypress dashboard</a>.
> Tags: `@tag.Sanity`
> Spec:
> <hr>Thu, 07 Nov 2024 13:48:18 UTC
<!-- end of auto-generated comment: Cypress test results  -->


## Communication
Should the DevRel and Marketing teams inform users about this change?
- [ ] Yes
- [ ] No


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **New Features**
- Enhanced the `PluginActionResponse` component for improved
functionality and dynamic response handling.
- Introduced a new state variable to manage response tab visibility on
initial load.
- Added logic to automatically open the response and schema tabs based
on action responses.

- **Bug Fixes**
- Improved control flow and error handling for displaying responses
based on action success.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Ankita Kinger <ankitakinger@Ankitas-MacBook-Pro.local>
  • Loading branch information
ankitakinger and Ankita Kinger authored Nov 8, 2024
1 parent 1f25adc commit 5e89aa0
Showing 1 changed file with 50 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useCallback } from "react";
import React, { useCallback, useEffect } from "react";
import { IDEBottomView, ViewHideBehaviour } from "IDE";
import { ActionExecutionResizerHeight } from "./constants";
import EntityBottomTabs from "components/editorComponents/EntityBottomTabs";
Expand All @@ -8,17 +8,66 @@ import { getPluginActionDebuggerState } from "../../store";
import { DEBUGGER_TAB_KEYS } from "components/editorComponents/Debugger/constants";
import AnalyticsUtil from "ee/utils/AnalyticsUtil";
import { usePluginActionResponseTabs } from "./hooks";
import { usePluginActionContext } from "../../PluginActionContext";
import { doesPluginRequireDatasource } from "ee/entities/Engine/actionHelpers";
import useShowSchema from "./hooks/useShowSchema";
import { actionResponseDisplayDataFormats } from "pages/Editor/utils";

function PluginActionResponse() {
const dispatch = useDispatch();
const { actionResponse, plugin } = usePluginActionContext();

const tabs = usePluginActionResponseTabs();
const pluginRequireDatasource = doesPluginRequireDatasource(plugin);

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

// TODO combine API and Query Debugger state
const { open, responseTabHeight, selectedTab } = useSelector(
getPluginActionDebuggerState,
);

const { responseDisplayFormat } =
actionResponseDisplayDataFormats(actionResponse);

// These useEffects are used to open the response tab by default for page load queries
// as for page load queries, query response is available and can be shown in response tab
useEffect(
function openResponseTabForPageLoadQueries() {
// actionResponse and responseDisplayFormat is present only when query has response available
if (
!!responseDisplayFormat?.title &&
actionResponse?.isExecutionSuccess
) {
dispatch(
setPluginActionEditorDebuggerState({
open: true,
selectedTab: DEBUGGER_TAB_KEYS.RESPONSE_TAB,
}),
);
}
},
[
responseDisplayFormat?.title,
actionResponse?.isExecutionSuccess,
dispatch,
],
);

useEffect(
function openSchemaTabWhenNoTabIsSelected() {
if (showSchema && !selectedTab) {
dispatch(
setPluginActionEditorDebuggerState({
open: true,
selectedTab: DEBUGGER_TAB_KEYS.SCHEMA_TAB,
}),
);
}
},
[showSchema, selectedTab, dispatch],
);

const toggleHide = useCallback(
() => dispatch(setPluginActionEditorDebuggerState({ open: !open })),
[dispatch, open],
Expand Down

0 comments on commit 5e89aa0

Please sign in to comment.