geido commented on code in PR #33255:
URL: https://github.com/apache/superset/pull/33255#discussion_r2099945941


##########
superset-frontend/src/pages/Login/index.tsx:
##########
@@ -0,0 +1,211 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import { SupersetClient, styled, t, css } from '@superset-ui/core';
+import {
+  Button,
+  Card,
+  Flex,
+  Form,
+  Input,
+  Typography,
+  Icons,
+} from 'src/components';
+import { useState } from 'react';
+import { capitalize } from 'lodash/fp';
+import getBootstrapData from 'src/utils/getBootstrapData';
+
+type OAuthProvider = {
+  name: string;
+  icon: string;
+};
+
+type OIDProvider = {
+  name: string;
+  url: string;
+};
+
+type Provider = OAuthProvider | OIDProvider;
+
+interface LoginForm {
+  username: string;
+  password: string;
+}
+
+enum AuthType {
+  AuthOID = 0,
+  AuthDB = 1,
+  AuthLDAP = 2,
+  AuthOauth = 4,
+}
+
+const AuthIconMap: Record<string, React.JSX.Element> = {
+  github: <Icons.GithubOutlined />,
+  google: <Icons.GoogleOutlined />,
+  facebook: <Icons.FacebookOutlined />,
+};
+
+const LoginContainer = styled(Flex)`
+  width: 100%;
+`;
+
+const StyledCard = styled(Card)`
+  ${({ theme }) => css`
+    width: 40%;
+    margin-top: ${theme.marginXL}px;
+    background: ${theme.colorBgBase};
+    .antd5-form-item-label label {
+      color: ${theme.colorPrimary};
+    }
+  `}
+`;
+
+const StyledLabel = styled(Typography.Text)`
+  ${({ theme }) => css`
+    font-size: ${theme.fontSizeSM}px;
+  `}
+`;
+
+export default function Login() {
+  const [form] = Form.useForm<LoginForm>();
+  const [loading, setLoading] = useState(false);
+
+  const bootstrapData = getBootstrapData();
+
+  const authType: AuthType = bootstrapData.common.conf.AUTH_TYPE;
+  const providers: Provider[] = bootstrapData.common.conf.AUTH_PROVIDERS;
+  const authRegistration: boolean =
+    bootstrapData.common.conf.AUTH_USER_REGISTRATION;
+
+  const onFinish = (values: LoginForm) => {
+    setLoading(true);
+    SupersetClient.postForm('/login', values, '').finally(() => {
+      setLoading(false);
+    });
+  };
+
+  return (
+    <LoginContainer justify="center" data-test="login-form">
+      <StyledCard title={t('Sign in')} padded>
+        {authType === AuthType.AuthOID && (
+          <Flex justify="center" vertical gap="middle">
+            <Form layout="vertical" requiredMark="optional" form={form}>
+              {providers.map((provider: OIDProvider) => (
+                <Form.Item<LoginForm>>
+                  <Button
+                    href={`/login/${provider.name}`}
+                    block
+                    iconPosition="start"
+                    icon={AuthIconMap[provider.name]}

Review Comment:
   It seems that there is a pattern in naming convention for social icons on 
Ant Design. We can make a util function that gets the provider name, 
capitalizes it and adds either Outlined or Filled (to check with Kasia) and if 
it does not exist can fallback to a button or a fallback icon.



-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to