From 2b735804bb44f91fdad36a937e02dc1d90c63ea1 Mon Sep 17 00:00:00 2001
From: Fewwy <62722417+Fewwy@users.noreply.github.com>
Date: Mon, 28 Mar 2022 16:43:49 +0200
Subject: [PATCH] feat(Single cluster page): View in clusters button (#192)
---
compiled-lang/en.json | 2 +
src/App.scss | 4 ++
src/Components/ClusterHeader/ClusterHeader.js | 38 ++++++++++++++++++-
.../ClusterHeader/ClusterHeader.spec.ct.js | 11 ++++++
src/Messages.js | 11 ++++++
5 files changed, 64 insertions(+), 2 deletions(-)
diff --git a/compiled-lang/en.json b/compiled-lang/en.json
index 1ee13f8d..2deb3589 100644
--- a/compiled-lang/en.json
+++ b/compiled-lang/en.json
@@ -4,6 +4,7 @@
"all": "All",
"cancel": "Cancel",
"category": "Category",
+ "clusterDetailsRedirect": "View cluster details",
"clusterName": "Cluster name",
"clusters": "Clusters",
"comingSoonBody": "We’re currently working on this page. In the meantime, you can visit the Insights Advisor recommendations page to view potential issues with your clusters.",
@@ -17,6 +18,7 @@
"disableRuleSingleCluster": "Disable only for this cluster",
"disabled": "Disabled",
"documentTitle": "{subnav} - OCP Advisor | Red Hat Insights",
+ "dropDownActionSingleCluster": "Action",
"enable": "Enable",
"enableRule": "Enable recommendation",
"enableRuleForClusters": "Enable this recommendation for all clusters",
diff --git a/src/App.scss b/src/App.scss
index e96f3207..d51ad67c 100644
--- a/src/App.scss
+++ b/src/App.scss
@@ -12,4 +12,8 @@
.pf-c-table tr > *:first-child {
--pf-c-table--cell--PaddingLeft: 1rem;
--pf-c-table--cell--PaddingRight: 1rem;
+}
+
+#cluster-header-dropdown {
+ justify-self: end;
}
\ No newline at end of file
diff --git a/src/Components/ClusterHeader/ClusterHeader.js b/src/Components/ClusterHeader/ClusterHeader.js
index 9a718dc2..58784e0d 100644
--- a/src/Components/ClusterHeader/ClusterHeader.js
+++ b/src/Components/ClusterHeader/ClusterHeader.js
@@ -1,10 +1,11 @@
-import React from 'react';
+import React, { useState } from 'react';
import PropTypes from 'prop-types';
import { useIntl } from 'react-intl';
import { Grid, GridItem } from '@patternfly/react-core/dist/js/layouts/Grid';
import { Stack, StackItem } from '@patternfly/react-core/dist/js/layouts/Stack';
import { Title } from '@patternfly/react-core/dist/js/components/Title';
+import { Dropdown, DropdownToggle, DropdownItem } from '@patternfly/react-core';
import Skeleton from '@redhat-cloud-services/frontend-components/Skeleton';
import DateFormat from '@redhat-cloud-services/frontend-components/DateFormat/DateFormat';
@@ -12,6 +13,8 @@ import messages from '../../Messages';
import { OneLineLoader } from '../../Utilities/Loaders';
export const ClusterHeader = ({ clusterId, clusterData }) => {
+ const location = window.location;
+ const [isOpen, setIsOpen] = useState(false);
const intl = useIntl();
// subscribe to the cluster data query
const {
@@ -20,9 +23,23 @@ export const ClusterHeader = ({ clusterId, clusterData }) => {
data: cluster,
} = clusterData;
+ const redirectOCM = (clusterId) => {
+ location.assign(
+ location.origin +
+ (location.pathname.includes('beta') ? `/beta` : '') +
+ `/openshift/details/${clusterId}`
+ );
+ };
+
+ const dropDownItems = [
+ redirectOCM(clusterId)}>
+ {intl.formatMessage(messages.clusterDetailsRedirect)}
+ ,
+ ];
+
return (