mirror of
https://github.com/tiennm99/ccstatusline.git
synced 2026-09-05 18:16:22 +00:00
refactor: improve main manu option (#170)
* chore: resolve eslint error Signed-off-by: ysknsid25 <kengo071225@gmail.com> * refactor: improve menu value handing Signed-off-by: ysknsid25 <kengo071225@gmail.com> * refactor: keep minimal typed main-menu options Co-authored-by: Kanon <kengo071225@gmail.com> * refactor: minimize typed menu diff against main Co-authored-by: Kanon <kengo071225@gmail.com> --------- Signed-off-by: ysknsid25 <kengo071225@gmail.com> Co-authored-by: Matthew Breedlove <sirmalloc@gmail.com>
This commit is contained in:
co-authored by
Matthew Breedlove
parent
97d7491c12
commit
c4d0f4b5ad
+3
-2
@@ -52,7 +52,8 @@ import {
|
||||
PowerlineSetup,
|
||||
StatusLinePreview,
|
||||
TerminalOptionsMenu,
|
||||
TerminalWidthMenu
|
||||
TerminalWidthMenu,
|
||||
type MainMenuOption
|
||||
} from './components';
|
||||
|
||||
const GITHUB_REPO_URL = 'https://github.com/sirmalloc/ccstatusline';
|
||||
@@ -206,7 +207,7 @@ export const App: React.FC = () => {
|
||||
}
|
||||
};
|
||||
|
||||
const handleMainMenuSelect = async (value: string) => {
|
||||
const handleMainMenuSelect = async (value: MainMenuOption) => {
|
||||
switch (value) {
|
||||
case 'lines':
|
||||
setScreen('lines');
|
||||
|
||||
@@ -8,8 +8,18 @@ import React, { useState } from 'react';
|
||||
import type { Settings } from '../../types/Settings';
|
||||
import { type PowerlineFontStatus } from '../../utils/powerline';
|
||||
|
||||
export type MainMenuOption = 'lines'
|
||||
| 'colors'
|
||||
| 'powerline'
|
||||
| 'terminalConfig'
|
||||
| 'globalOverrides'
|
||||
| 'install'
|
||||
| 'starGithub'
|
||||
| 'save'
|
||||
| 'exit';
|
||||
|
||||
export interface MainMenuProps {
|
||||
onSelect: (value: string) => void;
|
||||
onSelect: (value: MainMenuOption) => void;
|
||||
isClaudeInstalled: boolean;
|
||||
hasChanges: boolean;
|
||||
initialSelection?: number;
|
||||
@@ -59,7 +69,8 @@ export const MainMenu: React.FC<MainMenuProps> = ({ onSelect, isClaudeInstalled,
|
||||
} else if (key.return) {
|
||||
const item = selectableItems[selectedIndex];
|
||||
if (item) {
|
||||
onSelect(item.value);
|
||||
// Since we filtered by selectable: true, value is guaranteed to be MainMenuOption
|
||||
onSelect(item.value as MainMenuOption);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user