-
Notifications
You must be signed in to change notification settings - Fork 4.6k
chore: Opening response pane by default on query creation and for page load queries #37245
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
Changes from 3 commits
c596aeb
55c2332
ac20d09
5142e4c
cb31dd4
98db89c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| import React, { useCallback } from "react"; | ||
| import React, { useCallback, useEffect, useState } from "react"; | ||
| import { IDEBottomView, ViewHideBehaviour } from "IDE"; | ||
| import { ActionExecutionResizerHeight } from "./constants"; | ||
| import EntityBottomTabs from "components/editorComponents/EntityBottomTabs"; | ||
|
|
@@ -8,17 +8,76 @@ 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 { action, 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 [showResponseOnFirstLoad, setShowResponseOnFirstLoad] = | ||
| useState<boolean>(false); | ||
|
|
||
| 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(() => { | ||
|
ankitakinger marked this conversation as resolved.
Outdated
|
||
| // actionResponse and responseDisplayFormat is present only when query has response available | ||
| if ( | ||
| responseDisplayFormat && | ||
| !!responseDisplayFormat?.title && | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are these needed? Would they be available when the action has a failed response?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is required and basically works only when the response is a success. This is how it works in the normal flow as well. |
||
| actionResponse && | ||
| actionResponse.isExecutionSuccess && | ||
| !showResponseOnFirstLoad | ||
| ) { | ||
| dispatch( | ||
| setPluginActionEditorDebuggerState({ | ||
| open: true, | ||
| selectedTab: DEBUGGER_TAB_KEYS.RESPONSE_TAB, | ||
| }), | ||
| ); | ||
| setShowResponseOnFirstLoad(true); | ||
| } | ||
| }, [ | ||
| responseDisplayFormat, | ||
| actionResponse, | ||
| showResponseOnFirstLoad, | ||
| dispatch, | ||
| ]); | ||
|
|
||
| useEffect(() => { | ||
| if (showSchema && !selectedTab) { | ||
| dispatch( | ||
| setPluginActionEditorDebuggerState({ | ||
| open: true, | ||
| selectedTab: DEBUGGER_TAB_KEYS.SCHEMA_TAB, | ||
| }), | ||
| ); | ||
| } | ||
| }, [showSchema, selectedTab, dispatch]); | ||
|
|
||
| // When multiple page load queries exist, we want to response tab by default for all of them | ||
| // Hence this useEffect will reset showResponseOnFirstLoad flag used to track whether to show response tab or not | ||
| useEffect(() => { | ||
|
ankitakinger marked this conversation as resolved.
Outdated
|
||
| if (action?.id) { | ||
|
ankitakinger marked this conversation as resolved.
Outdated
|
||
| setShowResponseOnFirstLoad(false); | ||
| } | ||
| }, [action?.id]); | ||
|
|
||
| const toggleHide = useCallback( | ||
| () => dispatch(setPluginActionEditorDebuggerState({ open: !open })), | ||
| [dispatch, open], | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.