Skip to content

Commit 4e9d28c

Browse files
committed
update error message and added sorting
1 parent 68cc533 commit 4e9d28c

File tree

4 files changed

+26
-9
lines changed

4 files changed

+26
-9
lines changed

src/components/configmap/index.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const ConfigMapTab = (props: any) => {
99
const { workLoadOne, workLoadTwo, loading, activeTab } = props;
1010
const [configMapData, setConfigMapData] = useState<any>([]);
1111
const [error, setError] = useState("");
12+
const [isMatch, setIsMatch] = useState(true);
1213
const getDeployments = async (props: any) => {
1314
let queryString = [
1415
props.workLoadOne ? `workload1=${props.workLoadOne}` : '',
@@ -35,6 +36,7 @@ const ConfigMapTab = (props: any) => {
3536
for (let i = 0; i < confData.length; i++) {
3637
if (isOpenFlag) {
3738
confData[i][index].isConfigMapOpen = value
39+
confData[i][index].isConfigMapOther = Object.entries(confData[i][index].configMaps)
3840
} else {
3941
confData[i][index].setCurrentView = value
4042
}
@@ -48,6 +50,9 @@ const ConfigMapTab = (props: any) => {
4850
getConfigFromLocal();
4951
}
5052

53+
const countMaps = (count) => {
54+
setIsMatch(count + count === count * 2);
55+
}
5156
const getConfigFromLocal = () => {
5257
setConfigMapData(getConfigData());
5358
}
@@ -67,17 +72,18 @@ const ConfigMapTab = (props: any) => {
6772
<div> {error ? error : ""}</div>
6873
<div className="flex flex-row p-2 gap-8">
6974
{
75+
7076
configMapData?.map((deployment: any, index: number) => (
71-
7277
<div key={index} className="flex flex-col gap-2">
78+
7379
<h3 className="font-bold flex-row text-l p-2">
7480
{`${index + 1}.`} <span className="text-blue-500">
7581
{index == 0 ? findName(workLoadOne || workLoadTwo) : findName(workLoadTwo)} </span>
7682
<small className="text-sm">({index == 0 ? workLoadOne || workLoadTwo : workLoadTwo})</small>
7783
&nbsp; <small className="text-xs font-light text-green-500">{loading ? "Loading..." : ""}</small>
7884
</h3>
7985
<div className="flex flex-col gap-2">
80-
<CountTable deployments={deployment} />
86+
<CountTable deployments={deployment} configMapData={configMapData} index={index} countMaps={countMaps} isMatch={isMatch}/>
8187
<ConfigMapDeployments deployments={deployment} updateDataWithIndex={updateDataWithIndex} title="Services" />
8288
</div>
8389
</div>

src/components/configmap/tables/countInfo.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
1-
import { deploymentHavingIssue, filterDeployments } from '@/functions';
1+
import { deploymentHavingIssue, filterDeployments, getConfigMapDifferenceCount } from '@/functions';
22
import React from 'react';
33

44
const CountTable = (props: any) => {
55
const allServices = props.deployments? filterDeployments(props.deployments) : [];
6-
const deploymentHavingIssues = allServices.length ? deploymentHavingIssue(allServices): []
7-
6+
const count = getConfigMapDifferenceCount(props.deployments);
7+
props.countMaps( count, props.index);
8+
89
return (
910
<div className="overflow-x-auto">
1011
<table className="w-full text-center table-auto border-collapse border border-gray-300">
1112
<thead>
1213
<tr className="bg-gray-200">
1314
<th className="border border-gray-300 px-4 py-2">Services</th>
14-
<th className="border border-gray-300 px-4 py-2">Config Item</th>
15+
1516
<th className="border border-gray-300 px-4 py-2">Diff</th>
1617
</tr>
1718
</thead>
1819
<tbody>
1920
<tr>
2021
<td className="border border-gray-300 px-4 py-2">{allServices.length}</td>
21-
<td className="border border-gray-300 px-4 py-2">2</td>
22-
<td className={`border border-gray-300 px-4 py-2 ${deploymentHavingIssues.length ? "text-red-500": "text-green-500"}`}>{deploymentHavingIssues.length}</td>
22+
<td className={`border border-gray-300 px-4 py-2 ${props.isMatch ? "text-green-500": "text-red-500"}`}>{count}</td>
2323
</tr>
2424
</tbody>
2525
</table>

src/components/configmap/tables/deploymentItem.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const ConfigMapDeploymentList = ({ deployment, index, updateDataWithIndex }: { d
1919
<tbody>
2020
{
2121
deployment && configMapArray.map((item: any, index: number) => {
22-
return<tr className="border-b-gray-50"><td>{index+1}</td> <td>{item[0]} </td><td>{item[1]}</td></tr>
22+
return (<tr className="border-b-gray-50"><td>{index+1}</td> <td>{item[0]} </td><td>{item[1]}</td></tr>)
2323
})
2424
}
2525
</tbody>

src/functions/index.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,3 +94,14 @@ export const findDifferentNamesInList = (list: any[]) => {
9494
return keyVaults.find((item: { value: any; }) => item.value == workload)?.name;
9595
}
9696

97+
98+
export const getConfigMapDifferenceCount = (deployments: any) => {
99+
let totalConfigMapKeys = 0;
100+
101+
deployments.forEach(deployment => {
102+
totalConfigMapKeys += deployment.configMaps ? Object.keys(deployment.configMaps).length : 0;
103+
});
104+
105+
return totalConfigMapKeys;
106+
}
107+

0 commit comments

Comments
 (0)