Skip to content

Commit

Permalink
add 2 save buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
ChloeMouret committed Aug 25, 2023
1 parent a9411c9 commit 421798b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
paidModels,
} from "@/lib/context/BrainConfigProvider/types";
import { defineMaxTokens } from "@/lib/helpers/defineMaxTokens";
import { SaveButton } from "@/shared/SaveButton";

import { PublicPrompts } from "./components/PublicPrompts/PublicPrompts";
import { useSettingsTab } from "./hooks/useSettingsTab";
Expand Down Expand Up @@ -54,7 +55,7 @@ export const SettingsTab = ({ brainId }: SettingsTabProps): JSX.Element => {
<div className="flex flex-row flex-1 justify-between w-full">
<div>
<Field
label={ t("brainName", { ns: "brain" })}
label={t("brainName", { ns: "brain" })}
placeholder={t("brainNamePlaceholder", { ns: "brain" })}
autoComplete="off"
className="flex-1"
Expand Down Expand Up @@ -140,6 +141,9 @@ export const SettingsTab = ({ brainId }: SettingsTabProps): JSX.Element => {
{...register("maxTokens")}
/>
</fieldset>
<div className="flex w-full justify-end py-4">
<SaveButton handleSubmit={handleSubmit} />
</div>
<Divider text={t("customPromptSection", { ns: "config" })} />
<PublicPrompts onSelect={pickPublicPrompt} />
<Field
Expand All @@ -156,6 +160,9 @@ export const SettingsTab = ({ brainId }: SettingsTabProps): JSX.Element => {
className="flex-1"
{...register("prompt.content")}
/>
<div className="flex w-full justify-end py-4">
<SaveButton handleSubmit={handleSubmit} />
</div>
{promptId !== "" && (
<Button disabled={isUpdating} onClick={() => void removeBrainPrompt()}>
{t("removePrompt", { ns: "config" })}
Expand Down
16 changes: 16 additions & 0 deletions frontend/shared/SaveButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { ReactElement } from "react";

import Button from "@/lib/components/ui/Button";

interface Props {
handleSubmit: (checkDirty: boolean) => Promise<void>;
}
export const SaveButton = ({ handleSubmit }: Props): ReactElement => (
<Button
variant={"primary"}
onClick={() => void handleSubmit(false)}
type="button"
>
Save
</Button>
);

0 comments on commit 421798b

Please sign in to comment.