11import React from 'react' ;
22
3- import { CircleQuestion , Gear , Keyboard , Person } from '@gravity-ui/icons' ;
3+ import { CircleQuestion , Gear , Person } from '@gravity-ui/icons' ;
44import type { MenuItem } from '@gravity-ui/navigation' ;
55import { AsideHeader , FooterItem , HotkeysPanel } from '@gravity-ui/navigation' ;
6- import { Hotkey , Icon } from '@gravity-ui/uikit' ;
6+ import { Hotkey } from '@gravity-ui/uikit' ;
77import type { IconData } from '@gravity-ui/uikit' ;
88import hotkeys from 'hotkeys-js' ;
99import { useHistory } from 'react-router-dom' ;
@@ -12,8 +12,7 @@ import {cn} from '../../utils/cn';
1212import { ASIDE_HEADER_COMPACT_KEY } from '../../utils/constants' ;
1313import { useSetting } from '../../utils/hooks' ;
1414
15- import { HelpCenterContent } from './HelpCenter' ;
16- import type { FooterItem as HelpCenterFooterItem } from './HelpCenter/types' ;
15+ import { InformationPopup } from './InformationPopup' ;
1716import { HOTKEYS , SHORTCUTS_HOTKEY } from './constants' ;
1817import i18n from './i18n' ;
1918
@@ -66,60 +65,37 @@ export interface AsideNavigationProps {
6665
6766enum Panel {
6867 UserSettings = 'UserSettings' ,
69- Documentation = 'Documentation ' ,
68+ Information = 'Information ' ,
7069 Hotkeys = 'Hotkeys' ,
7170}
7271
73- // Footer items for the help menu
74- const FOOTER_ITEMS : HelpCenterFooterItem [ ] = [
75- {
76- id : 'shortCuts' ,
77- text : 'Keyboard shortcuts' ,
78- icon : < Icon data = { Keyboard } /> ,
79- rightContent : < Hotkey value = { SHORTCUTS_HOTKEY } /> ,
80- } ,
81- ] ;
82-
8372export function AsideNavigation ( props : AsideNavigationProps ) {
8473 const history = useHistory ( ) ;
8574
8675 const [ visiblePanel , setVisiblePanel ] = React . useState < Panel > ( ) ;
87- const [ documentationPopupVisible , setDocumentationPopupVisible ] = React . useState ( false ) ;
76+ const [ informationPopupVisible , setInformationPopupVisible ] = React . useState ( false ) ;
8877 const [ compact , setIsCompact ] = useSetting < boolean > ( ASIDE_HEADER_COMPACT_KEY ) ;
8978
90- const toggleDocumentationPopup = React . useCallback (
91- ( ) => setDocumentationPopupVisible ( ! documentationPopupVisible ) ,
92- [ documentationPopupVisible ] ,
79+ const toggleInformationPopup = React . useCallback (
80+ ( ) => setInformationPopupVisible ( ! informationPopupVisible ) ,
81+ [ informationPopupVisible ] ,
9382 ) ;
9483
95- const closeDocumentationPopup = React . useCallback (
96- ( ) => setDocumentationPopupVisible ( false ) ,
97- [ ] ,
98- ) ;
84+ const closeInformationPopup = React . useCallback ( ( ) => setInformationPopupVisible ( false ) , [ ] ) ;
9985
10086 const openHotkeysPanel = React . useCallback ( ( ) => {
101- closeDocumentationPopup ( ) ;
87+ closeInformationPopup ( ) ;
10288 setVisiblePanel ( Panel . Hotkeys ) ;
103- } , [ closeDocumentationPopup ] ) ;
89+ } , [ closeInformationPopup ] ) ;
10490
10591 const closePanel = React . useCallback ( ( ) => {
10692 setVisiblePanel ( undefined ) ;
10793 } , [ ] ) ;
10894
109- const renderHelpMenu = ( ) => {
110- // Create a modified copy of FOOTER_ITEMS with the shortCuts onClick handler properly set
111- const footerItemsWithHandlers : HelpCenterFooterItem [ ] = FOOTER_ITEMS . map ( ( item ) => {
112- if ( item . id === 'shortCuts' ) {
113- return {
114- ...item ,
115- onClick : openHotkeysPanel ,
116- } ;
117- }
118- return item ;
119- } ) ;
120-
121- return < HelpCenterContent view = "single" footerItems = { footerItemsWithHandlers } /> ;
95+ const renderInformationPopup = ( ) => {
96+ return < InformationPopup onKeyboardShortcutsClick = { openHotkeysPanel } /> ;
12297 } ;
98+
12399 React . useEffect ( ( ) => {
124100 // Register hotkey for keyboard shortcuts
125101 hotkeys ( SHORTCUTS_HOTKEY , ( event ) => {
@@ -161,16 +137,16 @@ export function AsideNavigation(props: AsideNavigationProps) {
161137 < FooterItem
162138 compact = { compact }
163139 item = { {
164- id : 'documentation ' ,
165- title : i18n ( 'navigation-item.documentation ' ) ,
140+ id : 'information ' ,
141+ title : i18n ( 'navigation-item.information ' ) ,
166142 icon : CircleQuestion ,
167- current : documentationPopupVisible ,
168- onItemClick : toggleDocumentationPopup ,
143+ current : informationPopupVisible ,
144+ onItemClick : toggleInformationPopup ,
169145 } }
170- enableTooltip = { ! documentationPopupVisible }
171- popupVisible = { documentationPopupVisible }
172- onClosePopup = { closeDocumentationPopup }
173- renderPopupContent = { renderHelpMenu }
146+ enableTooltip = { ! informationPopupVisible }
147+ popupVisible = { informationPopupVisible }
148+ onClosePopup = { closeInformationPopup }
149+ renderPopupContent = { renderInformationPopup }
174150 />
175151
176152 < FooterItem
@@ -202,9 +178,8 @@ export function AsideNavigation(props: AsideNavigationProps) {
202178 content : props . settings ,
203179 } ,
204180 {
205- id : 'documentation' ,
206- visible : visiblePanel === Panel . Documentation ,
207- content : renderHelpMenu ( ) ,
181+ id : 'information' ,
182+ visible : visiblePanel === Panel . Information ,
208183 } ,
209184 {
210185 id : 'hotkeys' ,
@@ -216,7 +191,7 @@ export function AsideNavigation(props: AsideNavigationProps) {
216191 className = { b ( 'hotkeys-panel' ) }
217192 title = {
218193 < div className = { b ( 'hotkeys-panel-title' ) } >
219- Keyboard Shortcuts
194+ { i18n ( 'help-center.footer.shortcuts' ) }
220195 < Hotkey value = { SHORTCUTS_HOTKEY } />
221196 </ div >
222197 }
0 commit comments