-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: [Plugin Action Editor] Combine Plugin Editor UI state (#36651)
## Description Removes the parallel apiPaneReducer and queryPaneReducer and combines it into pluginActionEditor Fixes #36153 ## 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/11231694032> > Commit: 3a204e2 > <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=11231694032&attempt=2" target="_blank">Cypress dashboard</a>. > Tags: `@tag.All` > Spec: > <hr>Tue, 08 Oct 2024 10:15:30 UTC <!-- end of auto-generated comment: Cypress test results --> ## Communication Should the DevRel and Marketing teams inform users about this change? - [ ] Yes - [x] No <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit ## Release Notes - **New Features** - Introduced a new constant `POST_BODY_FORM_DATA_KEY` for improved data handling. - Added several action creators and selectors for enhanced management of the plugin action editor's state. - Implemented state management for the plugin action editor's debugger. - Added the ability to execute commands related to plugins in the `CodeEditor` component. - Introduced a new enumeration `DEBUGGER_TAB_KEYS` for better organization of debugger tabs. - **Improvements** - Refactored import statements for better organization and reduced complexity. - Enhanced the `PluginActionResponse` component to focus on plugin action state management. - Updated the tab management logic in various components to reflect the new plugin action state. - Improved state management in the `QueryEditor` and `APIEditor` components to accurately represent action processing states. - Added error handling in the `ActionSettings` component for missing configuration. - **Bug Fixes** - Updated logic in hooks to ensure proper state management for plugin actions. - Adjusted navigation and tab selection methods to align with the new plugin action state management. - Corrected test selectors for error tabs in Cypress tests to ensure accurate UI interactions. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
- Loading branch information
Showing
72 changed files
with
665 additions
and
984 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
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
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
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
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
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
27 changes: 12 additions & 15 deletions
27
...ditor/components/PluginActionForm/components/CommonEditorForm/hooks/useSelectedFormTab.ts
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 |
---|---|---|
@@ -1,25 +1,22 @@ | ||
import { useCallback } from "react"; | ||
import { useDispatch, useSelector } from "react-redux"; | ||
import { getApiPaneConfigSelectedTabIndex } from "selectors/apiPaneSelectors"; | ||
import { API_EDITOR_TABS } from "constants/ApiEditorConstants/CommonApiConstants"; | ||
import { setApiPaneConfigSelectedTabIndex } from "actions/apiPaneActions"; | ||
import { | ||
getPluginActionConfigSelectedTab, | ||
setPluginActionEditorSelectedTab, | ||
} from "PluginActionEditor/store"; | ||
|
||
export function useSelectedFormTab(): [string, (id: string) => void] { | ||
export function useSelectedFormTab(): [ | ||
string | undefined, | ||
(id: string) => void, | ||
] { | ||
const dispatch = useDispatch(); | ||
// the redux form has been configured with indexes, but the new ads components need strings to work. | ||
// these functions convert them back and forth as needed. | ||
const selectedIndex = useSelector(getApiPaneConfigSelectedTabIndex); | ||
const selectedValue = Object.values(API_EDITOR_TABS)[selectedIndex]; | ||
const setSelectedIndex = useCallback( | ||
const selectedValue = useSelector(getPluginActionConfigSelectedTab); | ||
const setSelectedTab = useCallback( | ||
(value: string) => { | ||
const index = Object.values(API_EDITOR_TABS).indexOf( | ||
value as API_EDITOR_TABS, | ||
); | ||
|
||
dispatch(setApiPaneConfigSelectedTabIndex(index)); | ||
dispatch(setPluginActionEditorSelectedTab(value)); | ||
}, | ||
[dispatch], | ||
); | ||
|
||
return [selectedValue, setSelectedIndex]; | ||
return [selectedValue, setSelectedTab]; | ||
} |
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
3 changes: 1 addition & 2 deletions
3
app/client/src/PluginActionEditor/components/PluginActionForm/hooks/useChangeActionCall.ts
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
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
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 @@ | ||
export const POST_BODY_FORM_DATA_KEY = "displayFormat"; |
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
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,4 @@ | ||
export { default as pluginActionReducer } from "./pluginEditorReducer"; | ||
|
||
export * from "./pluginActionEditorActions"; | ||
export * from "./pluginActionEditorSelectors"; |
57 changes: 57 additions & 0 deletions
57
app/client/src/PluginActionEditor/store/pluginActionEditorActions.ts
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,57 @@ | ||
import type { PluginEditorDebuggerState } from "./pluginEditorReducer"; | ||
import { | ||
type ReduxAction, | ||
ReduxActionTypes, | ||
} from "ee/constants/ReduxActionConstants"; | ||
import type { Action } from "entities/Action"; | ||
|
||
export const setPluginActionEditorDebuggerState = ( | ||
payload: Partial<PluginEditorDebuggerState>, | ||
) => ({ | ||
type: ReduxActionTypes.SET_PLUGIN_ACTION_EDITOR_DEBUGGER_STATE, | ||
payload, | ||
}); | ||
|
||
export const setPluginActionEditorSelectedTab = (payload: string) => ({ | ||
type: ReduxActionTypes.SET_PLUGIN_ACTION_EDITOR_FORM_SELECTED_TAB, | ||
payload: { | ||
selectedTab: payload, | ||
}, | ||
}); | ||
|
||
export const updatePostBodyContentType = ( | ||
title: string, | ||
apiId: string, | ||
): ReduxAction<{ title: string; apiId: string }> => ({ | ||
type: ReduxActionTypes.UPDATE_API_ACTION_BODY_CONTENT_TYPE, | ||
payload: { title, apiId }, | ||
}); | ||
|
||
export const changeApi = ( | ||
id: string, | ||
isSaas: boolean, | ||
newApi?: boolean, | ||
): ReduxAction<{ id: string; isSaas: boolean; newApi?: boolean }> => { | ||
return { | ||
type: ReduxActionTypes.API_PANE_CHANGE_API, | ||
payload: { id, isSaas, newApi }, | ||
}; | ||
}; | ||
|
||
export interface ChangeQueryPayload { | ||
baseQueryId: string; | ||
packageId?: string; | ||
applicationId?: string; | ||
basePageId?: string; | ||
moduleId?: string; | ||
workflowId?: string; | ||
newQuery?: boolean; | ||
action?: Action; | ||
} | ||
|
||
export const changeQuery = (payload: ChangeQueryPayload) => { | ||
return { | ||
type: ReduxActionTypes.QUERY_PANE_CHANGE, | ||
payload, | ||
}; | ||
}; |
61 changes: 61 additions & 0 deletions
61
app/client/src/PluginActionEditor/store/pluginActionEditorSelectors.ts
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,61 @@ | ||
import type { AppState } from "ee/reducers"; | ||
import { createSelector } from "reselect"; | ||
|
||
import { POST_BODY_FORM_DATA_KEY } from "../constants"; | ||
|
||
export const getActionEditorSavingMap = (state: AppState) => | ||
state.ui.pluginActionEditor.isSaving; | ||
|
||
export const isActionSaving = (id: string) => | ||
createSelector([getActionEditorSavingMap], (savingMap) => { | ||
return id in savingMap && savingMap[id]; | ||
}); | ||
|
||
const getActionDirtyState = (state: AppState) => | ||
state.ui.pluginActionEditor.isDirty; | ||
|
||
export const isActionDirty = (id: string) => | ||
createSelector([getActionDirtyState], (actionDirtyMap) => { | ||
return id in actionDirtyMap && actionDirtyMap[id]; | ||
}); | ||
|
||
const getActionRunningState = (state: AppState) => | ||
state.ui.pluginActionEditor.isRunning; | ||
|
||
export const isActionRunning = (id: string) => | ||
createSelector( | ||
[getActionRunningState], | ||
(isRunningMap) => id in isRunningMap && isRunningMap[id], | ||
); | ||
|
||
const getActionDeletingState = (state: AppState) => | ||
state.ui.pluginActionEditor.isDeleting; | ||
|
||
export const isActionDeleting = (id: string) => | ||
createSelector( | ||
[getActionDeletingState], | ||
(deletingMap) => id in deletingMap && deletingMap[id], | ||
); | ||
|
||
type GetFormData = ( | ||
state: AppState, | ||
id: string, | ||
) => { label: string; value: string } | undefined; | ||
|
||
export const getPostBodyFormat: GetFormData = (state, id) => { | ||
const formData = state.ui.pluginActionEditor.formData; | ||
|
||
if (id in formData) { | ||
return formData[id][POST_BODY_FORM_DATA_KEY]; | ||
} | ||
|
||
return undefined; | ||
}; | ||
export const getPluginActionConfigSelectedTab = (state: AppState) => | ||
state.ui.pluginActionEditor.selectedConfigTab; | ||
|
||
export const getPluginActionDebuggerState = (state: AppState) => | ||
state.ui.pluginActionEditor.debugger; | ||
|
||
export const isPluginActionCreating = (state: AppState) => | ||
state.ui.pluginActionEditor.isCreating; |
Oops, something went wrong.