aritra24 commented on code in PR #48550:
URL: https://github.com/apache/airflow/pull/48550#discussion_r2021060051
##########
airflow-core/src/airflow/api_fastapi/auth/managers/simple/ui/src/login/Login.tsx:
##########
@@ -17,84 +17,118 @@
* under the License.
*/
-import React, {useState} from "react";
-import {Alert, CloseButton, Container, Heading, Text} from "@chakra-ui/react";
+import { useState } from "react";
+import { Alert, CloseButton, Container, Heading, Text } from
"@chakra-ui/react";
-import {useCreateToken} from "src/queries/useCreateToken";
-import {LoginForm} from "src/login/LoginForm";
-import type {ApiError} from "openapi-gen/requests/core/ApiError";
-import type {LoginResponse, HTTPExceptionResponse, HTTPValidationError} from
"openapi-gen/requests/types.gen";
+import { useCreateToken } from "src/queries/useCreateToken";
+import { LoginForm } from "src/login/LoginForm";
+import type { ApiError } from "openapi-gen/requests/core/ApiError";
+import type {
+ LoginResponse,
+ HTTPExceptionResponse,
+ HTTPValidationError,
+} from "openapi-gen/requests/types.gen";
import { useSearchParams } from "react-router-dom";
-import { useCookies } from 'react-cookie';
+import { useCookies } from "react-cookie";
export type LoginBody = {
- username: string; password: string;
+ password: string;
+ username: string;
};
type ExpandedApiError = {
body: HTTPExceptionResponse | HTTPValidationError;
} & ApiError;
-const LOCAL_STORAGE_DISABLE_BANNER_KEY = "disable-sam-banner"
+const LOCAL_STORAGE_DISABLE_BANNER_KEY = "disable-sam-banner";
export const Login = () => {
- const [searchParams, setSearchParams] = useSearchParams();
- const [cookies, setCookie] = useCookies(['_token']);
- const [isBannerDisabled, setIsBannerDisabled] =
useState(localStorage.getItem(LOCAL_STORAGE_DISABLE_BANNER_KEY))
+ const [searchParams] = useSearchParams();
+ const [, setCookie] = useCookies(["_token"]);
+ const [isBannerDisabled, setIsBannerDisabled] = useState(
+ localStorage.getItem(LOCAL_STORAGE_DISABLE_BANNER_KEY),
+ );
const onSuccess = (data: LoginResponse) => {
// Redirect to appropriate page with the token
- const next = searchParams.get("next")
+ const next = searchParams.get("next");
- setCookie('_token', data.jwt_token, {path: "/", secure:
globalThis.location.protocol !== "http:"})
+ setCookie("_token", data.jwt_token, {
+ path: "/",
+ secure: globalThis.location.protocol !== "http:",
+ });
- globalThis.location.replace(`${next ?? ""}`);
- }
- const {createToken, error: err, isPending, setError} =
useCreateToken({onSuccess});
+ globalThis.location.replace(next ?? "");
+ };
+ const {
+ createToken,
+ error: err,
+ isPending,
+ setError,
+ } = useCreateToken({ onSuccess });
const error = err as ExpandedApiError;
- const error_message = error?.body?.detail;
+ const errorMessage = error.body.detail;
Review Comment:
There's a couple more things that are failing too, will look into fixing all
of them and push a change.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]