-
Notifications
You must be signed in to change notification settings - Fork 4.7k
chore: Updating some states related to action execution #36801
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 1 commit
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 |
|---|---|---|
|
|
@@ -17,17 +17,24 @@ import DebuggerLogs from "components/editorComponents/Debugger/DebuggerLogs"; | |
| import { PluginType } from "entities/Action"; | ||
| import { ApiResponse } from "PluginActionEditor/components/PluginActionResponse/components/ApiResponse"; | ||
| import { ApiResponseHeaders } from "PluginActionEditor/components/PluginActionResponse/components/ApiResponseHeaders"; | ||
| import { noop } from "lodash"; | ||
| import { EditorTheme } from "components/editorComponents/CodeEditor/EditorConfig"; | ||
| import { getErrorCount } from "selectors/debuggerSelectors"; | ||
| import { getPluginActionDebuggerState } from "PluginActionEditor/store"; | ||
| import { | ||
| getPluginActionDebuggerState, | ||
| isActionRunning, | ||
| } from "PluginActionEditor/store"; | ||
| import { doesPluginRequireDatasource } from "ee/entities/Engine/actionHelpers"; | ||
| import useShowSchema from "components/editorComponents/ActionRightPane/useShowSchema"; | ||
| import Schema from "components/editorComponents/Debugger/Schema"; | ||
| import QueryResponseTab from "pages/Editor/QueryEditor/QueryResponseTab"; | ||
| import type { SourceEntity } from "entities/AppsmithConsole"; | ||
| import { ENTITY_TYPE as SOURCE_ENTITY_TYPE } from "ee/entities/AppsmithConsole/utils"; | ||
| import { useHandleRunClick } from "PluginActionEditor/hooks"; | ||
| import useDebuggerTriggerClick from "components/editorComponents/Debugger/hooks/useDebuggerTriggerClick"; | ||
| import { useFeatureFlag } from "utils/hooks/useFeatureFlag"; | ||
| import { FEATURE_FLAG } from "ee/entities/FeatureFlag"; | ||
| import { getHasExecuteActionPermission } from "ee/utils/BusinessFeatures/permissionPageHelpers"; | ||
| import { DEFAULT_DATASOURCE_NAME } from "constants/ApiEditorConstants/ApiEditorConstants"; | ||
|
|
||
| function usePluginActionResponseTabs() { | ||
| const { action, actionResponse, datasource, plugin } = | ||
|
|
@@ -42,8 +49,36 @@ function usePluginActionResponseTabs() { | |
|
|
||
| const { responseTabHeight } = useSelector(getPluginActionDebuggerState); | ||
|
|
||
| const onDebugClick = useDebuggerTriggerClick(); | ||
| const isRunning = useSelector(isActionRunning(action.id)); | ||
|
|
||
| const isFeatureEnabled = useFeatureFlag(FEATURE_FLAG.license_gac_enabled); | ||
| const isExecutePermitted = getHasExecuteActionPermission( | ||
| isFeatureEnabled, | ||
| action?.userPermissions, | ||
| ); | ||
| // this gets the url of the current action's datasource | ||
| const actionDatasourceUrl = | ||
| action?.datasource?.datasourceConfiguration?.url || ""; | ||
| const actionDatasourceUrlPath = action?.actionConfiguration?.path || ""; | ||
| // this gets the name of the current action's datasource | ||
| const actionDatasourceName = action?.datasource.name || ""; | ||
|
|
||
|
ankitakinger marked this conversation as resolved.
Outdated
|
||
| // if the url is empty and the action's datasource name is the default datasource name (this means the api does not have a datasource attached) | ||
| // or the user does not have permission, | ||
| // we block action execution. | ||
| const blockExecution = | ||
| (!actionDatasourceUrl && | ||
| !actionDatasourceUrlPath && | ||
| actionDatasourceName === DEFAULT_DATASOURCE_NAME) || | ||
| !isExecutePermitted; | ||
|
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. This is only related to API actions and should be extracted out into its own hook. Also should this condition not be applied at the toolbar run level as well?
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. Yes you're correct. It will be needed there too. Although, I just checked, both Query and Api uses different conditions for blocking execution. Should we return the value from the hook based on action type?
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. If they rely on completely different logic to decide this, it should be extracted out into separate utils.
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. I've kept it in the same hook because |
||
|
|
||
|
ankitakinger marked this conversation as resolved.
|
||
| const tabs: BottomTab[] = []; | ||
|
|
||
| const onRunClick = () => { | ||
| handleRunClick(); | ||
| }; | ||
|
|
||
| if (IDEViewMode === EditorViewMode.FullScreen) { | ||
| tabs.push( | ||
| { | ||
|
|
@@ -69,9 +104,9 @@ function usePluginActionResponseTabs() { | |
| <ApiResponse | ||
| action={action} | ||
| actionResponse={actionResponse} | ||
| isRunDisabled={false} | ||
| isRunning={false} | ||
| onRunClick={handleRunClick} | ||
| isRunDisabled={blockExecution} | ||
| isRunning={isRunning} | ||
| onRunClick={onRunClick} | ||
| responseTabHeight={responseTabHeight} | ||
| theme={EditorTheme.LIGHT} | ||
| /> | ||
|
|
@@ -83,10 +118,10 @@ function usePluginActionResponseTabs() { | |
| panelComponent: ( | ||
| <ApiResponseHeaders | ||
| actionResponse={actionResponse} | ||
| isRunDisabled={false} | ||
| isRunning={false} | ||
| onDebugClick={noop} | ||
| onRunClick={handleRunClick} | ||
| isRunDisabled={blockExecution} | ||
| isRunning={isRunning} | ||
| onDebugClick={onDebugClick} | ||
| onRunClick={onRunClick} | ||
| /> | ||
| ), | ||
| }, | ||
|
|
@@ -132,8 +167,8 @@ function usePluginActionResponseTabs() { | |
| actionName={action.name} | ||
| actionSource={actionSource} | ||
| currentActionConfig={action} | ||
| isRunning={false} | ||
| onRunClick={handleRunClick} | ||
| isRunning={isRunning} | ||
| onRunClick={onRunClick} | ||
| runErrorMessage={""} // TODO | ||
| /> | ||
| ), | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.