Skip to content

Commit 8decef2

Browse files
removed custom data from env
1 parent 22cdfd6 commit 8decef2

File tree

1 file changed

+6
-68
lines changed
  • frontend/src/base/components/environment

1 file changed

+6
-68
lines changed

frontend/src/base/components/environment/NewEnv.jsx

Lines changed: 6 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
1-
import { useState, useEffect, useCallback, useMemo } from "react";
1+
import { useState, useEffect, useCallback } from "react";
22
import Cookies from "js-cookie";
33
import { Button, Divider, Modal, Space } from "antd";
44
import PropTypes from "prop-types";
55
import isEqual from "lodash/isEqual.js";
66

77
import { useAxiosPrivate } from "../../../service/axios-service";
88
import { orgStore } from "../../../store/org-store";
9-
import { generateKey } from "../../../common/helpers";
109
import {
1110
fetchAllConnections,
12-
fetchProjectByConnection,
1311
fetchSingleEnvironment,
1412
updateEnvironmentApi,
1513
createEnvironmentApi,
@@ -23,7 +21,6 @@ import encryptionService from "../../../service/encryption-service";
2321

2422
import "./environment.css";
2523
import EnvGeneralSection from "./EnvGeneralSection";
26-
import EnvCustomDataSection from "./EnvCustomDataSection";
2724
import { CreateConnection } from "./CreateConnection";
2825
import { useNotificationService } from "../../../service/notification-service";
2926

@@ -41,7 +38,6 @@ const NewEnv = ({
4138

4239
const [isModalOpen, setIsModalOpen] = useState(false);
4340
const [connectionList, setConnectionList] = useState([]);
44-
const [customData, setCustomData] = useState([]);
4541
const [connection, setConnection] = useState({ id: "" });
4642
const [connectionDataSource, setConnectionDataSource] = useState(null);
4743
const [connectionSchema, setConnectionSchema] = useState({});
@@ -53,13 +49,11 @@ const NewEnv = ({
5349
const [connType, setConnType] = useState("url");
5450
const [connectionDetailsUpdated, setConnectionDetailsUpdated] =
5551
useState(false);
56-
const [projListDep, setProjListDep] = useState([]);
5752
const [connectDetailBackup, setConnectDetailBackup] = useState({});
5853
const [initialPrefillData, setInitialPrefillData] = useState({
5954
name: "",
6055
description: "",
6156
deployment_type: "",
62-
custom_data: [],
6357
});
6458
const [activeUpdateBtn, setActiveUpdateBtn] = useState(false);
6559
const [isEncryptionLoading, setIsEncryptionLoading] = useState(true);
@@ -109,7 +103,6 @@ const NewEnv = ({
109103
description: "",
110104
deployment_type: "",
111105
});
112-
setCustomData([]);
113106
setInputFields({});
114107
setConnection({ id: "" });
115108
setConnectionDataSource(null);
@@ -121,7 +114,6 @@ const NewEnv = ({
121114
name: "",
122115
description: "",
123116
deployment_type: "",
124-
custom_data: [],
125117
});
126118
setConnectDetailBackup({});
127119
setIsCredentialsRevealed(false);
@@ -135,7 +127,6 @@ const NewEnv = ({
135127
description: "",
136128
deployment_type: "",
137129
});
138-
setCustomData([]);
139130
setInputFields({});
140131
setConnection({ id: "" });
141132
setConnectionDataSource(null);
@@ -147,7 +138,6 @@ const NewEnv = ({
147138
name: "",
148139
description: "",
149140
deployment_type: "",
150-
custom_data: [],
151141
});
152142
setConnectDetailBackup({});
153143
setIsCredentialsRevealed(false);
@@ -262,40 +252,27 @@ const NewEnv = ({
262252
}
263253
}, [selectedOrgId]);
264254

265-
const getProjectDependency = useCallback(async () => {
266-
try {
267-
const data = await fetchProjectByConnection(axiosRef, selectedOrgId, id);
268-
setProjListDep(data);
269-
} catch (error) {
270-
console.error(error);
271-
notify({ error });
272-
}
273-
}, [id, selectedOrgId]);
274-
275255
useEffect(() => {
276256
getAllConnections();
277257
}, [getAllConnections]);
278258

279259
const getSingleEnvironmentDetails = useCallback(async () => {
280260
try {
281261
const data = await fetchSingleEnvironment(axiosRef, selectedOrgId, id);
282-
const { connection, name, description, custom_data, deployment_type } =
283-
data;
262+
const { connection, name, description, deployment_type } = data;
284263
const connDetail = data.connection_details;
285264

286265
setEnvNameDescInfo({ name, description, deployment_type });
287266
setInitialPrefillData({
288267
name,
289268
description,
290269
deployment_type,
291-
custom_data,
292270
});
293271
setConnectDetailBackup({ connection_details: connDetail });
294272
setConnType(
295273
connDetail?.connection_type ? connDetail?.connection_type : "host"
296274
);
297275
setConnection({ id: connection.id });
298-
setCustomData(Array.isArray(custom_data) ? custom_data : []);
299276

300277
// Process connection details to handle JSON objects for textarea fields
301278
const processedConnDetail = { ...connDetail };
@@ -322,14 +299,13 @@ const NewEnv = ({
322299
useEffect(() => {
323300
if (id) {
324301
getSingleEnvironmentDetails();
325-
getProjectDependency();
326302
} else {
327303
setConnection({ id: "" });
328304
setEnvNameDescInfo({ name: "", description: "", deployment_type: "" });
329305
setConnectionDataSource(null);
330306
setConnectionSchema({});
331307
}
332-
}, [id, getSingleEnvironmentDetails, getProjectDependency]);
308+
}, [id, getSingleEnvironmentDetails]);
333309

334310
const handleEnvNameDesChange = (value, name) => {
335311
setEnvNameDescInfo((prev) => ({ ...prev, [name]: value }));
@@ -437,29 +413,6 @@ const NewEnv = ({
437413
connectionDataSource,
438414
]);
439415

440-
const AddnewEntry = () => {
441-
const singleData = { source_schema: "", destination_schema: "" };
442-
setCustomData((prev) => [...prev, { id: generateKey(), ...singleData }]);
443-
};
444-
445-
const handleCustomFieldChange = (value, name, rowId) => {
446-
setCustomData((prev) =>
447-
prev.map((item) =>
448-
item.id === rowId ? { ...item, [name]: value } : item
449-
)
450-
);
451-
};
452-
453-
const disabledAddCustomBtn = useMemo(() => {
454-
return customData.some(
455-
(item) => !item.source_schema || !item.destination_schema
456-
);
457-
}, [customData]);
458-
459-
const handleDelete = (rowId) => {
460-
setCustomData((prev) => prev.filter((el) => el.id !== rowId));
461-
};
462-
463416
const updateEnvironment = async () => {
464417
try {
465418
// Prepare environment data
@@ -472,7 +425,7 @@ const NewEnv = ({
472425
connection_type: connType,
473426
}),
474427
},
475-
custom_data: customData,
428+
476429
};
477430

478431
// Encrypt sensitive fields if encryption service is available
@@ -526,7 +479,7 @@ const NewEnv = ({
526479
connection_type: connType,
527480
}),
528481
},
529-
custom_data: customData,
482+
530483
};
531484

532485
// Encrypt sensitive fields if encryption service is available
@@ -561,7 +514,6 @@ const NewEnv = ({
561514
message: "Environment Created Successfully",
562515
});
563516
setEnvNameDescInfo({ name: "", description: "", deployment_type: "" });
564-
setCustomData([]);
565517
setConnection({ id: "" });
566518
}
567519
} catch (error) {
@@ -581,10 +533,9 @@ const NewEnv = ({
581533
name: envNameDescInfo.name,
582534
description: envNameDescInfo.description,
583535
deployment_type: envNameDescInfo.deployment_type,
584-
custom_data: customData,
585536
});
586537
setActiveUpdateBtn(!res);
587-
}, [envNameDescInfo, customData, initialPrefillData]);
538+
}, [envNameDescInfo, initialPrefillData]);
588539

589540
useEffect(() => {
590541
const res = isEqual(connectDetailBackup, {
@@ -625,19 +576,6 @@ const NewEnv = ({
625576

626577
<Divider className="divider-modal" />
627578

628-
<EnvCustomDataSection
629-
actionState={actionState}
630-
customData={customData}
631-
AddnewEntry={AddnewEntry}
632-
handleCustomFieldChange={handleCustomFieldChange}
633-
disabledAddCustomBtn={disabledAddCustomBtn}
634-
handleDelete={handleDelete}
635-
projListDep={projListDep}
636-
id={id}
637-
/>
638-
639-
<Divider className="divider-modal" />
640-
641579
<div className="envBtnWrap">
642580
<Space>
643581
<Button onClick={() => setIsEnvModalOpen(false)}>Cancel</Button>

0 commit comments

Comments
 (0)