diff --git a/src/ConfigEditor/Auth/auth-method/BasicAuth.tsx b/src/ConfigEditor/Auth/auth-method/BasicAuth.tsx index f44c9e4..18eb578 100644 --- a/src/ConfigEditor/Auth/auth-method/BasicAuth.tsx +++ b/src/ConfigEditor/Auth/auth-method/BasicAuth.tsx @@ -1,7 +1,6 @@ import React from 'react'; import { cx, css } from '@emotion/css'; -import { InlineField, Input, PopoverContent } from '@grafana/ui'; -import { SecretInput } from '../common'; +import { InlineField, Input, PopoverContent, SecretInput } from '@grafana/ui'; import { useCommonStyles } from '../styles'; export type Props = { diff --git a/src/ConfigEditor/Auth/common/SecretInput.tsx b/src/ConfigEditor/Auth/common/SecretInput.tsx deleted file mode 100644 index 4005b89..0000000 --- a/src/ConfigEditor/Auth/common/SecretInput.tsx +++ /dev/null @@ -1,30 +0,0 @@ -/** - * Copy & paste from https://github.com/grafana/grafana/blob/main/packages/grafana-ui/src/components/SecretInput/SecretInput.tsx - * Available starting from @grafana/ui 9.2 - * Needed, because Auth component is also used in Grafana 8, which doesn't have SecretInput - */ - -import * as React from 'react'; -import { HorizontalGroup, Input, Button } from '@grafana/ui'; - -export type Props = React.ComponentProps & { - /** TRUE if the secret was already configured. (It is needed as often the backend doesn't send back the actual secret, only the information that it was configured) */ - isConfigured: boolean; - /** Called when the user clicks on the "Reset" button in order to clear the secret */ - onReset: () => void; -}; - -export const CONFIGURED_TEXT = 'configured'; -export const RESET_BUTTON_TEXT = 'Reset'; - -export const SecretInput = ({ isConfigured, onReset, ...props }: Props) => ( - - {!isConfigured && } - {isConfigured && } - {isConfigured && ( - - )} - -); diff --git a/src/ConfigEditor/Auth/common/SecretTextarea.tsx b/src/ConfigEditor/Auth/common/SecretTextarea.tsx deleted file mode 100644 index eb43201..0000000 --- a/src/ConfigEditor/Auth/common/SecretTextarea.tsx +++ /dev/null @@ -1,52 +0,0 @@ -/** - * Copy & paste from https://github.com/grafana/grafana/blob/main/packages/grafana-ui/src/components/SecretTextArea/SecretTextArea.tsx - * Available starting from @grafana/ui 9.2 - * Needed, because Auth component is also used in Grafana 8, which doesn't have SecretTextarea - */ - -import { css, cx } from '@emotion/css'; -import * as React from 'react'; - -import { GrafanaTheme2 } from '@grafana/data'; -import { useStyles2, Button, TextArea, HorizontalGroup } from '@grafana/ui'; - -export type Props = React.ComponentProps & { - /** TRUE if the secret was already configured. (It is needed as often the backend doesn't send back the actual secret, only the information that it was configured) */ - isConfigured: boolean; - /** Called when the user clicks on the "Reset" button in order to clear the secret */ - onReset: () => void; -}; - -export const CONFIGURED_TEXT = 'configured'; -export const RESET_BUTTON_TEXT = 'Reset'; - -const getStyles = (theme: GrafanaTheme2) => { - return { - configuredStyle: css` - min-height: ${theme.spacing(theme.components.height.md)}; - padding-top: ${theme.spacing(0.5) /** Needed to mimic vertically centered text in an input box */}; - resize: none; - `, - }; -}; - -/** - * Text area that does not disclose an already configured value but lets the user reset the current value and enter a new one. - * Typically useful for asymmetric cryptography keys. - */ -export const SecretTextArea = ({ isConfigured, onReset, ...props }: Props) => { - const styles = useStyles2(getStyles); - return ( - - {!isConfigured &&