mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-02 17:25:44 +00:00
Fix incorrect imports, build errors
This commit is contained in:
@@ -1,41 +0,0 @@
|
|||||||
import { useEffect } from 'react';
|
|
||||||
import { useRouter } from 'next/router';
|
|
||||||
import queryString from 'query-string';
|
|
||||||
|
|
||||||
import AuthorizeIntegration from './api/integrations/authorizeIntegration';
|
|
||||||
|
|
||||||
export default function Github() {
|
|
||||||
const router = useRouter();
|
|
||||||
const parsedUrl = queryString.parse(router.asPath.split('?')[1]);
|
|
||||||
const {code} = parsedUrl;
|
|
||||||
const {state} = parsedUrl;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Here we forward to the default workspace if a user opens this url
|
|
||||||
*/
|
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
||||||
useEffect(() => {
|
|
||||||
(async () => {
|
|
||||||
try {
|
|
||||||
if (state === localStorage.getItem('latestCSRFToken')) {
|
|
||||||
localStorage.removeItem('latestCSRFToken');
|
|
||||||
await AuthorizeIntegration({
|
|
||||||
workspaceId: localStorage.getItem('projectData.id') as string,
|
|
||||||
code: code as string,
|
|
||||||
integration: 'github',
|
|
||||||
});
|
|
||||||
router.push(
|
|
||||||
`/integrations/${localStorage.getItem('projectData.id')}`
|
|
||||||
);
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Github integration error: ', error);
|
|
||||||
}
|
|
||||||
})();
|
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
return <div />;
|
|
||||||
}
|
|
||||||
|
|
||||||
Github.requireAuth = true;
|
|
||||||
@@ -1,159 +0,0 @@
|
|||||||
import { useEffect, useState } from 'react';
|
|
||||||
import { useRouter } from 'next/router';
|
|
||||||
import queryString from 'query-string';
|
|
||||||
|
|
||||||
import { getTranslatedServerSideProps } from '@app/components/utilities/withTranslateProps';
|
|
||||||
|
|
||||||
import {
|
|
||||||
Button,
|
|
||||||
Card,
|
|
||||||
CardTitle,
|
|
||||||
FormControl,
|
|
||||||
Select,
|
|
||||||
SelectItem
|
|
||||||
} from '../components/v2';
|
|
||||||
import AuthorizeIntegration from './api/integrations/authorizeIntegration';
|
|
||||||
import getIntegrationApps from './api/integrations/GetIntegrationApps';
|
|
||||||
import getAWorkspace from './api/workspace/getAWorkspace';
|
|
||||||
|
|
||||||
interface Integration {
|
|
||||||
_id: string;
|
|
||||||
isActive: boolean;
|
|
||||||
app: string | null;
|
|
||||||
appId: string | null;
|
|
||||||
createdAt: string;
|
|
||||||
updatedAt: string;
|
|
||||||
environment: string;
|
|
||||||
integration: string;
|
|
||||||
targetEnvironment: string;
|
|
||||||
workspace: string;
|
|
||||||
integrationAuth: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface IntegrationApp {
|
|
||||||
name: string;
|
|
||||||
appId?: string;
|
|
||||||
owner?: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export default function Heroku() {
|
|
||||||
const router = useRouter();
|
|
||||||
const parsedUrl = queryString.parse(router.asPath.split('?')[1]);
|
|
||||||
const { code } = parsedUrl;
|
|
||||||
const { state } = parsedUrl;
|
|
||||||
|
|
||||||
const [integration, setIntegration] = useState<Integration | null>(null);
|
|
||||||
const [environments, setEnvironments] = useState<
|
|
||||||
{
|
|
||||||
name: string;
|
|
||||||
slug: string;
|
|
||||||
}[]
|
|
||||||
>([]);
|
|
||||||
const [environment, setEnvironment] = useState('');
|
|
||||||
const [app, setApp] = useState('');
|
|
||||||
const [apps, setApps] = useState<IntegrationApp[]>([]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
(async () => {
|
|
||||||
try {
|
|
||||||
if (state === localStorage.getItem('latestCSRFToken')) {
|
|
||||||
localStorage.removeItem('latestCSRFToken');
|
|
||||||
const integrationDetails = await AuthorizeIntegration({
|
|
||||||
workspaceId: localStorage.getItem('projectData.id') as string,
|
|
||||||
code: code as string,
|
|
||||||
integration: 'heroku',
|
|
||||||
});
|
|
||||||
|
|
||||||
setIntegration(integrationDetails.integration);
|
|
||||||
|
|
||||||
const workspaceId = localStorage.getItem('projectData.id');
|
|
||||||
if (!workspaceId) return;
|
|
||||||
|
|
||||||
const workspace = await getAWorkspace(workspaceId);
|
|
||||||
setEnvironment(workspace.environments[0].slug);
|
|
||||||
setEnvironments(workspace.environments);
|
|
||||||
|
|
||||||
const tempApps: [IntegrationApp] = await getIntegrationApps({
|
|
||||||
integrationAuthId: integrationDetails.integration.integrationAuth
|
|
||||||
});
|
|
||||||
|
|
||||||
console.log('tempApps: ', tempApps);
|
|
||||||
setApp(tempApps[0].name);
|
|
||||||
setApps(tempApps);
|
|
||||||
|
|
||||||
// router.push(
|
|
||||||
// `/integrations/${ localStorage.getItem('projectData.id')}`
|
|
||||||
// );
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Heroku integration error: ', error);
|
|
||||||
}
|
|
||||||
})();
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
const handleButtonClick = async () => {
|
|
||||||
try {
|
|
||||||
console.log('handleButtonClick');
|
|
||||||
console.log('project environment: ', environment);
|
|
||||||
console.log('app', app);
|
|
||||||
} catch (err) {
|
|
||||||
console.error(err);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log('integration: ', integration);
|
|
||||||
console.log('environments: ', environments);
|
|
||||||
console.log('apps: ', apps);
|
|
||||||
|
|
||||||
return (integration && environments.length > 0 && apps.length > 0) ? (
|
|
||||||
<div className="h-full w-full flex justify-center items-center">
|
|
||||||
<Card className="max-w-md p-8 rounded-md">
|
|
||||||
<CardTitle className='text-center'>Heroku Integration</CardTitle>
|
|
||||||
<FormControl
|
|
||||||
label="Project Environment"
|
|
||||||
className='mt-4'
|
|
||||||
>
|
|
||||||
<Select
|
|
||||||
value={environment}
|
|
||||||
onValueChange={(val) => setEnvironment(val)}
|
|
||||||
className='w-full border border-mineshaft-500'
|
|
||||||
>
|
|
||||||
{environments.map((e) => (
|
|
||||||
<SelectItem value={e.slug} key={`heroku-environment-${e.slug}`}>
|
|
||||||
{e.name}
|
|
||||||
</SelectItem>
|
|
||||||
))}
|
|
||||||
</Select>
|
|
||||||
</FormControl>
|
|
||||||
<FormControl
|
|
||||||
label="Heroku App"
|
|
||||||
className='mt-4'
|
|
||||||
>
|
|
||||||
<Select
|
|
||||||
value={app}
|
|
||||||
onValueChange={(val) => setApp(val)}
|
|
||||||
className='w-full border border-mineshaft-500'
|
|
||||||
>
|
|
||||||
{apps.map((a) => (
|
|
||||||
<SelectItem value={a.name} key={`heroku-environment-${a.name}`}>
|
|
||||||
{a.name}
|
|
||||||
</SelectItem>
|
|
||||||
))}
|
|
||||||
</Select>
|
|
||||||
</FormControl>
|
|
||||||
<Button
|
|
||||||
onClick={handleButtonClick}
|
|
||||||
color="mineshaft"
|
|
||||||
className='mt-4'
|
|
||||||
isLoading={isLoading}
|
|
||||||
>
|
|
||||||
Create Integration
|
|
||||||
</Button>
|
|
||||||
</Card>
|
|
||||||
</div>
|
|
||||||
) : <div>Hello</div>
|
|
||||||
}
|
|
||||||
|
|
||||||
Heroku.requireAuth = true;
|
|
||||||
|
|
||||||
export const getServerSideProps = getTranslatedServerSideProps(['integrations']);
|
|
||||||
@@ -49,6 +49,7 @@ interface Integration {
|
|||||||
}
|
}
|
||||||
|
|
||||||
interface IntegrationOption {
|
interface IntegrationOption {
|
||||||
|
tenantId?: string;
|
||||||
clientId: string;
|
clientId: string;
|
||||||
clientSlug?: string; // vercel-integration specific
|
clientSlug?: string; // vercel-integration specific
|
||||||
docsLink: string;
|
docsLink: string;
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import {
|
|||||||
Select,
|
Select,
|
||||||
SelectItem
|
SelectItem
|
||||||
} from '../../../components/v2';
|
} from '../../../components/v2';
|
||||||
import { useGetIntegrationAuthById } from '../../../hooks/api/integrationAuth';
|
import { useGetIntegrationAuthApps,useGetIntegrationAuthById } from '../../../hooks/api/integrationAuth';
|
||||||
import { useGetWorkspaceById } from '../../../hooks/api/workspace';
|
import { useGetWorkspaceById } from '../../../hooks/api/workspace';
|
||||||
import createIntegration from "../../api/integrations/createIntegration";
|
import createIntegration from "../../api/integrations/createIntegration";
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import {
|
|||||||
Select,
|
Select,
|
||||||
SelectItem
|
SelectItem
|
||||||
} from '../../../components/v2';
|
} from '../../../components/v2';
|
||||||
import { useGetIntegrationAuthById } from '../../../hooks/api/integrationAuth';
|
import { useGetIntegrationAuthApps,useGetIntegrationAuthById } from '../../../hooks/api/integrationAuth';
|
||||||
import { useGetWorkspaceById } from '../../../hooks/api/workspace';
|
import { useGetWorkspaceById } from '../../../hooks/api/workspace';
|
||||||
import createIntegration from "../../api/integrations/createIntegration";
|
import createIntegration from "../../api/integrations/createIntegration";
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import {
|
|||||||
Select,
|
Select,
|
||||||
SelectItem
|
SelectItem
|
||||||
} from '../../../components/v2';
|
} from '../../../components/v2';
|
||||||
import { useGetIntegrationAuthById } from '../../../hooks/api/integrationAuth';
|
import { useGetIntegrationAuthApps,useGetIntegrationAuthById } from '../../../hooks/api/integrationAuth';
|
||||||
import { useGetWorkspaceById } from '../../../hooks/api/workspace';
|
import { useGetWorkspaceById } from '../../../hooks/api/workspace';
|
||||||
import createIntegration from "../../api/integrations/createIntegration";
|
import createIntegration from "../../api/integrations/createIntegration";
|
||||||
|
|
||||||
|
|||||||
@@ -14,17 +14,14 @@ export default function HerokuOAuth2CallbackPage() {
|
|||||||
(async () => {
|
(async () => {
|
||||||
try {
|
try {
|
||||||
// validate state
|
// validate state
|
||||||
console.log('A');
|
|
||||||
if (state !== localStorage.getItem('latestCSRFToken')) return;
|
if (state !== localStorage.getItem('latestCSRFToken')) return;
|
||||||
localStorage.removeItem('latestCSRFToken');
|
localStorage.removeItem('latestCSRFToken');
|
||||||
console.log('B');
|
|
||||||
const integrationAuth = await AuthorizeIntegration({
|
const integrationAuth = await AuthorizeIntegration({
|
||||||
workspaceId: localStorage.getItem('projectData.id') as string,
|
workspaceId: localStorage.getItem('projectData.id') as string,
|
||||||
code: code as string,
|
code: code as string,
|
||||||
integration: 'heroku'
|
integration: 'heroku'
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log('C');
|
|
||||||
router.push(
|
router.push(
|
||||||
`/integrations/heroku/create?integrationAuthId=${integrationAuth._id}`
|
`/integrations/heroku/create?integrationAuthId=${integrationAuth._id}`
|
||||||
);
|
);
|
||||||
@@ -32,7 +29,6 @@ export default function HerokuOAuth2CallbackPage() {
|
|||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
}
|
}
|
||||||
console.log('D');
|
|
||||||
})();
|
})();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import {
|
|||||||
Select,
|
Select,
|
||||||
SelectItem
|
SelectItem
|
||||||
} from '../../../components/v2';
|
} from '../../../components/v2';
|
||||||
import { useGetIntegrationAuthById } from '../../../hooks/api/integrationAuth';
|
import { useGetIntegrationAuthApps,useGetIntegrationAuthById } from '../../../hooks/api/integrationAuth';
|
||||||
import { useGetWorkspaceById } from '../../../hooks/api/workspace';
|
import { useGetWorkspaceById } from '../../../hooks/api/workspace';
|
||||||
import createIntegration from "../../api/integrations/createIntegration";
|
import createIntegration from "../../api/integrations/createIntegration";
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import {
|
|||||||
Select,
|
Select,
|
||||||
SelectItem
|
SelectItem
|
||||||
} from '../../../components/v2';
|
} from '../../../components/v2';
|
||||||
import { useGetIntegrationAuthById } from '../../../hooks/api/integrationAuth';
|
import { useGetIntegrationAuthApps,useGetIntegrationAuthById } from '../../../hooks/api/integrationAuth';
|
||||||
import { useGetWorkspaceById } from '../../../hooks/api/workspace';
|
import { useGetWorkspaceById } from '../../../hooks/api/workspace';
|
||||||
import createIntegration from "../../api/integrations/createIntegration";
|
import createIntegration from "../../api/integrations/createIntegration";
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import {
|
|||||||
Select,
|
Select,
|
||||||
SelectItem
|
SelectItem
|
||||||
} from '../../../components/v2';
|
} from '../../../components/v2';
|
||||||
import { useGetIntegrationAuthById } from '../../../hooks/api/integrationAuth';
|
import { useGetIntegrationAuthApps,useGetIntegrationAuthById } from '../../../hooks/api/integrationAuth';
|
||||||
import { useGetWorkspaceById } from '../../../hooks/api/workspace';
|
import { useGetWorkspaceById } from '../../../hooks/api/workspace';
|
||||||
import createIntegration from "../../api/integrations/createIntegration";
|
import createIntegration from "../../api/integrations/createIntegration";
|
||||||
|
|
||||||
|
|||||||
@@ -1,46 +0,0 @@
|
|||||||
import { useEffect } from 'react';
|
|
||||||
import { useRouter } from 'next/router';
|
|
||||||
import queryString from 'query-string';
|
|
||||||
|
|
||||||
import AuthorizeIntegration from './api/integrations/authorizeIntegration';
|
|
||||||
|
|
||||||
export default function Netlify() {
|
|
||||||
const router = useRouter();
|
|
||||||
const parsedUrl = queryString.parse(router.asPath.split('?')[1]);
|
|
||||||
const {code} = parsedUrl;
|
|
||||||
const {state} = parsedUrl;
|
|
||||||
// modify comment here
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Here we forward to the default workspace if a user opens this url
|
|
||||||
*/
|
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
||||||
useEffect(() => {
|
|
||||||
(async () => {
|
|
||||||
try {
|
|
||||||
if (!code) throw new Error('Code not found');
|
|
||||||
|
|
||||||
if (state === localStorage.getItem('latestCSRFToken')) {
|
|
||||||
localStorage.removeItem('latestCSRFToken');
|
|
||||||
|
|
||||||
await AuthorizeIntegration({
|
|
||||||
workspaceId: localStorage.getItem('projectData.id') as string,
|
|
||||||
code: code as string,
|
|
||||||
integration: 'netlify',
|
|
||||||
});
|
|
||||||
|
|
||||||
router.push(
|
|
||||||
`/integrations/${ localStorage.getItem('projectData.id')}`
|
|
||||||
);
|
|
||||||
}
|
|
||||||
} catch (err) {
|
|
||||||
console.error('Netlify integration error: ', err);
|
|
||||||
}
|
|
||||||
})();
|
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
return <div />;
|
|
||||||
}
|
|
||||||
|
|
||||||
Netlify.requireAuth = true;
|
|
||||||
@@ -1,46 +0,0 @@
|
|||||||
import { useEffect } from 'react';
|
|
||||||
import { useRouter } from 'next/router';
|
|
||||||
import queryString from 'query-string';
|
|
||||||
|
|
||||||
import AuthorizeIntegration from './api/integrations/authorizeIntegration';
|
|
||||||
|
|
||||||
export default function Vercel() {
|
|
||||||
const router = useRouter();
|
|
||||||
const parsedUrl = queryString.parse(router.asPath.split('?')[1]);
|
|
||||||
const {code} = parsedUrl;
|
|
||||||
const {state} = parsedUrl;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Here we forward to the default workspace if a user opens this url
|
|
||||||
*/
|
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
||||||
useEffect(() => {
|
|
||||||
(async () => {
|
|
||||||
try {
|
|
||||||
// type check
|
|
||||||
if (!code) throw new Error('Code not found');
|
|
||||||
|
|
||||||
if (state === localStorage.getItem('latestCSRFToken')) {
|
|
||||||
localStorage.removeItem('latestCSRFToken');
|
|
||||||
|
|
||||||
await AuthorizeIntegration({
|
|
||||||
workspaceId: localStorage.getItem('projectData.id') as string,
|
|
||||||
code: code as string,
|
|
||||||
integration: 'vercel',
|
|
||||||
});
|
|
||||||
|
|
||||||
router.push(
|
|
||||||
`/integrations/${ localStorage.getItem('projectData.id')}`
|
|
||||||
);
|
|
||||||
}
|
|
||||||
} catch (err) {
|
|
||||||
console.error('Vercel integration error: ', err);
|
|
||||||
}
|
|
||||||
})();
|
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
return <div />;
|
|
||||||
}
|
|
||||||
|
|
||||||
Vercel.requireAuth = true;
|
|
||||||
Reference in New Issue
Block a user