2023-09-11 02:58:05 +02:00
|
|
|
import { Anchor, Button, Card, Collapse, Group, Stack, Tabs, Text, TextInput } from '@mantine/core';
|
2022-12-04 21:19:40 +01:00
|
|
|
import { UseFormReturnType } from '@mantine/form';
|
2023-09-11 02:58:05 +02:00
|
|
|
import { useDisclosure } from '@mantine/hooks';
|
|
|
|
|
import { IconAlertCircle, IconClick, IconCursorText, IconLink } from '@tabler/icons-react';
|
2022-12-04 21:19:40 +01:00
|
|
|
import { useTranslation } from 'next-i18next';
|
2023-09-03 16:23:40 +02:00
|
|
|
import { AppType } from '~/types/app';
|
2023-09-11 02:58:05 +02:00
|
|
|
|
2022-12-18 22:27:01 +01:00
|
|
|
import { EditAppModalTab } from '../type';
|
2022-12-04 21:19:40 +01:00
|
|
|
|
|
|
|
|
interface GeneralTabProps {
|
2022-12-18 22:27:01 +01:00
|
|
|
form: UseFormReturnType<AppType, (values: AppType) => AppType>;
|
|
|
|
|
openTab: (tab: EditAppModalTab) => void;
|
2022-12-04 21:19:40 +01:00
|
|
|
}
|
|
|
|
|
|
2022-12-06 20:48:35 +01:00
|
|
|
export const GeneralTab = ({ form, openTab }: GeneralTabProps) => {
|
2022-12-20 11:34:07 +09:00
|
|
|
const { t } = useTranslation('layout/modals/add-app');
|
2023-09-11 02:58:05 +02:00
|
|
|
|
|
|
|
|
const [opened, { toggle }] = useDisclosure(false);
|
|
|
|
|
|
|
|
|
|
const commonMistakes = [
|
|
|
|
|
t('general.internalAddress.troubleshoot.lines.nothingAfterPort'),
|
|
|
|
|
t('general.internalAddress.troubleshoot.lines.protocolCheck'),
|
|
|
|
|
t('general.internalAddress.troubleshoot.lines.iframe'),
|
|
|
|
|
t('general.internalAddress.troubleshoot.lines.clearCache'),
|
|
|
|
|
];
|
|
|
|
|
|
2022-12-04 21:19:40 +01:00
|
|
|
return (
|
2022-12-20 11:34:07 +09:00
|
|
|
<Tabs.Panel value="general" pt="sm">
|
2023-08-06 19:36:36 +02:00
|
|
|
<Stack spacing="xs">
|
|
|
|
|
<TextInput
|
|
|
|
|
icon={<IconCursorText size={16} />}
|
|
|
|
|
label={t('general.appname.label')}
|
|
|
|
|
description={t('general.appname.description')}
|
|
|
|
|
placeholder="My example app"
|
|
|
|
|
variant="default"
|
|
|
|
|
withAsterisk
|
|
|
|
|
{...form.getInputProps('name')}
|
|
|
|
|
/>
|
|
|
|
|
<TextInput
|
|
|
|
|
icon={<IconLink size={16} />}
|
|
|
|
|
label={t('general.internalAddress.label')}
|
|
|
|
|
description={t('general.internalAddress.description')}
|
|
|
|
|
placeholder="https://google.com"
|
|
|
|
|
variant="default"
|
|
|
|
|
withAsterisk
|
|
|
|
|
{...form.getInputProps('url')}
|
|
|
|
|
onChange={(e) => {
|
|
|
|
|
form.setFieldValue('url', e.target.value);
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
<TextInput
|
|
|
|
|
icon={<IconClick size={16} />}
|
|
|
|
|
label={t('general.externalAddress.label')}
|
|
|
|
|
description={t('general.externalAddress.description')}
|
|
|
|
|
placeholder="https://homarr.mywebsite.com/"
|
|
|
|
|
variant="default"
|
|
|
|
|
{...form.getInputProps('behaviour.externalUrl')}
|
|
|
|
|
/>
|
2023-07-24 21:25:41 +02:00
|
|
|
|
2023-09-11 02:58:05 +02:00
|
|
|
<Group position="right" mt={22}>
|
|
|
|
|
<Button rightIcon={<IconAlertCircle />} onClick={toggle}>
|
|
|
|
|
{t('general.internalAddress.troubleshoot.label')}
|
|
|
|
|
</Button>
|
|
|
|
|
</Group>
|
|
|
|
|
|
|
|
|
|
<Collapse in={opened}>
|
|
|
|
|
<Card withBorder>
|
|
|
|
|
<Text>{t('general.internalAddress.troubleshoot.header')}</Text>
|
|
|
|
|
{commonMistakes.map((value: string, key: number) => {
|
|
|
|
|
return (
|
|
|
|
|
<Group key={key} display="flex" style={{ alignItems: 'start' }}>
|
|
|
|
|
<Text>•</Text>
|
|
|
|
|
<Text style={{ flex: '1' }}>{value}</Text>
|
|
|
|
|
</Group>
|
|
|
|
|
);
|
|
|
|
|
})}
|
|
|
|
|
<Text>
|
|
|
|
|
{t('general.internalAddress.troubleshoot.footer').split('{{discord}}')[0]}
|
|
|
|
|
<Anchor href="https://discord.gg/aCsmEV5RgA" target="_blank">
|
|
|
|
|
Discord
|
|
|
|
|
</Anchor>
|
|
|
|
|
{t('general.internalAddress.troubleshoot.footer').split('{{discord}}')[1]}
|
|
|
|
|
</Text>
|
|
|
|
|
</Card>
|
|
|
|
|
</Collapse>
|
|
|
|
|
|
2023-08-06 19:36:36 +02:00
|
|
|
{!form.values.behaviour.externalUrl.startsWith('https://') &&
|
|
|
|
|
!form.values.behaviour.externalUrl.startsWith('http://') && (
|
|
|
|
|
<Text color="red" mt="sm" size="sm">
|
|
|
|
|
{t('behaviour.customProtocolWarning')}
|
|
|
|
|
</Text>
|
2023-09-11 02:58:05 +02:00
|
|
|
)}
|
2023-08-06 19:36:36 +02:00
|
|
|
</Stack>
|
2022-12-04 21:19:40 +01:00
|
|
|
</Tabs.Panel>
|
|
|
|
|
);
|
|
|
|
|
};
|