mirror of
https://github.com/ajnart/homarr.git
synced 2025-11-10 15:35:55 +01:00
✨ Add popover with validation message for validation errors
This commit is contained in:
@@ -61,5 +61,8 @@
|
|||||||
"save": "Save secret",
|
"save": "Save secret",
|
||||||
"update": "Update secret"
|
"update": "Update secret"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"validation": {
|
||||||
|
"popover": "Your form contains invalid data. Hence, it can't be saved. Please resolve all issues and click this button again to save your changes"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
import { Alert, Button, Group, Stack, Tabs, Text, ThemeIcon } from '@mantine/core';
|
import { Alert, Button, Group, Popover, Stack, Tabs, Text, ThemeIcon } from '@mantine/core';
|
||||||
import { useForm } from '@mantine/form';
|
import { useForm } from '@mantine/form';
|
||||||
|
import { useDisclosure } from '@mantine/hooks';
|
||||||
import { ContextModalProps } from '@mantine/modals';
|
import { ContextModalProps } from '@mantine/modals';
|
||||||
import {
|
import {
|
||||||
IconAccessPoint,
|
IconAccessPoint,
|
||||||
@@ -210,12 +211,28 @@ export const EditAppModal = ({
|
|||||||
<Button onClick={closeModal} px={50} variant="light" color="gray">
|
<Button onClick={closeModal} px={50} variant="light" color="gray">
|
||||||
{t('common:cancel')}
|
{t('common:cancel')}
|
||||||
</Button>
|
</Button>
|
||||||
<Button disabled={!form.isValid()} px={50} type="submit">
|
<SaveButton formIsValid={form.isValid()} />
|
||||||
{t('common:save')}
|
|
||||||
</Button>
|
|
||||||
</Group>
|
</Group>
|
||||||
</Stack>
|
</Stack>
|
||||||
</form>
|
</form>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const SaveButton = ({ formIsValid }: { formIsValid: boolean }) => {
|
||||||
|
const [opened, { close, open }] = useDisclosure(false);
|
||||||
|
const { t } = useTranslation(['layout/modals/add-app', 'common']);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Popover opened={opened && !formIsValid} withArrow withinPortal>
|
||||||
|
<Popover.Target>
|
||||||
|
<div onMouseEnter={open} onMouseLeave={close}>
|
||||||
|
<Button disabled={!formIsValid} px={50} type="submit">
|
||||||
|
{t('common:save')}
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</Popover.Target>
|
||||||
|
<Popover.Dropdown sx={{ pointerEvents: 'none' }}>{t('validation.popover')}</Popover.Dropdown>
|
||||||
|
</Popover>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user