From fdb2175d5aab915078e99cc1cbc0e8f34203508d Mon Sep 17 00:00:00 2001 From: niravparikh05 Date: Thu, 6 Oct 2022 19:51:51 +0530 Subject: [PATCH 1/5] Added web kubectl in cluster list page and removed type agent columns from auditlogs --- CHANGELOG.md | 2 + .../edges/routes/PrivateEdgeList/index.js | 95 +++++++++++++------ .../components/LogsDataTable/index.js | 10 -- src/components/KubeCtlShellAccess.js | 3 +- 4 files changed, 69 insertions(+), 41 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f413ffca..ac02d4a7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ All notable changes to this project will be documented in this file. ## Unreleased +- Added web kubectl in cluster list page and removed type agent columns from auditlogs from [niravparikh05](https://github.com/niravparikh05) + ## [0.1.2] - 2022-09-30 ### Fixed - Fix download kubeconfig file name issue from [akshay196](https://github.com/akshay196) diff --git a/src/app/routes/edges/routes/PrivateEdgeList/index.js b/src/app/routes/edges/routes/PrivateEdgeList/index.js index a544dd36..bd43b042 100644 --- a/src/app/routes/edges/routes/PrivateEdgeList/index.js +++ b/src/app/routes/edges/routes/PrivateEdgeList/index.js @@ -52,6 +52,7 @@ import SettingsIcon from "@material-ui/icons/Settings"; import DeleteIconComponent from "components/DeleteIconComponent"; import KubectlSettings from "components/ClusterActions/KubectlSettings"; import ClusterActionDialog from "components/ClusterActions/ClusterActionDialog"; +import KubeCtlShellAccess from "components/KubeCtlShellAccess"; const styles = (theme) => ({ clusterHeading: { @@ -1223,6 +1224,32 @@ class PrivateEdgeList extends React.Component { const { history } = this.props; const cluster_type = cluster?.cluster_type || null; + const isClusterReady = (cluster) => { + let ready = false; + if ( + cluster?.spec.clusterData && + cluster?.spec.clusterData.cluster_status && + cluster?.spec.clusterData.cluster_status.conditions && + cluster?.spec.clusterData.cluster_status.conditions.length > 0 + ) { + for ( + let index = 0; + index < cluster?.spec.clusterData?.cluster_status?.conditions?.length; + index++ + ) { + ready = + cluster.spec.clusterData.cluster_status.conditions[index].type === + "ClusterReady" && + cluster.spec.clusterData.cluster_status.conditions[index].status === + "Success"; + if (ready) { + return ready; + } + } + } + return ready; + }; + return (
@@ -1314,37 +1341,45 @@ class PrivateEdgeList extends React.Component {
- {this.state.userRole !== "READ_ONLY_OPS" && ( - - { - this.handleKubectlSettings(null, n); +
+ { isClusterReady(n) && ( + + )} + {this.state.userRole !== "READ_ONLY_OPS" && ( + + { + this.handleKubectlSettings(null, n); + }} + > + + + + )} + {this.state.userRole !== "READ_ONLY_OPS" && ( + + Are you sure you want to delete + {n.metadata.name} ? + + ), + handleClick: () => { + this.handleRemoveEdge(n, true); + }, }} - > - - - - )} - {this.state.userRole !== "READ_ONLY_OPS" && ( - - Are you sure you want to delete - {n.metadata.name} ? - - ), - handleClick: () => { - this.handleRemoveEdge(n, true); - }, - }} - /> - )} + /> + )} +
))} diff --git a/src/appMain/routes/auditLogs/components/LogsDataTable/index.js b/src/appMain/routes/auditLogs/components/LogsDataTable/index.js index 1bc36c99..54520be3 100644 --- a/src/appMain/routes/auditLogs/components/LogsDataTable/index.js +++ b/src/appMain/routes/auditLogs/components/LogsDataTable/index.js @@ -74,18 +74,10 @@ const LogsDataTable = (props) => { type: "regular", value: data._source.json.client.type, }, - { - type: "regular", - value: data._source.json.type, - }, { type: "regular", value: data._source.json.detail.message, }, - { - type: "regular", - value: data._source.json.client.user_agent, - }, ].filter(Boolean); const columnLabels = [ @@ -96,9 +88,7 @@ const LogsDataTable = (props) => { { label: "Groups", style: { minWidth: "170px" } }, props.isRelayCommands && { label: "Cluster" }, { label: "Client" }, - { label: "Type" }, { label: "Message" }, - { label: "Agent" }, ].filter(Boolean); const parseExpandedRow = (data) => { diff --git a/src/components/KubeCtlShellAccess.js b/src/components/KubeCtlShellAccess.js index 98eac112..5a555aae 100644 --- a/src/components/KubeCtlShellAccess.js +++ b/src/components/KubeCtlShellAccess.js @@ -16,6 +16,7 @@ const useStyles = makeStyles((theme) => ({ marginRight: "5px", marginTop: "4px", lineHeight: "10px", + height: "25px" }, label: { marginTop: "4px", @@ -24,7 +25,7 @@ const useStyles = makeStyles((theme) => ({ marginLeft: "2px", }, root: { - marginTop: 42, + marginTop: 12, }, })); From 647b0f1ef013fd1e6ab7452a0ccd04f1cfa459ac Mon Sep 17 00:00:00 2001 From: niravparikh05 Date: Fri, 7 Oct 2022 21:28:06 +0530 Subject: [PATCH 2/5] changes for icon only and relogin issue --- .../edges/routes/PrivateEdgeList/index.js | 3 ++- src/components/KubeCtlShellAccess.js | 17 ++++++++++++++--- src/containers/Auth/Login/index.js | 2 ++ .../ClusterView/components/ClusterHeader.js | 1 + 4 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/app/routes/edges/routes/PrivateEdgeList/index.js b/src/app/routes/edges/routes/PrivateEdgeList/index.js index bd43b042..e831be7e 100644 --- a/src/app/routes/edges/routes/PrivateEdgeList/index.js +++ b/src/app/routes/edges/routes/PrivateEdgeList/index.js @@ -1342,10 +1342,11 @@ class PrivateEdgeList extends React.Component {
- { isClusterReady(n) && ( + {isClusterReady(n) && ( )} {this.state.userRole !== "READ_ONLY_OPS" && ( diff --git a/src/components/KubeCtlShellAccess.js b/src/components/KubeCtlShellAccess.js index 5a555aae..3e070ba2 100644 --- a/src/components/KubeCtlShellAccess.js +++ b/src/components/KubeCtlShellAccess.js @@ -1,7 +1,7 @@ import React from "react"; import { useDispatch, useSelector } from "react-redux"; import { openKubectlDrawer, closeKubectlDrawer } from "actions/index"; -import { makeStyles } from "@material-ui/core"; +import { makeStyles, Tooltip } from "@material-ui/core"; const useStyles = makeStyles((theme) => ({ icon: { @@ -16,7 +16,7 @@ const useStyles = makeStyles((theme) => ({ marginRight: "5px", marginTop: "4px", lineHeight: "10px", - height: "25px" + height: "20px", }, label: { marginTop: "4px", @@ -29,7 +29,7 @@ const useStyles = makeStyles((theme) => ({ }, })); -function KubeCtlShellAccess({ projectId, clusterName }) { +function KubeCtlShellAccess({ projectId, clusterName, iconOnly }) { const classes = useStyles(); const dispatch = useDispatch(); const KubectlConfig = useSelector((s) => s.Kubectl?.kubectlConfig); @@ -39,6 +39,17 @@ function KubeCtlShellAccess({ projectId, clusterName }) { }; if (KubectlConfig?.disableWebKubectl) return null; + if (iconOnly) { + return ( + +
+
+ {">_"} +
+
+
+ ); + } return (
{">_"}
diff --git a/src/containers/Auth/Login/index.js b/src/containers/Auth/Login/index.js index e1812374..92446adb 100644 --- a/src/containers/Auth/Login/index.js +++ b/src/containers/Auth/Login/index.js @@ -178,6 +178,8 @@ class Login extends Component { const { username, flow } = this.state; auth.username = username; + this.initializeFlow(); + newKratosSdk() .submitSelfServiceLoginFlow(flow.id, undefined, { csrf_token: this.state.csrf_token, diff --git a/src/views/ClusterView/components/ClusterHeader.js b/src/views/ClusterView/components/ClusterHeader.js index ae67d55d..ad01787c 100644 --- a/src/views/ClusterView/components/ClusterHeader.js +++ b/src/views/ClusterView/components/ClusterHeader.js @@ -188,6 +188,7 @@ export default function ClusterHeader({ From edc6d1fdb314ad25b9d6d3c59ae0e8bbad37cfd8 Mon Sep 17 00:00:00 2001 From: niravparikh05 Date: Mon, 10 Oct 2022 12:05:12 +0530 Subject: [PATCH 3/5] added css pointer and updated changelog.md --- CHANGELOG.md | 1 + src/components/KubeCtlShellAccess.js | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ac02d4a7..6edb3939 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ All notable changes to this project will be documented in this file. ## Unreleased - Added web kubectl in cluster list page and removed type agent columns from auditlogs from [niravparikh05](https://github.com/niravparikh05) +- Added fix for relogin from [niravparikh05](https://github.com/niravparikh05) ## [0.1.2] - 2022-09-30 ### Fixed diff --git a/src/components/KubeCtlShellAccess.js b/src/components/KubeCtlShellAccess.js index 3e070ba2..2cc1048b 100644 --- a/src/components/KubeCtlShellAccess.js +++ b/src/components/KubeCtlShellAccess.js @@ -27,6 +27,9 @@ const useStyles = makeStyles((theme) => ({ root: { marginTop: 12, }, + hover: { + cursor: "pointer", + }, })); function KubeCtlShellAccess({ projectId, clusterName, iconOnly }) { @@ -43,7 +46,10 @@ function KubeCtlShellAccess({ projectId, clusterName, iconOnly }) { return (
-
+
{">_"}
From 06739d852089f069c081ec06e0a8f1a674068c86 Mon Sep 17 00:00:00 2001 From: niravparikh05 Date: Mon, 10 Oct 2022 12:56:37 +0530 Subject: [PATCH 4/5] removed login issue fix and updated changelog.md --- CHANGELOG.md | 1 - src/containers/Auth/Login/index.js | 32 ------------------------------ 2 files changed, 33 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6edb3939..ac02d4a7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,6 @@ All notable changes to this project will be documented in this file. ## Unreleased - Added web kubectl in cluster list page and removed type agent columns from auditlogs from [niravparikh05](https://github.com/niravparikh05) -- Added fix for relogin from [niravparikh05](https://github.com/niravparikh05) ## [0.1.2] - 2022-09-30 ### Fixed diff --git a/src/containers/Auth/Login/index.js b/src/containers/Auth/Login/index.js index 92446adb..c2e966d4 100644 --- a/src/containers/Auth/Login/index.js +++ b/src/containers/Auth/Login/index.js @@ -178,8 +178,6 @@ class Login extends Component { const { username, flow } = this.state; auth.username = username; - this.initializeFlow(); - newKratosSdk() .submitSelfServiceLoginFlow(flow.id, undefined, { csrf_token: this.state.csrf_token, @@ -470,9 +468,6 @@ class Login extends Component { render() { const { partnerDetail, - isTotpRequired, - isTotpVerified, - isLoginFailed, isLoginSuccess, userAndRoleDetail, UserSession, @@ -481,15 +476,6 @@ class Login extends Component { let formContent = this.renderLoginForm(); - // if ( - // isLoginFailed && - // ["AUTH003", "AUTH004", "AUTH006"].includes( - // this.props.auth.error.details[0].error_code - // ) - // ) { - // return ; - // } - if (isLoginSuccess) { if (userAndRoleDetail?.account?.require_change_password) { this.state.password = ""; @@ -504,18 +490,6 @@ class Login extends Component { /> ); } - // TODO: Hidden. What do we do here? Why are we doing this? Also no READ_ONLY anymore - // if (userAndRoleDetail && userAndRoleDetail.role.name === "READ_ONLY") { - // return ; - // } - - // if ( - // userAndRoleDetail && - // userAndRoleDetail.roles && - // userAndRoleDetail.roles.length === 0 - // ) { - // return ; - // } // Make an API call after 12hrs(+1min) which will trigger user session expiry setTimeout( this.props.getUserSessionInfo.bind(this), @@ -524,12 +498,6 @@ class Login extends Component { if (UserSession.noRolesUser) { return ; } - // if (UserSession.visibleInfra || UserSession.visibleAdmin) { - // return ; - // } - // if (UserSession.visibleApps) { - // return ; - // } return ; } From bf58895674de089929c3d01d685948a1c9c71496 Mon Sep 17 00:00:00 2001 From: niravparikh05 Date: Mon, 10 Oct 2022 12:57:22 +0530 Subject: [PATCH 5/5] ran format --- src/containers/Auth/Login/index.js | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/containers/Auth/Login/index.js b/src/containers/Auth/Login/index.js index c2e966d4..1797e0e5 100644 --- a/src/containers/Auth/Login/index.js +++ b/src/containers/Auth/Login/index.js @@ -466,12 +466,8 @@ class Login extends Component { } render() { - const { - partnerDetail, - isLoginSuccess, - userAndRoleDetail, - UserSession, - } = this.props; + const { partnerDetail, isLoginSuccess, userAndRoleDetail, UserSession } = + this.props; const { isResponseError } = this.state; let formContent = this.renderLoginForm();