Skip to content

Commit

Permalink
Merge pull request #407 from truefoundry/ss_fix_error-toast_collectio…
Browse files Browse the repository at this point in the history
…n-selection

fix: frontend changes for error toast, collections
  • Loading branch information
mnvsk97 authored Nov 11, 2024
2 parents 3a55fe6 + 4e7ad5a commit d086977
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
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);
}

0 comments on commit d086977

Please sign in to comment.