Skip to content

Commit

Permalink
Disable save until all fields are entered
Browse files Browse the repository at this point in the history
Signed-off-by: hemahg <[email protected]>
  • Loading branch information
hemahg committed Dec 20, 2024
1 parent fdf3cd9 commit 5f69629
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { updateConsumerGroup } from "@/api/consumerGroups/actions";
import { Dryrun } from "./Dryrun";
import { LoadingPage } from "./LoadingPage";
import { ResetOffset } from "./ResetOffset";
import { Page } from "@/libs/patternfly/react-core";
import { Page, PageSection } from "@/libs/patternfly/react-core";
import { useTranslations } from "next-intl";
import { useAlert } from "@/components/AlertContext";

Expand Down Expand Up @@ -208,19 +208,21 @@ export function ResetConsumerOffset({
kafkaId,
consumerGroupName,
uniqueOffsets,
true // dryRun
true, // dryRun
);

if (response.payload) {
const res = response.payload;
const offsets: Offset[] = Array.from(res.attributes?.offsets ?? []).map(o => {
return {
const offsets: Offset[] = Array.from(res.attributes?.offsets ?? []).map(
(o) => {
return {
topicId: o.topicId!,
topicName: o.topicName,
partition: o.partition,
offset: o.offset,
}
});
};
},
);

setNewOffsetData(offsets);
setShowDryRun(true);
Expand Down Expand Up @@ -280,7 +282,7 @@ export function ResetConsumerOffset({
};

return (
<Page>
<PageSection isFilled={true} hasOverflowScroll={true}>
{isLoading ? (
<LoadingPage />
) : showDryRun ? (
Expand Down Expand Up @@ -316,6 +318,6 @@ export function ResetConsumerOffset({
cliCommand={generateCliCommand()}
/>
)}
</Page>
</PageSection>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,20 @@ export function ResetOffset({
onOffsetSelect: (value: OffsetValue) => void;
}) {
const t = useTranslations("ConsumerGroupsTable");

const isDisabled =
(selectTopic === "allTopics" ||
(selectTopic === "selectedTopic" &&
offset.topicName &&
(selectPartition === "allPartitions" ||
(selectPartition === "selectedPartition" &&
offset.partition !== undefined)))) &&
(selectOffset === "custom"
? offset.offset
: selectOffset === "specificDateTime"
? offset.offset
: selectOffset === "latest" || selectOffset === "earliest");

return (
<Panel>
<PanelHeader>
Expand Down Expand Up @@ -224,20 +238,14 @@ export function ResetOffset({
<Button
variant="primary"
onClick={handleSave}
isDisabled={isLoading}
isDisabled={isLoading || !isDisabled}
>
{t("save")}
</Button>
<DryrunSelect
openDryrun={openDryrun}
cliCommand={cliCommand}
isDisabled={
selectOffset === "custom"
? !offset.offset
: selectOffset === "specificDateTime"
? !offset.offset
: selectOffset !== "latest" && selectOffset !== "earliest"
}
isDisabled={!isDisabled}
/>
<Button
variant="link"
Expand Down

0 comments on commit 5f69629

Please sign in to comment.