mirror of
https://github.com/OpenHands/OpenHands.git
synced 2025-12-26 05:48:36 +08:00
Removed in page callback (#6657)
This commit is contained in:
parent
61c709b7c7
commit
707cb07f4f
@ -132,6 +132,7 @@ describe("AccountSettingsModal", () => {
|
||||
agent: "CodeActAgent",
|
||||
confirmation_mode: false,
|
||||
enable_default_condenser: false,
|
||||
github_token: undefined,
|
||||
language: "en",
|
||||
llm_base_url: "",
|
||||
llm_model: "anthropic/claude-3-5-sonnet-20241022",
|
||||
|
||||
@ -5,10 +5,16 @@ interface AuthContextType {
|
||||
setGitHubTokenIsSet: (value: boolean) => void;
|
||||
}
|
||||
|
||||
interface AuthContextProps extends React.PropsWithChildren {
|
||||
initialGithubTokenIsSet?: boolean;
|
||||
}
|
||||
|
||||
const AuthContext = React.createContext<AuthContextType | undefined>(undefined);
|
||||
|
||||
function AuthProvider({ children }: React.PropsWithChildren) {
|
||||
const [githubTokenIsSet, setGitHubTokenIsSet] = React.useState(false);
|
||||
function AuthProvider({ children, initialGithubTokenIsSet }: AuthContextProps) {
|
||||
const [githubTokenIsSet, setGitHubTokenIsSet] = React.useState(
|
||||
!!initialGithubTokenIsSet,
|
||||
);
|
||||
|
||||
const value = React.useMemo(
|
||||
() => ({
|
||||
|
||||
@ -50,13 +50,5 @@ export const useSettings = () => {
|
||||
setGitHubTokenIsSet(!!query.data?.GITHUB_TOKEN_IS_SET);
|
||||
}, [query.data?.GITHUB_TOKEN_IS_SET, query.isFetched]);
|
||||
|
||||
// Return default settings if in SAAS mode and not authenticated
|
||||
if (config?.APP_MODE === "saas" && !githubTokenIsSet) {
|
||||
return {
|
||||
...query,
|
||||
data: DEFAULT_SETTINGS,
|
||||
};
|
||||
}
|
||||
|
||||
return query;
|
||||
};
|
||||
|
||||
@ -15,6 +15,4 @@ export default [
|
||||
route("served", "routes/app.tsx"),
|
||||
]),
|
||||
]),
|
||||
|
||||
route("oauth/github/callback", "routes/oauth.github.callback.tsx"),
|
||||
] satisfies RouteConfig;
|
||||
|
||||
@ -1,39 +0,0 @@
|
||||
import { useNavigate, useSearchParams } from "react-router";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import React from "react";
|
||||
import OpenHands from "#/api/open-hands";
|
||||
|
||||
function OAuthGitHubCallback() {
|
||||
const navigate = useNavigate();
|
||||
const [searchParams] = useSearchParams();
|
||||
const code = searchParams.get("code");
|
||||
|
||||
const { isSuccess, error } = useQuery({
|
||||
queryKey: ["access_token", code],
|
||||
queryFn: () => OpenHands.getGitHubAccessToken(code!),
|
||||
enabled: !!code,
|
||||
});
|
||||
|
||||
React.useEffect(() => {
|
||||
if (isSuccess) {
|
||||
navigate("/");
|
||||
}
|
||||
}, [isSuccess]);
|
||||
|
||||
if (error) {
|
||||
return (
|
||||
<div>
|
||||
<h1>Error</h1>
|
||||
<p>{error.message}</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
<h1>Redirecting...</h1>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default OAuthGitHubCallback;
|
||||
@ -66,7 +66,7 @@ export function renderWithProviders(
|
||||
function Wrapper({ children }: PropsWithChildren) {
|
||||
return (
|
||||
<Provider store={store}>
|
||||
<AuthProvider>
|
||||
<AuthProvider initialGithubTokenIsSet={true}>
|
||||
<QueryClientProvider
|
||||
client={
|
||||
new QueryClient({
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user