Skip to content

Commit aa6d345

Browse files
committed
Merge branch 'feature/improve-datasets-info-ui' into 'master'
Redesign Disks section to group datasets under a shared pool header Closes #682 See merge request postgres-ai/database-lab!1103
2 parents 9b4adcc + b22fa92 commit aa6d345

File tree

6 files changed

+322
-241
lines changed

6 files changed

+322
-241
lines changed

ui/packages/shared/pages/Instance/Info/Disks/Disk/Marker/index.tsx

Lines changed: 0 additions & 26 deletions
This file was deleted.

ui/packages/shared/pages/Instance/Info/Disks/Disk/ProgressBar/index.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { CSSProperties } from 'react'
2+
13
import { makeStyles } from '@material-ui/core'
24

35
import { colors } from '@postgres.ai/shared/styles/colors'
@@ -9,6 +11,7 @@ type Props = {
911
value: number
1012
total: number
1113
thresholdPercent: number
14+
style?: CSSProperties
1215
}
1316

1417
const useStyles = makeStyles(
@@ -53,10 +56,10 @@ export const ProgressBar = (props: Props) => {
5356
const classes = useStyles()
5457

5558
return (
56-
<div className={classes.root}>
59+
<div className={classes.root} style={props.style}>
5760
<div
5861
className={classes.indicator}
59-
style={{ width: `${(props.value / props.total) * 100}%` }}
62+
style={{ width: `${props.total === 0 ? 0 : (props.value / props.total) * 100}%` }}
6063
/>
6164
<Tooltip
6265
content={`+${props.thresholdPercent}% disk usage may result in performance degradation`}

ui/packages/shared/pages/Instance/Info/Disks/Disk/index.tsx

Lines changed: 0 additions & 174 deletions
This file was deleted.
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
import { makeStyles } from '@material-ui/core'
2+
import { formatDistanceToNowStrict } from 'date-fns'
3+
4+
import { colors } from '@postgres.ai/shared/styles/colors'
5+
import { formatBytesIEC } from '@postgres.ai/shared/utils/units'
6+
import { formatUTC, isValidDate } from '@postgres.ai/shared/utils/date'
7+
8+
import { Property } from '../../../components/Property'
9+
import { ActionsMenu } from '../../Disk/ActionsMenu'
10+
import { Status } from '../../Disk/Status'
11+
12+
export type DatasetInfo = {
13+
id: string | null
14+
name: string
15+
showName: boolean
16+
status: 'refreshing' | 'active' | 'empty'
17+
mode: string
18+
usedDataSize: number
19+
clonesCount: number
20+
snapshotsCount: number
21+
refreshingStartDate: Date | null
22+
}
23+
24+
const useStyles = makeStyles(
25+
{
26+
root: {
27+
border: `1px solid ${colors.consoleStroke}`,
28+
padding: '6px 8px 8px',
29+
borderRadius: '4px',
30+
backgroundColor: colors.white,
31+
},
32+
header: {
33+
display: 'flex',
34+
justifyContent: 'space-between',
35+
alignItems: 'center',
36+
},
37+
titleWrapper: {
38+
display: 'flex',
39+
flex: '1 1 auto',
40+
alignItems: 'center',
41+
marginRight: '16px',
42+
minWidth: 0,
43+
},
44+
title: {
45+
fontWeight: 700,
46+
fontSize: '14px',
47+
margin: '0 4px 0 0',
48+
whiteSpace: 'nowrap',
49+
textOverflow: 'ellipsis',
50+
overflow: 'hidden',
51+
},
52+
content: {
53+
marginTop: '8px',
54+
},
55+
uppercaseContent: {
56+
textTransform: 'uppercase',
57+
},
58+
},
59+
{ index: 1 },
60+
)
61+
62+
export const DatasetRow = (props: DatasetInfo) => {
63+
const classes = useStyles()
64+
65+
return (
66+
<div className={classes.root}>
67+
<div className={classes.header}>
68+
{props.showName ? (
69+
<div className={classes.titleWrapper}>
70+
<h6 title={props.name} className={classes.title}>
71+
{props.name}
72+
</h6>
73+
<ActionsMenu
74+
poolId={props.id}
75+
poolName={props.id ?? props.name}
76+
isActive={props.status === 'active'}
77+
/>
78+
</div>
79+
) : (
80+
<ActionsMenu
81+
poolId={props.id}
82+
poolName={props.id ?? props.name}
83+
isActive={props.status === 'active'}
84+
/>
85+
)}
86+
<Status value={props.status} hasWarning={false} />
87+
</div>
88+
89+
<Property name="Mode" classes={{ content: classes.uppercaseContent }}>
90+
{props.mode}
91+
</Property>
92+
93+
{props.status === 'refreshing' && props.refreshingStartDate && (
94+
<div className={classes.content}>
95+
<Property name="Refreshing started at">
96+
{formatUTC(props.refreshingStartDate, 'yyyy-MM-dd HH:mm:ss')} UTC (
97+
{isValidDate(props.refreshingStartDate)
98+
? formatDistanceToNowStrict(props.refreshingStartDate, {
99+
addSuffix: true,
100+
})
101+
: '-'}
102+
)
103+
</Property>
104+
</div>
105+
)}
106+
107+
<div className={classes.content}>
108+
<Property name="Clones">{props.clonesCount}</Property>
109+
<Property name="Snapshots">{props.snapshotsCount}</Property>
110+
</div>
111+
112+
<div className={classes.content}>
113+
<Property name="Size">{formatBytesIEC(props.usedDataSize)}</Property>
114+
</div>
115+
</div>
116+
)
117+
}

0 commit comments

Comments
 (0)