Skip to content

Commit 6e5828d

Browse files
committed
refactor index.tsx to improve component imports and organization
1 parent 986bcac commit 6e5828d

File tree

1 file changed

+32
-30
lines changed

1 file changed

+32
-30
lines changed

src/index.tsx

Lines changed: 32 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,24 @@
11
import {
22
registerRoute,
33
registerSidebarEntry,
4-
K8s,
54
// Plugin, // Uncomment if you need Plugin class features
65
} from '@kinvolk/headlamp-plugin/lib';
76
import {
8-
DetailsGrid,
7+
ConditionsTable,
8+
Link,
99
Loader,
10-
ResourceListView,
1110
MainInfoSection,
12-
SectionBox,
1311
NameValueTable,
14-
ConditionsTable,
15-
Link,
12+
ResourceListView,
13+
SectionBox,
1614
StatusLabel,
1715
Table,
1816
} from '@kinvolk/headlamp-plugin/lib/CommonComponents';
19-
import {
20-
Box,
21-
Typography,
22-
Tabs,
23-
Tab,
24-
} from '@mui/material';
2517
import { KubeObjectInterface } from '@kinvolk/headlamp-plugin/lib/K8s/cluster';
2618
import { makeCustomResourceClass } from '@kinvolk/headlamp-plugin/lib/K8s/crd';
27-
import { useParams } from 'react-router-dom';
19+
import { Box, Tab, Tabs, Typography } from '@mui/material';
2820
import React from 'react';
29-
30-
const { makeKubeObject } = K8s.cluster;
21+
import { useParams } from 'react-router-dom';
3122

3223
// Define functions that return the Longhorn Resource Classes
3324
const longhornGroup = 'longhorn.io';
@@ -812,9 +803,7 @@ function TabPanel(props: TabPanelProps) {
812803
>
813804
{value === index && (
814805
// Add some padding to the panel content
815-
<Box sx={{ pt: 2, pb: 2 }}>
816-
{children}
817-
</Box>
806+
<Box sx={{ pt: 2, pb: 2 }}>{children}</Box>
818807
)}
819808
</div>
820809
);
@@ -871,7 +860,9 @@ function SettingsView() {
871860

872861
if (error) {
873862
// @ts-ignore Allow error message display
874-
return <Typography color="error">Error loading settings: {(error as Error).message}</Typography>;
863+
return (
864+
<Typography color="error">Error loading settings: {(error as Error).message}</Typography>
865+
);
875866
}
876867

877868
if (!groupedSettings) {
@@ -885,18 +876,18 @@ function SettingsView() {
885876
<Box sx={{ width: '100%' }}>
886877
{/* Tab Headers */}
887878
<Box sx={{ borderBottom: 1, borderColor: 'divider' }}>
888-
<Tabs
889-
value={activeTab}
890-
onChange={handleTabChange}
879+
<Tabs
880+
value={activeTab}
881+
onChange={handleTabChange}
891882
aria-label="Longhorn settings categories"
892883
variant="scrollable" // Allow tabs to scroll if they overflow
893884
scrollButtons="auto" // Show scroll buttons automatically
894885
>
895886
{categories.map((category, index) => (
896-
<Tab
897-
key={category}
898-
label={`${category} (${groupedSettings[category].length})`}
899-
{...a11yProps(index)}
887+
<Tab
888+
key={category}
889+
label={`${category} (${groupedSettings[category].length})`}
890+
{...a11yProps(index)}
900891
/>
901892
))}
902893
</Tabs>
@@ -909,13 +900,24 @@ function SettingsView() {
909900
rows={groupedSettings[category].map(setting => ({
910901
name: setting.metadata.name,
911902
value: (
912-
<Box sx={{ display: 'flex', flexDirection: 'row', alignItems: 'baseline', width: '100%' }}>
913-
<Typography component="span" variant="body2" sx={{ wordBreak: 'break-word', flexGrow: 1, mr: 1 }}>
914-
{(setting.jsonData.value ?? '-').toString()}
903+
<Box
904+
sx={{
905+
display: 'flex',
906+
flexDirection: 'row',
907+
alignItems: 'baseline',
908+
width: '100%',
909+
}}
910+
>
911+
<Typography
912+
component="span"
913+
variant="body2"
914+
sx={{ wordBreak: 'break-word', flexGrow: 1, mr: 1 }}
915+
>
916+
{(setting.jsonData.value ?? '-').toString()}
915917
</Typography>
916918
<Box component="span" sx={{ flexShrink: 0, ml: 1 }}>
917919
<StatusLabel status={setting.jsonData.status?.applied ? 'success' : 'error'}>
918-
{(setting.jsonData.status?.applied ? 'applied' : 'not applied')}
920+
{setting.jsonData.status?.applied ? 'applied' : 'not applied'}
919921
</StatusLabel>
920922
</Box>
921923
</Box>

0 commit comments

Comments
 (0)