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

View File

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