This repository has been archived by the owner on Jun 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[web] Move state management from Context API to Zustand 🐻 (#36)
- Loading branch information
1 parent
bd7dd63
commit d80aeca
Showing
107 changed files
with
1,942 additions
and
1,520 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,5 +19,8 @@ | |
], | ||
"devDependencies": { | ||
"lerna": "^7.0.2" | ||
}, | ||
"dependencies": { | ||
"immer": "^10.0.2" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { ReactNode } from "react"; | ||
import v4_4_0 from "./v4-4-0"; | ||
|
||
export type ChangelogEntrySection = { | ||
label: ReactNode; | ||
items: ReactNode[]; | ||
}; | ||
|
||
export type ChangelogEntry = { | ||
version: string; | ||
date: Date; | ||
sections: ChangelogEntrySection[]; | ||
}; | ||
|
||
// First entry is the latest version | ||
export const changelog = [v4_4_0]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { ChangelogEntry } from "."; | ||
import { CHANGELOG_SECTION } from "../config/constants"; | ||
|
||
const v4_4_0: ChangelogEntry = { | ||
version: "4.4.0 - Zustand", | ||
date: new Date("july 12 2023"), | ||
sections: [ | ||
{ | ||
label: CHANGELOG_SECTION.FEATURES, | ||
items: [ | ||
"Added the ability to remove all callable functions.", | ||
"Added the ability to remove all saved contexts.", | ||
"Added the ability to remove all saved prompts.", | ||
"Added the ability to reset default settings.", | ||
"Added the ability to reset function warnings.", | ||
"Added this changelog!", | ||
], | ||
}, | ||
{ | ||
label: CHANGELOG_SECTION.IMPROVEMENTS, | ||
items: [ | ||
"Revamped state management from React Context API to Zustand.", | ||
"With Zustand comes a new persistence system, which will (hopefully) help with invalid saved data in the future, thanks to migrations.", | ||
], | ||
}, | ||
{ | ||
label: CHANGELOG_SECTION.FIXES, | ||
items: [ | ||
"Fixed an issue preventing from having more than 1 callable function in a conversation.", | ||
], | ||
}, | ||
{ | ||
label: CHANGELOG_SECTION.REMOVALS, | ||
items: [ | ||
"Removed the API key from saved conversations. It will be taken from your default settings instead.", | ||
], | ||
}, | ||
], | ||
}; | ||
|
||
export default v4_4_0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import { Group, SimpleGrid, Stack, Text } from "@mantine/core"; | ||
import { removeAllCallableFunctions } from "../store/actions/callableFunctions/removeAllCallableFunctions"; | ||
import { removeAllConversations } from "../store/actions/conversations/removeAllConversations"; | ||
import InlineConfirmButton from "./InlineConfirmButton"; | ||
import React from "react"; | ||
import { resetCallableFunctionWarnings } from "../store/actions/callableFunctions/resetCallableFunctionWarnings"; | ||
import { resetDefaultSettings } from "../store/actions/defaultConversationSettings/resetDefaultSettings"; | ||
import { removeAllSavedContexts } from "../store/actions/savedContexts/removeAllSavedContexts"; | ||
import { removeAllSavedPrompts } from "../store/actions/savedPrompts/removeAllSavedPrompts"; | ||
|
||
const AppSettingsDangerZone = () => { | ||
const actions = React.useMemo( | ||
() => [ | ||
{ | ||
label: "Delete conversations", | ||
unconfirmedLabel: "Delete", | ||
action: removeAllConversations, | ||
}, | ||
{ | ||
label: "Delete Functions", | ||
unconfirmedLabel: "Delete", | ||
action: removeAllCallableFunctions, | ||
}, | ||
{ | ||
label: "Delete Saved Contexts", | ||
unconfirmedLabel: "Delete", | ||
action: removeAllSavedContexts, | ||
}, | ||
{ | ||
label: "Delete Saved Prompts", | ||
unconfirmedLabel: "Delete", | ||
action: removeAllSavedPrompts, | ||
}, | ||
{ | ||
label: "Reset Function Warnings", | ||
unconfirmedLabel: "Reset", | ||
action: resetCallableFunctionWarnings, | ||
}, | ||
{ | ||
label: "Reset Default Settings", | ||
unconfirmedLabel: "Reset", | ||
action: resetDefaultSettings, | ||
}, | ||
], | ||
[] | ||
); | ||
|
||
return ( | ||
<Stack> | ||
<SimpleGrid cols={1} breakpoints={[{ minWidth: "sm", cols: 2 }]}> | ||
{actions.map(({ label, unconfirmedLabel, action }) => ( | ||
<Group key={label} position="apart"> | ||
<Text size="sm">{label}</Text> | ||
<InlineConfirmButton | ||
color="red" | ||
onConfirm={action} | ||
confirm={`${unconfirmedLabel}?`} | ||
> | ||
{unconfirmedLabel} | ||
</InlineConfirmButton> | ||
</Group> | ||
))} | ||
</SimpleGrid> | ||
</Stack> | ||
); | ||
}; | ||
|
||
export default AppSettingsDangerZone; |
Oops, something went wrong.