-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: hemahg <[email protected]>
- Loading branch information
Showing
10 changed files
with
148 additions
and
66 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 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,10 @@ | ||
import { createContext, useContext } from "react"; | ||
|
||
export const ReconciliationContext = createContext<{ | ||
isReconciliationPaused: boolean; | ||
setReconciliationPaused: (paused: boolean) => void; | ||
}>(null!); | ||
|
||
export function useReconciliationContext() { | ||
return useContext(ReconciliationContext); | ||
} |
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,50 @@ | ||
|
||
"use client"; | ||
|
||
import { Banner, Bullseye, Button, FlexItem, Flex } from "@/libs/patternfly/react-core"; | ||
import { useTranslations } from "next-intl"; | ||
import { useReconciliationContext } from "./ReconciliationContext"; | ||
import { updateKafkaCluster } from "@/api/kafka/actions"; | ||
|
||
export function ReconciliationPausedBanner({ kafkaId }: { kafkaId: string | undefined }) { | ||
const t = useTranslations(); | ||
|
||
const { isReconciliationPaused, setReconciliationPaused } = useReconciliationContext(); | ||
|
||
const resumeReconciliation = async () => { | ||
if (!kafkaId) { | ||
console.log("kafkaId is undefined"); | ||
return; | ||
} | ||
|
||
try { | ||
const success = await updateKafkaCluster(kafkaId, false); | ||
|
||
if (success) { | ||
setReconciliationPaused(false); | ||
} | ||
} catch (e: unknown) { | ||
console.log("Unknown error occurred"); | ||
} | ||
} | ||
|
||
return ( | ||
isReconciliationPaused && ( | ||
<Banner variant="gold"> | ||
<Bullseye> | ||
<Flex> | ||
<FlexItem spacer={{ default: "spacerNone" }}> | ||
{t("reconciliation.reconciliation_paused_warning")} | ||
</FlexItem> | ||
<FlexItem spacer={{ default: "spacerLg" }}> | ||
<Button variant="link" isInline onClick={resumeReconciliation}> | ||
{t("reconciliation.resume")} | ||
</Button> | ||
</FlexItem> | ||
</Flex> | ||
</Bullseye> | ||
</Banner> | ||
) | ||
) | ||
} | ||
|
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,25 @@ | ||
"use client"; | ||
|
||
import { useState } from "react"; | ||
import { ReconciliationContext } from "./ReconciliationContext"; | ||
|
||
export function ReconciliationProvider({ | ||
children, | ||
}: { | ||
children: React.ReactNode; | ||
}) { | ||
const [isReconciliationPaused, setIsReconciliationPaused] = | ||
useState<boolean>(false); | ||
|
||
const setReconciliationPaused = (paused: boolean) => { | ||
setIsReconciliationPaused(paused); | ||
}; | ||
|
||
return ( | ||
<ReconciliationContext.Provider | ||
value={{ isReconciliationPaused, setReconciliationPaused }} | ||
> | ||
{children} | ||
</ReconciliationContext.Provider> | ||
); | ||
} |
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