Skip to content

Commit

Permalink
Refactor the feature flags
Browse files Browse the repository at this point in the history
  • Loading branch information
riccardo-forina committed Jun 14, 2024
1 parent 90bdbb9 commit bf7e240
Show file tree
Hide file tree
Showing 15 changed files with 259 additions and 203 deletions.
7 changes: 5 additions & 2 deletions ui/app/[locale]/AppLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ import { HelpIcon } from "@/libs/patternfly/react-icons";
import { useTranslations } from "next-intl";
import { PropsWithChildren, Suspense } from "react";

export function AppLayout({ children }: PropsWithChildren) {
export function AppLayout({
children,
showLearningLinks,
}: PropsWithChildren<{ showLearningLinks: boolean }>) {
const t = useTranslations();
return (
<Page
Expand All @@ -45,7 +48,7 @@ export function AppLayout({ children }: PropsWithChildren) {
>
{/*<HelpContainer>*/}
<ClusterDrawerProvider>
<ClusterDrawer>
<ClusterDrawer showLearningLinks={showLearningLinks}>
<Banner variant={"blue"}>
<Split>
<SplitItem isFilled={true}>
Expand Down
49 changes: 29 additions & 20 deletions ui/app/[locale]/ClusterConnectionDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@ import {
} from "@/libs/patternfly/react-core";
import { Divider, Stack, StackItem } from "@patternfly/react-core";
import { useTranslations } from "next-intl";
import { enabled as learningLinksEnabled } from "@/utils/learningLinks";

export async function ClusterConnectionDetails({
clusterId,
showLearningLinks,
}: {
clusterId: string;
showLearningLinks: boolean;
}) {
const t = useTranslations();
const data = await getKafkaCluster(clusterId);
Expand Down Expand Up @@ -102,25 +103,33 @@ export async function ClusterConnectionDetails({
</ExpandableSection>
</TextContent>
</StackItem>
{ learningLinksEnabled() &&
<StackItem>
<Divider />
<Stack hasGutter={true} className={"pf-v5-u-p-lg"}>
{ t("learning.links.connecting") &&
<StackItem>
<ExternalLink testId={"drawer-footer-help-1"} href={t("learning.links.connecting")}>
{t("ClusterConnectionDetails.developing_kafka_client_applications",)}
</ExternalLink>
</StackItem>
}
<StackItem>
<ExternalLink testId={"drawer-footer-help-1"} href={t("learning.links.overview")}>
{t("ClusterConnectionDetails.streams_portal")}
</ExternalLink>
</StackItem>
</Stack>
</StackItem>
}
{showLearningLinks && (
<StackItem>
<Divider />
<Stack hasGutter={true} className={"pf-v5-u-p-lg"}>
{t("learning.links.connecting") && (
<StackItem>
<ExternalLink
testId={"drawer-footer-help-1"}
href={t("learning.links.connecting")}
>
{t(
"ClusterConnectionDetails.developing_kafka_client_applications",
)}
</ExternalLink>
</StackItem>
)}
<StackItem>
<ExternalLink
testId={"drawer-footer-help-1"}
href={t("learning.links.overview")}
>
{t("ClusterConnectionDetails.streams_portal")}
</ExternalLink>
</StackItem>
</Stack>
</StackItem>
)}
</Stack>
);
}
12 changes: 10 additions & 2 deletions ui/app/[locale]/ClusterDrawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ import { Skeleton } from "@patternfly/react-core";
import { useTranslations } from "next-intl";
import { PropsWithChildren, Suspense } from "react";

export function ClusterDrawer({ children }: PropsWithChildren) {
export function ClusterDrawer({
children,
showLearningLinks,
}: PropsWithChildren<{ showLearningLinks: boolean }>) {
const t = useTranslations();
const { expanded, clusterId, close } = useClusterDrawerContext();
return (
Expand Down Expand Up @@ -48,7 +51,12 @@ export function ClusterDrawer({ children }: PropsWithChildren) {
</div>
}
>
{clusterId && <ClusterConnectionDetails clusterId={clusterId} />}
{clusterId && (
<ClusterConnectionDetails
clusterId={clusterId}
showLearningLinks={showLearningLinks}
/>
)}
</Suspense>
</DrawerPanelContent>
}
Expand Down
Loading

0 comments on commit bf7e240

Please sign in to comment.