Skip to content

Commit

Permalink
chore(robot): merge with latest main
Browse files Browse the repository at this point in the history
  • Loading branch information
LatentDream committed Apr 25, 2024
2 parents 2a7ea6f + 2f405d4 commit df8c784
Show file tree
Hide file tree
Showing 6 changed files with 186 additions and 119 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -171,5 +171,5 @@
],
"all": true
},
"packageManager": "[email protected].5"
"packageManager": "[email protected].6"
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ import SequencerKeyboardShortcuts from "@/renderer/routes/test_sequencer_panel/S
import { ControlButton } from "./ControlButton";
import { DesignBar } from "./DesignBar";
import { useDisplayedSequenceState } from "@/renderer/hooks/useTestSequencerState";
import { TestSequencerProjectModal } from "./modals/TestSequencerProjectModal";
import { ImportTestModal } from "./modals/ImportTestModal";
import { ErrorModal } from "./modals/ErrorModal";
import { RenameTestModal } from "./modals/RenameTestModal";
import { CreateSequenceModal } from "./modals/CreateSequenceModal";

const TestSequencerView = () => {
const { backendGlobalState } = useDisplayedSequenceState();
Expand All @@ -40,7 +40,7 @@ const TestSequencerView = () => {
}}
className="overflow-y-auto"
>
<TestSequencerProjectModal />
<CreateSequenceModal />
<ImportTestModal />
<ErrorModal />
<RenameTestModal />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
import { Dialog, DialogContent } from "@/renderer/components/ui/dialog";
import { Button } from "@/renderer/components/ui/button";
import { useState } from "react";
import { Input } from "@/renderer/components/ui/input";
import { useDisplayedSequenceState } from "@/renderer/hooks/useTestSequencerState";
import { useCreateSequence } from "@/renderer/hooks/useTestSequencerProject";
import { InterpreterType } from "@/renderer/types/test-sequencer";
import { PathInput } from "@/renderer/components/ui/path-input";
import { useSequencerModalStore } from "@/renderer/stores/modal";
import { z } from "zod";
import { zodResolver } from "@hookform/resolvers/zod";
import { useForm } from "react-hook-form";
import {
Form,
FormControl,
FormField,
FormItem,
FormLabel,
FormMessage,
} from "@/renderer/components/ui/form";

const formSchema = z.object({
name: z
.string()
.min(1)
.max(50)
.regex(/\S/, {
message: "The sequence name should not contain white spaces",
})
.transform((val) => val.trim()),
description: z.string().max(100),
projectPath: z.string().min(1).regex(/\S/, {
message: "The project path should not contain white spaces",
}),
});

export const CreateSequenceModal = () => {
const { isCreateProjectModalOpen, setIsCreateProjectModalOpen } =
useSequencerModalStore();
const { elems } = useDisplayedSequenceState();
const handleCreate = useCreateSequence();
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const [interpreterPath, setInterpreterPath] = useState("");
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const [type, setType] = useState<InterpreterType>("flojoy");

const form = useForm<z.infer<typeof formSchema>>({
resolver: zodResolver(formSchema),
defaultValues: {
name: "",
description: "",
projectPath: "",
},
});

function handleSubmit(values: z.infer<typeof formSchema>) {
handleCreate(
{
name: values.name,
description: values.description,
elems: elems,
projectPath: values.projectPath,
interpreter: {
type: type,
path: interpreterPath === "" ? null : interpreterPath,
requirementsPath: "flojoy_requirements.txt",
},
},
setIsCreateProjectModalOpen,
);
}

return (
<Dialog
open={isCreateProjectModalOpen}
onOpenChange={setIsCreateProjectModalOpen}
>
<DialogContent>
<h2 className="mb-2 text-lg font-bold text-accent1 ">New Sequence</h2>
<Form {...form}>
<form
onSubmit={form.handleSubmit(handleSubmit)}
className="space-y-4"
>
<FormField
control={form.control}
name="name"
render={({ field }) => (
<FormItem>
<FormLabel>Sequence Name</FormLabel>
<FormControl>
<Input
placeholder="Sequence Name"
data-testid="new-seq-modal-name-input"
{...field}
/>
</FormControl>
<FormMessage />
</FormItem>
)}
/>
<FormField
control={form.control}
name="description"
render={({ field }) => (
<FormItem>
<FormLabel>Description</FormLabel>
<FormControl>
<Input
placeholder="Sequence Description"
data-testid="new-seq-modal-desc-input"
{...field}
/>
</FormControl>
<FormMessage />
</FormItem>
)}
/>
<FormField
control={form.control}
name="projectPath"
render={({ field }) => (
<FormItem>
<FormLabel>Project Root Directory</FormLabel>
<FormControl>
<PathInput
placeholder="Root Directory"
allowedExtention={["tjoy"]}
{...field}
pickerType="directory"
allowDirectoryCreation={true}
/>
</FormControl>
<FormMessage />
</FormItem>
)}
/>
{
// <div className="flex gap-2">
// <div className="flex-none w-[200px]">
// <Select onValueChange={(e: InterpreterType) => {setType(e)}}>
// <SelectTrigger className="w-[200px]">
// <SelectValue placeholder="Dependencies Manager" />
// </SelectTrigger>
// <SelectContent>
// <SelectGroup>
// <SelectLabel>Interpreter</SelectLabel>
// { availableInterpreter.map((interpreter) => (
// <SelectItem value={interpreter} key={interpreter}>
// { interpreter.charAt(0).toUpperCase() + interpreter.slice(1) }
// </SelectItem>
// ))}
// </SelectGroup>
// </SelectContent>
// </Select>
// </div>
// <PathInput
// placeholder="Interpreter"
// onChange={(event) => {setInterpreterPath(event.target.value)}}
// />
// </div>
}
<Button
data-testid="new-seq-modal-create-btn"
type="submit"
className="mt-4 w-full"
>
New Sequence
</Button>
</form>
</Form>
</DialogContent>
</Dialog>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ import { Separator } from "@/renderer/components/ui/separator";
import { Button } from "@/renderer/components/ui/button";
import { useImportAllSequencesInFolder } from "@/renderer/hooks/useTestSequencerProject";

type AppGalleryModalProps = {
type SequencerGalleryModalProps = {
isGalleryOpen: boolean;
setIsGalleryOpen: (open: boolean) => void;
};

export const SequencerGalleryModal = ({
isGalleryOpen,
setIsGalleryOpen,
}: AppGalleryModalProps) => {
}: SequencerGalleryModalProps) => {
const importSequence = useImportAllSequencesInFolder();

const handleSequenceLoad = (relativePath: string) => {
Expand Down Expand Up @@ -55,17 +55,17 @@ export const SequencerGalleryModal = ({
</DialogTitle>
</DialogHeader>
<ScrollArea className="">
{data.map((SeqExample) => (
{data.map((seqExample) => (
<>
<Separator />
<div className="1 inline-flex min-h-20 w-full items-center">
<div className="flex w-3/4">
<div className="flex grow flex-col items-start">
<div className="text-xl font-semibold">
{SeqExample.title}
{seqExample.title}
</div>
<div className="text-sm font-thin">
{SeqExample.description}
{seqExample.description}
</div>
</div>
</div>
Expand All @@ -74,12 +74,12 @@ export const SequencerGalleryModal = ({
variant="outline"
size="sm"
className="ml-6 gap-2"
data-testid={SeqExample.title
data-testid={seqExample.title
.toLowerCase()
.split(" ")
.join("_")}
onClick={() => {
handleSequenceLoad(SeqExample.dirPath);
handleSequenceLoad(seqExample.dirPath);
}}
>
Load
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ async function saveToDisk(
}

async function installDeps(sequence: TestSequencerProject): Promise<boolean> {
if (sequence.interpreter.requirementsPath !== null) {
if (sequence.interpreter.requirementsPath === null) {
return true;
}
const success = await window.api.poetryInstallRequirementsUserGroup(
Expand Down

0 comments on commit df8c784

Please sign in to comment.