Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Site replication status #1834

Merged
merged 5 commits into from
Apr 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
97 changes: 97 additions & 0 deletions models/site_replication_status_response.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 7 additions & 2 deletions portal-ui/src/common/SecureComponent/permissions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ export const IAM_PAGES = {
TIERS_ADD: "/settings/tiers/add",
TIERS_ADD_SERVICE: "/settings/tiers/add/:service",
SITE_REPLICATION: "/settings/site-replication",
SITE_REPLICATION_STATUS: "/settings/site-replication/status",

/* Operator */
TENANTS: "/tenants",
Expand All @@ -185,7 +186,7 @@ export const IAM_PAGES = {
NAMESPACE_TENANT_POOLS_ADD:
"/namespaces/:tenantNamespace/tenants/:tenantName/add-pool",
NAMESPACE_TENANT_POOLS_EDIT:
"/namespaces/:tenantNamespace/tenants/:tenantName/edit-pool",
"/namespaces/:tenantNamespace/tenants/:tenantName/edit-pool",
NAMESPACE_TENANT_VOLUMES:
"/namespaces/:tenantNamespace/tenants/:tenantName/volumes",
NAMESPACE_TENANT_LICENSE:
Expand Down Expand Up @@ -384,7 +385,11 @@ export const IAM_PAGES_PERMISSIONS = {
IAM_SCOPES.ADMIN_SERVER_INFO,
IAM_SCOPES.ADMIN_CONFIG_UPDATE,
],
};
[IAM_PAGES.SITE_REPLICATION_STATUS]: [
IAM_SCOPES.ADMIN_SERVER_INFO,
IAM_SCOPES.ADMIN_CONFIG_UPDATE,
],
}

export const S3_ALL_RESOURCES = "arn:aws:s3:::*";
export const CONSOLE_UI_RESOURCE = "console-ui";
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ type DeleteButtonProps = {
tooltip?: string;
classes?: any;
icon?: React.ReactNode;
showLabelAlways?:boolean;
[x: string]: any;
};

Expand Down Expand Up @@ -80,6 +81,7 @@ const RBIconButton = (props: RBIconProps) => {
tooltip,
icon = null,
className = "",
showLabelAlways=false,
...restProps
} = props;

Expand All @@ -98,7 +100,8 @@ const RBIconButton = (props: RBIconProps) => {
"& span": {
fontSize: 14,
"@media (max-width: 900px)": {
display: "none",
display: showLabelAlways?"inline":"none",
marginRight:showLabelAlways?"7px":""
},
},
}}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,210 @@
// This file is part of MinIO Console Server
// Copyright (c) 2022 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

import React, { useState } from "react";
import { Box, Grid } from "@mui/material";
import SelectWrapper from "../../Common/FormComponents/SelectWrapper/SelectWrapper";
import InputBoxWrapper from "../../Common/FormComponents/InputBoxWrapper/InputBoxWrapper";
import RBIconButton from "../../Buckets/BucketDetails/SummaryItems/RBIconButton";
import { ClustersIcon } from "../../../../icons";
import useApi from "../../Common/Hooks/useApi";
import { StatsResponseType } from "./SiteReplicationStatus";
import BucketEntityStatus from "./LookupStatus/BucketEntityStatus";
import Loader from "../../Common/Loader/Loader";
import PolicyEntityStatus from "./LookupStatus/PolicyEntityStatus";
import GroupEntityStatus from "./LookupStatus/GroupEntityStatus";
import UserEntityStatus from "./LookupStatus/UserEntityStatus";

const EntityReplicationLookup = () => {
const [entityType, setEntityType] = useState<string>("bucket");
const [entityValue, setEntityValue] = useState<string>("");

const [stats, setStats] = useState<StatsResponseType>({});
const [statsLoaded, setStatsLoaded] = useState<boolean>(false);

const [isStatsLoading, invokeSiteStatsApi] = useApi(
(res: any) => {
setStats(res);
setStatsLoaded(true);
},
(err: any) => {
setStats({});
setStatsLoaded(true);
}
);

const {
bucketStats = {},
sites = {},
userStats = {},
policyStats = {},
groupStats = {},
} = stats || {};

const getStats = (entityType: string = "", entityValue: string = "") => {
setStatsLoaded(false);
if (entityType && entityValue) {
let url = `api/v1/admin/site-replication/status?buckets=false&entityType=${entityType}&entityValue=${entityValue}&groups=false&policies=false&users=false`;
invokeSiteStatsApi("GET", url);
}
};

return (
<Box>
<Box
sx={{
display: "grid",
alignItems: "center",
gridTemplateColumns: {
md: ".7fr .9fr 1.2fr .3fr",
sm: "1.2fr .7fr .7fr .3fr",
xs: "1fr",
},
gap: "15px",
}}
>
<Box sx={{ width: "240px", flexGrow: "0" }}>
View Replication Status for a:
</Box>
<Box
sx={{
marginLeft: {
md: "-25px",
xs: "0px",
},
}}
>
<SelectWrapper
id="replicationEntityLookup"
name="replicationEntityLookup"
onChange={(e) => {
setEntityType(e.target.value);
setStatsLoaded(false);
}}
label=""
value={entityType}
options={[
{
label: "Bucket",
value: "bucket",
},
{
label: "User",
value: "user",
},
{
label: "Group",
value: "group",
},
{
label: "Policy",
value: "policy",
},
]}
disabled={false}
/>
</Box>

<Box
sx={{
flex: 2,
}}
>
<InputBoxWrapper
id="replicationLookupEntityValue"
name="replicationLookupEntityValue"
onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
setEntityValue(e.target.value);
setStatsLoaded(false);
}}
placeholder={`test-${entityType}`}
label=""
value={entityValue}
/>
</Box>
<Box
sx={{
maxWidth: "80px",
}}
>
<RBIconButton
type={"button"}
onClick={() => {
getStats(entityType, entityValue);
}}
text={`View `}
tooltip={"View across sites"}
icon={<ClustersIcon />}
color={"primary"}
showLabelAlways
disabled={!entityValue || !entityType}
/>
</Box>
</Box>

{isStatsLoading ? (
<Grid
item
xs={12}
display={"flex"}
alignItems={"center"}
justifyContent={"center"}
marginTop={"45px"}
>
<Loader style={{ width: 25, height: 25 }} />
</Grid>
) : null}

{statsLoaded ? (
<Box>
{!isStatsLoading && entityType === "bucket" && entityValue ? (
<BucketEntityStatus
bucketStats={bucketStats}
sites={sites}
lookupValue={entityValue}
/>
) : null}

{!isStatsLoading && entityType === "user" && entityValue ? (
<UserEntityStatus
userStats={userStats}
sites={sites}
lookupValue={entityValue}
/>
) : null}

{!isStatsLoading && entityType === "group" && entityValue ? (
<GroupEntityStatus
groupStats={groupStats}
sites={sites}
lookupValue={entityValue}
/>
) : null}

{!isStatsLoading && entityType === "policy" && entityValue ? (
<PolicyEntityStatus
policyStats={policyStats}
sites={sites}
lookupValue={entityValue}
/>
) : null}
</Box>
) : null}
</Box>
);
};

export default EntityReplicationLookup;