Grafana UI: SecretTextArea - Replace HorizontalGroup with Stack and Box (#85849)

This commit is contained in:
Laura Fernández
2024-04-10 13:41:02 +02:00
committed by GitHub
parent d480cf4977
commit 22d33bd354
2 changed files with 16 additions and 10 deletions
-3
View File
@@ -880,9 +880,6 @@ exports[`better eslint`] = {
"packages/grafana-ui/src/components/PanelChrome/index.ts:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"]
],
"packages/grafana-ui/src/components/SecretTextArea/SecretTextArea.tsx:5381": [
[0, 0, 0, "\'HorizontalGroup\' import from \'../Layout/Layout\' is restricted from being used by a pattern. Use Stack component instead.", "0"]
],
"packages/grafana-ui/src/components/Segment/SegmentSelect.tsx:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"]
],
@@ -5,7 +5,8 @@ import { GrafanaTheme2 } from '@grafana/data';
import { useStyles2 } from '../../themes/ThemeContext';
import { Button } from '../Button';
import { HorizontalGroup } from '../Layout/Layout';
import { Box } from '../Layout/Box/Box';
import { Stack } from '../Layout/Stack/Stack';
import { TextArea } from '../TextArea/TextArea';
export type Props = React.ComponentProps<typeof TextArea> & {
@@ -35,16 +36,24 @@ const getStyles = (theme: GrafanaTheme2) => {
export const SecretTextArea = ({ isConfigured, onReset, ...props }: Props) => {
const styles = useStyles2(getStyles);
return (
<HorizontalGroup>
{!isConfigured && <TextArea {...props} />}
{isConfigured && (
<TextArea {...props} rows={1} disabled={true} value={CONFIGURED_TEXT} className={cx(styles.configuredStyle)} />
)}
<Stack>
<Box>
{!isConfigured && <TextArea {...props} />}
{isConfigured && (
<TextArea
{...props}
rows={1}
disabled={true}
value={CONFIGURED_TEXT}
className={cx(styles.configuredStyle)}
/>
)}
</Box>
{isConfigured && (
<Button onClick={onReset} variant="secondary">
{RESET_BUTTON_TEXT}
</Button>
)}
</HorizontalGroup>
</Stack>
);
};