Skip to content

Commit 4a6668a

Browse files
committed
Merge branch '440-fix-ui-configuration-tab' into 'master'
fix: Configuration tab ui updates for platform (#440) Closes #440 See merge request postgres-ai/database-lab!631
2 parents 4783b70 + c61b645 commit 4a6668a

File tree

7 files changed

+30
-20
lines changed

7 files changed

+30
-20
lines changed

ui/packages/platform/src/components/IndexPage.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ const styles = () => ({
9292
paddingTop: '40px'
9393
},
9494
'position': 'absolute',
95-
'min-width': drawerWidth,
95+
'width': drawerWidth,
9696
'background-color': colors.consoleMenuBackground,
9797
'border-right-color': colors.consoleStroke,
9898
'& hr': {
@@ -140,6 +140,7 @@ const styles = () => ({
140140
},
141141
toolbar: theme.mixins.toolbar,
142142
topToolbar: {
143+
color: '#fff',
143144
minHeight: 40,
144145
height: 40,
145146
paddingLeft: 14,

ui/packages/platform/src/pages/Instance/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ export const Instance = () => {
4747

4848
const api = {
4949
getInstance,
50-
refreshInstance,
5150
getSnapshots,
5251
destroyClone,
52+
refreshInstance,
5353
resetClone,
5454
getWSToken,
5555
}
@@ -77,6 +77,7 @@ export const Instance = () => {
7777
<InstancePage
7878
title={`Database Lab instance #${params.instanceId}`}
7979
instanceId={params.instanceId}
80+
hideInstanceTabs
8081
routes={routes}
8182
api={api}
8283
callbacks={callbacks}

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,16 @@ const useStyles = makeStyles({
3737
color: colors.pgaiDarkGray,
3838
},
3939
},
40+
tabHidden: {
41+
display: 'none',
42+
},
4043
})
4144

4245
type Props = {
4346
value: number
4447
handleChange: (event: React.ChangeEvent<{}>, newValue: number) => void
4548
hasLogs: boolean
49+
hideInstanceTabs?: boolean
4650
}
4751

4852
export const Tabs = (props: Props) => {
@@ -67,14 +71,14 @@ export const Tabs = (props: Props) => {
6771
label="Logs"
6872
disabled={!hasLogs}
6973
classes={{
70-
root: classes.tabRoot,
74+
root: props.hideInstanceTabs ? classes.tabHidden : classes.tabRoot,
7175
}}
7276
value={1}
7377
/>
7478
<TabComponent
7579
label="Configuration"
7680
classes={{
77-
root: classes.tabRoot,
81+
root: props.hideInstanceTabs ? classes.tabHidden : classes.tabRoot,
7882
}}
7983
value={2}
8084
/>

ui/packages/shared/pages/Instance/context.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export type Host = {
2626
breadcrumbs: React.ReactNode
2727
},
2828
wsHost?: string
29+
hideInstanceTabs?: boolean
2930
}
3031

3132
// Host context.

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

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ const useStyles = makeStyles((theme) => ({
4949
marginTop: '16px',
5050
position: 'relative',
5151
flex: '1 1 100%',
52+
height: "100%",
5253

5354
[theme.breakpoints.down('sm')]: {
5455
flexDirection: 'column',
@@ -91,7 +92,7 @@ export const Instance = observer((props: Props) => {
9192
const switchTab = (_: React.ChangeEvent<{} | null>, tabID: number) => {
9293
const contentElement = document.getElementById('content-container')
9394
setActiveTab(tabID);
94-
contentElement.scroll(0, 0)
95+
contentElement?.scroll(0, 0)
9596
};
9697

9798
return (
@@ -118,6 +119,7 @@ export const Instance = observer((props: Props) => {
118119
value={activeTab}
119120
handleChange={switchTab}
120121
hasLogs={api.initWS != undefined}
122+
hideInstanceTabs={props?.hideInstanceTabs}
121123
/>
122124
</SectionTitle>
123125

@@ -130,11 +132,13 @@ export const Instance = observer((props: Props) => {
130132
<div className={classes.content}>
131133
{!instance || !instance?.state.retrieving?.status && <StubSpinner />}
132134

133-
{instance && (
135+
{instance ? (
134136
<>
135137
<Clones />
136138
<Info />
137139
</>
140+
) : (
141+
<StubSpinner />
138142
)}
139143
</div>
140144
)}
@@ -149,16 +153,12 @@ export const Instance = observer((props: Props) => {
149153
</TabPanel>
150154
</>
151155

152-
<TabPanel value={activeTab} index={2}>
153-
<Configuration
154-
isConfigurationActive={isConfigurationActive}
155-
disableConfigModification={instance?.state.engine.disableConfigModification}
156-
switchActiveTab={switchTab}
157-
activeTab={activeTab}
158-
reload={() => stores.main.load(props.instanceId)}
159-
/>
160-
</TabPanel>
161-
156+
<TabPanel value={activeTab} index={2}>
157+
<Configuration
158+
switchActiveTab={(id: number) => setActiveTab(id)}
159+
activeTab={activeTab}
160+
reload={() => stores.main.load(props.instanceId)} />
161+
</TabPanel>
162162
</StoresProvider>
163163
</HostProvider>
164164
)
@@ -174,9 +174,12 @@ function TabPanel(props: PropTypes.InferProps<any>) {
174174
hidden={value !== index}
175175
id={`scrollable-auto-tabpanel-${index}`}
176176
aria-labelledby={`scrollable-auto-tab-${index}`}
177+
style={{height: "100%"}}
177178
{...other}
178179
>
179-
<Box p={3}>{children}</Box>
180+
<Box p={3}sx={{ height: '100%' }}>
181+
{children}
182+
</Box>
180183
</Typography>
181184
);
182185
}

ui/packages/shared/pages/Logs/hooks/useWsScroll.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ import { wsSnackbar } from '@postgres.ai/shared/pages/Logs/wsSnackbar'
33

44
export const useWsScroll = () => {
55
const snackbarTag = document.createElement('div')
6-
const contentElement = document.getElementById('content-container')
6+
const contentElement = document.getElementById('content-container') as HTMLElement
77

88
useEffect(() => {
9-
const targetNode = document.getElementById('logs-container')
9+
const targetNode = document.getElementById('logs-container') as HTMLElement
1010
contentElement.addEventListener(
1111
'scroll',
1212
() => {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export const Logs = ({ api }: { api: Api }) => {
2929

3030
useEffect(() => {
3131
const config = { attributes: false, childList: true, subtree: true }
32-
const targetNode = document.getElementById('logs-container')
32+
const targetNode = document.getElementById('logs-container') as HTMLElement
3333

3434
if (isLoading && targetNode.querySelectorAll('p').length === 1) {
3535
setIsLoading(false)

0 commit comments

Comments
 (0)