Skip to content

Commit 249011d

Browse files
feat: hide some columns and storage nodes for users-viewers (#1967)
1 parent 99ee997 commit 249011d

File tree

23 files changed

+98
-52
lines changed

23 files changed

+98
-52
lines changed

src/components/PDiskInfo/PDiskInfo.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
import {Flex} from '@gravity-ui/uikit';
22

33
import {getPDiskPagePath} from '../../routes';
4-
import {selectIsUserAllowedToMakeChanges} from '../../store/reducers/authentication/authentication';
54
import {valueIsDefined} from '../../utils';
65
import {formatBytes} from '../../utils/bytesParsers';
76
import {cn} from '../../utils/cn';
87
import {formatStorageValuesToGb} from '../../utils/dataFormatters/dataFormatters';
98
import {createPDiskDeveloperUILink} from '../../utils/developerUI/developerUI';
109
import type {PreparedPDisk} from '../../utils/disks/types';
11-
import {useTypedSelector} from '../../utils/hooks';
10+
import {useIsUserAllowedToMakeChanges} from '../../utils/hooks/useIsUserAllowedToMakeChanges';
1211
import type {InfoViewerItem} from '../InfoViewer';
1312
import {InfoViewer} from '../InfoViewer/InfoViewer';
1413
import {LinkWithIcon} from '../LinkWithIcon/LinkWithIcon';
@@ -189,7 +188,7 @@ export function PDiskInfo<T extends PreparedPDisk>({
189188
withPDiskPageLink,
190189
className,
191190
}: PDiskInfoProps<T>) {
192-
const isUserAllowedToMakeChanges = useTypedSelector(selectIsUserAllowedToMakeChanges);
191+
const isUserAllowedToMakeChanges = useIsUserAllowedToMakeChanges();
193192

194193
const [generalInfo, statusInfo, spaceInfo, additionalInfo] = getPDiskInfo({
195194
pDisk,

src/components/PDiskPopup/PDiskPopup.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import React from 'react';
22

3-
import {selectIsUserAllowedToMakeChanges} from '../../store/reducers/authentication/authentication';
43
import {selectNodesMap} from '../../store/reducers/nodesList';
54
import {EFlag} from '../../types/api/enums';
65
import {valueIsDefined} from '../../utils';
76
import {EMPTY_DATA_PLACEHOLDER} from '../../utils/constants';
87
import {createPDiskDeveloperUILink} from '../../utils/developerUI/developerUI';
98
import type {PreparedPDisk} from '../../utils/disks/types';
109
import {useTypedSelector} from '../../utils/hooks';
10+
import {useIsUserAllowedToMakeChanges} from '../../utils/hooks/useIsUserAllowedToMakeChanges';
1111
import {bytesToGB, isNumeric} from '../../utils/utils';
1212
import {InfoViewer} from '../InfoViewer';
1313
import type {InfoViewerItem} from '../InfoViewer';
@@ -92,7 +92,7 @@ interface PDiskPopupProps {
9292
}
9393

9494
export const PDiskPopup = ({data}: PDiskPopupProps) => {
95-
const isUserAllowedToMakeChanges = useTypedSelector(selectIsUserAllowedToMakeChanges);
95+
const isUserAllowedToMakeChanges = useIsUserAllowedToMakeChanges();
9696
const nodesMap = useTypedSelector(selectNodesMap);
9797
const nodeData = valueIsDefined(data.NodeId) ? nodesMap?.get(data.NodeId) : undefined;
9898
const info = React.useMemo(

src/components/TabletNameWrapper/TabletNameWrapper.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import {DefinitionList, PopoverBehavior} from '@gravity-ui/uikit';
22

33
import {getTabletPagePath} from '../../routes';
4-
import {selectIsUserAllowedToMakeChanges} from '../../store/reducers/authentication/authentication';
54
import {createTabletDeveloperUIHref} from '../../utils/developerUI/developerUI';
6-
import {useTypedSelector} from '../../utils/hooks';
5+
import {useIsUserAllowedToMakeChanges} from '../../utils/hooks/useIsUserAllowedToMakeChanges';
76
import {CellWithPopover} from '../CellWithPopover/CellWithPopover';
87
import {EntityStatus} from '../EntityStatus/EntityStatus';
98
import {LinkWithIcon} from '../LinkWithIcon/LinkWithIcon';
@@ -16,7 +15,7 @@ interface TabletNameWrapperProps {
1615
}
1716

1817
export function TabletNameWrapper({tabletId, database}: TabletNameWrapperProps) {
19-
const isUserAllowedToMakeChanges = useTypedSelector(selectIsUserAllowedToMakeChanges);
18+
const isUserAllowedToMakeChanges = useIsUserAllowedToMakeChanges();
2019

2120
const tabletPath = getTabletPagePath(tabletId, {database});
2221

src/components/TenantNameWrapper/TenantNameWrapper.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import {DefinitionList, PopoverBehavior} from '@gravity-ui/uikit';
22

33
import {getTenantPath} from '../../containers/Tenant/TenantPages';
4-
import {selectIsUserAllowedToMakeChanges} from '../../store/reducers/authentication/authentication';
54
import type {PreparedTenant} from '../../store/reducers/tenants/types';
65
import type {AdditionalTenantsProps, NodeAddress} from '../../types/additionalProps';
7-
import {useTypedSelector} from '../../utils/hooks';
6+
import {useIsUserAllowedToMakeChanges} from '../../utils/hooks/useIsUserAllowedToMakeChanges';
87
import {CellWithPopover} from '../CellWithPopover/CellWithPopover';
98
import {EntityStatus} from '../EntityStatus/EntityStatus';
109
import {LinkWithIcon} from '../LinkWithIcon/LinkWithIcon';
@@ -34,7 +33,7 @@ const getTenantBackend = (
3433
};
3534

3635
export function TenantNameWrapper({tenant, additionalTenantsProps}: TenantNameWrapperProps) {
37-
const isUserAllowedToMakeChanges = useTypedSelector(selectIsUserAllowedToMakeChanges);
36+
const isUserAllowedToMakeChanges = useIsUserAllowedToMakeChanges();
3837

3938
const backend = getTenantBackend(tenant, additionalTenantsProps);
4039
const isExternalLink = Boolean(backend);

src/components/TooltipsContent/NodeEndpointsTooltipContent/NodeEndpointsTooltipContent.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import type {DefinitionListItemProps} from '@gravity-ui/uikit';
22
import {DefinitionList} from '@gravity-ui/uikit';
33

4-
import {selectIsUserAllowedToMakeChanges} from '../../../store/reducers/authentication/authentication';
54
import type {TSystemStateInfo} from '../../../types/api/nodes';
65
import {cn} from '../../../utils/cn';
7-
import {useTypedSelector} from '../../../utils/hooks';
6+
import {useIsUserAllowedToMakeChanges} from '../../../utils/hooks/useIsUserAllowedToMakeChanges';
87
import {LinkWithIcon} from '../../LinkWithIcon/LinkWithIcon';
98

109
import i18n from './i18n';
@@ -19,7 +18,7 @@ interface NodeEdpointsTooltipProps {
1918
}
2019

2120
export const NodeEndpointsTooltipContent = ({data, nodeHref}: NodeEdpointsTooltipProps) => {
22-
const isUserAllowedToMakeChanges = useTypedSelector(selectIsUserAllowedToMakeChanges);
21+
const isUserAllowedToMakeChanges = useIsUserAllowedToMakeChanges();
2322
const info: (DefinitionListItemProps & {key: string})[] = [];
2423

2524
if (data?.Roles?.length) {

src/components/VDiskInfo/VDiskInfo.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
import React from 'react';
22

33
import {getVDiskPagePath} from '../../routes';
4-
import {selectIsUserAllowedToMakeChanges} from '../../store/reducers/authentication/authentication';
54
import {valueIsDefined} from '../../utils';
65
import {cn} from '../../utils/cn';
76
import {formatStorageValuesToGb} from '../../utils/dataFormatters/dataFormatters';
87
import {createVDiskDeveloperUILink} from '../../utils/developerUI/developerUI';
98
import {getSeverityColor} from '../../utils/disks/helpers';
109
import type {PreparedVDisk} from '../../utils/disks/types';
11-
import {useTypedSelector} from '../../utils/hooks';
10+
import {useIsUserAllowedToMakeChanges} from '../../utils/hooks/useIsUserAllowedToMakeChanges';
1211
import {bytesToSpeed} from '../../utils/utils';
1312
import {InfoViewer} from '../InfoViewer';
1413
import type {InfoViewerProps} from '../InfoViewer/InfoViewer';
@@ -35,7 +34,7 @@ export function VDiskInfo<T extends PreparedVDisk>({
3534
withTitle,
3635
...infoViewerProps
3736
}: VDiskInfoProps<T>) {
38-
const isUserAllowedToMakeChanges = useTypedSelector(selectIsUserAllowedToMakeChanges);
37+
const isUserAllowedToMakeChanges = useIsUserAllowedToMakeChanges();
3938

4039
const {
4140
AllocatedSize,

src/components/VDiskPopup/VDiskPopup.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import React from 'react';
22

33
import {Label} from '@gravity-ui/uikit';
44

5-
import {selectIsUserAllowedToMakeChanges} from '../../store/reducers/authentication/authentication';
65
import {selectNodesMap} from '../../store/reducers/nodesList';
76
import {EFlag} from '../../types/api/enums';
87
import {valueIsDefined} from '../../utils';
@@ -12,6 +11,7 @@ import {createVDiskDeveloperUILink} from '../../utils/developerUI/developerUI';
1211
import {isFullVDiskData} from '../../utils/disks/helpers';
1312
import type {PreparedVDisk, UnavailableDonor} from '../../utils/disks/types';
1413
import {useTypedSelector} from '../../utils/hooks';
14+
import {useIsUserAllowedToMakeChanges} from '../../utils/hooks/useIsUserAllowedToMakeChanges';
1515
import {bytesToGB, bytesToSpeed} from '../../utils/utils';
1616
import type {InfoViewerItem} from '../InfoViewer';
1717
import {InfoViewer} from '../InfoViewer';
@@ -178,7 +178,7 @@ interface VDiskPopupProps {
178178
export const VDiskPopup = ({data}: VDiskPopupProps) => {
179179
const isFullData = isFullVDiskData(data);
180180

181-
const isUserAllowedToMakeChanges = useTypedSelector(selectIsUserAllowedToMakeChanges);
181+
const isUserAllowedToMakeChanges = useIsUserAllowedToMakeChanges();
182182

183183
const vdiskInfo = React.useMemo(
184184
() =>

src/components/nodesColumns/constants.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,13 @@ export const NODES_COLUMNS_IDS = {
3535

3636
export type NodesColumnId = ValueOf<typeof NODES_COLUMNS_IDS>;
3737

38+
// Columns, that should displayed only for users with isMonitoringAllowed:true
39+
const MONITORING_USER_COLUMNS_IDS: NodesColumnId[] = ['Pools', 'Memory'];
40+
41+
export function isMonitoringUserNodesColumn(columnId: string): boolean {
42+
return MONITORING_USER_COLUMNS_IDS.includes(columnId as NodesColumnId);
43+
}
44+
3845
// This code is running when module is initialized and correct language may not be set yet
3946
// get functions guarantee that i18n fields will be inited on render with current render language
4047
export const NODES_COLUMNS_TITLES = {

src/containers/Header/Header.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ import {useLocation} from 'react-router-dom';
66

77
import {getConnectToDBDialog} from '../../components/ConnectToDB/ConnectToDBDialog';
88
import {InternalLink} from '../../components/InternalLink';
9-
import {selectIsUserAllowedToMakeChanges} from '../../store/reducers/authentication/authentication';
109
import {useClusterBaseInfo} from '../../store/reducers/cluster/cluster';
1110
import {cn} from '../../utils/cn';
1211
import {DEVELOPER_UI_TITLE} from '../../utils/constants';
1312
import {createDeveloperUIInternalPageHref} from '../../utils/developerUI/developerUI';
1413
import {useTypedSelector} from '../../utils/hooks';
1514
import {useDatabaseFromQuery} from '../../utils/hooks/useDatabaseFromQuery';
15+
import {useIsUserAllowedToMakeChanges} from '../../utils/hooks/useIsUserAllowedToMakeChanges';
1616

1717
import type {RawBreadcrumbItem} from './breadcrumbs';
1818
import {getBreadcrumbs} from './breadcrumbs';
@@ -28,7 +28,7 @@ interface HeaderProps {
2828

2929
function Header({mainPage}: HeaderProps) {
3030
const {page, pageBreadcrumbsOptions} = useTypedSelector((state) => state.header);
31-
const isUserAllowedToMakeChanges = useTypedSelector(selectIsUserAllowedToMakeChanges);
31+
const isUserAllowedToMakeChanges = useIsUserAllowedToMakeChanges();
3232

3333
const clusterInfo = useClusterBaseInfo();
3434

src/containers/Node/NodeStructure/Pdisk.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import {PDiskInfo} from '../../../components/PDiskInfo/PDiskInfo';
1010
import {ProgressViewer} from '../../../components/ProgressViewer/ProgressViewer';
1111
import {StatusIcon} from '../../../components/StatusIcon/StatusIcon';
1212
import {VDiskInfo} from '../../../components/VDiskInfo/VDiskInfo';
13-
import {selectIsUserAllowedToMakeChanges} from '../../../store/reducers/authentication/authentication';
1413
import type {
1514
PreparedStructurePDisk,
1615
PreparedStructureVDisk,
@@ -23,7 +22,7 @@ import {cn} from '../../../utils/cn';
2322
import {DEFAULT_TABLE_SETTINGS} from '../../../utils/constants';
2423
import {formatStorageValuesToGb} from '../../../utils/dataFormatters/dataFormatters';
2524
import {createVDiskDeveloperUILink} from '../../../utils/developerUI/developerUI';
26-
import {useTypedSelector} from '../../../utils/hooks';
25+
import {useIsUserAllowedToMakeChanges} from '../../../utils/hooks/useIsUserAllowedToMakeChanges';
2726
import i18n from '../i18n';
2827

2928
import {PDiskTitleBadge} from './PDiskTitleBadge';
@@ -171,7 +170,7 @@ export function PDisk({
171170
nodeId,
172171
unfolded: unfoldedFromProps,
173172
}: PDiskProps) {
174-
const isUserAllowedToMakeChanges = useTypedSelector(selectIsUserAllowedToMakeChanges);
173+
const isUserAllowedToMakeChanges = useIsUserAllowedToMakeChanges();
175174

176175
const [unfolded, setUnfolded] = React.useState(unfoldedFromProps ?? false);
177176

0 commit comments

Comments
 (0)