2021-02-11 12:28:06 +00:00
|
|
|
import {
|
|
|
|
|
ReduxAction,
|
|
|
|
|
ReduxActionTypes,
|
|
|
|
|
ReduxActionWithCallbacks,
|
|
|
|
|
} from "constants/ReduxActionConstants";
|
2021-01-12 04:17:28 +00:00
|
|
|
import { CreateDatasourceConfig } from "api/DatasourcesApi";
|
|
|
|
|
import { Datasource } from "entities/Datasource";
|
2021-04-22 03:30:09 +00:00
|
|
|
import { PluginType } from "entities/Action";
|
2021-07-29 08:13:10 +00:00
|
|
|
import { executeDatasourceQueryRequest } from "../api/DatasourcesApi";
|
|
|
|
|
import { ResponseMeta } from "../api/ApiResponses";
|
2020-04-28 06:52:53 +00:00
|
|
|
|
2020-05-07 04:44:52 +00:00
|
|
|
export const createDatasourceFromForm = (payload: CreateDatasourceConfig) => {
|
|
|
|
|
return {
|
|
|
|
|
type: ReduxActionTypes.CREATE_DATASOURCE_FROM_FORM_INIT,
|
|
|
|
|
payload,
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
2021-02-11 12:28:06 +00:00
|
|
|
export const updateDatasource = (
|
|
|
|
|
payload: Datasource,
|
|
|
|
|
onSuccess?: ReduxAction<unknown>,
|
|
|
|
|
onError?: ReduxAction<unknown>,
|
|
|
|
|
): ReduxActionWithCallbacks<Datasource, unknown, unknown> => {
|
2020-04-28 06:52:53 +00:00
|
|
|
return {
|
|
|
|
|
type: ReduxActionTypes.UPDATE_DATASOURCE_INIT,
|
2020-09-02 06:07:18 +00:00
|
|
|
payload,
|
2021-02-11 12:28:06 +00:00
|
|
|
onSuccess,
|
|
|
|
|
onError,
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
2021-04-19 13:17:27 +00:00
|
|
|
export type UpdateDatasourceSuccessAction = {
|
|
|
|
|
type: string;
|
|
|
|
|
payload: Datasource;
|
|
|
|
|
redirect: boolean;
|
2021-07-29 08:13:10 +00:00
|
|
|
queryParams?: Record<string, string>;
|
2021-04-19 13:17:27 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const updateDatasourceSuccess = (
|
|
|
|
|
payload: Datasource,
|
|
|
|
|
redirect = true,
|
2021-07-29 08:13:10 +00:00
|
|
|
queryParams = {},
|
2021-04-19 13:17:27 +00:00
|
|
|
): UpdateDatasourceSuccessAction => ({
|
|
|
|
|
type: ReduxActionTypes.UPDATE_DATASOURCE_SUCCESS,
|
|
|
|
|
payload,
|
|
|
|
|
redirect,
|
2021-07-29 08:13:10 +00:00
|
|
|
queryParams,
|
2021-04-19 13:17:27 +00:00
|
|
|
});
|
|
|
|
|
|
2021-02-16 12:28:03 +00:00
|
|
|
export const redirectAuthorizationCode = (
|
|
|
|
|
pageId: string,
|
|
|
|
|
datasourceId: string,
|
2021-04-22 03:30:09 +00:00
|
|
|
pluginType: PluginType,
|
2021-02-16 12:28:03 +00:00
|
|
|
) => {
|
2021-02-11 12:28:06 +00:00
|
|
|
return {
|
|
|
|
|
type: ReduxActionTypes.REDIRECT_AUTHORIZATION_CODE,
|
|
|
|
|
payload: {
|
2021-02-16 12:28:03 +00:00
|
|
|
pageId,
|
|
|
|
|
datasourceId,
|
2021-04-22 03:30:09 +00:00
|
|
|
pluginType,
|
2021-02-11 12:28:06 +00:00
|
|
|
},
|
2020-04-28 06:52:53 +00:00
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
2021-07-29 08:13:10 +00:00
|
|
|
export const fetchDatasourceStructure = (id: string, ignoreCache?: boolean) => {
|
2020-09-21 09:11:42 +00:00
|
|
|
return {
|
|
|
|
|
type: ReduxActionTypes.FETCH_DATASOURCE_STRUCTURE_INIT,
|
|
|
|
|
payload: {
|
|
|
|
|
id,
|
2021-07-29 08:13:10 +00:00
|
|
|
ignoreCache,
|
2020-09-21 09:11:42 +00:00
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
2020-10-12 12:43:35 +00:00
|
|
|
export const expandDatasourceEntity = (id: string) => {
|
|
|
|
|
return {
|
|
|
|
|
type: ReduxActionTypes.EXPAND_DATASOURCE_ENTITY,
|
|
|
|
|
payload: id,
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
2020-09-29 04:17:25 +00:00
|
|
|
export const refreshDatasourceStructure = (id: string) => {
|
|
|
|
|
return {
|
|
|
|
|
type: ReduxActionTypes.REFRESH_DATASOURCE_STRUCTURE_INIT,
|
|
|
|
|
payload: {
|
|
|
|
|
id,
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
2020-08-26 05:24:44 +00:00
|
|
|
export const saveDatasourceName = (payload: { id: string; name: string }) => ({
|
|
|
|
|
type: ReduxActionTypes.SAVE_DATASOURCE_NAME,
|
|
|
|
|
payload: payload,
|
|
|
|
|
});
|
|
|
|
|
|
2021-12-07 09:45:18 +00:00
|
|
|
export const changeDatasource = (payload: { datasource?: Datasource }) => {
|
2020-05-19 06:10:59 +00:00
|
|
|
return {
|
|
|
|
|
type: ReduxActionTypes.CHANGE_DATASOURCE,
|
|
|
|
|
payload,
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
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
|
|
|
export const switchDatasource = (id: string) => {
|
|
|
|
|
return {
|
|
|
|
|
type: ReduxActionTypes.SWITCH_DATASOURCE,
|
|
|
|
|
payload: { datasourceId: id },
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
2020-04-28 06:52:53 +00:00
|
|
|
export const testDatasource = (payload: Partial<Datasource>) => {
|
|
|
|
|
return {
|
|
|
|
|
type: ReduxActionTypes.TEST_DATASOURCE_INIT,
|
|
|
|
|
payload,
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
2021-04-22 03:30:09 +00:00
|
|
|
export const deleteDatasource = (
|
|
|
|
|
payload: Partial<Datasource>,
|
|
|
|
|
onSuccess?: ReduxAction<unknown>,
|
|
|
|
|
onError?: ReduxAction<unknown>,
|
2021-07-29 08:13:10 +00:00
|
|
|
onSuccessCallback?: () => void,
|
2021-04-22 03:30:09 +00:00
|
|
|
): ReduxActionWithCallbacks<Partial<Datasource>, unknown, unknown> => {
|
2020-04-29 10:03:56 +00:00
|
|
|
return {
|
|
|
|
|
type: ReduxActionTypes.DELETE_DATASOURCE_INIT,
|
|
|
|
|
payload,
|
2021-04-22 03:30:09 +00:00
|
|
|
onSuccess,
|
|
|
|
|
onError,
|
2021-07-29 08:13:10 +00:00
|
|
|
onSuccessCallback,
|
2020-04-29 10:03:56 +00:00
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
2020-10-12 13:37:18 +00:00
|
|
|
export const setDatsourceEditorMode = (payload: {
|
|
|
|
|
id: string;
|
|
|
|
|
viewMode: boolean;
|
|
|
|
|
}) => {
|
|
|
|
|
return {
|
|
|
|
|
type: ReduxActionTypes.SET_DATASOURCE_EDITOR_MODE,
|
|
|
|
|
payload,
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
2020-04-28 06:52:53 +00:00
|
|
|
export const fetchDatasources = () => {
|
|
|
|
|
return {
|
|
|
|
|
type: ReduxActionTypes.FETCH_DATASOURCES_INIT,
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
2021-07-07 03:46:16 +00:00
|
|
|
export const fetchMockDatasources = () => {
|
|
|
|
|
return {
|
|
|
|
|
type: ReduxActionTypes.FETCH_MOCK_DATASOURCES_INIT,
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
2021-07-29 08:13:10 +00:00
|
|
|
export interface addMockRequest
|
|
|
|
|
extends ReduxAction<{
|
|
|
|
|
name: string;
|
|
|
|
|
organizationId: string;
|
|
|
|
|
pluginId: string;
|
|
|
|
|
packageName: string;
|
|
|
|
|
isGeneratePageMode?: string;
|
|
|
|
|
}> {
|
|
|
|
|
extraParams?: any;
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-07 03:46:16 +00:00
|
|
|
export const addMockDatasourceToOrg = (
|
2021-07-08 05:59:11 +00:00
|
|
|
name: string,
|
|
|
|
|
organizationId: string,
|
|
|
|
|
pluginId: string,
|
2021-07-08 10:33:41 +00:00
|
|
|
packageName: string,
|
2021-07-29 08:13:10 +00:00
|
|
|
isGeneratePageMode?: string,
|
|
|
|
|
): addMockRequest => {
|
2021-07-07 03:46:16 +00:00
|
|
|
return {
|
|
|
|
|
type: ReduxActionTypes.ADD_MOCK_DATASOURCES_INIT,
|
2021-07-08 10:33:41 +00:00
|
|
|
payload: { name, packageName, pluginId, organizationId },
|
2021-07-29 08:13:10 +00:00
|
|
|
extraParams: { isGeneratePageMode },
|
2021-07-07 03:46:16 +00:00
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
2020-04-28 06:52:53 +00:00
|
|
|
export const initDatasourcePane = (
|
|
|
|
|
pluginType: string,
|
|
|
|
|
urlId?: string,
|
|
|
|
|
): ReduxAction<{ pluginType: string; id?: string }> => {
|
|
|
|
|
return {
|
|
|
|
|
type: ReduxActionTypes.INIT_DATASOURCE_PANE,
|
|
|
|
|
payload: { id: urlId, pluginType },
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
2020-06-03 05:40:48 +00:00
|
|
|
export const storeAsDatasource = () => {
|
|
|
|
|
return {
|
|
|
|
|
type: ReduxActionTypes.STORE_AS_DATASOURCE_INIT,
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
2021-04-22 03:30:09 +00:00
|
|
|
export const getOAuthAccessToken = (datasourceId: string) => {
|
|
|
|
|
return {
|
|
|
|
|
type: ReduxActionTypes.SAAS_GET_OAUTH_ACCESS_TOKEN,
|
|
|
|
|
payload: { datasourceId },
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
2021-08-20 06:57:01 +00:00
|
|
|
export type executeDatasourceQuerySuccessPayload<T> = {
|
2021-07-29 08:13:10 +00:00
|
|
|
responseMeta: ResponseMeta;
|
|
|
|
|
data: {
|
2021-08-20 06:57:01 +00:00
|
|
|
body: T;
|
2021-07-29 08:13:10 +00:00
|
|
|
headers: Record<string, string[]>;
|
|
|
|
|
statusCode: string;
|
|
|
|
|
isExecutionSuccess: boolean;
|
|
|
|
|
};
|
|
|
|
|
};
|
2021-08-20 09:55:59 +00:00
|
|
|
type errorPayload = string;
|
2021-07-29 08:13:10 +00:00
|
|
|
|
2021-08-20 06:57:01 +00:00
|
|
|
export type executeDatasourceQueryReduxAction<T> = ReduxActionWithCallbacks<
|
2021-07-29 08:13:10 +00:00
|
|
|
executeDatasourceQueryRequest,
|
2021-08-20 06:57:01 +00:00
|
|
|
executeDatasourceQuerySuccessPayload<T>,
|
2021-07-29 08:13:10 +00:00
|
|
|
errorPayload
|
|
|
|
|
>;
|
|
|
|
|
|
|
|
|
|
export const executeDatasourceQuery = ({
|
|
|
|
|
onErrorCallback,
|
|
|
|
|
onSuccessCallback,
|
|
|
|
|
payload,
|
|
|
|
|
}: {
|
|
|
|
|
onErrorCallback?: (payload: errorPayload) => void;
|
2021-08-20 06:57:01 +00:00
|
|
|
onSuccessCallback?: (
|
|
|
|
|
payload: executeDatasourceQuerySuccessPayload<any>,
|
|
|
|
|
) => void;
|
2021-07-29 08:13:10 +00:00
|
|
|
payload: executeDatasourceQueryRequest;
|
2021-08-20 06:57:01 +00:00
|
|
|
}): executeDatasourceQueryReduxAction<any> => {
|
2021-07-29 08:13:10 +00:00
|
|
|
return {
|
|
|
|
|
type: ReduxActionTypes.EXECUTE_DATASOURCE_QUERY_INIT,
|
|
|
|
|
payload,
|
|
|
|
|
onErrorCallback,
|
|
|
|
|
onSuccessCallback,
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
2020-04-28 06:52:53 +00:00
|
|
|
export default {
|
|
|
|
|
fetchDatasources,
|
|
|
|
|
initDatasourcePane,
|
|
|
|
|
};
|