Skip to content

Commit 5bf21ea

Browse files
committed
fix(Tenant): move general tabs outside navigation
1 parent f940421 commit 5bf21ea

File tree

6 files changed

+113
-91
lines changed

6 files changed

+113
-91
lines changed

src/containers/Tenant/ObjectGeneral/ObjectGeneral.scss

-22
Original file line numberDiff line numberDiff line change
@@ -9,28 +9,6 @@
99
height: 100%;
1010
max-height: 100%;
1111

12-
&__tabs {
13-
display: flex;
14-
gap: 20px;
15-
16-
padding: 13px 20px 0;
17-
18-
box-shadow: inset 0 -1px 0 0 var(--yc-color-line-generic);
19-
.yc-tabs {
20-
box-shadow: unset;
21-
}
22-
}
23-
&__tab {
24-
text-decoration: none;
25-
26-
// fix for bug in uikit, gap is set for yc-tabs__item:not(:last-child),
27-
// it doesn't work for wrapped items
28-
// feel free to remove if the bug is fixed
29-
&:not(:last-child) {
30-
margin-right: var(--yc-tabs-gap);
31-
}
32-
}
33-
3412
&__loader {
3513
display: flex;
3614
}
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,15 @@
1-
import {connect} from 'react-redux';
2-
import {Link} from 'react-router-dom';
3-
import cn from 'bem-cn-lite';
4-
import {useLocation} from 'react-router';
51
import qs from 'qs';
6-
import _ from 'lodash';
2+
import {useLocation} from 'react-router';
3+
import cn from 'bem-cn-lite';
4+
5+
import {useThemeValue} from '@yandex-cloud/uikit';
6+
7+
import type {EPathType} from '../../../types/api/schema';
78

8-
import {Tabs, useThemeValue} from '@yandex-cloud/uikit';
9-
//@ts-ignore
109
import QueryEditor from '../QueryEditor/QueryEditor';
1110
import Diagnostics from '../Diagnostics/Diagnostics';
1211

13-
import {TenantGeneralTabsIds, TenantTabsGroups, TENANT_GENERAL_TABS} from '../TenantPages';
14-
import routes, {createHref} from '../../../routes';
15-
import {setSettingValue} from '../../../store/reducers/settings';
16-
import {TENANT_INITIAL_TAB_KEY} from '../../../utils/constants';
17-
import type {EPathType} from '../../../types/api/schema';
12+
import {TenantGeneralTabsIds} from '../TenantPages';
1813

1914
import './ObjectGeneral.scss';
2015

@@ -24,7 +19,6 @@ interface ObjectGeneralProps {
2419
type?: EPathType;
2520
additionalTenantInfo?: any;
2621
additionalNodesInfo?: any;
27-
setSettingValue: (name: string, value: string) => void;
2822
}
2923

3024
function ObjectGeneral(props: ObjectGeneralProps) {
@@ -38,32 +32,6 @@ function ObjectGeneral(props: ObjectGeneralProps) {
3832

3933
const {name: tenantName, general: generalTab} = queryParams;
4034

41-
const renderTabs = () => {
42-
return (
43-
<div className={b('tabs')}>
44-
<Tabs
45-
size="xl"
46-
items={TENANT_GENERAL_TABS}
47-
activeTab={generalTab as string}
48-
wrapTo={({id}, node) => {
49-
const path = createHref(routes.tenant, undefined, {
50-
...queryParams,
51-
name: tenantName as string,
52-
[TenantTabsGroups.general]: id,
53-
});
54-
return (
55-
<Link to={path} key={id} className={b('tab')}>
56-
{node}
57-
</Link>
58-
);
59-
}}
60-
allowNotSelected
61-
onSelectTab={(id) => props.setSettingValue(TENANT_INITIAL_TAB_KEY, id)}
62-
/>
63-
</div>
64-
);
65-
};
66-
6735
const renderTabContent = () => {
6836
const {type, additionalTenantInfo, additionalNodesInfo} = props;
6937
switch (generalTab) {
@@ -88,7 +56,6 @@ function ObjectGeneral(props: ObjectGeneralProps) {
8856
}
8957
return (
9058
<div className={b()}>
91-
{renderTabs()}
9259
{renderTabContent()}
9360
</div>
9461
);
@@ -97,8 +64,4 @@ function ObjectGeneral(props: ObjectGeneralProps) {
9764
return renderContent();
9865
}
9966

100-
const mapDispatchToProps = {
101-
setSettingValue,
102-
};
103-
104-
export default connect(null, mapDispatchToProps)(ObjectGeneral);
67+
export default ObjectGeneral;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
@import '../../../styles/mixins.scss';
2+
3+
.object-general-tabs {
4+
padding: 12px 20px 0 12px;
5+
6+
&__tab {
7+
text-decoration: none;
8+
}
9+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
import qs from 'qs';
2+
import {connect} from 'react-redux';
3+
import {useLocation} from 'react-router';
4+
import {Link} from 'react-router-dom';
5+
import cn from 'bem-cn-lite';
6+
7+
import {Tabs} from '@yandex-cloud/uikit';
8+
9+
import routes, {createHref} from '../../../routes';
10+
import {TENANT_INITIAL_TAB_KEY} from '../../../utils/constants';
11+
import {setSettingValue} from '../../../store/reducers/settings';
12+
13+
import {TenantTabsGroups, TENANT_GENERAL_TABS} from '../TenantPages';
14+
15+
import './ObjectGeneralTabs.scss';
16+
17+
const b = cn('object-general-tabs');
18+
19+
interface ObjectGeneralTabsProps {
20+
setSettingValue: (name: string, value: string) => void;
21+
}
22+
23+
function ObjectGeneralTabs(props: ObjectGeneralTabsProps) {
24+
const location = useLocation();
25+
26+
const queryParams = qs.parse(location.search, {
27+
ignoreQueryPrefix: true,
28+
});
29+
30+
const {name: tenantName, general: generalTab} = queryParams;
31+
32+
const renderContent = () => {
33+
if (!tenantName) {
34+
return null;
35+
}
36+
return (
37+
<div className={b()}>
38+
<Tabs
39+
size="xl"
40+
items={TENANT_GENERAL_TABS}
41+
activeTab={generalTab as string}
42+
wrapTo={({id}, node) => {
43+
const path = createHref(routes.tenant, undefined, {
44+
...queryParams,
45+
name: tenantName as string,
46+
[TenantTabsGroups.general]: id,
47+
});
48+
return (
49+
<Link to={path} key={id} className={b('tab')}>
50+
{node}
51+
</Link>
52+
);
53+
}}
54+
allowNotSelected
55+
onSelectTab={(id) => props.setSettingValue(TENANT_INITIAL_TAB_KEY, id)}
56+
/>
57+
</div>
58+
);
59+
};
60+
61+
return renderContent();
62+
}
63+
64+
const mapDispatchToProps = {
65+
setSettingValue,
66+
};
67+
68+
export default connect(null, mapDispatchToProps)(ObjectGeneralTabs);

src/containers/Tenant/QueryEditor/QueryEditor.scss

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
&__upper-controls {
4646
position: absolute;
4747
top: -38px;
48-
right: 16px;
48+
right: 20px;
4949

5050
display: flex;
5151
gap: 12px;

src/containers/Tenant/Tenant.tsx

+27-23
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ import qs from 'qs';
77
import EmptyState from '../../components/EmptyState/EmptyState';
88
import {Illustration} from '../../components/Illustration';
99

10-
import ObjectSummary from './ObjectSummary/ObjectSummary';
1110
import {setHeader} from '../../store/reducers/header';
11+
import ObjectGeneralTabs from './ObjectGeneralTabs/ObjectGeneralTabs';
12+
import ObjectSummary from './ObjectSummary/ObjectSummary';
1213
import ObjectGeneral from './ObjectGeneral/ObjectGeneral';
1314
//@ts-ignore
1415
import SplitPane from '../../components/SplitPane';
@@ -131,28 +132,31 @@ function Tenant(props: TenantProps) {
131132
description="You don’t have the necessary roles to view this page."
132133
/>
133134
) : (
134-
<SplitPane
135-
defaultSizePaneKey={DEFAULT_SIZE_TENANT_KEY}
136-
defaultSizes={[25, 75]}
137-
triggerCollapse={summaryVisibilityState.triggerCollapse}
138-
triggerExpand={summaryVisibilityState.triggerExpand}
139-
minSize={[36, 200]}
140-
onSplitStartDragAdditional={onSplitStartDragAdditional}
141-
>
142-
<ObjectSummary
143-
type={currentPathType}
144-
subType={currentPathSubType}
145-
onCollapseSummary={onCollapseSummaryHandler}
146-
onExpandSummary={onExpandSummaryHandler}
147-
isCollapsed={summaryVisibilityState.collapsed}
148-
additionalTenantInfo={props.additionalTenantInfo}
149-
/>
150-
<ObjectGeneral
151-
type={currentPathType}
152-
additionalTenantInfo={props.additionalTenantInfo}
153-
additionalNodesInfo={props.additionalNodesInfo}
154-
/>
155-
</SplitPane>
135+
<>
136+
<ObjectGeneralTabs />
137+
<SplitPane
138+
defaultSizePaneKey={DEFAULT_SIZE_TENANT_KEY}
139+
defaultSizes={[25, 75]}
140+
triggerCollapse={summaryVisibilityState.triggerCollapse}
141+
triggerExpand={summaryVisibilityState.triggerExpand}
142+
minSize={[36, 200]}
143+
onSplitStartDragAdditional={onSplitStartDragAdditional}
144+
>
145+
<ObjectSummary
146+
type={currentPathType}
147+
subType={currentPathSubType}
148+
onCollapseSummary={onCollapseSummaryHandler}
149+
onExpandSummary={onExpandSummaryHandler}
150+
isCollapsed={summaryVisibilityState.collapsed}
151+
additionalTenantInfo={props.additionalTenantInfo}
152+
/>
153+
<ObjectGeneral
154+
type={currentPathType}
155+
additionalTenantInfo={props.additionalTenantInfo}
156+
additionalNodesInfo={props.additionalNodesInfo}
157+
/>
158+
</SplitPane>
159+
</>
156160
)}
157161
</div>
158162
);

0 commit comments

Comments
 (0)