Remove unused method (#2721)
This commit is contained in:
parent
f19b9ed4f8
commit
dbd626054f
|
@ -153,7 +153,6 @@ const App = ({ config, settings, startupWarnings = [] }: AppProps) => {
|
|||
isAuthDialogOpen,
|
||||
openAuthDialog,
|
||||
handleAuthSelect,
|
||||
handleAuthHighlight,
|
||||
isAuthenticating,
|
||||
cancelAuthentication,
|
||||
} = useAuthCommand(settings, setAuthError, config);
|
||||
|
@ -672,7 +671,6 @@ const App = ({ config, settings, startupWarnings = [] }: AppProps) => {
|
|||
<Box flexDirection="column">
|
||||
<AuthDialog
|
||||
onSelect={handleAuthSelect}
|
||||
onHighlight={handleAuthHighlight}
|
||||
settings={settings}
|
||||
initialErrorMessage={authError}
|
||||
/>
|
||||
|
|
|
@ -31,7 +31,6 @@ describe('AuthDialog', () => {
|
|||
const { lastFrame } = render(
|
||||
<AuthDialog
|
||||
onSelect={() => {}}
|
||||
onHighlight={() => {}}
|
||||
settings={settings}
|
||||
initialErrorMessage="GEMINI_API_KEY environment variable not found"
|
||||
/>,
|
||||
|
@ -59,11 +58,7 @@ describe('AuthDialog', () => {
|
|||
);
|
||||
|
||||
const { lastFrame, stdin, unmount } = render(
|
||||
<AuthDialog
|
||||
onSelect={onSelect}
|
||||
onHighlight={() => {}}
|
||||
settings={settings}
|
||||
/>,
|
||||
<AuthDialog onSelect={onSelect} settings={settings} />,
|
||||
);
|
||||
await wait();
|
||||
|
||||
|
@ -96,11 +91,7 @@ describe('AuthDialog', () => {
|
|||
);
|
||||
|
||||
const { stdin, unmount } = render(
|
||||
<AuthDialog
|
||||
onSelect={onSelect}
|
||||
onHighlight={() => {}}
|
||||
settings={settings}
|
||||
/>,
|
||||
<AuthDialog onSelect={onSelect} settings={settings} />,
|
||||
);
|
||||
await wait();
|
||||
|
||||
|
|
|
@ -13,15 +13,13 @@ import { AuthType } from '@google/gemini-cli-core';
|
|||
import { validateAuthMethod } from '../../config/auth.js';
|
||||
|
||||
interface AuthDialogProps {
|
||||
onSelect: (authMethod: string | undefined, scope: SettingScope) => void;
|
||||
onHighlight: (authMethod: string | undefined) => void;
|
||||
onSelect: (authMethod: AuthType | undefined, scope: SettingScope) => void;
|
||||
settings: LoadedSettings;
|
||||
initialErrorMessage?: string | null;
|
||||
}
|
||||
|
||||
export function AuthDialog({
|
||||
onSelect,
|
||||
onHighlight,
|
||||
settings,
|
||||
initialErrorMessage,
|
||||
}: AuthDialogProps): React.JSX.Element {
|
||||
|
@ -45,7 +43,7 @@ export function AuthDialog({
|
|||
initialAuthIndex = 0;
|
||||
}
|
||||
|
||||
const handleAuthSelect = (authMethod: string) => {
|
||||
const handleAuthSelect = (authMethod: AuthType) => {
|
||||
const error = validateAuthMethod(authMethod);
|
||||
if (error) {
|
||||
setErrorMessage(error);
|
||||
|
@ -81,7 +79,6 @@ export function AuthDialog({
|
|||
items={items}
|
||||
initialIndex={initialAuthIndex}
|
||||
onSelect={handleAuthSelect}
|
||||
onHighlight={onHighlight}
|
||||
isFocused={true}
|
||||
/>
|
||||
{errorMessage && (
|
||||
|
|
|
@ -13,11 +13,6 @@ import {
|
|||
getErrorMessage,
|
||||
} from '@google/gemini-cli-core';
|
||||
|
||||
async function performAuthFlow(authMethod: AuthType, config: Config) {
|
||||
await config.refreshAuth(authMethod);
|
||||
console.log(`Authenticated via "${authMethod}".`);
|
||||
}
|
||||
|
||||
export const useAuthCommand = (
|
||||
settings: LoadedSettings,
|
||||
setAuthError: (error: string | null) => void,
|
||||
|
@ -35,16 +30,15 @@ export const useAuthCommand = (
|
|||
|
||||
useEffect(() => {
|
||||
const authFlow = async () => {
|
||||
if (isAuthDialogOpen || !settings.merged.selectedAuthType) {
|
||||
const authType = settings.merged.selectedAuthType;
|
||||
if (isAuthDialogOpen || !authType) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
setIsAuthenticating(true);
|
||||
await performAuthFlow(
|
||||
settings.merged.selectedAuthType as AuthType,
|
||||
config,
|
||||
);
|
||||
await config.refreshAuth(authType);
|
||||
console.log(`Authenticated via "${authType}".`);
|
||||
} catch (e) {
|
||||
setAuthError(`Failed to login. Message: ${getErrorMessage(e)}`);
|
||||
openAuthDialog();
|
||||
|
@ -57,10 +51,10 @@ export const useAuthCommand = (
|
|||
}, [isAuthDialogOpen, settings, config, setAuthError, openAuthDialog]);
|
||||
|
||||
const handleAuthSelect = useCallback(
|
||||
async (authMethod: string | undefined, scope: SettingScope) => {
|
||||
if (authMethod) {
|
||||
async (authType: AuthType | undefined, scope: SettingScope) => {
|
||||
if (authType) {
|
||||
await clearCachedCredentialFile();
|
||||
settings.setValue(scope, 'selectedAuthType', authMethod);
|
||||
settings.setValue(scope, 'selectedAuthType', authType);
|
||||
}
|
||||
setIsAuthDialogOpen(false);
|
||||
setAuthError(null);
|
||||
|
@ -68,10 +62,6 @@ export const useAuthCommand = (
|
|||
[settings, setAuthError],
|
||||
);
|
||||
|
||||
const handleAuthHighlight = useCallback((_authMethod: string | undefined) => {
|
||||
// For now, we don't do anything on highlight.
|
||||
}, []);
|
||||
|
||||
const cancelAuthentication = useCallback(() => {
|
||||
setIsAuthenticating(false);
|
||||
}, []);
|
||||
|
@ -80,7 +70,6 @@ export const useAuthCommand = (
|
|||
isAuthDialogOpen,
|
||||
openAuthDialog,
|
||||
handleAuthSelect,
|
||||
handleAuthHighlight,
|
||||
isAuthenticating,
|
||||
cancelAuthentication,
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue