-
Notifications
You must be signed in to change notification settings - Fork 17
feat(Header): add manage DB dropdown #2680
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,23 +1,41 @@ | ||||||||||||||||||||||||||
| import React from 'react'; | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| import {ArrowUpRightFromSquare, CirclePlus, PlugConnection} from '@gravity-ui/icons'; | ||||||||||||||||||||||||||
| import {Breadcrumbs, Button, Divider, Flex, Icon} from '@gravity-ui/uikit'; | ||||||||||||||||||||||||||
| import {useLocation} from 'react-router-dom'; | ||||||||||||||||||||||||||
| import { | ||||||||||||||||||||||||||
| ArrowUpRightFromSquare, | ||||||||||||||||||||||||||
| ChevronDown, | ||||||||||||||||||||||||||
| CirclePlus, | ||||||||||||||||||||||||||
| Pencil, | ||||||||||||||||||||||||||
| PlugConnection, | ||||||||||||||||||||||||||
| TrashBin, | ||||||||||||||||||||||||||
| } from '@gravity-ui/icons'; | ||||||||||||||||||||||||||
| import type {DropdownMenuItem, DropdownMenuProps} from '@gravity-ui/uikit'; | ||||||||||||||||||||||||||
| import {Breadcrumbs, Button, Divider, DropdownMenu, Flex, Icon} from '@gravity-ui/uikit'; | ||||||||||||||||||||||||||
| import {skipToken} from '@reduxjs/toolkit/query'; | ||||||||||||||||||||||||||
| import {useHistory, useLocation} from 'react-router-dom'; | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| import {getConnectToDBDialog} from '../../components/ConnectToDB/ConnectToDBDialog'; | ||||||||||||||||||||||||||
| import {InternalLink} from '../../components/InternalLink'; | ||||||||||||||||||||||||||
| import {useAddClusterFeatureAvailable} from '../../store/reducers/capabilities/hooks'; | ||||||||||||||||||||||||||
| import { | ||||||||||||||||||||||||||
| useAddClusterFeatureAvailable, | ||||||||||||||||||||||||||
| useDeleteDatabaseFeatureAvailable, | ||||||||||||||||||||||||||
| useEditDatabaseFeatureAvailable, | ||||||||||||||||||||||||||
| } from '../../store/reducers/capabilities/hooks'; | ||||||||||||||||||||||||||
| import {useClusterBaseInfo} from '../../store/reducers/cluster/cluster'; | ||||||||||||||||||||||||||
| import {tenantApi} from '../../store/reducers/tenant/tenant'; | ||||||||||||||||||||||||||
| import {uiFactory} from '../../uiFactory/uiFactory'; | ||||||||||||||||||||||||||
| import {cn} from '../../utils/cn'; | ||||||||||||||||||||||||||
| import {DEVELOPER_UI_TITLE} from '../../utils/constants'; | ||||||||||||||||||||||||||
| import {createDeveloperUIInternalPageHref} from '../../utils/developerUI/developerUI'; | ||||||||||||||||||||||||||
| import {useTypedSelector} from '../../utils/hooks'; | ||||||||||||||||||||||||||
| import {useDatabaseFromQuery} from '../../utils/hooks/useDatabaseFromQuery'; | ||||||||||||||||||||||||||
| import { | ||||||||||||||||||||||||||
| useClusterNameFromQuery, | ||||||||||||||||||||||||||
| useDatabaseFromQuery, | ||||||||||||||||||||||||||
| } from '../../utils/hooks/useDatabaseFromQuery'; | ||||||||||||||||||||||||||
| import { | ||||||||||||||||||||||||||
| useIsUserAllowedToMakeChanges, | ||||||||||||||||||||||||||
| useIsViewerUser, | ||||||||||||||||||||||||||
| } from '../../utils/hooks/useIsUserAllowedToMakeChanges'; | ||||||||||||||||||||||||||
| import {getClusterPath} from '../Cluster/utils'; | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| import {getBreadcrumbs} from './breadcrumbs'; | ||||||||||||||||||||||||||
| import {headerKeyset} from './i18n'; | ||||||||||||||||||||||||||
|
|
@@ -35,13 +53,29 @@ function Header() { | |||||||||||||||||||||||||
| const {title: clusterTitle} = useClusterBaseInfo(); | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| const database = useDatabaseFromQuery(); | ||||||||||||||||||||||||||
| const clusterName = useClusterNameFromQuery(); | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| const location = useLocation(); | ||||||||||||||||||||||||||
| const history = useHistory(); | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| const isDatabasePage = location.pathname === '/tenant'; | ||||||||||||||||||||||||||
| const isClustersPage = location.pathname === '/clusters'; | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| const isAddClusterAvailable = | ||||||||||||||||||||||||||
| useAddClusterFeatureAvailable() && uiFactory.onAddCluster !== undefined; | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| const isEditDBAvailable = useEditDatabaseFeatureAvailable() && uiFactory.onEditDB !== undefined; | ||||||||||||||||||||||||||
| const isDeleteDBAvailable = | ||||||||||||||||||||||||||
| useDeleteDatabaseFeatureAvailable() && uiFactory.onDeleteDB !== undefined; | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| const shouldRequestTenantData = | ||||||||||||||||||||||||||
| database && isDatabasePage && (isEditDBAvailable || isDeleteDBAvailable); | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| const params = shouldRequestTenantData ? {path: database, clusterName} : skipToken; | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| const {currentData: databaseData, isLoading: isDatabaseDataLoading} = | ||||||||||||||||||||||||||
| tenantApi.useGetTenantInfoQuery(params); | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| const breadcrumbItems = React.useMemo(() => { | ||||||||||||||||||||||||||
| let options = { | ||||||||||||||||||||||||||
| ...pageBreadcrumbsOptions, | ||||||||||||||||||||||||||
|
|
@@ -82,6 +116,57 @@ function Header() { | |||||||||||||||||||||||||
| {headerKeyset('connect')} | ||||||||||||||||||||||||||
| </Button>, | ||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| const menuItems: DropdownMenuItem[] = []; | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| const {onEditDB, onDeleteDB} = uiFactory; | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| const isEnoughtData = clusterName && databaseData; | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| if (isEditDBAvailable && onEditDB && isEnoughtData) { | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
| const isEnoughtData = clusterName && databaseData; | |
| if (isEditDBAvailable && onEditDB && isEnoughtData) { | |
| const isEnoughData = clusterName && databaseData; | |
| if (isEditDBAvailable && onEditDB && isEnoughData) { |
Outdated
Copilot
AI
Aug 6, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The variable 'isEnoughtData' contains a spelling error. It should be 'isEnoughData' (missing 'u' in 'enough').
| const isEnoughtData = clusterName && databaseData; | |
| if (isEditDBAvailable && onEditDB && isEnoughtData) { | |
| const isEnoughData = clusterName && databaseData; | |
| if (isEditDBAvailable && onEditDB && isEnoughData) { |
Outdated
Copilot
AI
Aug 6, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The variable 'isEnoughtData' contains a spelling error. It should be 'isEnoughData' (missing 'u' in 'enough').
| if (isDeleteDBAvailable && onDeleteDB && isEnoughtData) { | |
| if (isDeleteDBAvailable && onDeleteDB && isEnoughData) { |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need to define className, just use theme: 'danger',
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, there wasn't such option previously, fixed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it may be removed after using
theme: 'danger',for menu item