Skip to content

Commit 478c9e8

Browse files
authored
fix(Cluster): side paddings (#2301)
1 parent c4a4abf commit 478c9e8

File tree

9 files changed

+91
-70
lines changed

9 files changed

+91
-70
lines changed

src/components/TableWithControlsLayout/TableWithControlsLayout.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
&__controls {
2121
z-index: 3;
2222

23-
width: 100%;
23+
width: max-content;
2424
height: 62px;
2525

2626
@include mixins.controls();

src/components/TableWithControlsLayout/TableWithControlsLayout.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import {Flex} from '@gravity-ui/uikit';
2+
13
import {cn} from '../../utils/cn';
24
import {TableSkeleton} from '../TableSkeleton/TableSkeleton';
35

@@ -7,6 +9,7 @@ const b = cn('ydb-table-with-controls-layout');
79

810
interface TableWithControlsLayoutItemProps {
911
children: React.ReactNode;
12+
renderExtraControls?: () => React.ReactNode;
1013
className?: string;
1114
}
1215

@@ -23,12 +26,19 @@ export const TableWithControlsLayout = ({
2326

2427
TableWithControlsLayout.Controls = function TableControls({
2528
children,
29+
renderExtraControls,
2630
className,
2731
}: TableWithControlsLayoutItemProps) {
2832
return (
29-
<div className={b('controls-wrapper')}>
33+
<Flex
34+
justifyContent="space-between"
35+
alignItems="center"
36+
className={b('controls-wrapper')}
37+
gap={2}
38+
>
3039
<div className={b('controls', className)}>{children}</div>
31-
</div>
40+
{renderExtraControls?.()}
41+
</Flex>
3242
);
3343
};
3444

src/containers/Cluster/Cluster.scss

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,29 @@
88

99
width: 100%;
1010
height: 100%;
11-
padding: 0 var(--cluster-side-padding);
11+
12+
&__sticky-wrapper {
13+
padding: 0 var(--cluster-side-padding);
14+
}
15+
16+
&__dashboard {
17+
position: sticky;
18+
left: 0;
19+
20+
padding: 0 var(--cluster-side-padding);
21+
}
22+
23+
&__content {
24+
width: calc(100% - var(--cluster-side-padding));
25+
//allows controls of TableWithControlsLayout to stick properly
26+
transform: translateX(var(--cluster-side-padding));
27+
}
1228

1329
&__header {
1430
position: sticky;
1531
left: 0;
1632

17-
padding: 20px 0;
33+
padding: var(--g-spacing-5) var(--cluster-side-padding);
1834
}
1935

2036
&__title {
@@ -32,11 +48,7 @@
3248
z-index: 3;
3349

3450
margin-top: 20px;
35-
margin-right: calc(var(--cluster-side-padding) * -2);
36-
padding-right: calc(var(--cluster-side-padding) * 2);
37-
padding-left: var(--cluster-side-padding);
38-
39-
transform: translateX(calc(var(--cluster-side-padding) * -1));
51+
padding: 0 var(--cluster-side-padding);
4052
@include mixins.sticky-top();
4153
}
4254
&__tabs {

src/containers/Cluster/Cluster.tsx

Lines changed: 57 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -123,13 +123,15 @@ export function Cluster({
123123
<AutoRefreshControl className={b('auto-refresh-control')} />
124124
</div>
125125
{isClusterDashboardAvailable && (
126-
<ClusterOverview
127-
cluster={cluster ?? {}}
128-
groupStats={groupsStats}
129-
loading={infoLoading}
130-
error={clusterError || cluster?.error}
131-
additionalClusterProps={additionalClusterProps}
132-
/>
126+
<div className={b('dashboard')}>
127+
<ClusterOverview
128+
cluster={cluster ?? {}}
129+
groupStats={groupsStats}
130+
loading={infoLoading}
131+
error={clusterError || cluster?.error}
132+
additionalClusterProps={additionalClusterProps}
133+
/>
134+
</div>
133135
)}
134136
<div className={b('tabs-sticky-wrapper')}>
135137
<Tabs
@@ -153,46 +155,54 @@ export function Cluster({
153155
}}
154156
/>
155157
</div>
156-
<Switch>
157-
<Route
158-
path={
159-
getLocationObjectFromHref(getClusterPath(clusterTabsIds.tablets)).pathname
160-
}
161-
>
162-
<TabletsTable loading={infoLoading} tablets={clusterTablets} />
163-
</Route>
164-
<Route
165-
path={
166-
getLocationObjectFromHref(getClusterPath(clusterTabsIds.tenants)).pathname
167-
}
168-
>
169-
<Tenants additionalTenantsProps={additionalTenantsProps} />
170-
</Route>
171-
<Route
172-
path={getLocationObjectFromHref(getClusterPath(clusterTabsIds.nodes)).pathname}
173-
>
174-
<Nodes parentRef={container} additionalNodesProps={additionalNodesProps} />
175-
</Route>
176-
<Route
177-
path={
178-
getLocationObjectFromHref(getClusterPath(clusterTabsIds.storage)).pathname
179-
}
180-
>
181-
<PaginatedStorage parentRef={container} />
182-
</Route>
183-
<Route
184-
path={
185-
getLocationObjectFromHref(getClusterPath(clusterTabsIds.versions)).pathname
186-
}
187-
>
188-
<VersionsContainer cluster={cluster} loading={infoLoading} />
189-
</Route>
190-
<Route
191-
render={() => (
192-
<Redirect to={getLocationObjectFromHref(getClusterPath(activeTabId))} />
193-
)}
194-
/>
195-
</Switch>
158+
<div className={b('content')}>
159+
<Switch>
160+
<Route
161+
path={
162+
getLocationObjectFromHref(getClusterPath(clusterTabsIds.tablets))
163+
.pathname
164+
}
165+
>
166+
<TabletsTable loading={infoLoading} tablets={clusterTablets} />
167+
</Route>
168+
<Route
169+
path={
170+
getLocationObjectFromHref(getClusterPath(clusterTabsIds.tenants))
171+
.pathname
172+
}
173+
>
174+
<Tenants additionalTenantsProps={additionalTenantsProps} />
175+
</Route>
176+
<Route
177+
path={
178+
getLocationObjectFromHref(getClusterPath(clusterTabsIds.nodes)).pathname
179+
}
180+
>
181+
<Nodes parentRef={container} additionalNodesProps={additionalNodesProps} />
182+
</Route>
183+
<Route
184+
path={
185+
getLocationObjectFromHref(getClusterPath(clusterTabsIds.storage))
186+
.pathname
187+
}
188+
>
189+
<PaginatedStorage parentRef={container} />
190+
</Route>
191+
<Route
192+
path={
193+
getLocationObjectFromHref(getClusterPath(clusterTabsIds.versions))
194+
.pathname
195+
}
196+
>
197+
<VersionsContainer cluster={cluster} loading={infoLoading} />
198+
</Route>
199+
<Route
200+
render={() => (
201+
<Redirect to={getLocationObjectFromHref(getClusterPath(activeTabId))} />
202+
)}
203+
/>
204+
</Switch>
205+
</div>
196206
</div>
197207
);
198208
}

src/containers/Cluster/ClusterOverview/ClusterOverview.scss

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@
3030
&__overview-wrapper {
3131
--g-button-background-color-hover: var(--g-color-base-background);
3232
--g-button-padding: 0;
33-
position: sticky;
34-
left: 0;
3533

3634
padding: var(--g-spacing-4);
3735

src/containers/Nodes/Nodes.scss

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,4 @@
1515
&__node_unavailable {
1616
opacity: 0.6;
1717
}
18-
19-
&__groups-wrapper {
20-
padding-right: 20px;
21-
}
2218
}

src/containers/Storage/Storage.scss

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,4 @@
1515
.entity-status {
1616
justify-content: center;
1717
}
18-
19-
&__groups-wrapper {
20-
padding-right: 20px;
21-
}
2218
}

src/containers/Tenants/Tenants.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959

6060
&__create-database {
6161
position: sticky;
62-
right: 0;
62+
right: calc(var(--cluster-side-padding) * 2);
6363

6464
margin: 0 0 0 auto;
6565
}

src/containers/Tenants/Tenants.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,6 @@ export const Tenants = ({additionalTenantsProps}: TenantsProps) => {
123123
label={'Databases'}
124124
loading={loading}
125125
/>
126-
{renderCreateDBButton()}
127126
</React.Fragment>
128127
);
129128
};
@@ -268,7 +267,7 @@ export const Tenants = ({additionalTenantsProps}: TenantsProps) => {
268267
return (
269268
<div className={b('table-wrapper')}>
270269
<TableWithControlsLayout>
271-
<TableWithControlsLayout.Controls>
270+
<TableWithControlsLayout.Controls renderExtraControls={renderCreateDBButton}>
272271
{renderControls()}
273272
</TableWithControlsLayout.Controls>
274273
{error ? <ResponseError error={error} /> : null}

0 commit comments

Comments
 (0)