diff --git a/cyclops-ui/src/components/k8s-resources/StatefulSet.tsx b/cyclops-ui/src/components/k8s-resources/StatefulSet.tsx
index 9186ce54..92727444 100644
--- a/cyclops-ui/src/components/k8s-resources/StatefulSet.tsx
+++ b/cyclops-ui/src/components/k8s-resources/StatefulSet.tsx
@@ -25,32 +25,32 @@ const StatefulSet = ({ name, namespace }: Props) => {
description: "",
});
- function fetchStatefulSet() {
- axios
- .get(`/api/resources`, {
- params: {
- group: `apps`,
- version: `v1`,
- kind: `StatefulSet`,
- name: name,
- namespace: namespace,
- },
- })
- .then((res) => {
- setStatefulSet(res.data);
- })
- .catch((error) => {
- setError(mapResponseError(error));
- });
- }
-
useEffect(() => {
+ function fetchStatefulSet() {
+ axios
+ .get(`/api/resources`, {
+ params: {
+ group: `apps`,
+ version: `v1`,
+ kind: `StatefulSet`,
+ name: name,
+ namespace: namespace,
+ },
+ })
+ .then((res) => {
+ setStatefulSet(res.data);
+ })
+ .catch((error) => {
+ setError(mapResponseError(error));
+ });
+ }
+
fetchStatefulSet();
const interval = setInterval(() => fetchStatefulSet(), 15000);
return () => {
clearInterval(interval);
};
- }, []);
+ }, [name, namespace]);
return (
diff --git a/cyclops-ui/src/components/k8s-resources/common/PodTable.tsx b/cyclops-ui/src/components/k8s-resources/common/PodTable.tsx
index bee83f31..cf6e7965 100644
--- a/cyclops-ui/src/components/k8s-resources/common/PodTable.tsx
+++ b/cyclops-ui/src/components/k8s-resources/common/PodTable.tsx
@@ -1,4 +1,4 @@
-import React, { useEffect, useState } from "react";
+import React, { useState } from "react";
import {
Button,
Col,
diff --git a/cyclops-ui/src/components/pages/EditModule.tsx b/cyclops-ui/src/components/pages/EditModule.tsx
index c4cb7ff0..b913e633 100644
--- a/cyclops-ui/src/components/pages/EditModule.tsx
+++ b/cyclops-ui/src/components/pages/EditModule.tsx
@@ -1,4 +1,4 @@
-import React, { useEffect, useState } from "react";
+import React, { useCallback, useEffect, useState } from "react";
import {
Alert,
Button,
@@ -42,10 +42,7 @@ import { fileExtension, findMaps, flattenObjectKeys } from "../../utils/form";
import "./custom.css";
import { numberInputValidators } from "../../utils/validators/number";
import { stringInputValidators } from "../../utils/validators/string";
-import {
- moduleTemplateReferenceView,
- templateRef,
-} from "../../utils/templateRef";
+import { templateRef } from "../../utils/templateRef";
import {
FeedbackError,
FormValidationErrors,
@@ -57,8 +54,6 @@ import {
Template,
} from "../../utils/api/template";
-const { TextArea } = Input;
-
const { Title } = Typography;
const layout = {
wrapperCol: { span: 16 },
@@ -89,7 +84,6 @@ const EditModule = () => {
const [initialValuesRaw, setInitialValuesRaw] = useState({});
- const [allConfigs, setAllConfigs] = useState([]);
const [values, setValues] = useState({});
const [isChanged, setIsChanged] = useState(false);
const [isTemplateChanged, setIsTemplateChanged] = useState(false);
@@ -138,7 +132,7 @@ const EditModule = () => {
let { moduleName } = useParams();
- const mapsToArray = (fields: any[], values: any): any => {
+ const mapsToArray = useCallback((fields: any[], values: any): any => {
let out: any = {};
fields.forEach((field) => {
let valuesList: any[] = [];
@@ -202,7 +196,7 @@ const EditModule = () => {
});
return out;
- };
+ }, []);
useEffect(() => {
const fetchModuleData = async () => {
@@ -258,16 +252,11 @@ const EditModule = () => {
});
};
fetchModuleData();
- }, []);
+ }, [editTemplateForm, form, moduleName, mapsToArray]);
useEffect(() => {
form.validateFields(flattenObjectKeys(values));
- }, [values]);
-
- const configNames: {} | any = [];
- allConfigs.map((c: any) => {
- configNames.push(
{c.name});
- });
+ }, [values, form]);
const handleValuesChange = (changedValues: any, allValues: any) => {
if (JSON.stringify(allValues) === JSON.stringify(values)) {
@@ -590,6 +579,7 @@ const EditModule = () => {
arrayIndexLifetime = arrayIndexLifetime - 1;
}
+ var header;
switch (field.type) {
case "string":
if (field.enum) {
@@ -689,7 +679,7 @@ const EditModule = () => {
);
return;
case "object":
- var header =
{field.name}
;
+ header =
{field.name}
;
if (field.description && field.description.length !== 0) {
header = (
@@ -774,7 +764,7 @@ const EditModule = () => {
);
return;
case "array":
- var header =
{field.name}
;
+ header =
{field.name}
;
if (field.description && field.description.length !== 0) {
header = (
diff --git a/cyclops-ui/src/components/pages/History.tsx b/cyclops-ui/src/components/pages/History.tsx
index 4a483590..55891566 100644
--- a/cyclops-ui/src/components/pages/History.tsx
+++ b/cyclops-ui/src/components/pages/History.tsx
@@ -6,7 +6,7 @@ import { useParams } from "react-router-dom";
import ReactDiffViewer from "react-diff-viewer";
import ReactAce from "react-ace";
-const { Title, Text } = Typography;
+const { Title } = Typography;
require(`ace-builds/src-noconflict/mode-sass`);
require(`ace-builds/src-noconflict/snippets/sass`);
@@ -44,7 +44,7 @@ const ModuleHistory = () => {
previous: diff.previous,
});
});
- }, []);
+ }, [diff.previous, moduleName]);
const handleOk = () => {
setDiffModal({
diff --git a/cyclops-ui/src/components/pages/ModuleDetails.tsx b/cyclops-ui/src/components/pages/ModuleDetails.tsx
index c052cf97..562aa62b 100644
--- a/cyclops-ui/src/components/pages/ModuleDetails.tsx
+++ b/cyclops-ui/src/components/pages/ModuleDetails.tsx
@@ -1,4 +1,4 @@
-import React, { useEffect, useState } from "react";
+import React, { useEffect, useState, useCallback } from "react";
import {
Alert,
Button,
@@ -174,21 +174,7 @@ const ModuleDetails = () => {
});
}
- function fetchModule() {
- axios
- .get(`/api/modules/` + moduleName)
- .then((res) => {
- setModule(res.data);
- setLoadModule(true);
- })
- .catch((error) => {
- setLoading(false);
- setLoadModule(true);
- setError(mapResponseError(error));
- });
- }
-
- function fetchModuleResources() {
+ const fetchModuleResources = useCallback(() => {
axios
.get(`/api/modules/` + moduleName + `/resources`)
.then((res) => {
@@ -200,16 +186,30 @@ const ModuleDetails = () => {
setLoadResources(true);
setError(mapResponseError(error));
});
- }
+ }, [moduleName]);
useEffect(() => {
+ function fetchModule() {
+ axios
+ .get(`/api/modules/` + moduleName)
+ .then((res) => {
+ setModule(res.data);
+ setLoadModule(true);
+ })
+ .catch((error) => {
+ setLoading(false);
+ setLoadModule(true);
+ setError(mapResponseError(error));
+ });
+ }
+
fetchModule();
fetchModuleResources();
const interval = setInterval(() => fetchModuleResources(), 15000);
return () => {
clearInterval(interval);
};
- }, []);
+ }, [moduleName, fetchModuleResources]);
const getCollapseColor = (fieldName: string) => {
if (
@@ -590,6 +590,7 @@ const ModuleDetails = () => {
diff --git a/cyclops-ui/src/components/pages/Modules/Modules.tsx b/cyclops-ui/src/components/pages/Modules/Modules.tsx
index b68b823a..1ed3011a 100644
--- a/cyclops-ui/src/components/pages/Modules/Modules.tsx
+++ b/cyclops-ui/src/components/pages/Modules/Modules.tsx
@@ -4,7 +4,6 @@ import {
Col,
Divider,
Row,
- Select,
Typography,
Input,
Card,
@@ -27,7 +26,6 @@ const Modules = () => {
const [allData, setAllData] = useState([]);
const [filteredData, setFilteredData] = useState([]);
const [loadingModules, setLoadingModules] = useState(false);
- const [namespacesState, setNamespacesState] = useState([]);
const [error, setError] = useState({
message: "",
description: "",
@@ -48,23 +46,10 @@ const Modules = () => {
});
}, []);
- const namespaces: {} | any = [];
- namespacesState.map((namespace: any) => {
- namespaces.push(
- {namespace.name},
- );
- });
-
- const [value, setValue] = useState("");
-
const handleClick = () => {
history("/modules/new");
};
- const handleClickNew = () => {
- history("/new-app");
- };
-
const handleSearch = (event: any) => {
const query = event.target.value;
var updatedList = [...allData];
@@ -104,7 +89,7 @@ const Modules = () => {
return ;
}
- if (filteredData.length == 0) {
+ if (filteredData.length === 0) {
return (
@@ -119,6 +104,7 @@ const Modules = () => {
title={
diff --git a/cyclops-ui/src/components/pages/NewModule.tsx b/cyclops-ui/src/components/pages/NewModule.tsx
index 11b081fc..9a523376 100644
--- a/cyclops-ui/src/components/pages/NewModule.tsx
+++ b/cyclops-ui/src/components/pages/NewModule.tsx
@@ -129,7 +129,7 @@ const NewModule = () => {
useEffect(() => {
form.validateFields(flattenObjectKeys(initialValues));
- }, [initialValues]);
+ }, [initialValues, form]);
const mapsToArray = (fields: any[], values: any): any => {
let out: any = {};
@@ -566,6 +566,7 @@ const NewModule = () => {
arrayIndexLifetime = arrayIndexLifetime - 1;
}
+ var header;
switch (field.type) {
case "string":
if (field.enum) {
@@ -663,7 +664,7 @@ const NewModule = () => {
);
return;
case "object":
- var header =
{field.name}
;
+ header =
{field.name}
;
if (field.description && field.description.length !== 0) {
header = (
@@ -745,7 +746,7 @@ const NewModule = () => {
);
return;
case "array":
- var header =
{field.name}
;
+ header =
{field.name}
;
if (field.description && field.description.length !== 0) {
header = (
@@ -1042,6 +1043,7 @@ const NewModule = () => {
{templateStore.map((option: any, index) => (