Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: frontend changes for error toast, collections #407

Merged
merged 4 commits into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions frontend/src/screens/dashboard/docsqa/NewCollection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { notifyError } from '@/utils/error'

interface NewCollectionProps {
open: boolean
onClose: () => void
onClose: (collectionName?: string) => void
onSuccess?: () => void
}

Expand Down Expand Up @@ -105,7 +105,7 @@ const NewCollection = ({ open, onClose, onSuccess }: NewCollectionProps) => {
}),
)

onClose()
onClose(collectionName)
resetForm()
onSuccess?.()
notify(
Expand Down
7 changes: 6 additions & 1 deletion frontend/src/screens/dashboard/docsqa/settings/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ const DocsQASettings = () => {
) {
setSelectedCollection(collectionsNames[0])
}
} else {
setSelectedCollection(undefined)
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [collectionsNames])
Expand Down Expand Up @@ -182,11 +184,14 @@ const DocsQASettings = () => {
{newCollectionModalOpen && (
<NewCollection
open={newCollectionModalOpen}
onClose={() => {
onClose={(newCollectionName) => {
if (searchParams.has('newCollectionOpen')) {
searchParams.delete('newCollectionOpen')
setSearchParams(searchParams)
}
if (newCollectionName) {
setSelectedCollection(newCollectionName)
}
setNewCollectionModalOpen(false)
}}
/>
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/utils/error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export function notifyError(baseMessage: string, err?: any, defaultMessage? : st
err?.message ||
err?.data?.error ||
err?.error ||
err?.details?.msg || defaultMessage;
err?.details?.msg || (typeof err?.data?.detail === 'string' && err?.data?.detail) || defaultMessage;

notify('error', baseMessage, message);
}
Loading