move commit code into one file
This commit is contained in:
parent
637f75b93e
commit
30d5cd2b65
@ -22,7 +22,8 @@ import DeprecationMessage from "./components/messages/DeprecationMessage";
|
|||||||
import { GenerationSettings } from "./components/settings/GenerationSettings";
|
import { GenerationSettings } from "./components/settings/GenerationSettings";
|
||||||
import StartPane from "./components/start-pane/StartPane";
|
import StartPane from "./components/start-pane/StartPane";
|
||||||
import { takeScreenshot } from "./lib/takeScreenshot";
|
import { takeScreenshot } from "./lib/takeScreenshot";
|
||||||
import { Commit, createCommit } from "./components/history/history_types";
|
import { Commit } from "./components/commits/types";
|
||||||
|
import { createCommit } from "./components/commits/utils";
|
||||||
|
|
||||||
function App() {
|
function App() {
|
||||||
const {
|
const {
|
||||||
|
|||||||
@ -1,5 +1,3 @@
|
|||||||
export type CommitType = "ai_create" | "ai_edit" | "code_create";
|
|
||||||
|
|
||||||
export type CommitHash = string;
|
export type CommitHash = string;
|
||||||
|
|
||||||
export type Variant = {
|
export type Variant = {
|
||||||
@ -14,19 +12,7 @@ export type BaseCommit = {
|
|||||||
selectedVariantIndex: number;
|
selectedVariantIndex: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
import { nanoid } from "nanoid";
|
export type CommitType = "ai_create" | "ai_edit" | "code_create";
|
||||||
|
|
||||||
// TODO: Move to a different file
|
|
||||||
// TODO: Fix the type to be better
|
|
||||||
export function createCommit(
|
|
||||||
commit:
|
|
||||||
| Omit<AiCreateCommit, "hash">
|
|
||||||
| Omit<AiEditCommit, "hash">
|
|
||||||
| Omit<CodeCreateCommit, "hash">
|
|
||||||
): Commit {
|
|
||||||
const hash = nanoid();
|
|
||||||
return { ...commit, hash };
|
|
||||||
}
|
|
||||||
|
|
||||||
export type AiCreateCommit = BaseCommit & {
|
export type AiCreateCommit = BaseCommit & {
|
||||||
type: "ai_create";
|
type: "ai_create";
|
||||||
@ -48,10 +34,3 @@ export type CodeCreateCommit = BaseCommit & {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export type Commit = AiCreateCommit | AiEditCommit | CodeCreateCommit;
|
export type Commit = AiCreateCommit | AiEditCommit | CodeCreateCommit;
|
||||||
|
|
||||||
export type RenderedHistoryItem = {
|
|
||||||
type: string;
|
|
||||||
summary: string;
|
|
||||||
parentVersion: string | null;
|
|
||||||
isActive: boolean;
|
|
||||||
};
|
|
||||||
17
frontend/src/components/commits/utils.ts
Normal file
17
frontend/src/components/commits/utils.ts
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
import { nanoid } from "nanoid";
|
||||||
|
import {
|
||||||
|
AiCreateCommit,
|
||||||
|
AiEditCommit,
|
||||||
|
CodeCreateCommit,
|
||||||
|
Commit,
|
||||||
|
} from "./types";
|
||||||
|
|
||||||
|
export function createCommit(
|
||||||
|
commit:
|
||||||
|
| Omit<AiCreateCommit, "hash">
|
||||||
|
| Omit<AiEditCommit, "hash">
|
||||||
|
| Omit<CodeCreateCommit, "hash">
|
||||||
|
): Commit {
|
||||||
|
const hash = nanoid();
|
||||||
|
return { ...commit, hash };
|
||||||
|
}
|
||||||
@ -1,4 +1,4 @@
|
|||||||
import { Commit, CommitHash, CommitType } from "./history_types";
|
import { Commit, CommitHash, CommitType } from "../commits/types";
|
||||||
|
|
||||||
export function extractHistory(
|
export function extractHistory(
|
||||||
hash: CommitHash,
|
hash: CommitHash,
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import { create } from "zustand";
|
import { create } from "zustand";
|
||||||
import { Commit, CommitHash } from "../components/history/history_types";
|
import { Commit, CommitHash } from "../components/commits/types";
|
||||||
|
|
||||||
// Store for app-wide state
|
// Store for app-wide state
|
||||||
interface ProjectStore {
|
interface ProjectStore {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user