Skip to content

Commit

Permalink
fix(coral): Make all env available when using prefix in ACL request (#…
Browse files Browse the repository at this point in the history
…1145)

when choosing the PREFIXED pattern type in environment Select input in ACL forms, all environments would be disabled and render a wrong state, because the prefix may not be === an existing topic name.

In regards to how the PREFIXED option is used, we should allow all environments to be chosen in this case.

Signed-off-by: Mathieu Anderson <mathieu.anderson@aiven.io>
  • Loading branch information
Mathieu Anderson authored May 11, 2023
1 parent 848d5a2 commit aeeddea
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,23 @@ import { ExtendedEnvironment } from "src/app/features/topics/acl-request/queries
interface EnvironmentFieldProps {
environments: ExtendedEnvironment[];
selectedTopic?: string;
prefixed?: boolean;
}

const getOptions = (
environments: ExtendedEnvironment[],
prefixed: boolean,
topicName?: string
) => {
return environments.map((env) => {
if (prefixed) {
return (
<Option key={env.id} value={env.id}>
{env.name}
</Option>
);
}

if (env.topicNames.length === 0) {
return (
<Option key={env.id} value={env.id} disabled>
Expand Down Expand Up @@ -39,6 +49,7 @@ const getOptions = (
const EnvironmentField = ({
environments,
selectedTopic,
prefixed = false,
}: EnvironmentFieldProps) => {
return (
<NativeSelect
Expand All @@ -47,7 +58,7 @@ const EnvironmentField = ({
placeholder={"-- Please select --"}
required
>
{getOptions(environments, selectedTopic)}
{getOptions(environments, prefixed, selectedTopic)}
</NativeSelect>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ const TopicProducerForm = ({
<EnvironmentField
environments={environments}
selectedTopic={topicname}
prefixed={aclPatternType === "PREFIXED"}
/>
</GridItem>

Expand Down

0 comments on commit aeeddea

Please sign in to comment.