PromucFlow_constructor/app/client/src/reducers/uiReducers/apiPaneReducer.ts
NandanAnantharamu 05f190c102
Feature/entity browse (#220)
# New Feature: Entity Explorer
- Entities are actions (apis and queries), datasources, pages, and widgets
- With this new feature, all entities in the application will be available
  to view in the new entity explorer sidebar
- All existing application features from the api sidebar, query sidebar, datasource sidebar and pages sidebar
  now are avialable on the entity explorer sidebar
- Users are now able to quickly switch to any entity in the application from the entity explorer sidebar.
- Users can also search all entities in the application from the new sidebar. Use cmd + f or ctrl + f to focus on the search input
- Users can rename entities from the new sidebar
- Users can also perform contextual actions on these entities like set a page as home page, copy/move actions, delete entity, etc from the context menu available alongside the entities in the sidebar
- Users can view the properties of the entities in the sidebar, as well as copy bindings to use in the application.
2020-08-10 14:22:45 +05:30

195 lines
4.6 KiB
TypeScript

import { createReducer } from "utils/AppsmithUtils";
import {
ReduxActionTypes,
ReduxActionErrorTypes,
ReduxAction,
} from "constants/ReduxActionConstants";
import { RestAction } from "entities/Action";
import { UpdateActionPropertyActionPayload } from "actions/actionActions";
const initialState: ApiPaneReduxState = {
isCreating: false,
isFetching: false,
isRunning: {},
isSaving: {},
isDeleting: {},
isDirty: {},
currentCategory: "",
extraformData: {},
};
export interface ApiPaneReduxState {
isCreating: boolean; // RR
isFetching: boolean; // RR
isRunning: Record<string, boolean>;
isSaving: Record<string, boolean>; // RN
isDeleting: Record<string, boolean>;
isDirty: Record<string, boolean>;
currentCategory: string;
extraformData: Record<string, any>;
}
const apiPaneReducer = createReducer(initialState, {
[ReduxActionTypes.FETCH_ACTIONS_INIT]: (state: ApiPaneReduxState) => ({
...state,
isFetching: true,
}),
[ReduxActionTypes.FETCH_ACTIONS_SUCCESS]: (state: ApiPaneReduxState) => ({
...state,
isFetching: false,
}),
[ReduxActionErrorTypes.FETCH_ACTIONS_ERROR]: (state: ApiPaneReduxState) => ({
...state,
isFetching: false,
}),
[ReduxActionTypes.CREATE_ACTION_INIT]: (
state: ApiPaneReduxState,
): ApiPaneReduxState => ({
...state,
isCreating: true,
}),
[ReduxActionTypes.CREATE_ACTION_SUCCESS]: (
state: ApiPaneReduxState,
): ApiPaneReduxState => ({
...state,
isCreating: false,
}),
[ReduxActionErrorTypes.CREATE_ACTION_ERROR]: (
state: ApiPaneReduxState,
): ApiPaneReduxState => ({
...state,
isCreating: false,
}),
[ReduxActionTypes.RUN_ACTION_REQUEST]: (
state: ApiPaneReduxState,
action: ReduxAction<{ id: string }>,
) => ({
...state,
isRunning: {
...state.isRunning,
[action.payload.id]: true,
},
}),
[ReduxActionTypes.RUN_ACTION_SUCCESS]: (
state: ApiPaneReduxState,
action: ReduxAction<{ [id: string]: any }>,
) => {
const actionId = Object.keys(action.payload)[0];
return {
...state,
isRunning: {
...state.isRunning,
[actionId]: false,
},
};
},
[ReduxActionErrorTypes.RUN_ACTION_ERROR]: (
state: ApiPaneReduxState,
action: ReduxAction<{ id: string }>,
) => ({
...state,
isRunning: {
...state.isRunning,
[action.payload.id]: false,
},
}),
[ReduxActionTypes.UPDATE_ACTION_PROPERTY]: (
state: ApiPaneReduxState,
action: ReduxAction<UpdateActionPropertyActionPayload>,
) => ({
...state,
isDirty: {
...state.isDirty,
[action.payload.id]: true,
},
}),
[ReduxActionTypes.UPDATE_ACTION_INIT]: (
state: ApiPaneReduxState,
action: ReduxAction<{ id: string }>,
) => ({
...state,
isSaving: {
...state.isSaving,
[action.payload.id]: true,
},
}),
[ReduxActionTypes.UPDATE_ACTION_SUCCESS]: (
state: ApiPaneReduxState,
action: ReduxAction<{ data: RestAction }>,
) => ({
...state,
isSaving: {
...state.isSaving,
[action.payload.data.id]: false,
},
isDirty: {
...state.isDirty,
[action.payload.data.id]: false,
},
}),
[ReduxActionErrorTypes.UPDATE_ACTION_ERROR]: (
state: ApiPaneReduxState,
action: ReduxAction<{ id: string }>,
) => ({
...state,
isSaving: {
...state.isSaving,
[action.payload.id]: false,
},
}),
[ReduxActionTypes.DELETE_ACTION_INIT]: (
state: ApiPaneReduxState,
action: ReduxAction<{ id: string }>,
) => ({
...state,
isDeleting: {
...state.isDeleting,
[action.payload.id]: true,
},
}),
[ReduxActionTypes.DELETE_ACTION_SUCCESS]: (
state: ApiPaneReduxState,
action: ReduxAction<{ id: string }>,
) => ({
...state,
isDeleting: {
...state.isDeleting,
[action.payload.id]: false,
},
}),
[ReduxActionErrorTypes.DELETE_ACTION_ERROR]: (
state: ApiPaneReduxState,
action: ReduxAction<{ id: string }>,
) => ({
...state,
isDeleting: {
...state.isDeleting,
[action.payload.id]: false,
},
}),
[ReduxActionTypes.SET_CURRENT_CATEGORY]: (
state: ApiPaneReduxState,
action: ReduxAction<{ category: string }>,
) => ({
...state,
currentCategory: action.payload.category,
}),
[ReduxActionTypes.SET_EXTRA_FORMDATA]: (
state: ApiPaneReduxState,
action: ReduxAction<{ id: string; values: {} }>,
) => {
const { id, values } = action.payload;
return {
...state,
extraformData: {
...state.extraformData,
[id]: values,
},
};
},
});
export default apiPaneReducer;