/** * 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 React, { useState } from 'react'; import { t, styled } from '@superset-ui/core'; import { AntdForm, Col, Row } from 'src/components'; import { Form, FormLabel } from 'src/components/Form'; import { Radio } from 'src/components/Radio'; import { Input, TextArea } from 'src/components/Input'; import { Input as AntdInput, Tooltip } from 'antd'; import { EyeInvisibleOutlined, EyeOutlined } from '@ant-design/icons'; import { DatabaseObject, FieldPropTypes } from '../types'; import { AuthType } from '.'; const StyledDiv = styled.div` padding-top: ${({ theme }) => theme.gridUnit * 2}px; label { color: ${({ theme }) => theme.colors.grayscale.base}; text-transform: uppercase; margin-bottom: ${({ theme }) => theme.gridUnit * 2}px; } `; const StyledRow = styled(Row)` padding-bottom: ${({ theme }) => theme.gridUnit * 2}px; `; const StyledFormItem = styled(AntdForm.Item)` margin-bottom: 0 !important; `; const StyledInputPassword = styled(AntdInput.Password)` margin: ${({ theme }) => `${theme.gridUnit}px 0 ${theme.gridUnit * 2}px`}; `; const SSHTunnelForm = ({ db, onSSHTunnelParametersChange, setSSHTunnelLoginMethod, }: { db: DatabaseObject | null; onSSHTunnelParametersChange: FieldPropTypes['changeMethods']['onSSHTunnelParametersChange']; setSSHTunnelLoginMethod: (method: AuthType) => void; }) => { const [usePassword, setUsePassword] = useState(AuthType.Password); return (
{t('SSH Host')} {t('SSH Port')} {t('Username')} {t('Login with')} { setUsePassword(value); setSSHTunnelLoginMethod(value); }} > {t('Password')} {t('Private Key & Password')} {usePassword === AuthType.Password && ( {t('SSH Password')} visible ? ( ) : ( ) } role="textbox" /> )} {usePassword === AuthType.PrivateKey && ( <> {t('Private Key')}