@@ -2,14 +2,15 @@ import { useRef, useCallback } from 'react'
22import { MODE , Mode } from '@/views/panel/types/main-view-mode'
33import { use_is_narrow_viewport , use_is_mac } from '@shared/hooks'
44import { ApiPromptType , WebPromptType } from '@shared/types/prompt-types'
5- import { InlineDropdown as UiInlineDropdown } from '@ui/components/editor/panel/InlineDropdown '
5+ import { PromptTypeDropdown as UiPromptTypeDropdown } from '@ui/components/editor/panel/PromptTypeDropdown '
66import { IconButton as UiIconButton } from '@ui/components/editor/common/IconButton'
77import styles from './Header.module.scss'
88import {
99 api_prompt_type_labels ,
1010 web_prompt_type_labels
1111} from '../../prompt-type-labels'
1212import { use_keyboard_shortcuts } from './hooks/use-keyboard-shortcuts'
13+ import { use_alternate_prompt_type } from './hooks/use-alternate-prompt-type'
1314import { use_translation } from '../../../../i18n/use-translation'
1415
1516type Props = {
@@ -33,6 +34,14 @@ export const Header: React.FC<Props> = (props) => {
3334 const header_left_ref = useRef < HTMLDivElement > ( null )
3435 const dropdown_container_ref = useRef < HTMLDivElement > ( null )
3536
37+ const { handle_alternate_click, has_alternate } = use_alternate_prompt_type ( {
38+ mode : props . mode ,
39+ web_prompt_type : props . web_prompt_type ,
40+ api_prompt_type : props . api_prompt_type ,
41+ on_web_prompt_type_change : props . on_web_prompt_type_change ,
42+ on_api_prompt_type_change : props . on_api_prompt_type_change
43+ } )
44+
3645 const handle_heading_click = useCallback ( ( ) => {
3746 if ( props . mode == MODE . WEB ) {
3847 props . on_mode_change ( MODE . API )
@@ -76,7 +85,7 @@ export const Header: React.FC<Props> = (props) => {
7685 ref = { dropdown_container_ref }
7786 >
7887 { props . mode == MODE . WEB && (
79- < UiInlineDropdown
88+ < UiPromptTypeDropdown
8089 options = { Object . entries ( web_prompt_type_labels ) . map (
8190 ( [ value , label ] ) => ( {
8291 value : value as WebPromptType ,
@@ -86,6 +95,9 @@ export const Header: React.FC<Props> = (props) => {
8695 ) }
8796 selected_value = { props . web_prompt_type }
8897 on_change = { props . on_web_prompt_type_change }
98+ on_alternate_click = {
99+ has_alternate ? handle_alternate_click : undefined
100+ }
89101 menu_max_height = { MENU_MAX_HEIGHT }
90102 info = { t ( 'header.prompt-type' ) }
91103 title = {
@@ -97,7 +109,7 @@ export const Header: React.FC<Props> = (props) => {
97109 />
98110 ) }
99111 { props . mode == MODE . API && (
100- < UiInlineDropdown
112+ < UiPromptTypeDropdown
101113 options = { Object . entries ( api_prompt_type_labels ) . map (
102114 ( [ value , label ] ) => ( {
103115 value : value as ApiPromptType ,
@@ -107,6 +119,9 @@ export const Header: React.FC<Props> = (props) => {
107119 ) }
108120 selected_value = { props . api_prompt_type }
109121 on_change = { props . on_api_prompt_type_change }
122+ on_alternate_click = {
123+ has_alternate ? handle_alternate_click : undefined
124+ }
110125 menu_max_height = { MENU_MAX_HEIGHT }
111126 info = { is_narrow_viewport ? undefined : t ( 'header.prompt-type' ) }
112127 title = {
0 commit comments