2020-05-05 07:50:30 +00:00
|
|
|
import { createReducer } from "utils/AppsmithUtils";
|
|
|
|
|
import {
|
|
|
|
|
ReduxActionTypes,
|
|
|
|
|
ReduxActionErrorTypes,
|
|
|
|
|
ReduxAction,
|
|
|
|
|
} from "constants/ReduxActionConstants";
|
2020-05-14 12:33:44 +00:00
|
|
|
import _ from "lodash";
|
2020-06-04 13:49:22 +00:00
|
|
|
import { RestAction } from "entities/Action";
|
2020-07-03 08:58:58 +00:00
|
|
|
import { ActionResponse } from "api/ActionAPI";
|
2020-05-05 07:50:30 +00:00
|
|
|
|
|
|
|
|
const initialState: QueryPaneReduxState = {
|
|
|
|
|
isFetching: false,
|
|
|
|
|
isCreating: false,
|
|
|
|
|
isRunning: {},
|
|
|
|
|
isSaving: {},
|
|
|
|
|
isDeleting: {},
|
2020-05-14 12:33:44 +00:00
|
|
|
runErrorMessage: {},
|
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 08:52:45 +00:00
|
|
|
lastUsed: "", // NR
|
2020-05-05 07:50:30 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export interface QueryPaneReduxState {
|
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 08:52:45 +00:00
|
|
|
isFetching: boolean; // RR
|
2020-05-05 07:50:30 +00:00
|
|
|
isRunning: Record<string, boolean>;
|
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 08:52:45 +00:00
|
|
|
isSaving: Record<string, boolean>; // RR
|
2020-05-05 07:50:30 +00:00
|
|
|
isDeleting: Record<string, boolean>;
|
2020-05-14 12:33:44 +00:00
|
|
|
runErrorMessage: Record<string, string>;
|
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 08:52:45 +00:00
|
|
|
lastUsed: string; // NR
|
|
|
|
|
isCreating: boolean; // RR
|
2020-05-05 07:50:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const queryPaneReducer = createReducer(initialState, {
|
|
|
|
|
[ReduxActionTypes.CREATE_ACTION_INIT]: (state: QueryPaneReduxState) => {
|
|
|
|
|
return {
|
|
|
|
|
...state,
|
|
|
|
|
isCreating: true,
|
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
[ReduxActionTypes.CREATE_ACTION_SUCCESS]: (state: QueryPaneReduxState) => {
|
|
|
|
|
return {
|
|
|
|
|
...state,
|
|
|
|
|
isCreating: false,
|
|
|
|
|
};
|
|
|
|
|
},
|
2020-07-01 07:21:02 +00:00
|
|
|
[ReduxActionErrorTypes.CREATE_ACTION_ERROR]: (state: QueryPaneReduxState) => {
|
2020-05-05 07:50:30 +00:00
|
|
|
return {
|
|
|
|
|
...state,
|
|
|
|
|
isCreating: false,
|
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
[ReduxActionTypes.QUERY_PANE_CHANGE]: (
|
|
|
|
|
state: QueryPaneReduxState,
|
|
|
|
|
action: ReduxAction<{ id: string }>,
|
|
|
|
|
) => ({
|
|
|
|
|
...state,
|
|
|
|
|
lastUsed: action.payload.id,
|
|
|
|
|
}),
|
|
|
|
|
[ReduxActionTypes.UPDATE_ACTION_INIT]: (
|
|
|
|
|
state: QueryPaneReduxState,
|
2020-07-06 13:35:31 +00:00
|
|
|
action: ReduxAction<{ id: string }>,
|
2020-05-05 07:50:30 +00:00
|
|
|
) => ({
|
|
|
|
|
...state,
|
|
|
|
|
isSaving: {
|
|
|
|
|
...state.isSaving,
|
2020-07-06 13:35:31 +00:00
|
|
|
[action.payload.id]: true,
|
2020-05-05 07:50:30 +00:00
|
|
|
},
|
|
|
|
|
}),
|
|
|
|
|
[ReduxActionTypes.UPDATE_ACTION_SUCCESS]: (
|
|
|
|
|
state: QueryPaneReduxState,
|
|
|
|
|
action: ReduxAction<{ data: RestAction }>,
|
|
|
|
|
) => ({
|
|
|
|
|
...state,
|
|
|
|
|
isSaving: {
|
|
|
|
|
...state.isSaving,
|
|
|
|
|
[action.payload.data.id]: false,
|
|
|
|
|
},
|
|
|
|
|
}),
|
|
|
|
|
[ReduxActionErrorTypes.UPDATE_ACTION_ERROR]: (
|
|
|
|
|
state: QueryPaneReduxState,
|
|
|
|
|
action: ReduxAction<{ id: string }>,
|
|
|
|
|
) => ({
|
|
|
|
|
...state,
|
|
|
|
|
isSaving: {
|
|
|
|
|
...state.isSaving,
|
|
|
|
|
[action.payload.id]: false,
|
|
|
|
|
},
|
|
|
|
|
}),
|
2020-07-06 13:35:31 +00:00
|
|
|
[ReduxActionTypes.DELETE_ACTION_INIT]: (
|
2020-05-05 07:50:30 +00:00
|
|
|
state: QueryPaneReduxState,
|
|
|
|
|
action: ReduxAction<{ id: string }>,
|
|
|
|
|
) => ({
|
|
|
|
|
...state,
|
|
|
|
|
isDeleting: {
|
|
|
|
|
...state.isDeleting,
|
|
|
|
|
[action.payload.id]: true,
|
|
|
|
|
},
|
|
|
|
|
}),
|
2020-07-06 13:35:31 +00:00
|
|
|
[ReduxActionTypes.DELETE_ACTION_SUCCESS]: (
|
2020-05-05 07:50:30 +00:00
|
|
|
state: QueryPaneReduxState,
|
|
|
|
|
action: ReduxAction<{ id: string }>,
|
|
|
|
|
) => ({
|
|
|
|
|
...state,
|
|
|
|
|
isDeleting: {
|
|
|
|
|
...state.isDeleting,
|
|
|
|
|
[action.payload.id]: false,
|
|
|
|
|
},
|
|
|
|
|
}),
|
2020-07-06 13:35:31 +00:00
|
|
|
[ReduxActionErrorTypes.DELETE_ACTION_ERROR]: (
|
2020-05-05 07:50:30 +00:00
|
|
|
state: QueryPaneReduxState,
|
|
|
|
|
action: ReduxAction<{ id: string }>,
|
|
|
|
|
) => ({
|
|
|
|
|
...state,
|
|
|
|
|
isDeleting: {
|
|
|
|
|
...state.isDeleting,
|
|
|
|
|
[action.payload.id]: false,
|
|
|
|
|
},
|
|
|
|
|
}),
|
2020-07-03 08:58:58 +00:00
|
|
|
[ReduxActionTypes.RUN_ACTION_REQUEST]: (
|
2020-05-05 07:50:30 +00:00
|
|
|
state: any,
|
2020-07-03 08:58:58 +00:00
|
|
|
action: ReduxAction<{ id: string }>,
|
2020-05-05 07:50:30 +00:00
|
|
|
) => {
|
|
|
|
|
return {
|
|
|
|
|
...state,
|
|
|
|
|
isRunning: {
|
|
|
|
|
...state.isRunning,
|
2020-07-03 08:58:58 +00:00
|
|
|
[action.payload.id]: true,
|
2020-05-05 07:50:30 +00:00
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
|
2020-07-03 08:58:58 +00:00
|
|
|
[ReduxActionTypes.RUN_ACTION_SUCCESS]: (
|
2020-05-05 07:50:30 +00:00
|
|
|
state: any,
|
2020-07-03 08:58:58 +00:00
|
|
|
action: ReduxAction<{ [id: string]: ActionResponse }>,
|
2020-05-05 07:50:30 +00:00
|
|
|
) => {
|
2020-07-03 08:58:58 +00:00
|
|
|
const actionId = Object.keys(action.payload)[0];
|
2020-05-05 07:50:30 +00:00
|
|
|
return {
|
|
|
|
|
...state,
|
|
|
|
|
isRunning: {
|
|
|
|
|
...state.isRunning,
|
2020-07-03 08:58:58 +00:00
|
|
|
[actionId]: false,
|
2020-05-05 07:50:30 +00:00
|
|
|
},
|
2020-05-14 12:33:44 +00:00
|
|
|
runErrorMessage: _.omit(state.runErrorMessage, [actionId]),
|
2020-05-05 07:50:30 +00:00
|
|
|
};
|
|
|
|
|
},
|
2020-07-03 08:58:58 +00:00
|
|
|
[ReduxActionErrorTypes.RUN_ACTION_ERROR]: (
|
2020-05-05 07:50:30 +00:00
|
|
|
state: any,
|
2020-07-03 08:58:58 +00:00
|
|
|
action: ReduxAction<{ id: string; error: Error }>,
|
2020-05-05 07:50:30 +00:00
|
|
|
) => {
|
2020-07-03 08:58:58 +00:00
|
|
|
const { id, error } = action.payload;
|
2020-05-14 12:33:44 +00:00
|
|
|
|
2020-05-05 07:50:30 +00:00
|
|
|
return {
|
|
|
|
|
...state,
|
|
|
|
|
isRunning: {
|
|
|
|
|
...state.isRunning,
|
2020-07-03 08:58:58 +00:00
|
|
|
[id]: false,
|
2020-05-14 12:33:44 +00:00
|
|
|
},
|
|
|
|
|
runErrorMessage: {
|
|
|
|
|
...state.runError,
|
2020-07-03 08:58:58 +00:00
|
|
|
[id]: error.message,
|
2020-05-05 07:50:30 +00:00
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
export default queryPaneReducer;
|