fix: github setup workflow

This commit is contained in:
sriram veeraghanta 2024-05-15 17:42:08 +05:30
parent e1197f2b8f
commit 0587c50ced
11 changed files with 54 additions and 49 deletions

View File

@ -1,15 +1,17 @@
import { ReactNode } from "react";
import { Metadata } from "next";
// components
import { InstanceFailureView, InstanceNotReady } from "@/components/instance";
import { InstanceFailureView, InstanceSetupForm } from "@/components/instance";
// helpers
import { ASSET_PREFIX } from "@/helpers/common.helper";
// layout
import { DefaultLayout } from "@/layouts/default-layout";
// lib
import { AppProvider } from "@/lib/app-providers";
// styles
import "./globals.css";
// services
import { InstanceService } from "@/services";
import { InstanceService } from "@/services/instance.service";
const instanceService = new InstanceService();
@ -45,9 +47,23 @@ export default async function RootLayout({ children }: { children: ReactNode })
<body className={`antialiased`}>
<AppProvider initialState={{ instance: instanceDetails }}>
{instanceDetails ? (
<>{instanceDetails?.instance?.is_setup_done ? <>{children}</> : <InstanceNotReady />}</>
<>
{instanceDetails?.instance?.is_setup_done ? (
<>{children}</>
) : (
<DefaultLayout>
<div className="relative w-screen min-h-screen overflow-y-auto px-5 py-10 mx-auto flex justify-center items-center">
<InstanceSetupForm />
</div>
</DefaultLayout>
)}
</>
) : (
<DefaultLayout>
<div className="relative w-screen min-h-[500px] overflow-y-auto px-5 mx-auto flex justify-center items-center">
<InstanceFailureView />
</div>
</DefaultLayout>
)}
</AppProvider>
</body>

View File

@ -1 +0,0 @@
export * from "./sign-up-form";

View File

@ -1,23 +1,14 @@
"use client";
import { ReactNode } from "react";
// helpers
import { EAuthenticationPageType, EInstancePageType } from "@/helpers";
// lib
import { AuthWrapper, InstanceWrapper } from "@/lib/wrappers";
// layouts
import { DefaultLayout } from "@/layouts/default-layout";
interface SetupLayoutProps {
children: ReactNode;
params: any;
}
export default function SetupLayout(props: SetupLayoutProps) {
const { children, params } = props;
const { error_code } = params;
console.log("error_code", error_code);
return (
<InstanceWrapper pageType={EInstancePageType.PRE_SETUP}>
<AuthWrapper authType={EAuthenticationPageType.NOT_AUTHENTICATED}>{children}</AuthWrapper>
</InstanceWrapper>
);
const { children } = props;
return <DefaultLayout>{children}</DefaultLayout>;
}

View File

@ -1,19 +1,11 @@
import { Metadata } from "next";
// layouts
import { DefaultLayout } from "@/layouts/default-layout";
// components
import { InstanceSignUpForm } from "./components";
import { InstanceSetupForm } from "@/components/instance";
export const metadata: Metadata = {
title: "Setup - God Mode",
};
export default function SetupPage() {
return (
<>
<DefaultLayout>
<InstanceSignUpForm />
</DefaultLayout>
</>
);
return <InstanceSetupForm />;
}

View File

@ -11,7 +11,7 @@ import { API_BASE_URL, cn } from "@/helpers/common.helper";
import { useTheme, useUser } from "@/hooks/store";
// helpers
// services
import { AuthService } from "@/services";
import { AuthService } from "@/services/auth.service";
// service initialization
const authService = new AuthService();

View File

@ -1,2 +1,3 @@
export * from "./instance-not-ready";
export * from "./instance-failure-view";
export * from "./setup-form";

View File

@ -52,7 +52,7 @@ const defaultFromData: TFormData = {
is_telemetry_enabled: true,
};
export const InstanceSignUpForm: FC = (props) => {
export const InstanceSetupForm: FC = (props) => {
const {} = props;
// search params
const searchParams = useSearchParams();
@ -122,7 +122,7 @@ export const InstanceSignUpForm: FC = (props) => {
);
return (
<div className="relative w-full h-full overflow-hidden container mx-auto max-w-lg px-10 lg:max-w-md lg:px-5 flex flex-col justify-center items-center">
<div className="max-w-lg px-10 lg:max-w-md lg:px-5">
<div className="relative flex flex-col space-y-6">
<div className="text-center space-y-1">
<h3 className="flex gap-4 justify-center text-3xl font-bold text-onboarding-text-100">

View File

@ -1,3 +0,0 @@
export * from "./auth.service";
export * from "./instance.service";
export * from "./user.service";

View File

@ -13,8 +13,7 @@ export class InstanceService extends APIService {
return this.get<IInstance>("/api/instances/")
.then((response) => response.data)
.catch((error) => {
console.log("error", error);
throw error;
throw error?.response?.data;
});
}

View File

@ -3,7 +3,7 @@ import { IUser } from "@plane/types";
// helpers
import { EUserStatus, TUserStatus } from "@/helpers";
// services
import { AuthService } from "@/services";
import { AuthService } from "@/services/auth.service";
import { UserService } from "@/services/user.service";
// root store
import { RootStore } from "@/store/root.store";

View File

@ -3,6 +3,8 @@ import hashlib
from django.conf import settings
from cryptography.fernet import Fernet
from plane.utils.exception_logger import log_exception
def derive_key(secret_key):
# Use a key derivation function to get a suitable encryption key
@ -12,16 +14,21 @@ def derive_key(secret_key):
# Encrypt data
def encrypt_data(data):
try:
if data:
cipher_suite = Fernet(derive_key(settings.SECRET_KEY))
encrypted_data = cipher_suite.encrypt(data.encode())
return encrypted_data.decode() # Convert bytes to string
else:
return ""
except Exception as e:
log_exception(e)
return ""
# Decrypt data
def decrypt_data(encrypted_data):
try:
if encrypted_data:
cipher_suite = Fernet(derive_key(settings.SECRET_KEY))
decrypted_data = cipher_suite.decrypt(
@ -30,3 +37,6 @@ def decrypt_data(encrypted_data):
return decrypted_data.decode()
else:
return ""
except Exception as e:
log_exception(e)
return ""