github.com/SmartMeshFoundation/Spectrum@v0.0.0-20220621030607-452a266fee1e/dashboard/assets/components/Common.jsx (about)

     1  // @flow
     2  
     3  // Copyright 2017 The Spectrum Authors
     4  // This file is part of the Spectrum library.
     5  //
     6  // The Spectrum library is free software: you can redistribute it and/or modify
     7  // it under the terms of the GNU Lesser General Public License as published by
     8  // the Free Software Foundation, either version 3 of the License, or
     9  // (at your option) any later version.
    10  //
    11  // The Spectrum library is distributed in the hope that it will be useful,
    12  // but WITHOUT ANY WARRANTY; without even the implied warranty of
    13  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    14  // GNU Lesser General Public License for more details.
    15  //
    16  // You should have received a copy of the GNU Lesser General Public License
    17  // along with the Spectrum library. If not, see <http://www.gnu.org/licenses/>.
    18  
    19  type ProvidedMenuProp = {|title: string, icon: string|};
    20  const menuSkeletons: Array<{|id: string, menu: ProvidedMenuProp|}> = [
    21  	{
    22  		id:   'home',
    23  		menu: {
    24  			title: 'Home',
    25  			icon:  'home',
    26  		},
    27  	}, {
    28  		id:   'chain',
    29  		menu: {
    30  			title: 'Chain',
    31  			icon:  'link',
    32  		},
    33  	}, {
    34  		id:   'txpool',
    35  		menu: {
    36  			title: 'TxPool',
    37  			icon:  'credit-card',
    38  		},
    39  	}, {
    40  		id:   'network',
    41  		menu: {
    42  			title: 'Network',
    43  			icon:  'globe',
    44  		},
    45  	}, {
    46  		id:   'system',
    47  		menu: {
    48  			title: 'System',
    49  			icon:  'tachometer',
    50  		},
    51  	}, {
    52  		id:   'logs',
    53  		menu: {
    54  			title: 'Logs',
    55  			icon:  'list',
    56  		},
    57  	},
    58  ];
    59  export type MenuProp = {|...ProvidedMenuProp, id: string|};
    60  // The sidebar menu and the main content are rendered based on these elements.
    61  // Using the id is circumstantial in some cases, so it is better to insert it also as a value.
    62  // This way the mistyping is prevented.
    63  export const MENU: Map<string, {...MenuProp}> = new Map(menuSkeletons.map(({id, menu}) => ([id, {id, ...menu}])));
    64  
    65  type ProvidedSampleProp = {|limit: number|};
    66  const sampleSkeletons: Array<{|id: string, sample: ProvidedSampleProp|}> = [
    67  	{
    68  		id:     'memory',
    69  		sample: {
    70  			limit: 200,
    71  		},
    72  	}, {
    73  		id:     'traffic',
    74  		sample: {
    75  			limit: 200,
    76  		},
    77  	}, {
    78  		id:     'logs',
    79  		sample: {
    80  			limit: 200,
    81  		},
    82  	},
    83  ];
    84  export type SampleProp = {|...ProvidedSampleProp, id: string|};
    85  export const SAMPLE: Map<string, {...SampleProp}> = new Map(sampleSkeletons.map(({id, sample}) => ([id, {id, ...sample}])));
    86  
    87  export const DURATION = 200;
    88  
    89  export const LENS: Map<string, string> = new Map([
    90  	'content',
    91  	...menuSkeletons.map(({id}) => id),
    92  	...sampleSkeletons.map(({id}) => id),
    93  ].map(lens => [lens, lens]));