Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion web/src/assets/react.svg

This file was deleted.

25 changes: 0 additions & 25 deletions web/src/components/external-ui/checkbox.tsx

This file was deleted.

39 changes: 31 additions & 8 deletions web/src/components/internal-ui/CheckBox.tsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,46 @@
import { useFormContext } from "react-hook-form";

import { HStack } from "@chakra-ui/react";
import { CSSProperties } from "react";

export interface Checkboxprops {
fieldName: string;
label: string;
style?: CSSProperties;
variant?: "chunk" | "standard";
}

const CheckBox = ({ fieldName, label }: Checkboxprops) => {
const CheckBox = ({
fieldName,
label,
style,
variant = "standard",
}: Checkboxprops) => {
const { register } = useFormContext();
return (
<>
<HStack alignItems={"center"} justifyContent={"center"}>
<p>{label}</p>
<input
className=" w-4 h-4 accent-orange-700"
{...register(fieldName)}
type="checkbox"
/>
<HStack alignItems={"center"}>
{variant === "standard" ? (
<>
<p>{label}</p>
<input
className=" w-4 h-4 accent-orange-700"
{...register(fieldName)}
type="checkbox"
style={style}
/>
</>
) : (
<div className="flex rounded-md border-[0.5px] border-orange-300 py-4 px-14 gap-x-5 items-center justify-between">
<p>{label}</p>
<input
className=" w-8 h-8 accent-orange-700"
{...register(fieldName)}
type="checkbox"
style={style}
/>
</div>
)}
</HStack>
</>
);
Expand Down
3 changes: 2 additions & 1 deletion web/src/components/internal-ui/Input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ interface Props {
placeholder?: string;
disabled?: boolean;
style?: CSSProperties;
classname?: string;
}

const Input = ({
Expand All @@ -28,7 +29,7 @@ const Input = ({
fieldName === BugFixFields.BUG_DESCRIPTION;

const defaultStyle =
"border border-stone-600 bg-stone-900 rounded-md flex h-auto p-4";
"border border-stone-600 bg-stone-900 rounded-md flex h-auto p-4 placeholder-gray-600 ";

const error = errors[fieldName];
return (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Button, HStack } from "@chakra-ui/react";
import { DefaultValues, FormProvider } from "react-hook-form";
import useTerraFormHandler from "../../features/terraform/hooks";
import useQueryGenerator from "../../hooks/useQueryGenerator";
import CheckBox, { Checkboxprops } from "./CheckBox";
import { Endpoints } from "../../features/constants";

Expand All @@ -12,7 +12,7 @@ interface PlatformProps<FormData, RequestData> {
mapperFunction: (data: FormData) => RequestData;
}

const PlatformBox = <FormData extends {}, RequestData extends {}>({
const Platform = <FormData extends {}, RequestData extends {}>({
serviceName,
defaultValues,
endpoint,
Expand All @@ -27,7 +27,7 @@ const PlatformBox = <FormData extends {}, RequestData extends {}>({
status,
data,
isSuccess,
} = useTerraFormHandler<FormData, RequestData>(defaultValues, endpoint);
} = useQueryGenerator<FormData, RequestData>(defaultValues, endpoint);
const handleFormSubmit = handleSubmit((formData) =>
onSubmit(mapperFunction(formData))
);
Expand Down Expand Up @@ -70,4 +70,4 @@ const PlatformBox = <FormData extends {}, RequestData extends {}>({
);
};

export default PlatformBox;
export default Platform;
4 changes: 2 additions & 2 deletions web/src/features/basicGen/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ import { ApiRequestBasicGen, BasicGenFormData } from "../models";

import { IoSendOutline } from "react-icons/io5";

import useFormHandler from "../../hooks/useFormHandler";
import useAiChat from "../../hooks/useAiChat";
import { basicGenMapper } from "../../utils/mapperFunctions";

const BasicGen = () => {
const { formMethods, handleSubmit, onSubmit, request } = useFormHandler<
const { formMethods, handleSubmit, onSubmit, request } = useAiChat<
BasicGenFormData,
ApiRequestBasicGen
>(basicGenDefaultValues);
Expand Down
4 changes: 2 additions & 2 deletions web/src/features/bugFix/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ import { FormProvider } from "react-hook-form";
import { IoSendOutline } from "react-icons/io5";
import ChatBox from "../../components/internal-ui/ChatBox";
import Input from "../../components/internal-ui/Input";
import useFormHandler from "../../hooks/useFormHandler";
import useAiChat from "../../hooks/useAiChat";
import { bugFixMapper } from "../../utils/mapperFunctions";
import useGptStore from "../../utils/store";
import { bugFixDefaultValues, BugFixFields, Endpoints } from "../constants";
import { ApiRequestBugFix, BugFixFormData } from "../models";

const BugFix = () => {
const { request, handleSubmit, onSubmit, formMethods } = useFormHandler<
const { request, handleSubmit, onSubmit, formMethods } = useAiChat<
BugFixFormData,
ApiRequestBugFix
>(bugFixDefaultValues);
Expand Down
57 changes: 55 additions & 2 deletions web/src/features/constants.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import {
BasicGenFormData,
BugFixFormData,
Environment,
HelmFormData,
InstallFormData,
TerraformArgocdFormData,
TerraformDockerFormData,
TerraformEc2FormData,
Expand All @@ -10,6 +13,7 @@ import {

export enum DownloadFolders {
MY_TERRAFORM = "MyTerraform",
MY_HELM = "MyHelm",
}

export enum TerraformServices {
Expand All @@ -30,8 +34,7 @@ export enum Endpoints {
POST_IAC_T_IAM = "/IaC-template/aws/iam",
POST_IAC_ARGOCD = "/IaC-template/argocd",
POST_IAC_HELM = "/Helm-template",
GET_DOWNLOAD_TERRAFORM = "/download-folder",
GET_DOWNLOAD_HELM = "/download-helm",
GET_DOWNLOAD = "/download-folder",
GET_DIRECTORY = "/list-directory",
}

Expand Down Expand Up @@ -82,6 +85,29 @@ export enum TerraformArgocdFields {
ARGOCD_CLUSTER = "argocdCluster",
}

export enum EnvironmentFields {
ENVIRONMENT_NAME = "environmentName",
VALUE = "value",
}

export enum HelmFields {
API_VERSION = "apiVersion",
NAME = "name",
IMAGE = "image",
TARGET_PORT = "targetPort",
REPLICAS = "replicas",
SIZE = "size",
ACCESS_MODES = "accessModes",
STATELESS = "stateless",
ENABLED = "enabled",
HOST = "host",
}

export enum InstallFields {
OS = "os",
SERVICE = "service",
}

export enum UserType {
USER = "user",
BOT = "bot",
Expand Down Expand Up @@ -133,3 +159,30 @@ export const terraformIamDefaultValues: TerraformIAMFormData = {
iamUser: false,
iamGroup: false,
};

export const environmentDefaultValues: Environment = {
environmentName: "ENV1",
value: "Hi",
};

export const helmDefaultValues: HelmFormData = {
apiVersion: 2,
pods: [
{
accessModes: "ReadWriteOnce",
enabled: false,
host: "www.example.com",
image: "nginx",
name: "web",
replicas: 1,
size: "1Gi",
stateless: false,
targetPort: 80,
},
],
};

export const installDefaultValues: InstallFormData = {
os: "",
service: "",
};
85 changes: 85 additions & 0 deletions web/src/features/helm/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
import { HelmFields } from "../constants";
import { FieldProperties } from "./models";

export enum HelmGroupNames {
GENERIC_SETTINGS = "Generic settings",
PERSISTANCE = "Persistance",
ENVIRONMENT = "Environment",
INGRESS = "Ingress",
}

export const helmFieldProperties: FieldProperties[] = [
{
group: {
name: HelmGroupNames.GENERIC_SETTINGS,
fields: [
{
fieldName: HelmFields.NAME,
label: "Name",
type: "input",
placeholder: "ex: web",
},
{
fieldName: HelmFields.IMAGE,
label: "Image",
type: "input",
placeholder: "nginx",
},
{
fieldName: HelmFields.TARGET_PORT,
label: "Target port",
type: "input",
placeholder: "80",
},
{
fieldName: HelmFields.REPLICAS,
label: "Replicas",
type: "input",
placeholder: "1",
},
{
fieldName: HelmFields.STATELESS,
label: "Stateless",
type: "checkbox",
},
],
},
},
{
group: {
name: HelmGroupNames.PERSISTANCE,
fields: [
{
fieldName: HelmFields.SIZE,
label: "Size",
type: "input",
placeholder: "1Gi",
},
{
fieldName: HelmFields.ACCESS_MODES,
label: "Access modes",
type: "input",
placeholder: "ex: ReadWriteOnce",
},
],
},
},
{
group: {
name: HelmGroupNames.INGRESS,
fields: [
{
fieldName: HelmFields.HOST,
label: "HOST",
type: "input",
placeholder: "ex: www.example.com",
},
{
fieldName: HelmFields.ENABLED,
label: "Enabled",
type: "checkbox",
},
],
},
},
];
Loading