|
| 1 | +// Copyright © 2022 Kaleido, Inc. |
| 2 | +// |
| 3 | +// SPDX-License-Identifier: Apache-2.0 |
| 4 | +// |
| 5 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | +// you may not use this file except in compliance with the License. |
| 7 | +// You may obtain a copy of the License at |
| 8 | +// |
| 9 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +// |
| 11 | +// Unless required by applicable law or agreed to in writing, software |
| 12 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | +// See the License for the specific language governing permissions and |
| 15 | +// limitations under the License. |
| 16 | + |
| 17 | +import HexagonIcon from '@mui/icons-material/Hexagon'; |
| 18 | +import React, { useContext } from 'react'; |
| 19 | +import { useTranslation } from 'react-i18next'; |
| 20 | +import { useLocation, useNavigate } from 'react-router-dom'; |
| 21 | +import { ApplicationContext } from '../../contexts/ApplicationContext'; |
| 22 | +import { FF_NAV_PATHS, INavItem } from '../../interfaces'; |
| 23 | +import { NavSection } from './NavSection'; |
| 24 | + |
| 25 | +export const MyNodeNav = () => { |
| 26 | + const { t } = useTranslation(); |
| 27 | + const navigate = useNavigate(); |
| 28 | + const { selectedNamespace } = useContext(ApplicationContext); |
| 29 | + const { pathname } = useLocation(); |
| 30 | + |
| 31 | + const myNodePath = FF_NAV_PATHS.myNodePath(selectedNamespace); |
| 32 | + const myNodeSubscriptionsPath = |
| 33 | + FF_NAV_PATHS.myNodeSubscriptionsPath(selectedNamespace); |
| 34 | + |
| 35 | + const navItems: INavItem[] = [ |
| 36 | + { |
| 37 | + name: t('dashboard'), |
| 38 | + action: () => navigate(myNodePath), |
| 39 | + itemIsActive: pathname === myNodePath, |
| 40 | + }, |
| 41 | + { |
| 42 | + name: t('subscriptions'), |
| 43 | + action: () => navigate(myNodeSubscriptionsPath), |
| 44 | + itemIsActive: pathname === myNodeSubscriptionsPath, |
| 45 | + }, |
| 46 | + ]; |
| 47 | + |
| 48 | + return ( |
| 49 | + <NavSection |
| 50 | + icon={<HexagonIcon />} |
| 51 | + navItems={navItems} |
| 52 | + title={t('myNode')} |
| 53 | + /> |
| 54 | + ); |
| 55 | +}; |
0 commit comments