New Directory Setup (#2065)
* chore: moved app & space from apps to root * chore: modified workspace configuration * chore: modified dockerfiles for space and web * chore: modified icons for space * feat: updated files for new svg icons supported by next-images * chore: added /spaces base path for next * chore: added compose config for space * chore: updated husky configuration * chore: updated workflows for new configuration * chore: changed app name to web * fix: resolved build errors with web * chore: reset file tracing root for both projects * chore: added nginx config for deploy * fix: eslint and tsconfig settings for space app * husky setup fixes based on new dir * eslint fixes * prettier formatting --------- Co-authored-by: Henit Chobisa <chobisa.henit@gmail.com>
This commit is contained in:
parent
20e36194b4
commit
1e152c666c
1022 changed files with 1475 additions and 1240 deletions
108
web/pages/installations/[provider]/index.tsx
Normal file
108
web/pages/installations/[provider]/index.tsx
Normal file
|
|
@ -0,0 +1,108 @@
|
|||
import React, { useEffect } from "react";
|
||||
|
||||
// services
|
||||
import appinstallationsService from "services/app-installations.service";
|
||||
|
||||
import useToast from "hooks/use-toast";
|
||||
|
||||
// components
|
||||
import { Spinner } from "components/ui";
|
||||
|
||||
import { useRouter } from "next/router";
|
||||
|
||||
interface IGithuPostInstallationProps {
|
||||
installation_id: string;
|
||||
setup_action: string;
|
||||
state: string;
|
||||
provider: string;
|
||||
code: string;
|
||||
}
|
||||
|
||||
// TODO:Change getServerSideProps to router.query
|
||||
const AppPostInstallation = ({
|
||||
installation_id,
|
||||
setup_action,
|
||||
state,
|
||||
provider,
|
||||
code,
|
||||
}: IGithuPostInstallationProps) => {
|
||||
const { setToastAlert } = useToast();
|
||||
|
||||
useEffect(() => {
|
||||
if (provider === "github" && state && installation_id) {
|
||||
appinstallationsService
|
||||
.addInstallationApp(state, provider, { installation_id })
|
||||
.then(() => {
|
||||
window.opener = null;
|
||||
window.open("", "_self");
|
||||
window.close();
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
});
|
||||
} else if (provider === "slack" && state && code) {
|
||||
appinstallationsService
|
||||
.getSlackAuthDetails(code)
|
||||
.then((res) => {
|
||||
const [workspaceSlug, projectId, integrationId] = state.split(",");
|
||||
|
||||
if (!projectId) {
|
||||
const payload = {
|
||||
metadata: {
|
||||
...res,
|
||||
},
|
||||
};
|
||||
|
||||
appinstallationsService
|
||||
.addInstallationApp(state, provider, payload)
|
||||
.then((r) => {
|
||||
window.opener = null;
|
||||
window.open("", "_self");
|
||||
window.close();
|
||||
})
|
||||
.catch((err) => {
|
||||
throw err?.response;
|
||||
});
|
||||
} else {
|
||||
const payload = {
|
||||
access_token: res.access_token,
|
||||
bot_user_id: res.bot_user_id,
|
||||
webhook_url: res.incoming_webhook.url,
|
||||
data: res,
|
||||
team_id: res.team.id,
|
||||
team_name: res.team.name,
|
||||
scopes: res.scope,
|
||||
};
|
||||
appinstallationsService
|
||||
.addSlackChannel(workspaceSlug, projectId, integrationId, payload)
|
||||
.then((r) => {
|
||||
window.opener = null;
|
||||
window.open("", "_self");
|
||||
window.close();
|
||||
})
|
||||
.catch((err) => {
|
||||
throw err.response;
|
||||
});
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
});
|
||||
}
|
||||
}, [state, installation_id, provider, code]);
|
||||
|
||||
return (
|
||||
<div className="absolute top-0 left-0 z-50 flex h-full w-full flex-col items-center justify-center gap-y-3 bg-custom-background-80">
|
||||
<h2 className="text-2xl text-custom-text-100">Installing. Please wait...</h2>
|
||||
<Spinner />
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export async function getServerSideProps(context: any) {
|
||||
return {
|
||||
props: context.query,
|
||||
};
|
||||
}
|
||||
|
||||
export default AppPostInstallation;
|
||||
Loading…
Add table
Add a link
Reference in a new issue