Skip to content

Commit

Permalink
Create connector 404 (#92)
Browse files Browse the repository at this point in the history
+ removed component CreateConnectorButton.tsx
+ added prop showTooltip to Tooltip component
  • Loading branch information
Nilumilak committed Feb 21, 2024
1 parent 81cb57c commit d529c6a
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 42 deletions.
27 changes: 0 additions & 27 deletions frontend/src/components/Connect/List/CreateConnectorButton.tsx

This file was deleted.

37 changes: 24 additions & 13 deletions frontend/src/components/Connect/List/ListPage.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import React, { Suspense } from 'react';
import useAppParams from 'lib/hooks/useAppParams';
import { ClusterNameRoute } from 'lib/paths';
import { ClusterNameRoute, clusterConnectorNewRelativePath } from 'lib/paths';
import ClusterContext from 'components/contexts/ClusterContext';
import Search from 'components/common/Search/Search';
import * as Metrics from 'components/common/Metrics';
import PageHeading from 'components/common/PageHeading/PageHeading';
import Tooltip from 'components/common/Tooltip/Tooltip';
import { ControlPanelWrapper } from 'components/common/ControlPanel/ControlPanel.styled';
import PageLoader from 'components/common/PageLoader/PageLoader';
import { ConnectorState } from 'generated-sources';
import { ConnectorState, Action, ResourceType } from 'generated-sources';
import { useConnectors, useConnects } from 'lib/hooks/api/kafkaConnect';
import { ActionButton } from 'components/common/ActionComponent';

import CreateConnectorButton from './CreateConnectorButton';
import List from './List';

const ListPage: React.FC = () => {
Expand All @@ -34,16 +34,27 @@ const ListPage: React.FC = () => {
return (
<>
<PageHeading text="Connectors">
{!isReadOnly &&
(connects && connects.length > 0 ? (
<CreateConnectorButton />
) : (
<Tooltip
value={<CreateConnectorButton disabled />}
content="No connects available"
placement="left"
/>
))}
{!isReadOnly && (
<Tooltip
value={
<ActionButton
buttonType="primary"
buttonSize="M"
disabled={!connects.length}
to={clusterConnectorNewRelativePath}
permission={{
resource: ResourceType.CONNECT,
action: Action.CREATE,
}}
>
Create Connector
</ActionButton>
}
showTooltip={!connects.length}
content="No Connects available"
placement="left"
/>
)}
</PageHeading>
<Metrics.Wrapper>
<Metrics.Section>
Expand Down
10 changes: 8 additions & 2 deletions frontend/src/components/common/Tooltip/Tooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,15 @@ interface TooltipProps {
value: React.ReactNode;
content: string;
placement?: Placement;
showTooltip?: boolean;
}

const Tooltip: React.FC<TooltipProps> = ({ value, content, placement }) => {
const Tooltip: React.FC<TooltipProps> = ({
value,
content,
placement,
showTooltip = true,
}) => {
const [open, setOpen] = useState(false);
const { x, y, refs, strategy, context } = useFloating({
open,
Expand All @@ -28,7 +34,7 @@ const Tooltip: React.FC<TooltipProps> = ({ value, content, placement }) => {
<div ref={refs.setReference} {...getReferenceProps()}>
<S.Wrapper>{value}</S.Wrapper>
</div>
{open && (
{showTooltip && open && (
<S.MessageTooltip
ref={refs.setFloating}
style={{
Expand Down

0 comments on commit d529c6a

Please sign in to comment.