Add new input design for secrets

This commit is contained in:
Manuel Ruwe
2022-12-16 20:40:36 +01:00
parent 543bafc610
commit 3353d35a53
2 changed files with 13 additions and 28 deletions

View File

@@ -1,18 +1,16 @@
import { import {
ActionIcon,
Button, Button,
Card, Card,
createStyles, createStyles,
Flex, Flex,
Grid, Grid,
Group, Group,
PasswordInput,
Stack, Stack,
TextInput,
ThemeIcon, ThemeIcon,
Title, Title,
Tooltip,
} from '@mantine/core'; } from '@mantine/core';
import { IconDeviceFloppy, TablerIcon } from '@tabler/icons'; import { TablerIcon } from '@tabler/icons';
import { useState } from 'react'; import { useState } from 'react';
interface GenericSecretInputProps { interface GenericSecretInputProps {
@@ -27,12 +25,13 @@ export const GenericSecretInput = ({
value, value,
setIcon, setIcon,
onClickUpdateButton, onClickUpdateButton,
...props
}: GenericSecretInputProps) => { }: GenericSecretInputProps) => {
const { classes } = useStyles(); const { classes } = useStyles();
const Icon = setIcon; const Icon = setIcon;
const [fieldValue, setFieldValue] = useState<string>(value); const [displayUpdateField, setDisplayUpdateField] = useState<boolean>(false);
return ( return (
<Card withBorder> <Card withBorder>
@@ -51,31 +50,16 @@ export const GenericSecretInput = ({
</Grid.Col> </Grid.Col>
<Grid.Col xs={12} md={6}> <Grid.Col xs={12} md={6}>
<Flex gap={10} justify="end" align="end"> <Flex gap={10} justify="end" align="end">
<Button <Button variant="subtle" color="gray" px="xl">
onClick={() => {
setFieldValue('');
onClickUpdateButton(undefined);
}}
variant="subtle"
color="gray"
px="xl"
>
Clear Secret Clear Secret
</Button> </Button>
<TextInput {displayUpdateField === true ? (
onChange={(event) => setFieldValue(event.currentTarget.value)} <PasswordInput placeholder="new secret" width={200} {...props} />
rightSection={ ) : (
<Tooltip label="Update this secret" withinPortal> <Button onClick={() => setDisplayUpdateField(true)} variant="light">
<ActionIcon onClick={() => onClickUpdateButton(fieldValue)}> Set Secret
<IconDeviceFloppy width={20} strokeWidth={1.2} /> </Button>
</ActionIcon> )}
</Tooltip>
}
value={fieldValue}
type="password"
placeholder="no value is set"
withAsterisk
/>
</Flex> </Flex>
</Grid.Col> </Grid.Col>
</Grid> </Grid>

View File

@@ -56,6 +56,7 @@ export const IntegrationOptionsRenderer = ({ form }: IntegrationOptionsRendererP
label={`${property} (potentionally unmapped)`} label={`${property} (potentionally unmapped)`}
secretIsPresent={isPresent} secretIsPresent={isPresent}
setIcon={IconKey} setIcon={IconKey}
value={formValue.value}
{...form.getInputProps(`integration.properties.${index}.value`)} {...form.getInputProps(`integration.properties.${index}.value`)}
/> />
); );