diff --git a/app/client/src/components/editorComponents/ActionRightPane/index.tsx b/app/client/src/components/editorComponents/ActionRightPane/index.tsx index fe641b9c84..3758d2ee70 100644 --- a/app/client/src/components/editorComponents/ActionRightPane/index.tsx +++ b/app/client/src/components/editorComponents/ActionRightPane/index.tsx @@ -22,10 +22,7 @@ import type { } from "api/ActionAPI"; import { getPagePermissions } from "selectors/editorSelectors"; import DatasourceStructureHeader from "pages/Editor/DatasourceInfo/DatasourceStructureHeader"; -import { - DatasourceStructureContainer as DataStructureList, - SCHEMALESS_PLUGINS, -} from "pages/Editor/DatasourceInfo/DatasourceStructureContainer"; +import { DatasourceStructureContainer as DataStructureList } from "pages/Editor/DatasourceInfo/DatasourceStructureContainer"; import { getDatasourceStructureById, getIsFetchingDatasourceStructure, @@ -171,6 +168,8 @@ function ActionSidebar({ hasConnections, hasResponse, pluginId, + showSchema, + showSuggestedWidgets = true, suggestedWidgets, }: { actionName: string; @@ -182,6 +181,8 @@ function ActionSidebar({ context: DatasourceStructureContext; additionalSections?: React.ReactNode; actionRightPaneBackLink: React.ReactNode; + showSuggestedWidgets?: boolean; + showSchema: boolean; }) { const dispatch = useDispatch(); const widgets = useSelector(getWidgets); @@ -267,10 +268,6 @@ function ActionSidebar({ }); }; - const showSchema = - pluginDatasourceForm !== DatasourceComponentTypes.RestAPIDatasourceForm && - !SCHEMALESS_PLUGINS.includes(pluginName); - useEffect(() => { if (showSchema) { checkAndShowWalkthrough(); @@ -286,13 +283,13 @@ function ActionSidebar({ pagePermissions, ); - const showSuggestedWidgets = + const suggestedWidgetsEnabled = canEditPage && hasResponse && suggestedWidgets && !!suggestedWidgets.length; const showSnipingMode = hasResponse && hasWidgets; if ( !hasConnections && - !showSuggestedWidgets && + !suggestedWidgetsEnabled && !showSnipingMode && // putting this here to make the placeholder only appear for rest APIs. pluginDatasourceForm === DatasourceComponentTypes.RestAPIDatasourceForm @@ -300,53 +297,59 @@ function ActionSidebar({ return {createMessage(NO_CONNECTIONS)}; } + if (!additionalSections && !showSchema && !showSuggestedWidgets) { + return null; + } + return ( {actionRightPaneBackLink} {additionalSections && ( - <> - - {additionalSections} - - - + + {additionalSections} + )} {showSchema && ( - - + {additionalSections && } + - - - - - + + + + + + + )} - {showSchema && } - {showSuggestedWidgets ? ( + {showSuggestedWidgets && showSchema && } + {showSuggestedWidgets && suggestedWidgetsEnabled && ( - ) : ( + )} + {showSuggestedWidgets && !suggestedWidgetsEnabled && ( + getPluginDatasourceComponentFromId(state, pluginId), + ); + + const pluginName = useSelector((state) => + getPluginNameFromId(state, pluginId), + ); + + return ( + pluginDatasourceForm !== DatasourceComponentTypes.RestAPIDatasourceForm && + !SCHEMALESS_PLUGINS.includes(pluginName) + ); +} + +export default useShowSchema; diff --git a/app/client/src/pages/Editor/APIEditor/ApiRightPane.tsx b/app/client/src/pages/Editor/APIEditor/ApiRightPane.tsx index c698676482..2bad629176 100644 --- a/app/client/src/pages/Editor/APIEditor/ApiRightPane.tsx +++ b/app/client/src/pages/Editor/APIEditor/ApiRightPane.tsx @@ -20,6 +20,7 @@ import { DatasourceStructureContext } from "entities/Datasource"; import { getCurrentEnvironmentId } from "@appsmith/selectors/environmentSelectors"; import type { SuggestedWidget } from "api/ActionAPI"; +import useShowSchema from "components/editorComponents/ActionRightPane/useShowSchema"; interface ApiRightPaneProps { additionalSections?: React.ReactNode; @@ -142,7 +143,7 @@ const DataSourceNameContainer = styled.div` } `; -const SomeWrapper = styled.div` +const ActionRightPaneWrapper = styled.div` height: 100%; padding: 0 var(--ads-v2-spaces-4); `; @@ -209,6 +210,8 @@ function ApiRightPane(props: ApiRightPaneProps) { const selectedTab = useSelector(getApiRightPaneSelectedTab); const currentEnvironmentId = useSelector(getCurrentEnvironmentId); + const showSchema = useShowSchema(props.pluginId); + const setSelectedTab = useCallback((selectedIndex: string) => { dispatch(setApiRightPaneSelectedTab(selectedIndex)); }, []); @@ -230,6 +233,8 @@ function ApiRightPane(props: ApiRightPaneProps) { [props.datasources, props.currentActionDatasourceId], ); + if (!props.additionalSections && !props.showTabbedSection) return null; + return ( @@ -334,7 +339,7 @@ function ApiRightPane(props: ApiRightPaneProps) { )} - + - + )} diff --git a/app/client/src/pages/Editor/QueryEditor/EditorJSONtoForm.tsx b/app/client/src/pages/Editor/QueryEditor/EditorJSONtoForm.tsx index aeda5c3032..8a018981be 100644 --- a/app/client/src/pages/Editor/QueryEditor/EditorJSONtoForm.tsx +++ b/app/client/src/pages/Editor/QueryEditor/EditorJSONtoForm.tsx @@ -91,6 +91,7 @@ import { FEATURE_FLAG } from "@appsmith/entities/FeatureFlag"; import { QueryEditorContext } from "./QueryEditorContext"; import QueryResponseTabView from "./QueryResponseView"; import { setDebuggerSelectedTab, showDebugger } from "actions/debuggerActions"; +import useShowSchema from "components/editorComponents/ActionRightPane/useShowSchema"; const QueryFormContainer = styled.form` flex: 1; @@ -332,6 +333,7 @@ export function EditorJSONtoForm(props: Props) { closeEditorLink, moreActionsMenu, saveActionName, + showSuggestedWidgets = true, } = useContext(QueryEditorContext); const params = useParams<{ apiId?: string; queryId?: string }>(); @@ -365,6 +367,13 @@ export function EditorJSONtoForm(props: Props) { userWorkspacePermissions, ); + const showSchema = useShowSchema(currentActionConfig?.pluginId || ""); + + const showRightPane = + showSchema || + showSuggestedWidgets || + Boolean(actionRightPaneAdditionSections); + // get the current action's plugin name const currentActionPluginName = useSelector((state: AppState) => getPluginNameFromId(state, currentActionConfig?.pluginId || ""), @@ -783,19 +792,23 @@ export function EditorJSONtoForm(props: Props) { )} - - - + {showRightPane && ( + + + + )} diff --git a/app/client/src/pages/Editor/QueryEditor/QueryEditorContext.tsx b/app/client/src/pages/Editor/QueryEditor/QueryEditorContext.tsx index f4ddbef98b..f5e4a990d2 100644 --- a/app/client/src/pages/Editor/QueryEditor/QueryEditorContext.tsx +++ b/app/client/src/pages/Editor/QueryEditor/QueryEditorContext.tsx @@ -17,6 +17,7 @@ interface QueryEditorContextContextProps { ) => ReduxAction; closeEditorLink?: React.ReactNode; actionRightPaneAdditionSections?: React.ReactNode; + showSuggestedWidgets?: boolean; } type QueryEditorContextProviderProps = @@ -36,6 +37,7 @@ export function QueryEditorContextProvider({ onCreateDatasourceClick, onEntityNotFoundBackClick, saveActionName, + showSuggestedWidgets, }: QueryEditorContextProviderProps) { const value = useMemo( () => ({ @@ -47,6 +49,7 @@ export function QueryEditorContextProvider({ onCreateDatasourceClick, onEntityNotFoundBackClick, saveActionName, + showSuggestedWidgets, }), [ actionRightPaneBackLink, @@ -57,6 +60,7 @@ export function QueryEditorContextProvider({ onCreateDatasourceClick, onEntityNotFoundBackClick, saveActionName, + showSuggestedWidgets, ], );