Show pod name and namespace (#61)

This commit is contained in:
lirazyehezkel 2021-05-27 13:48:37 +03:00 committed by GitHub
parent 38a364fae5
commit fc5d6b2d0a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 43 additions and 11 deletions

View File

@ -1,5 +1,5 @@
import './style/StatusBar.sass';
import React from "react";
import React, {useState} from "react";
export interface TappingStatusPod {
name: string;
@ -15,14 +15,31 @@ export interface Props {
}
const pluralize = (noun: string, amount: number) => {
return `${noun}${amount != 1 ? 's' : ''}`
return `${noun}${amount !== 1 ? 's' : ''}`
}
export const StatusBar: React.FC<Props> = ({tappingStatus}) => {
const [expandedBar, setExpandedBar] = useState(false);
const uniqueNamespaces = Array.from(new Set(tappingStatus.pods.map(pod => pod.namespace)));
const amountOfPods = tappingStatus.pods.length;
return <div className='StatusBar'>
<span>{`Tapping ${amountOfPods} ${pluralize('pod', amountOfPods)} in ${pluralize('namespace', uniqueNamespaces.length)} ${uniqueNamespaces.join(", ")}`}</span>
return <div className={'statusBar' + (expandedBar ? ' expandedStatusBar' : "")} onMouseOver={() => setExpandedBar(true)} onMouseLeave={() => setExpandedBar(false)}>
<div className="podsCount">{`Tapping ${amountOfPods} ${pluralize('pod', amountOfPods)} in ${pluralize('namespace', uniqueNamespaces.length)} ${uniqueNamespaces.join(", ")}`}</div>
{expandedBar && <div style={{marginTop: 20}}>
<table>
<tr>
<th>Pod name</th>
<th>Namespace</th>
</tr>
<tbody>
{tappingStatus.pods.map(pod => <tr>
<td>{pod.name}</td>
<td>{pod.namespace}</td>
</tr>)}
</tbody>
</table>
</div>}
</div>;
}

View File

@ -1,20 +1,35 @@
@import 'variables.module.scss'
.StatusBar
.statusBar
position: absolute
transform: translate(-50%, -3px)
left: 50%
z-index: 9999
min-width: 200px
height: 32px
background: $blue-color
color: $light-blue-color
color: rgba(255,255,255,0.75)
border-bottom-left-radius: 8px
border-bottom-right-radius: 8px
top: 0
display: flex
align-items: center
padding: 2px 10px
user-select: none
font-size: 14px
opacity: 0.8
transition: max-height 2s ease-out
width: auto
max-height: 32px
overflow: hidden
.podsCount
display: flex
justify-content: center
padding: 8px
font-weight: 600
th
text-align: left
td
padding-right: 15px
padding-top: 5px
.expandedStatusBar
max-height: 100vh
padding-bottom: 15px