@@ -18,7 +18,7 @@ import React, { Fragment, useEffect, useState } from "react";
1818import { connect } from "react-redux" ;
1919import { Link , Redirect , Route , Router , Switch } from "react-router-dom" ;
2020import { createStyles , Theme , withStyles } from "@material-ui/core/styles" ;
21- import { IconButton , Tooltip } from "@material-ui/core" ;
21+ import { Box , IconButton , Tab , Tabs , Tooltip } from "@material-ui/core" ;
2222import get from "lodash/get" ;
2323import Grid from "@material-ui/core/Grid" ;
2424import { setErrorSnackMessage , setSnackBarMessage } from "../../../../actions" ;
@@ -242,6 +242,94 @@ const TenantDetails = ({
242242 : classes . greyState ;
243243 } ;
244244
245+ interface ListMenuItem {
246+ label : string ;
247+ value : string ;
248+ onclick : ( val : string ) => void ;
249+ selected : ( ) => boolean ;
250+ }
251+
252+ const menu : ListMenuItem [ ] = [
253+ {
254+ label : "Summary" ,
255+ value : "summary" ,
256+ onclick : ( val ) => {
257+ changeRoute ( val ) ;
258+ } ,
259+ selected : ( ) => {
260+ return currentTab === "summary" ;
261+ } ,
262+ } ,
263+ {
264+ label : "Metrics" ,
265+ value : "metrics" ,
266+ onclick : ( val ) => {
267+ changeRoute ( "metrics" ) ;
268+ } ,
269+ selected : ( ) => {
270+ return currentTab === "metrics" ;
271+ } ,
272+ } ,
273+ {
274+ label : "Security" ,
275+ value : "security" ,
276+ onclick : ( val ) => {
277+ changeRoute ( "security" ) ;
278+ } ,
279+ selected : ( ) => {
280+ return currentTab === "security" ;
281+ } ,
282+ } ,
283+ {
284+ label : "Pools" ,
285+ value : "pools" ,
286+ onclick : ( val ) => {
287+ changeRoute ( "pools" ) ;
288+ } ,
289+ selected : ( ) => {
290+ return currentTab === "pools" ;
291+ } ,
292+ } ,
293+ {
294+ label : "Pods" ,
295+ value : "pods" ,
296+ onclick : ( val ) => {
297+ changeRoute ( "pods" ) ;
298+ } ,
299+ selected : ( ) => {
300+ return currentTab === "pods" || currentTab === ":podName" ;
301+ } ,
302+ } ,
303+ {
304+ label : "Volumes" ,
305+ value : "volumes" ,
306+ onclick : ( val ) => {
307+ changeRoute ( "volumes" ) ;
308+ } ,
309+ selected : ( ) => {
310+ return currentTab === "volumes" ;
311+ } ,
312+ } ,
313+ {
314+ label : "License" ,
315+ value : "license" ,
316+ onclick : ( val ) => {
317+ changeRoute ( "license" ) ;
318+ } ,
319+ selected : ( ) => {
320+ return currentTab === "license" ;
321+ } ,
322+ } ,
323+ ] ;
324+
325+ let value = menu [ 0 ] . value ;
326+ for ( const mli of menu ) {
327+ if ( mli . selected ( ) ) {
328+ value = mli . value ;
329+ break ;
330+ }
331+ }
332+
245333 return (
246334 < Fragment >
247335 { yamlScreenOpen && (
@@ -336,74 +424,48 @@ const TenantDetails = ({
336424 }
337425 />
338426 </ Grid >
339- < Grid item xs = { 2 } >
340- < List component = "nav" dense = { true } >
341- < ListItem
342- button
343- selected = { currentTab === "summary" }
344- onClick = { ( ) => {
345- changeRoute ( "summary" ) ;
346- } }
347- >
348- < ListItemText primary = "Summary" />
349- </ ListItem >
350- < ListItem
351- button
352- selected = { currentTab === "metrics" }
353- onClick = { ( ) => {
354- changeRoute ( "metrics" ) ;
355- } }
356- >
357- < ListItemText primary = "Metrics" />
358- </ ListItem >
359- < ListItem
360- button
361- selected = { currentTab === "security" }
362- onClick = { ( ) => {
363- changeRoute ( "security" ) ;
364- } }
365- >
366- < ListItemText primary = "Security" />
367- </ ListItem >
368- < ListItem
369- button
370- selected = { currentTab === "pools" }
371- onClick = { ( ) => {
372- changeRoute ( "pools" ) ;
373- } }
374- >
375- < ListItemText primary = "Pools" />
376- </ ListItem >
377- < ListItem
378- button
379- selected = { currentTab === "pods" || currentTab === ":podName" }
380- onClick = { ( ) => {
381- changeRoute ( "pods" ) ;
382- } }
383- >
384- < ListItemText primary = "Pods" />
385- </ ListItem >
386- < ListItem
387- button
388- selected = { currentTab === "volumes" }
389- onClick = { ( ) => {
390- changeRoute ( "volumes" ) ;
391- } }
392- >
393- < ListItemText primary = "Volumes" />
394- </ ListItem >
395- < ListItem
396- button
397- selected = { currentTab === "license" }
398- onClick = { ( ) => {
399- changeRoute ( "license" ) ;
400- } }
427+ < Grid item xs = { 12 } sm = { 12 } md = { 2 } >
428+ < Box display = { { xs : "none" , sm : "none" , md : "block" } } >
429+ < List component = "nav" dense = { true } >
430+ { menu . map ( ( mli ) => {
431+ return (
432+ < ListItem
433+ button
434+ selected = { mli . selected ( ) }
435+ onClick = { ( ) => {
436+ mli . onclick ( mli . value ) ;
437+ } }
438+ >
439+ < ListItemText primary = { mli . label } />
440+ </ ListItem >
441+ ) ;
442+ } ) }
443+ </ List >
444+ </ Box >
445+ < Box display = { { xs : "block" , sm : "block" , md : "none" } } >
446+ < Tabs
447+ value = { value }
448+ indicatorColor = "primary"
449+ textColor = "primary"
450+ variant = "scrollable"
451+ scrollButtons = "auto"
452+ aria-label = "scrollable auto tabs example"
401453 >
402- < ListItemText primary = "License" />
403- </ ListItem >
404- </ List >
454+ { menu . map ( ( mli ) => {
455+ return (
456+ < Tab
457+ label = { mli . label }
458+ value = { mli . value }
459+ onClick = { ( ) => {
460+ mli . onclick ( mli . value ) ;
461+ } }
462+ />
463+ ) ;
464+ } ) }
465+ </ Tabs >
466+ </ Box >
405467 </ Grid >
406- < Grid item xs = { 10 } >
468+ < Grid item xs = { 12 } sm = { 12 } md = { 10 } >
407469 < Router history = { history } >
408470 < Switch >
409471 < Route
0 commit comments