Skip to content

Commit

Permalink
OS-7978. Add support for "Not Set" region filter
Browse files Browse the repository at this point in the history
  • Loading branch information
ek-hystax authored Nov 13, 2024
1 parent af39756 commit 576441e
Show file tree
Hide file tree
Showing 7 changed files with 235 additions and 165 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { NOT_SET_REGION_FILTER_NAME } from "components/forms/AssignmentRuleForm/FormElements/ConditionsFieldArray";
import KeyValueLabel from "components/KeyValueLabel/KeyValueLabel";
import { intl } from "translations/react-intl-config";
import { CONDITION_TYPES, TAG_IS, CLOUD_IS, TAG_VALUE_STARTS_WITH } from "utils/constants";
import { CONDITION_TYPES, TAG_IS, CLOUD_IS, TAG_VALUE_STARTS_WITH, REGION_IS } from "utils/constants";

const prepareData = ({ assignmentRules, entities }) => {
const translateType = (type) =>
Expand Down Expand Up @@ -36,6 +37,9 @@ const prepareData = ({ assignmentRules, entities }) => {
if (type === CLOUD_IS) {
value = entities?.[metaInfo]?.name;
}
if (type === REGION_IS) {
value = metaInfo === null ? NOT_SET_REGION_FILTER_NAME : metaInfo;
}
return {
...resultObject,
conditionsString: `${resultObject.conditionsString ? `${resultObject.conditionsString},` : ""}${translateType(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ const AssignmentRuleForm = ({
// We need to pass defaultValues to useForm in order to reset the Controller components' value.
// (defaultValues.poolId, defaultValues.ownerId are marked as required in the propTypes definition)
// see https://react-hook-form.com/api#reset
defaultValues,
shouldUnregister: true
defaultValues
});

const { handleSubmit, reset } = methods;
Expand Down Expand Up @@ -71,8 +70,10 @@ const AssignmentRuleForm = ({
};
}
if (REGION_IS_FIELD_NAME in item) {
const { regionName } = item[REGION_IS_FIELD_NAME];

return {
[META_INFO]: item[REGION_IS_FIELD_NAME].trim(),
[META_INFO]: regionName === null ? null : regionName.trim(),
[TYPE]: item[TYPE]
};
}
Expand Down
Loading

0 comments on commit 576441e

Please sign in to comment.