-
-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Leshe4ka <[email protected]> Co-authored-by: Roman Zabaluev <[email protected]> Co-authored-by: VladSenyuta <[email protected]>
- Loading branch information
1 parent
79553e4
commit fcb007c
Showing
36 changed files
with
653 additions
and
507 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
105 changes: 105 additions & 0 deletions
105
frontend/src/components/Nav/ClusterMenu/ClusterMenu.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
import React, { type FC, useState } from 'react'; | ||
import { Cluster, ClusterFeaturesEnum } from 'generated-sources'; | ||
import * as S from 'components/Nav/Nav.styled'; | ||
import MenuTab from 'components/Nav/Menu/MenuTab'; | ||
import MenuItem from 'components/Nav/Menu/MenuItem'; | ||
import { | ||
clusterACLPath, | ||
clusterAclRelativePath, | ||
clusterBrokerRelativePath, | ||
clusterBrokersPath, | ||
clusterConnectorsPath, | ||
clusterConnectorsRelativePath, | ||
clusterConsumerGroupsPath, | ||
clusterConsumerGroupsRelativePath, | ||
clusterKsqlDbPath, | ||
clusterKsqlDbRelativePath, | ||
clusterSchemasPath, | ||
clusterSchemasRelativePath, | ||
clusterTopicsPath, | ||
clusterTopicsRelativePath, | ||
} from 'lib/paths'; | ||
import { useLocation } from 'react-router-dom'; | ||
|
||
interface ClusterMenuProps { | ||
name: Cluster['name']; | ||
status: Cluster['status']; | ||
features: Cluster['features']; | ||
singleMode?: boolean; | ||
} | ||
|
||
const ClusterMenu: FC<ClusterMenuProps> = ({ | ||
name, | ||
status, | ||
features, | ||
singleMode, | ||
}) => { | ||
const hasFeatureConfigured = (key: ClusterFeaturesEnum) => | ||
features?.includes(key); | ||
const [isOpen, setIsOpen] = useState(!!singleMode); | ||
const location = useLocation(); | ||
|
||
const getIsMenuItemActive = (path: string) => | ||
location.pathname.includes(path); | ||
|
||
return ( | ||
<ul role="menu"> | ||
<MenuTab | ||
title={name} | ||
status={status} | ||
isOpen={isOpen} | ||
toggleClusterMenu={() => setIsOpen((prev) => !prev)} | ||
/> | ||
{isOpen && ( | ||
<S.List> | ||
<MenuItem | ||
isActive={getIsMenuItemActive(clusterBrokerRelativePath)} | ||
to={clusterBrokersPath(name)} | ||
title="Brokers" | ||
/> | ||
<MenuItem | ||
isActive={getIsMenuItemActive(clusterTopicsRelativePath)} | ||
to={clusterTopicsPath(name)} | ||
title="Topics" | ||
/> | ||
<MenuItem | ||
isActive={getIsMenuItemActive(clusterConsumerGroupsRelativePath)} | ||
to={clusterConsumerGroupsPath(name)} | ||
title="Consumers" | ||
/> | ||
{hasFeatureConfigured(ClusterFeaturesEnum.SCHEMA_REGISTRY) && ( | ||
<MenuItem | ||
isActive={getIsMenuItemActive(clusterSchemasRelativePath)} | ||
to={clusterSchemasPath(name)} | ||
title="Schema Registry" | ||
/> | ||
)} | ||
{hasFeatureConfigured(ClusterFeaturesEnum.KAFKA_CONNECT) && ( | ||
<MenuItem | ||
isActive={getIsMenuItemActive(clusterConnectorsRelativePath)} | ||
to={clusterConnectorsPath(name)} | ||
title="Kafka Connect" | ||
/> | ||
)} | ||
{hasFeatureConfigured(ClusterFeaturesEnum.KSQL_DB) && ( | ||
<MenuItem | ||
isActive={getIsMenuItemActive(clusterKsqlDbRelativePath)} | ||
to={clusterKsqlDbPath(name)} | ||
title="KSQL DB" | ||
/> | ||
)} | ||
{(hasFeatureConfigured(ClusterFeaturesEnum.KAFKA_ACL_VIEW) || | ||
hasFeatureConfigured(ClusterFeaturesEnum.KAFKA_ACL_EDIT)) && ( | ||
<MenuItem | ||
isActive={getIsMenuItemActive(clusterAclRelativePath)} | ||
to={clusterACLPath(name)} | ||
title="ACL" | ||
/> | ||
)} | ||
</S.List> | ||
)} | ||
</ul> | ||
); | ||
}; | ||
|
||
export default ClusterMenu; |
9 changes: 7 additions & 2 deletions
9
...onents/Nav/__tests__/ClusterMenu.spec.tsx → ...lusterMenu/__tests__/ClusterMenu.spec.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.