Skip to content

Commit 76a6d29

Browse files
committed
Merge branch 'correct-disable-state-for-dle-install' into 'master'
fix(ui): correct disabled call for install DLE button, conditionally call the snapshots API, increase cypress timeout duration, improve types See merge request postgres-ai/database-lab!803
2 parents e7e2023 + 4da59cf commit 76a6d29

File tree

17 files changed

+39
-36
lines changed

17 files changed

+39
-36
lines changed

ui/packages/ce/cypress.config.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
import { defineConfig } from "cypress";
1+
import { defineConfig } from 'cypress'
22

33
export default defineConfig({
4+
pageLoadTimeout: 10000,
5+
defaultCommandTimeout: 10000,
46
e2e: {
57
testIsolation: false,
68
supportFile: false,
@@ -11,8 +13,8 @@ export default defineConfig({
1113

1214
component: {
1315
devServer: {
14-
framework: "create-react-app",
15-
bundler: "webpack",
16+
framework: 'create-react-app',
17+
bundler: 'webpack',
1618
},
1719
},
18-
});
20+
})

ui/packages/platform/src/components/DbLabInstanceInstallForm/DbLabInstanceInstallFormSidebar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ export const DbLabInstanceFormInstallSidebar = ({
9999
variant="contained"
100100
color="primary"
101101
onClick={handleCreate}
102-
disabled={!state.name || !state.verificationToken || !disabled}
102+
disabled={!state.name || !state.verificationToken || disabled}
103103
>
104104
Install DLE
105105
</Button>

ui/packages/shared/components/ResetCloneModal/index.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,14 @@ import { ImportantText } from '@postgres.ai/shared/components/ImportantText'
1818
import { Spinner } from '@postgres.ai/shared/components/Spinner'
1919
import { SimpleModalControls } from '@postgres.ai/shared/components/SimpleModalControls'
2020
import { compareSnapshotsDesc } from '@postgres.ai/shared/utils/snapshot'
21-
import { InstanceState } from '@postgres.ai/shared/types/api/entities/instanceState'
2221

2322
type Props = {
2423
isOpen: boolean
2524
onClose: () => void
2625
clone: Clone
2726
onResetClone: (snapshotId: string) => void
2827
snapshots: Snapshot[] | null
29-
version: InstanceState['engine']['version']
28+
version: string | null | undefined
3029
}
3130

3231
const useStyles = makeStyles(

ui/packages/shared/pages/Clone/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ export const Clone = observer((props: Props) => {
398398

399399
<p className={classes.text}>
400400
<span className={classes.paramTitle}>Logical data size:</span>
401-
{instance.state.dataSize
401+
{instance.state?.dataSize
402402
? formatBytesIEC(instance.state.dataSize)
403403
: '-'}
404404
</p>
@@ -625,7 +625,7 @@ export const Clone = observer((props: Props) => {
625625
clone={clone}
626626
snapshots={stores.main.snapshots.data}
627627
onResetClone={resetClone}
628-
version={instance.state.engine.version}
628+
version={instance.state?.engine.version}
629629
/>
630630
</>
631631
</div>

ui/packages/shared/pages/CreateClone/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ export const CreateClone = observer((props: Props) => {
210210
<p className={styles.param}>
211211
<span>Data size:</span>
212212
<strong>
213-
{stores.main.instance.state.dataSize
213+
{stores.main.instance.state?.dataSize
214214
? formatBytesIEC(stores.main.instance.state.dataSize)
215215
: '-'}
216216
</strong>
@@ -220,7 +220,7 @@ export const CreateClone = observer((props: Props) => {
220220
<span>Expected cloning time:</span>
221221
<strong>
222222
{round(
223-
stores.main.instance.state.cloning.expectedCloningTime,
223+
stores.main.instance.state?.cloning.expectedCloningTime as number,
224224
2,
225225
)}{' '}
226226
s

ui/packages/shared/pages/Instance/Clones/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,15 @@ export const Clones = observer(() => {
6363
const host = useHost()
6464

6565
const { instance } = stores.main
66-
if (!instance) return null
66+
if (!instance || !instance.state) return null
6767

6868
const isShortList = isMobile && isShortListForMobile
6969
const toggleListSize = () => setIsShortListForMobile(!isShortListForMobile)
7070

7171
const goToCloneAddPage = () => history.push(host.routes.createClone())
7272

7373
const showListSizeButton =
74-
instance.state.cloning.clones?.length > SHORT_LIST_SIZE && isMobile
74+
instance.state?.cloning.clones?.length > SHORT_LIST_SIZE && isMobile
7575

7676
const isLoadingSnapshots = stores.main.snapshots.isLoading
7777
const hasSnapshots = Boolean(stores.main.snapshots.data?.length)

ui/packages/shared/pages/Instance/ClonesModal/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export const ClonesModal = observer(() => {
3636

3737
return (
3838
<Modal
39-
title={`Clones (${instance.state.cloning.clones.length})`}
39+
title={`Clones (${instance.state?.cloning.clones.length})`}
4040
isOpen={isOpenModal}
4141
onClose={closeModal}
4242
size="md"
@@ -58,7 +58,7 @@ export const ClonesModal = observer(() => {
5858
>
5959
<ClonesList
6060
isDisabled={false}
61-
clones={instance.state.cloning.clones.filter((clone) => {
61+
clones={instance.state?.cloning.clones.filter((clone) => {
6262
const isMatchedByPool = !pool || pool === clone.snapshot?.pool
6363
const isMatchedBySnapshot =
6464
!snapshotId || snapshotId === clone.snapshot?.id

ui/packages/shared/pages/Instance/InactiveInstance/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export const InactiveInstance = ({
6060
}) => {
6161
const classes = useStyles()
6262

63-
const getVersionDigits = (str: string | undefined) => {
63+
const getVersionDigits = (str: string | undefined | null) => {
6464
if (!str) {
6565
return 'N/A'
6666
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export const Disks = observer(() => {
2222

2323
return (
2424
<Section title="Disks">
25-
{instance.state.pools?.map((pool) => {
25+
{instance.state?.pools?.map((pool) => {
2626
return (
2727
<Disk
2828
key={pool.name}
@@ -38,11 +38,11 @@ export const Disks = observer(() => {
3838
totalDataSize={pool.fileSystem.size}
3939
usedDataSize={pool.fileSystem.used}
4040
freeDataSize={pool.fileSystem.free}
41-
refreshingStartDate={instance.state.retrieving?.lastRefresh ?? null}
41+
refreshingStartDate={instance.state?.retrieving?.lastRefresh ?? null}
4242
/>
4343
)
4444
}) ??
45-
(instance.state.fileSystem && (
45+
(instance.state?.fileSystem && (
4646
<Disk
4747
status={'active'}
4848
name={'Main'}

ui/packages/shared/pages/Instance/Info/Retrieval/RefreshFailedAlert/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export const RefreshFailedAlert = observer(() => {
1212
const stores = useStores()
1313

1414
const refreshFailed =
15-
stores.main.instance?.state.retrieving?.alerts?.refreshFailed
15+
stores.main.instance?.state?.retrieving?.alerts?.refreshFailed
1616
if (!refreshFailed) return null
1717

1818
return (

ui/packages/shared/pages/Instance/Info/Retrieval/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export const Retrieval = observer(() => {
4141
const { instance, instanceRetrieval } = stores.main
4242
if (!instance) return null
4343

44-
const { retrieving } = instance.state
44+
const retrieving = instance.state?.retrieving
4545
if (!retrieving) return null
4646

4747
if (!instanceRetrieval) return null

ui/packages/shared/pages/Instance/Info/Retrieval/utils.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
import { InstanceState } from '@postgres.ai/shared/types/api/entities/instanceState'
2-
3-
export const getTypeByStatus = (
4-
status: Exclude<InstanceState['retrieving'], undefined>['status'],
5-
) => {
1+
export const getTypeByStatus = (status: string | undefined) => {
62
if (status === 'finished') return 'ok'
73
if (status === 'refreshing') return 'waiting'
84
if (status === 'failed') return 'error'

ui/packages/shared/pages/Instance/Info/Status/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export const Status = observer(() => {
3030
const stores = useStores()
3131

3232
const { instance } = stores.main
33-
if (!instance) return null
33+
if (!instance || !instance.state) return null
3434

3535
const { code, message } = instance.state.status
3636
const { version, startedAt } = instance.state.engine

ui/packages/shared/pages/Instance/components/ClonesList/ConnectionModal/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ export const ConnectionModal = observer((props: Props) => {
7676
const { instance } = stores.main
7777
if (!instance) return null
7878

79-
const clone = instance.state.cloning.clones.find(
79+
const clone = instance.state?.cloning.clones.find(
8080
(clone) => clone.id === cloneId,
8181
)
8282
if (!clone) return null

ui/packages/shared/pages/Instance/components/ClonesList/MenuCell/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ export const MenuCell = observer((props: Props) => {
9191
onResetClone={(snapshotId) =>
9292
stores.main.resetClone(clone.id, snapshotId)
9393
}
94-
version={stores.main.instance.state.engine.version}
94+
version={stores.main.instance.state?.engine.version}
9595
/>
9696
</TableBodyCellMenu>
9797
)

ui/packages/shared/pages/Instance/components/ClonesList/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ import { ConnectionModal } from './ConnectionModal'
3939
import styles from './styles.module.scss'
4040

4141
type Props = {
42-
clones: Clone[]
42+
clones?: Clone[]
4343
isDisabled: boolean
4444
emptyStubText: string
4545
}
@@ -62,7 +62,7 @@ export const ClonesList = (props: Props) => {
6262
setIsOpenConnectionModal(false)
6363
}
6464

65-
if (!props.clones.length)
65+
if (!props.clones?.length)
6666
return <p className={styles.emptyStub}>{props.emptyStubText}</p>
6767

6868
return (

ui/packages/shared/pages/Instance/stores/Main.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,27 +89,33 @@ export class MainStore {
8989
load = (instanceId: string) => {
9090
this.instance = null
9191
this.isReloadingInstance = true
92-
this.loadInstance(instanceId, false)
92+
this.loadInstance(instanceId, false).then(() => {
93+
if (this.instance?.url) {
94+
this.snapshots.load(instanceId)
95+
}
96+
})
9397
this.loadInstanceRetrieval(instanceId).then(() => {
9498
if (this.instanceRetrieval) {
9599
this.getConfig()
96100
this.getFullConfig()
97101
}
98102
})
99-
this.snapshots.load(instanceId)
100103
}
101104

102105
reload = (instanceId: string) => {
103106
this.instance = null
104107
this.isReloadingInstance = true
105-
this.loadInstance(instanceId)
108+
this.loadInstance(instanceId, false).then(() => {
109+
if (this.instance?.url) {
110+
this.snapshots.load(instanceId)
111+
}
112+
})
106113
this.loadInstanceRetrieval(instanceId).then(() => {
107114
if (this.instanceRetrieval) {
108115
this.getConfig()
109116
this.getFullConfig()
110117
}
111118
})
112-
this.snapshots.load(instanceId)
113119
}
114120

115121
reloadSnapshots = async () => {
@@ -269,7 +275,7 @@ export class MainStore {
269275

270276
return {
271277
response,
272-
error
278+
error,
273279
}
274280
}
275281

0 commit comments

Comments
 (0)