-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: split default tab logic (#38414)
## 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
Showing
3 changed files
with
48 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
app/client/src/ce/PluginActionEditor/components/PluginActionResponse/hooks/useDefaultTab.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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], | ||
); | ||
} |
5 changes: 5 additions & 0 deletions
5
app/client/src/ee/PluginActionEditor/components/PluginActionResponse/hooks/useDefaultTab.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} |