Skip to content

Commit

Permalink
trigger unsaved changes alert when switching history
Browse files Browse the repository at this point in the history
  • Loading branch information
bekossy committed Jan 21, 2024
1 parent 8e3239f commit 2b452dd
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 14 deletions.
1 change: 1 addition & 0 deletions agenta-web/src/components/Playground/ViewNavigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ const ViewNavigation: React.FC<Props> = ({
isChatVariant={!!isChatVariant}
compareMode={compareMode}
setOptParams={setOptParams}
onStateChange={onStateChange}
/>
</Col>
</Row>
Expand Down
23 changes: 11 additions & 12 deletions agenta-web/src/components/Playground/Views/ParametersView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,17 @@ const ParametersView: React.FC<Props> = ({
</Col>
<Col>
<Space>
<Tooltip>
<Button
onClick={handleHistoryBtn}
data-cy="history-button"
type="link"
icon={compareMode && <HistoryOutlined />}
>
{compareMode ? null : "History"}
</Button>
</Tooltip>

{isVariantExisting && (
<Tooltip
placement="bottom"
Expand All @@ -168,18 +179,6 @@ const ParametersView: React.FC<Props> = ({
</Tooltip>
)}

<Tooltip>
<Button
onClick={handleHistoryBtn}
data-cy="history-button"
type="link"
icon={compareMode && <HistoryOutlined />}
style={{backgroundColor: "#fa8c16", color: "#fff"}}
>
{compareMode ? null : "History"}
</Button>
</Tooltip>

<Tooltip
placement="bottom"
title="Save the new parameters for the variant permanently"
Expand Down
7 changes: 5 additions & 2 deletions agenta-web/src/components/Playground/Views/TestView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ interface TestViewProps {
isChatVariant?: boolean
compareMode: boolean
setOptParams: React.Dispatch<React.SetStateAction<Parameter[] | null>>
onStateChange: (isDirty: boolean) => void
}

interface BoxComponentProps {
Expand Down Expand Up @@ -319,6 +320,7 @@ const App: React.FC<TestViewProps> = ({
isChatVariant,
compareMode,
setOptParams,
onStateChange,
}) => {
const router = useRouter()
const appId = router.query.app_id as unknown as string
Expand Down Expand Up @@ -493,8 +495,8 @@ const App: React.FC<TestViewProps> = ({
}
}

const handleRestore = (id: number) => {
const revision = promptRevisions?.revisions.find((rev) => rev.revision === id)
const handleRestore = (revisionId: number) => {
const revision = promptRevisions?.revisions.find((rev) => rev.revision === revisionId)

setOptParams((prevState: Parameter[] | null) => {
if (!prevState) {
Expand Down Expand Up @@ -522,6 +524,7 @@ const App: React.FC<TestViewProps> = ({
})

setIsDrawerOpen(false)
onStateChange(true)
}

return (
Expand Down

0 comments on commit 2b452dd

Please sign in to comment.