import { observer } from 'mobx-react-lite' ; import { AUTH_PROVIDER_LOCAL_ID } from '@cloudbeaver/core-authentication' ; import { Button , PlaceholderComponent } from '@cloudbeaver/core-blocks' ; import { isLocalConnection } from '@cloudbeaver/core-connections' ; import { useTranslate } from '@cloudbeaver/core-localization' ; import { useAuthenticationAction } from '@cloudbeaver/core-ui' ; import type { IConnectionFormProps } from '../IConnectionFormProps' ; export const AuthenticationButton = observer ( function ConnectionFormAuthenticationAction ( { state , } ) { const translate = useTranslate ( ) ; const authentication = useAuthenticationAction ( { origin : state . info ?. origin ?? { type : AUTH_PROVIDER_LOCAL_ID , displayName : 'Local' } , onAuthenticate : ( ) => state . loadConnectionInfo ( ) , } ) ; if ( authentication . authorized ) { return null ; } return ( < Button type = "button" disabled = { state . disabled } mod = { [ 'outlined' ] } onClick = { authentication . auth } > { translate ( 'authentication_authenticate' ) } < /Button>); } ) ; export const ConnectionFormAuthenticationAction = observer ( function ConnectionFormAuthenticationAction ( { state , } ) { if ( ! state . info || isLocalConnection ( state . info ) ) { return null ; } return < AuthenticationButton state = { state } />; } ) ;