Skip to content

Commit

Permalink
Merge pull request #4 from RedHatInsights/dynamic_cluster_name_header
Browse files Browse the repository at this point in the history
add dynamic title to display cluster name
  • Loading branch information
psav authored Jul 18, 2024
2 parents 72a93e8 + 4358a5f commit 039850b
Show file tree
Hide file tree
Showing 3 changed files with 110 additions and 13 deletions.
2 changes: 1 addition & 1 deletion plugins/openshift/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"@material-ui/core": "^4.9.13",
"@material-ui/icons": "^4.9.1",
"@material-ui/lab": "4.0.0-alpha.61",
"@mui/material": "^5.15.19",
"@mui/material": "^5.16.4",
"@patternfly/react-core": "^5.3.3",
"@patternfly/react-icons": "^5.3.2",
"@types/node": "^20.14.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
InfoCard,
} from '@backstage/core-components';
import QueryQontract from '../../common/QueryAppInterface'
import { makeStyles } from '@material-ui/core/styles';
import { createTheme, makeStyles, ThemeProvider } from '@material-ui/core/styles';
import LinearProgress from '@material-ui/core/LinearProgress';
import { NSQuery } from './query';

Expand All @@ -17,16 +17,13 @@ export const OpenshiftComponent = () => {
const { result: qontractResult, loaded: qontractLoaded, error: qontractError } = QueryQontract(NSQuery);

console.log(qontractResult)
const title: string = "Deployment Information"

// state variables for stage/prod buttons
const [isStageButtonDisabled, setIsStageButtonDisabled] = useState<boolean>(true);
const [isProdButtonDisabled, setIsProdButtonDisabled] = useState<boolean>(false);
const [currentEnvironment, setCurrentEnvironment] = useState<string>("")
const [currentEnvironmentUrl, setCurrentEnvironmentUrl] = useState<string>("")

// const environmentName = data.environmentName;

const getEnvironmentNamespace = (environment: string) => {
const clusterInfo = qontractResult.find(e => e.path.includes(`${environment}.yml`))
const namespaceName = clusterInfo?.name
Expand Down Expand Up @@ -63,7 +60,11 @@ export const OpenshiftComponent = () => {
}
return cluster;
};
const capitalizeFirstLetter = (currentEnvironment: string) => {
return currentEnvironment.charAt(0).toUpperCase() + currentEnvironment.slice(1);
}

const title: string = `Deployment Information - ${capitalizeFirstLetter(currentEnvironment)} cluster`;
const namespaceName = getEnvironmentNamespace(currentEnvironment)

// styles for linear progress bar
Expand All @@ -76,6 +77,16 @@ export const OpenshiftComponent = () => {
},
}));

const theme = createTheme({
palette: {
action: {
disabledBackground: '#191970',
disabled: 'set color of text here'
}
}
}
)

const classes = useStyles();

const buttonHandler = (isStageDisabled: boolean, isProdDisabled: boolean) => {
Expand All @@ -88,10 +99,10 @@ export const OpenshiftComponent = () => {

const ClusterButtons = () => {
return (
<ButtonGroup aria-label="Basic button group">
<ThemeProvider theme={theme}>
<Button size="small" variant="contained" color="primary" onClick={() => buttonHandler(true, false)} disabled={isStageButtonDisabled}>Stage</Button>
<Button size="small" variant="contained" color="primary" onClick={() => buttonHandler(false, true)} disabled={isProdButtonDisabled}>Prod</Button>
</ButtonGroup>
</ThemeProvider>
);
}

Expand Down
98 changes: 92 additions & 6 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5916,7 +5916,12 @@
resolved "https://registry.yarnpkg.com/@mui/core-downloads-tracker/-/core-downloads-tracker-5.15.20.tgz#6ede705770797c32f5a4fc0d3002ad0b758d23e8"
integrity sha512-DoL2ppgldL16utL8nNyj/P12f8mCNdx/Hb/AJnX9rLY4b52hCMIx1kH83pbXQ6uMy6n54M3StmEbvSGoj2OFuA==

"@mui/material@^5.12.2", "@mui/material@^5.15.19":
"@mui/core-downloads-tracker@^5.16.4":
version "5.16.4"
resolved "https://registry.yarnpkg.com/@mui/core-downloads-tracker/-/core-downloads-tracker-5.16.4.tgz#a34de72acd7e81fdbcc7eeb07786205e90dda148"
integrity sha512-rNdHXhclwjEZnK+//3SR43YRx0VtjdHnUFhMSGYmAMJve+KiwEja/41EYh8V3pZKqF2geKyfcFUenTfDTYUR4w==

"@mui/material@^5.12.2":
version "5.15.20"
resolved "https://registry.yarnpkg.com/@mui/material/-/material-5.15.20.tgz#87737404603ca2802a8e074b059f8329e013e615"
integrity sha512-tVq3l4qoXx/NxUgIx/x3lZiPn/5xDbdTE8VrLczNpfblLYZzlrbxA7kb9mI8NoBF6+w9WE9IrxWnKK5KlPI2bg==
Expand All @@ -5934,6 +5939,24 @@
react-is "^18.2.0"
react-transition-group "^4.4.5"

"@mui/material@^5.16.4":
version "5.16.4"
resolved "https://registry.yarnpkg.com/@mui/material/-/material-5.16.4.tgz#992d630637d9d38620e4937fb11d0a97965fdabf"
integrity sha512-dBnh3/zRYgEVIS3OE4oTbujse3gifA0qLMmuUk13ywsDCbngJsdgwW5LuYeiT5pfA8PGPGSqM7mxNytYXgiMCw==
dependencies:
"@babel/runtime" "^7.23.9"
"@mui/core-downloads-tracker" "^5.16.4"
"@mui/system" "^5.16.4"
"@mui/types" "^7.2.15"
"@mui/utils" "^5.16.4"
"@popperjs/core" "^2.11.8"
"@types/react-transition-group" "^4.4.10"
clsx "^2.1.0"
csstype "^3.1.3"
prop-types "^15.8.1"
react-is "^18.3.1"
react-transition-group "^4.4.5"

"@mui/private-theming@^5.15.20":
version "5.15.20"
resolved "https://registry.yarnpkg.com/@mui/private-theming/-/private-theming-5.15.20.tgz#028c4e3c717a13691ac2c8c98e29aa819d89001a"
Expand All @@ -5943,6 +5966,15 @@
"@mui/utils" "^5.15.20"
prop-types "^15.8.1"

"@mui/private-theming@^5.16.4":
version "5.16.4"
resolved "https://registry.yarnpkg.com/@mui/private-theming/-/private-theming-5.16.4.tgz#0118f137975b35dc4774c6d593b8fcf86594c3fc"
integrity sha512-ZsAm8cq31SJ37SVWLRlu02v9SRthxnfQofaiv14L5Bht51B0dz6yQEoVU/V8UduZDCCIrWkBHuReVfKhE/UuXA==
dependencies:
"@babel/runtime" "^7.23.9"
"@mui/utils" "^5.16.4"
prop-types "^15.8.1"

"@mui/styled-engine@^5.15.14":
version "5.15.14"
resolved "https://registry.yarnpkg.com/@mui/styled-engine/-/styled-engine-5.15.14.tgz#168b154c4327fa4ccc1933a498331d53f61c0de2"
Expand All @@ -5953,6 +5985,16 @@
csstype "^3.1.3"
prop-types "^15.8.1"

"@mui/styled-engine@^5.16.4":
version "5.16.4"
resolved "https://registry.yarnpkg.com/@mui/styled-engine/-/styled-engine-5.16.4.tgz#a7a8c9079c307bab91ccd65ed5dd1496ddf2a3ab"
integrity sha512-0+mnkf+UiAmTVB8PZFqOhqf729Yh0Cxq29/5cA3VAyDVTRIUUQ8FXQhiAhUIbijFmM72rY80ahFPXIm4WDbzcA==
dependencies:
"@babel/runtime" "^7.23.9"
"@emotion/cache" "^11.11.0"
csstype "^3.1.3"
prop-types "^15.8.1"

"@mui/system@^5.15.20":
version "5.15.20"
resolved "https://registry.yarnpkg.com/@mui/system/-/system-5.15.20.tgz#f1933aabc4c10f8580c7a951ca3b88542ef0f76b"
Expand All @@ -5967,11 +6009,30 @@
csstype "^3.1.3"
prop-types "^15.8.1"

"@mui/system@^5.16.4":
version "5.16.4"
resolved "https://registry.yarnpkg.com/@mui/system/-/system-5.16.4.tgz#c03f971ed273f0ad06c69c949c05e866ad211407"
integrity sha512-ET1Ujl2/8hbsD611/mqUuNArMCGv/fIWO/f8B3ZqF5iyPHM2aS74vhTNyjytncc4i6dYwGxNk+tLa7GwjNS0/w==
dependencies:
"@babel/runtime" "^7.23.9"
"@mui/private-theming" "^5.16.4"
"@mui/styled-engine" "^5.16.4"
"@mui/types" "^7.2.15"
"@mui/utils" "^5.16.4"
clsx "^2.1.0"
csstype "^3.1.3"
prop-types "^15.8.1"

"@mui/types@^7.2.14":
version "7.2.14"
resolved "https://registry.yarnpkg.com/@mui/types/-/types-7.2.14.tgz#8a02ac129b70f3d82f2f9b76ded2c8d48e3fc8c9"
integrity sha512-MZsBZ4q4HfzBsywtXgM1Ksj6HDThtiwmOKUXH1pKYISI9gAVXCNHNpo7TlGoGrBaYWZTdNoirIN7JsQcQUjmQQ==

"@mui/types@^7.2.15":
version "7.2.15"
resolved "https://registry.yarnpkg.com/@mui/types/-/types-7.2.15.tgz#dadd232fe9a70be0d526630675dff3b110f30b53"
integrity sha512-nbo7yPhtKJkdf9kcVOF8JZHPZTmqXjJ/tI0bdWgHg5tp9AnIN4Y7f7wm9T+0SyGYJk76+GYZ8Q5XaTYAsUHN0Q==

"@mui/utils@^5.14.15", "@mui/utils@^5.15.14", "@mui/utils@^5.15.20":
version "5.15.20"
resolved "https://registry.yarnpkg.com/@mui/utils/-/utils-5.15.20.tgz#92778d749ce5ded1598639b4e684aaedb1146e08"
Expand All @@ -5982,6 +6043,17 @@
prop-types "^15.8.1"
react-is "^18.2.0"

"@mui/utils@^5.16.4":
version "5.16.4"
resolved "https://registry.yarnpkg.com/@mui/utils/-/utils-5.16.4.tgz#8e50e27a630e3d8eeb3e9d3bc31cbb0e4956f5fd"
integrity sha512-nlppYwq10TBIFqp7qxY0SvbACOXeOjeVL3pOcDsK0FT8XjrEXh9/+lkg8AEIzD16z7YfiJDQjaJG2OLkE7BxNg==
dependencies:
"@babel/runtime" "^7.23.9"
"@types/prop-types" "^15.7.12"
clsx "^2.1.1"
prop-types "^15.8.1"
react-is "^18.3.1"

"@n1ru4l/push-pull-async-iterable-iterator@^3.1.0":
version "3.2.0"
resolved "https://registry.yarnpkg.com/@n1ru4l/push-pull-async-iterable-iterator/-/push-pull-async-iterable-iterator-3.2.0.tgz#c15791112db68dd9315d329d652b7e797f737655"
Expand Down Expand Up @@ -9543,7 +9615,7 @@
dependencies:
"@types/express" "*"

"@types/prop-types@*", "@types/prop-types@^15.0.0", "@types/prop-types@^15.7.11", "@types/prop-types@^15.7.3":
"@types/prop-types@*", "@types/prop-types@^15.0.0", "@types/prop-types@^15.7.11", "@types/prop-types@^15.7.12", "@types/prop-types@^15.7.3":
version "15.7.12"
resolved "https://registry.yarnpkg.com/@types/prop-types/-/prop-types-15.7.12.tgz#12bb1e2be27293c1406acb6af1c3f3a1481d98c6"
integrity sha512-5zvhXYtRNRluoE/jAp4GVsSduVUzNWKkOZrCDBWYtE7biZywwdC2AcEzg+cSMLFRfVgeAFqpfNabiPjxFddV1Q==
Expand Down Expand Up @@ -9572,7 +9644,7 @@
resolved "https://registry.yarnpkg.com/@types/range-parser/-/range-parser-1.2.7.tgz#50ae4353eaaddc04044279812f52c8c65857dbcb"
integrity sha512-hKormJbkJqzQGhziax5PItDUTMAM9uE2XXQmM37dyd4hVM+5aVl7oVxMVUiVQn2oCQFN/LKCZdvSM0pFRqbSmQ==

"@types/react-dom@*", "@types/react-dom@^18", "@types/react-dom@^18.0.0":
"@types/react-dom@*", "@types/react-dom@^18.0.0":
version "18.3.0"
resolved "https://registry.yarnpkg.com/@types/react-dom/-/react-dom-18.3.0.tgz#0cbc818755d87066ab6ca74fbedb2547d74a82b0"
integrity sha512-EhwApuTmMBmXuFOikhQLIBUn6uFg81SwLMOAUgodJF14SOBOCMdU04gDoYi0WOJJHD144TL32z4yDqCW3dnkQg==
Expand Down Expand Up @@ -9603,14 +9675,23 @@
dependencies:
"@types/react" "*"

"@types/react@*", "@types/react@^16.13.1 || ^17.0.0", "@types/react@^16.13.1 || ^17.0.0 || ^18.0.0", "@types/react@^18":
"@types/react@*", "@types/react@^16.13.1 || ^17.0.0 || ^18.0.0":
version "18.3.3"
resolved "https://registry.yarnpkg.com/@types/react/-/react-18.3.3.tgz#9679020895318b0915d7a3ab004d92d33375c45f"
integrity sha512-hti/R0pS0q1/xx+TsI73XIqk26eBsISZ2R0wUijXIngRK9R/e7Xw/cXVxQK7R5JjW+SV4zGcn5hXjudkN/pLIw==
dependencies:
"@types/prop-types" "*"
csstype "^3.0.2"

"@types/react@^16.13.1 || ^17.0.0":
version "17.0.80"
resolved "https://registry.yarnpkg.com/@types/react/-/react-17.0.80.tgz#a5dfc351d6a41257eb592d73d3a85d3b7dbcbb41"
integrity sha512-LrgHIu2lEtIo8M7d1FcI3BdwXWoRQwMoXOZ7+dPTW0lYREjmlHl3P0U1VD0i/9tppOuv8/sam7sOjx34TxSFbA==
dependencies:
"@types/prop-types" "*"
"@types/scheduler" "^0.16"
csstype "^3.0.2"

"@types/request@^2.47.1", "@types/request@^2.48.8":
version "2.48.12"
resolved "https://registry.yarnpkg.com/@types/request/-/request-2.48.12.tgz#0f590f615a10f87da18e9790ac94c29ec4c5ef30"
Expand Down Expand Up @@ -9648,6 +9729,11 @@
resolved "https://registry.yarnpkg.com/@types/sarif/-/sarif-2.1.7.tgz#dab4d16ba7568e9846c454a8764f33c5d98e5524"
integrity sha512-kRz0VEkJqWLf1LLVN4pT1cg1Z9wAuvI6L97V3m2f5B76Tg8d413ddvLBPTEHAZJlnn4XSvu0FkZtViCQGVyrXQ==

"@types/scheduler@^0.16":
version "0.16.8"
resolved "https://registry.yarnpkg.com/@types/scheduler/-/scheduler-0.16.8.tgz#ce5ace04cfeabe7ef87c0091e50752e36707deff"
integrity sha512-WZLiwShhwLRmeV6zH+GkbOFT6Z6VklCItrDioxUnv+u4Ll+8vKeFySoFyK/0ctcRpOmwAicELfmys1sDc/Rw+A==

"@types/semver@^7.3.12", "@types/semver@^7.5.0":
version "7.5.8"
resolved "https://registry.yarnpkg.com/@types/semver/-/semver-7.5.8.tgz#8268a8c57a3e4abd25c165ecd36237db7948a55e"
Expand Down Expand Up @@ -11777,7 +11863,7 @@ clsx@^1.0.2, clsx@^1.0.4, clsx@^1.2.1:
resolved "https://registry.yarnpkg.com/clsx/-/clsx-1.2.1.tgz#0ddc4a20a549b59c93a4116bb26f5294ca17dc12"
integrity sha512-EcR6r5a8bj6pu3ycsa/E/cKVGuTgZJZdsyUYHOksG/UHIiKfjxzRxYJpyVBwYaQeOvghal9fcc4PidlgzugAQg==

clsx@^2.1.0:
clsx@^2.1.0, clsx@^2.1.1:
version "2.1.1"
resolved "https://registry.yarnpkg.com/clsx/-/clsx-2.1.1.tgz#eed397c9fd8bd882bfb18deab7102049a2f32999"
integrity sha512-eYm0QWBtUrBWZWG0d386OGAw16Z995PiOVo2B7bjWSbHedGl5e0ZWaq65kOGgUSNesEIDkB9ISbTg/JK9dhCZA==
Expand Down Expand Up @@ -21633,7 +21719,7 @@ react-is@^16.13.1, react-is@^16.7.0:
resolved "https://registry.yarnpkg.com/react-is/-/react-is-17.0.2.tgz#e691d4a8e9c789365655539ab372762b0efb54f0"
integrity sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w==

react-is@^18.0.0, react-is@^18.2.0:
react-is@^18.0.0, react-is@^18.2.0, react-is@^18.3.1:
version "18.3.1"
resolved "https://registry.yarnpkg.com/react-is/-/react-is-18.3.1.tgz#e83557dc12eae63a99e003a46388b1dcbb44db7e"
integrity sha512-/LLMVyas0ljjAtoYiPqYiL8VWXzUUdThrmU5+n20DZv+a+ClRoevUzw5JxU+Ieh5/c87ytoTBV9G1FiKfNJdmg==
Expand Down

0 comments on commit 039850b

Please sign in to comment.