Skip to content

Commit

Permalink
fix: split default tab logic (#38414)
Browse files Browse the repository at this point in the history
## Description
Split the logic for the plugin action tabs. Now the files in CE and EE
repo for the `ce` folder are the same. Redefine the logic in EE hooks
only.

EE PR — appsmithorg/appsmith-ee#5840

## Automation

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

### 🔍 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/12546120368>
> Commit: 8fa499e
> <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=12546120368&attempt=2"
target="_blank">Cypress dashboard</a>.
> Tags: `@tag.All`
> Spec:
> <hr>Mon, 30 Dec 2024 13:26:11 UTC
<!-- end of auto-generated comment: Cypress test results  -->


## Communication
Should the DevRel and Marketing teams inform users about this change?
- [ ] Yes
- [x] No
  • Loading branch information
KelvinOm authored Dec 30, 2024
1 parent 39328fb commit de2d5a4
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,15 @@ import { DEBUGGER_TAB_KEYS } from "components/editorComponents/Debugger/constant
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";
import { PluginType } from "entities/Action";
import { hasFailed } from "./utils";
import { useDefaultTab } from "ee/PluginActionEditor/components/PluginActionResponse/hooks/useDefaultTab";

function PluginActionResponse() {
const dispatch = useDispatch();
const { actionResponse, plugin } = usePluginActionContext();
const { actionResponse } = 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(
Expand Down Expand Up @@ -75,26 +70,7 @@ function PluginActionResponse() {
[executionFailed, dispatch],
);

useEffect(
function openDefaultTabWhenNoTabIsSelected() {
if (showSchema && !selectedTab) {
dispatch(
setPluginActionEditorDebuggerState({
open: true,
selectedTab: DEBUGGER_TAB_KEYS.DATASOURCE_TAB,
}),
);
} else if (plugin.type === PluginType.API && !selectedTab) {
dispatch(
setPluginActionEditorDebuggerState({
open: true,
selectedTab: DEBUGGER_TAB_KEYS.RESPONSE_TAB,
}),
);
}
},
[showSchema, selectedTab, dispatch, plugin.type],
);
useDefaultTab();

const toggleHide = useCallback(
() => dispatch(setPluginActionEditorDebuggerState({ open: !open })),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { useEffect } from "react";
import { useDispatch, useSelector } from "react-redux";
import { DEBUGGER_TAB_KEYS } from "components/editorComponents/Debugger/constants";
import { PluginType } from "entities/Action";
import { usePluginActionContext } from "PluginActionEditor";
import useShowSchema from "PluginActionEditor/components/PluginActionResponse/hooks/useShowSchema";
import {
getPluginActionDebuggerState,
setPluginActionEditorDebuggerState,
} from "PluginActionEditor/store";
import { doesPluginRequireDatasource } from "ee/entities/Engine/actionHelpers";

export function useDefaultTab() {
const dispatch = useDispatch();
const { plugin } = usePluginActionContext();
const pluginRequireDatasource = doesPluginRequireDatasource(plugin);
const showSchema = useShowSchema(plugin?.id || "") && pluginRequireDatasource;
const { selectedTab } = useSelector(getPluginActionDebuggerState);

useEffect(
function openDefaultTabWhenNoTabIsSelected() {
if (showSchema && !selectedTab) {
dispatch(
setPluginActionEditorDebuggerState({
open: true,
selectedTab: DEBUGGER_TAB_KEYS.DATASOURCE_TAB,
}),
);
} else if (plugin.type === PluginType.API && !selectedTab) {
dispatch(
setPluginActionEditorDebuggerState({
open: true,
selectedTab: DEBUGGER_TAB_KEYS.RESPONSE_TAB,
}),
);
}
},
[showSchema, selectedTab, dispatch, plugin.type],
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { useDefaultTab as CE_useDefaultTab } from "ce/PluginActionEditor/components/PluginActionResponse/hooks/useDefaultTab";

export function useDefaultTab() {
return CE_useDefaultTab();
}

0 comments on commit de2d5a4

Please sign in to comment.