github.com/minio/console@v1.4.1/web-app/src/screens/Console/Configurations/SiteReplication/LookupStatus/UserEntityStatus.tsx (about) 1 // This file is part of MinIO Console Server 2 // Copyright (c) 2022 MinIO, Inc. 3 // 4 // This program is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU Affero General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // This program is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU Affero General Public License for more details. 13 // 14 // You should have received a copy of the GNU Affero General Public License 15 // along with this program. If not, see <http://www.gnu.org/licenses/>. 16 17 import React from "react"; 18 import { StatsResponseType } from "../SiteReplicationStatus"; 19 import LookupStatusTable from "./LookupStatusTable"; 20 import { EntityNotFound, isEntityNotFound, syncStatus } from "./Utils"; 21 22 type PolicyEntityStatusProps = Partial<StatsResponseType> & { 23 lookupValue?: string; 24 }; 25 const UserEntityStatus = ({ 26 userStats = {}, 27 sites = {}, 28 lookupValue = "", 29 }: PolicyEntityStatusProps) => { 30 const rowsForStatus = ["Info", "Policy mapping"]; 31 32 const userSites: Record<string, any> = userStats[lookupValue] || {}; 33 34 if (!lookupValue) return null; 35 36 const siteKeys = Object.keys(sites); 37 38 const notFound = isEntityNotFound(sites, userSites, "HasUser"); 39 40 const resultMatrix: any = []; 41 if (notFound) { 42 return <EntityNotFound entityType={"User"} entityValue={lookupValue} />; 43 } else { 44 const row = []; 45 for (let sCol = 0; sCol < siteKeys.length; sCol++) { 46 if (sCol === 0) { 47 row.push(""); 48 } 49 row.push(sites[siteKeys[sCol]].name); 50 } 51 resultMatrix.push(row); 52 for (let fi = 0; fi < rowsForStatus.length; fi++) { 53 const sfRow = []; 54 const feature = rowsForStatus[fi]; 55 let sbStatus: string | boolean = ""; 56 57 for (let si = 0; si < siteKeys.length; si++) { 58 const bucketSiteDeploymentId = sites[siteKeys[si]].deploymentID; 59 60 const rSite = userSites[bucketSiteDeploymentId]; 61 62 if (si === 0) { 63 sfRow.push(feature); 64 } 65 66 switch (fi) { 67 case 0: 68 sbStatus = syncStatus(rSite.UserInfoMismatch, rSite.HasUser); 69 sfRow.push(sbStatus); 70 break; 71 case 1: 72 sbStatus = syncStatus(rSite.PolicyMismatch, rSite.HasPolicyMapping); 73 sfRow.push(sbStatus); 74 break; 75 } 76 } 77 78 resultMatrix.push(sfRow); 79 } 80 } 81 82 return ( 83 <LookupStatusTable 84 matrixData={resultMatrix} 85 entityName={lookupValue} 86 entityType={"User"} 87 /> 88 ); 89 }; 90 91 export default UserEntityStatus;