mirror of
https://github.com/ajnart/homarr.git
synced 2025-11-11 07:55:52 +01:00
✨ Add new input design for secrets
This commit is contained in:
@@ -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>
|
||||||
|
|||||||
@@ -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`)}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user