Skip to content

fix(Cluster): side paddings #2301

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
May 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
&__controls {
z-index: 3;

width: 100%;
width: max-content;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

width: 100% here is for the create db button - it should stick to the right

Expected:
Screenshot 2025-05-21 at 15 46 53

You code:
Screenshot 2025-05-21 at 15 45 11

height: 62px;

@include mixins.controls();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import {Flex} from '@gravity-ui/uikit';

import {cn} from '../../utils/cn';
import {TableSkeleton} from '../TableSkeleton/TableSkeleton';

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

interface TableWithControlsLayoutItemProps {
children: React.ReactNode;
renderExtraControls?: () => React.ReactNode;
className?: string;
}

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

TableWithControlsLayout.Controls = function TableControls({
children,
renderExtraControls,
className,
}: TableWithControlsLayoutItemProps) {
return (
<div className={b('controls-wrapper')}>
<Flex
justifyContent="space-between"
alignItems="center"
className={b('controls-wrapper')}
gap={2}
>
<div className={b('controls', className)}>{children}</div>
</div>
{renderExtraControls?.()}
</Flex>
);
};

Expand Down
26 changes: 19 additions & 7 deletions src/containers/Cluster/Cluster.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,29 @@

width: 100%;
height: 100%;
padding: 0 var(--cluster-side-padding);

&__sticky-wrapper {
padding: 0 var(--cluster-side-padding);
}

&__dashboard {
position: sticky;
left: 0;

padding: 0 var(--cluster-side-padding);
}

&__content {
width: calc(100% - var(--cluster-side-padding));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that this is the last evil, but essential. For now our scroll container doesn't have paddings, so sticky elements stick to it.
I found this solution better than passing to all tables inside Cluster page classes with left: 20px

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if you add left padding to cluster scroll container, and right padding to all cluster components (dashboard, tabs, tabs content)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if you add left padding to cluster scroll container, and right padding to all cluster components (dashboard, tabs, tabs content)?

Than we get back with layout bug on the left from tabs :(
Screenshot 2025-05-20 at 17 42 57

//allows controls of TableWithControlsLayout to stick properly
transform: translateX(var(--cluster-side-padding));
}

&__header {
position: sticky;
left: 0;

padding: 20px 0;
padding: var(--g-spacing-5) var(--cluster-side-padding);
}

&__title {
Expand All @@ -32,11 +48,7 @@
z-index: 3;

margin-top: 20px;
margin-right: calc(var(--cluster-side-padding) * -2);
padding-right: calc(var(--cluster-side-padding) * 2);
padding-left: var(--cluster-side-padding);

transform: translateX(calc(var(--cluster-side-padding) * -1));
padding: 0 var(--cluster-side-padding);
@include mixins.sticky-top();
}
&__tabs {
Expand Down
104 changes: 57 additions & 47 deletions src/containers/Cluster/Cluster.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,15 @@ export function Cluster({
<AutoRefreshControl className={b('auto-refresh-control')} />
</div>
{isClusterDashboardAvailable && (
<ClusterOverview
cluster={cluster ?? {}}
groupStats={groupsStats}
loading={infoLoading}
error={clusterError || cluster?.error}
additionalClusterProps={additionalClusterProps}
/>
<div className={b('dashboard')}>
<ClusterOverview
cluster={cluster ?? {}}
groupStats={groupsStats}
loading={infoLoading}
error={clusterError || cluster?.error}
additionalClusterProps={additionalClusterProps}
/>
</div>
)}
<div className={b('tabs-sticky-wrapper')}>
<Tabs
Expand All @@ -153,46 +155,54 @@ export function Cluster({
}}
/>
</div>
<Switch>
<Route
path={
getLocationObjectFromHref(getClusterPath(clusterTabsIds.tablets)).pathname
}
>
<TabletsTable loading={infoLoading} tablets={clusterTablets} />
</Route>
<Route
path={
getLocationObjectFromHref(getClusterPath(clusterTabsIds.tenants)).pathname
}
>
<Tenants additionalTenantsProps={additionalTenantsProps} />
</Route>
<Route
path={getLocationObjectFromHref(getClusterPath(clusterTabsIds.nodes)).pathname}
>
<Nodes parentRef={container} additionalNodesProps={additionalNodesProps} />
</Route>
<Route
path={
getLocationObjectFromHref(getClusterPath(clusterTabsIds.storage)).pathname
}
>
<PaginatedStorage parentRef={container} />
</Route>
<Route
path={
getLocationObjectFromHref(getClusterPath(clusterTabsIds.versions)).pathname
}
>
<VersionsContainer cluster={cluster} loading={infoLoading} />
</Route>
<Route
render={() => (
<Redirect to={getLocationObjectFromHref(getClusterPath(activeTabId))} />
)}
/>
</Switch>
<div className={b('content')}>
<Switch>
<Route
path={
getLocationObjectFromHref(getClusterPath(clusterTabsIds.tablets))
.pathname
}
>
<TabletsTable loading={infoLoading} tablets={clusterTablets} />
</Route>
<Route
path={
getLocationObjectFromHref(getClusterPath(clusterTabsIds.tenants))
.pathname
}
>
<Tenants additionalTenantsProps={additionalTenantsProps} />
</Route>
<Route
path={
getLocationObjectFromHref(getClusterPath(clusterTabsIds.nodes)).pathname
}
>
<Nodes parentRef={container} additionalNodesProps={additionalNodesProps} />
</Route>
<Route
path={
getLocationObjectFromHref(getClusterPath(clusterTabsIds.storage))
.pathname
}
>
<PaginatedStorage parentRef={container} />
</Route>
<Route
path={
getLocationObjectFromHref(getClusterPath(clusterTabsIds.versions))
.pathname
}
>
<VersionsContainer cluster={cluster} loading={infoLoading} />
</Route>
<Route
render={() => (
<Redirect to={getLocationObjectFromHref(getClusterPath(activeTabId))} />
)}
/>
</Switch>
</div>
</div>
);
}
Expand Down
2 changes: 0 additions & 2 deletions src/containers/Cluster/ClusterOverview/ClusterOverview.scss
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@
&__overview-wrapper {
--g-button-background-color-hover: var(--g-color-base-background);
--g-button-padding: 0;
position: sticky;
left: 0;

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

Expand Down
4 changes: 0 additions & 4 deletions src/containers/Nodes/Nodes.scss
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,4 @@
&__node_unavailable {
opacity: 0.6;
}

&__groups-wrapper {
padding-right: 20px;
}
}
4 changes: 0 additions & 4 deletions src/containers/Storage/Storage.scss
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,4 @@
.entity-status {
justify-content: center;
}

&__groups-wrapper {
padding-right: 20px;
}
}
2 changes: 1 addition & 1 deletion src/containers/Tenants/Tenants.scss
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@

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

margin: 0 0 0 auto;
}
Expand Down
3 changes: 1 addition & 2 deletions src/containers/Tenants/Tenants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ export const Tenants = ({additionalTenantsProps}: TenantsProps) => {
label={'Databases'}
loading={loading}
/>
{renderCreateDBButton()}
</React.Fragment>
);
};
Expand Down Expand Up @@ -303,7 +302,7 @@ export const Tenants = ({additionalTenantsProps}: TenantsProps) => {
return (
<div className={b('table-wrapper')}>
<TableWithControlsLayout>
<TableWithControlsLayout.Controls>
<TableWithControlsLayout.Controls renderExtraControls={renderCreateDBButton}>
{renderControls()}
</TableWithControlsLayout.Controls>
{error ? <ResponseError error={error} /> : null}
Expand Down
Loading