2022-12-04 21:19:40 +01:00
|
|
|
import { Alert, Divider, Tabs, Text } from '@mantine/core';
|
|
|
|
|
import { UseFormReturnType } from '@mantine/form';
|
2023-05-15 17:40:59 +09:00
|
|
|
import { IconAlertTriangle } from '@tabler/icons-react';
|
2022-12-20 11:34:07 +09:00
|
|
|
import { Trans, useTranslation } from 'next-i18next';
|
2023-07-21 18:08:40 +09:00
|
|
|
|
2023-09-03 16:23:40 +02:00
|
|
|
import { AppType } from '~/types/app';
|
2022-12-04 21:19:40 +01:00
|
|
|
import { IntegrationSelector } from './Components/InputElements/IntegrationSelector';
|
|
|
|
|
import { IntegrationOptionsRenderer } from './Components/IntegrationOptionsRenderer/IntegrationOptionsRenderer';
|
|
|
|
|
|
|
|
|
|
interface IntegrationTabProps {
|
2022-12-18 22:27:01 +01:00
|
|
|
form: UseFormReturnType<AppType, (values: AppType) => AppType>;
|
2022-12-04 21:19:40 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const IntegrationTab = ({ form }: IntegrationTabProps) => {
|
2022-12-20 11:34:07 +09:00
|
|
|
const { t } = useTranslation('layout/modals/add-app');
|
2022-12-17 00:28:46 +09:00
|
|
|
const hasIntegrationSelected = form.values.integration?.type;
|
2022-12-04 21:19:40 +01:00
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<Tabs.Panel value="integration" pt="lg">
|
|
|
|
|
<IntegrationSelector form={form} />
|
|
|
|
|
|
|
|
|
|
{hasIntegrationSelected && (
|
|
|
|
|
<>
|
2022-12-20 11:45:33 +09:00
|
|
|
<Divider label={t('integration.type.label')} labelPosition="center" mt="xl" mb="md" />
|
2022-12-16 19:44:57 +01:00
|
|
|
<Text size="sm" color="dimmed" mb="lg">
|
2022-12-20 11:34:07 +09:00
|
|
|
{t('integration.secrets.description')}
|
2022-12-16 19:44:57 +01:00
|
|
|
</Text>
|
2022-12-04 21:19:40 +01:00
|
|
|
<IntegrationOptionsRenderer form={form} />
|
|
|
|
|
<Alert icon={<IconAlertTriangle />} color="yellow">
|
|
|
|
|
<Text>
|
2022-12-26 16:13:24 +09:00
|
|
|
<Trans i18nKey="layout/modals/add-app:integration.secrets.warning" />
|
2022-12-04 21:19:40 +01:00
|
|
|
</Text>
|
|
|
|
|
</Alert>
|
|
|
|
|
</>
|
|
|
|
|
)}
|
|
|
|
|
</Tabs.Panel>
|
|
|
|
|
);
|
|
|
|
|
};
|