1
- import {
2
- Button ,
3
- Dialog ,
4
- DialogActions ,
5
- DialogContent ,
6
- DialogTitle ,
7
- List ,
8
- ListItem ,
9
- ListItemButton ,
10
- ListItemText ,
11
- Typography ,
12
- } from '@mui/material'
13
- import { useGetModel } from 'actions/model'
14
- import { useMemo } from 'react'
15
- import EmptyBlob from 'src/common/EmptyBlob'
16
- import Loading from 'src/common/Loading'
1
+ import { Button , Dialog , DialogActions , DialogContent , DialogTitle } from '@mui/material'
17
2
import { Transition } from 'src/common/Transition'
18
- import Link from 'src/Link'
19
- import MessageAlert from 'src/MessageAlert'
20
- import { FileInterface , isFileInterface , ReleaseInterface } from 'types/types'
21
- import { formatDateString } from 'utils/dateUtils'
3
+ import AssociatedReleasesList from 'src/entry/model/releases/AssociatedReleasesList'
4
+ import { FileInterface , ReleaseInterface } from 'types/types'
22
5
23
6
type AssociatedReleasesDialogProps = {
24
7
modelId : string
@@ -37,53 +20,17 @@ export default function AssociatedReleasesDialog({
37
20
open,
38
21
onClose,
39
22
} : AssociatedReleasesDialogProps ) {
40
- const { model, isModelLoading, isModelError } = useGetModel ( modelId , 'model' )
41
-
42
- const associatedReleasesDisplay = useMemo (
43
- ( ) =>
44
- model && isFileInterface ( file ) && sortedAssociatedReleases . length > 0 ? (
45
- < List disablePadding >
46
- { sortedAssociatedReleases . map ( ( associatedRelease ) => (
47
- < ListItem disablePadding key = { associatedRelease . _id } >
48
- < Link
49
- href = { `/model/${ model . id } /release/${ associatedRelease . semver } ` }
50
- sx = { { textDecoration : 'none' , width : '100%' } }
51
- >
52
- < ListItemButton dense >
53
- < ListItemText
54
- primary = {
55
- < >
56
- < Typography color = 'primary' component = 'span' >
57
- { associatedRelease . semver }
58
- </ Typography >
59
- { latestRelease === associatedRelease . semver && (
60
- < Typography color = 'secondary' component = 'span' pl = { 1 } >
61
- (Latest)
62
- </ Typography >
63
- ) }
64
- </ >
65
- }
66
- secondary = { formatDateString ( file . createdAt . toString ( ) ) }
67
- />
68
- </ ListItemButton >
69
- </ Link >
70
- </ ListItem >
71
- ) ) }
72
- </ List >
73
- ) : (
74
- < EmptyBlob text = 'No Associated Releases' />
75
- ) ,
76
- [ file , latestRelease , model , sortedAssociatedReleases ] ,
77
- )
78
-
79
- if ( isModelError ) {
80
- return < MessageAlert message = { isModelError . info . message } severity = 'error' />
81
- }
82
-
83
23
return (
84
24
< Dialog fullWidth open = { open } onClose = { onClose } maxWidth = 'sm' slots = { { transition : Transition } } >
85
25
< DialogTitle > Associated Releases</ DialogTitle >
86
- < DialogContent > { isModelLoading ? < Loading /> : associatedReleasesDisplay } </ DialogContent >
26
+ < DialogContent >
27
+ < AssociatedReleasesList
28
+ modelId = { modelId }
29
+ file = { file }
30
+ latestRelease = { latestRelease }
31
+ releases = { sortedAssociatedReleases }
32
+ />
33
+ </ DialogContent >
87
34
< DialogActions >
88
35
< Button variant = 'contained' onClick = { onClose } >
89
36
Close
0 commit comments