Merge branch 'fix/update-create-datasource' into 'feature/acl'
fix: pass organization id to create datasource APIs See merge request theappsmith/internal-tools-client!687
This commit is contained in:
commit
9c2529105c
|
|
@ -63,12 +63,15 @@ export interface CreatePageResponse extends ApiResponse {
|
|||
}
|
||||
|
||||
export interface FetchPageListResponse extends ApiResponse {
|
||||
data: Array<{
|
||||
id: string;
|
||||
name: string;
|
||||
isDefault: boolean;
|
||||
layouts: Array<PageLayout>;
|
||||
}>;
|
||||
data: {
|
||||
pages: Array<{
|
||||
id: string;
|
||||
name: string;
|
||||
isDefault: boolean;
|
||||
layouts: Array<PageLayout>;
|
||||
}>;
|
||||
organizationId: string;
|
||||
};
|
||||
}
|
||||
|
||||
export interface DeletePageRequest {
|
||||
|
|
|
|||
|
|
@ -131,6 +131,7 @@ export const ReduxActionTypes: { [key: string]: string } = {
|
|||
FETCH_ORGS_SUCCESS: "FETCH_ORGS_SUCCES",
|
||||
FETCH_ORGS_INIT: "FETCH_ORGS_INIT",
|
||||
SAVE_ORG_INIT: "SAVE_ORG_INIT",
|
||||
SET_CURRENT_ORG_ID: "SET_CURRENT_ORG_ID",
|
||||
STORE_DATASOURCE_REFS: "STORE_DATASOURCE_REFS",
|
||||
UPDATE_DATASOURCE_REFS: "UPDATE_DATASOURCE_REFS",
|
||||
FETCH_USER_INIT: "FETCH_USER_INIT",
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ const initialState: OrgReduxState = {
|
|||
isFetchAllUsers: false,
|
||||
isDeletingOrgUser: false,
|
||||
},
|
||||
currentOrgId: "",
|
||||
orgUsers: [],
|
||||
orgRoles: [],
|
||||
};
|
||||
|
|
@ -39,6 +40,7 @@ const orgReducer = createReducer(initialState, {
|
|||
isFetchAllUsers: true,
|
||||
},
|
||||
}),
|
||||
|
||||
[ReduxActionTypes.FETCH_ORG_ROLES_SUCCESS]: (
|
||||
state: OrgReduxState,
|
||||
action: ReduxAction<OrgRole[]>,
|
||||
|
|
@ -113,6 +115,13 @@ const orgReducer = createReducer(initialState, {
|
|||
[ReduxActionTypes.DELETE_ORG_USER_ERROR]: (state: OrgReduxState) => {
|
||||
return { ...state, isDeletingOrgUser: false };
|
||||
},
|
||||
[ReduxActionTypes.SET_CURRENT_ORG_ID]: (
|
||||
state: OrgReduxState,
|
||||
action: ReduxAction<{ orgId: string }>,
|
||||
) => ({
|
||||
...state,
|
||||
currentOrgId: action.payload.orgId,
|
||||
}),
|
||||
|
||||
[ReduxActionTypes.FETCH_ORGS_SUCCESS]: (
|
||||
state: OrgReduxState,
|
||||
|
|
@ -134,6 +143,7 @@ export interface OrgReduxState {
|
|||
};
|
||||
orgUsers: OrgUser[];
|
||||
orgRoles: any;
|
||||
currentOrgId: string;
|
||||
}
|
||||
|
||||
export default orgReducer;
|
||||
|
|
|
|||
|
|
@ -43,6 +43,7 @@ import { AppToaster } from "components/editorComponents/ToastComponent";
|
|||
import { ToastType } from "react-toastify";
|
||||
import { getFormData } from "selectors/formSelectors";
|
||||
import { changeApi, setDatasourceFieldText } from "actions/apiPaneActions";
|
||||
import { getCurrentOrgId } from "selectors/organizationSelectors";
|
||||
|
||||
function* fetchDatasourcesSaga() {
|
||||
try {
|
||||
|
|
@ -66,8 +67,12 @@ function* createDatasourceSaga(
|
|||
actionPayload: ReduxAction<CreateDatasourceConfig>,
|
||||
) {
|
||||
try {
|
||||
const organizationId = yield select(getCurrentOrgId);
|
||||
const response: GenericApiResponse<Datasource> = yield DatasourcesApi.createDatasource(
|
||||
actionPayload.payload,
|
||||
{
|
||||
...actionPayload.payload,
|
||||
organizationId,
|
||||
},
|
||||
);
|
||||
const isValidResponse = yield validateResponse(response);
|
||||
if (isValidResponse) {
|
||||
|
|
@ -160,6 +165,7 @@ function* updateDatasourceSaga(actionPayload: ReduxAction<Datasource>) {
|
|||
}
|
||||
|
||||
function* testDatasourceSaga(actionPayload: ReduxAction<Datasource>) {
|
||||
const organizationId = yield select(getCurrentOrgId);
|
||||
const { initialValues, values } = yield select(
|
||||
getFormData,
|
||||
DATASOURCE_DB_FORM,
|
||||
|
|
@ -172,7 +178,10 @@ function* testDatasourceSaga(actionPayload: ReduxAction<Datasource>) {
|
|||
|
||||
try {
|
||||
const response: GenericApiResponse<Datasource> = yield DatasourcesApi.testDatasource(
|
||||
payload,
|
||||
{
|
||||
...payload,
|
||||
organizationId,
|
||||
},
|
||||
);
|
||||
const isValidResponse = yield validateResponse(response);
|
||||
if (isValidResponse) {
|
||||
|
|
@ -207,6 +216,7 @@ function* createDatasourceFromFormSaga(
|
|||
) {
|
||||
try {
|
||||
let formConfig;
|
||||
const organizationId = yield select(getCurrentOrgId);
|
||||
const initialValues = {};
|
||||
const parseConfig = (section: any): any => {
|
||||
return _.map(section.children, (subSection: any) => {
|
||||
|
|
@ -251,7 +261,10 @@ function* createDatasourceFromFormSaga(
|
|||
};
|
||||
|
||||
const response: GenericApiResponse<Datasource> = yield DatasourcesApi.createDatasource(
|
||||
payload,
|
||||
{
|
||||
...payload,
|
||||
organizationId,
|
||||
},
|
||||
);
|
||||
const isValidResponse = yield validateResponse(response);
|
||||
if (isValidResponse) {
|
||||
|
|
|
|||
|
|
@ -75,7 +75,8 @@ export function* fetchPageListSaga(
|
|||
);
|
||||
const isValidResponse = yield validateResponse(response);
|
||||
if (isValidResponse) {
|
||||
const pages: PageListPayload = response.data.map(page => ({
|
||||
const orgId = response.data.organizationId;
|
||||
const pages: PageListPayload = response.data.pages.map(page => ({
|
||||
pageName: page.name,
|
||||
pageId: page.id,
|
||||
isDefault: page.isDefault,
|
||||
|
|
@ -87,6 +88,13 @@ export function* fetchPageListSaga(
|
|||
applicationId,
|
||||
},
|
||||
});
|
||||
yield put({
|
||||
type: ReduxActionTypes.SET_CURRENT_ORG_ID,
|
||||
payload: {
|
||||
orgId,
|
||||
},
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
} catch (error) {
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@ import { OrgRole, Org } from "constants/orgConstants";
|
|||
export const getRolesFromState = (state: AppState) => {
|
||||
return state.ui.orgs.roles;
|
||||
};
|
||||
|
||||
export const getCurrentOrgId = (state: AppState) => state.ui.orgs.currentOrgId;
|
||||
export const getOrgs = (state: AppState) => state.ui.orgs.list;
|
||||
export const getAllUsers = (state: AppState) => state.ui.orgs.orgUsers;
|
||||
export const getAllRoles = (state: AppState) => state.ui.orgs.orgRoles;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user