1
- import { Box , Stack , Text , useToast } from '@sanity/ui'
1
+ import { Box , Stack , Text } from '@sanity/ui'
2
2
import { useCallback , useState } from 'react'
3
3
4
4
import { Dialog } from '../../../../ui-components'
5
5
import { LoadingBlock } from '../../../components'
6
6
import { useDocumentOperation , useSchema } from '../../../hooks'
7
- import { Translate , useTranslation } from '../../../i18n'
7
+ import { useTranslation } from '../../../i18n'
8
8
import { usePerspective } from '../../../perspective/usePerspective'
9
- import { Preview , unstable_useValuePreview as useValuePreview } from '../../../preview'
9
+ import { Preview } from '../../../preview'
10
10
import { getPublishedId , getVersionFromId , isVersionId } from '../../../util/draftUtils'
11
11
import { useVersionOperations } from '../../hooks'
12
12
import { releasesLocaleNamespace } from '../../i18n'
@@ -23,18 +23,14 @@ export function DiscardVersionDialog(props: {
23
23
} ) : React . JSX . Element {
24
24
const { onClose, documentId, documentType} = props
25
25
const { t} = useTranslation ( releasesLocaleNamespace )
26
- const { t : coreT } = useTranslation ( )
27
26
const { discardChanges} = useDocumentOperation ( getPublishedId ( documentId ) , documentType )
28
- const toast = useToast ( )
29
27
const { selectedPerspective} = usePerspective ( )
30
28
const { discardVersion} = useVersionOperations ( )
31
29
const schema = useSchema ( )
32
30
const [ isDiscarding , setIsDiscarding ] = useState ( false )
33
31
34
32
const schemaType = schema . get ( documentType )
35
33
36
- const preview = useValuePreview ( { schemaType, value : { _id : documentId } } )
37
-
38
34
const handleDiscardVersion = useCallback ( async ( ) => {
39
35
setIsDiscarding ( true )
40
36
@@ -44,18 +40,6 @@ export function DiscardVersionDialog(props: {
44
40
getReleaseIdFromReleaseDocumentId ( ( selectedPerspective as ReleaseDocument ) . _id ) ,
45
41
documentId ,
46
42
)
47
-
48
- toast . push ( {
49
- closable : true ,
50
- status : 'success' ,
51
- description : (
52
- < Translate
53
- t = { coreT }
54
- i18nKey = { 'release.action.discard-version.success' }
55
- values = { { title : preview . value ?. title || documentId } }
56
- />
57
- ) ,
58
- } )
59
43
} else {
60
44
// on the document header you can also discard the draft
61
45
discardChanges . execute ( )
@@ -64,16 +48,7 @@ export function DiscardVersionDialog(props: {
64
48
setIsDiscarding ( false )
65
49
66
50
onClose ( )
67
- } , [
68
- documentId ,
69
- onClose ,
70
- discardVersion ,
71
- selectedPerspective ,
72
- toast ,
73
- coreT ,
74
- preview . value ?. title ,
75
- discardChanges ,
76
- ] )
51
+ } , [ documentId , onClose , discardVersion , selectedPerspective , discardChanges ] )
77
52
78
53
return (
79
54
< Dialog
0 commit comments