Skip to content

Commit

Permalink
Fixing request type field (#4414)
Browse files Browse the repository at this point in the history
  • Loading branch information
galvana authored Nov 10, 2023
1 parent e8d934c commit da09d2a
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 68 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ The types of changes are:

### Fixed
- Persist bulk system add filter modal state [#4412](https://github.com/ethyca/fides/pull/4412)
- Fixing labels for request type field [#4414](https://github.com/ethyca/fides/pull/4414)

## [2.23.3](https://github.com/ethyca/fides/compare/2.23.2...2.23.3)

Expand Down
6 changes: 3 additions & 3 deletions clients/admin-ui/cypress/e2e/system-integrations-plus.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ describe("System integrations", () => {
it("should display Request types (enabled-actions) field", () => {
cy.getByTestId("enabled-actions").should("exist");
cy.getByTestId("enabled-actions").within(() => {
cy.contains("access");
cy.contains("erasure");
cy.contains("consent").should("not.exist");
cy.contains("Access");
cy.contains("Erasure");
cy.contains("Consent").should("not.exist");
});
});
});
Expand Down
7 changes: 7 additions & 0 deletions clients/admin-ui/src/features/common/form/inputs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,13 @@ export const SelectInput = ({
components.Option = CustomOption;
}

if (isDisabled) {
// prevent the tags from being removed if the input is disabled
components.MultiValueRemove = function CustomMultiValueRemove() {
return null;
};
}

return (
<Select
options={options}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -410,73 +410,75 @@ const ConnectorParametersForm: React.FC<ConnectorParametersFormProps> = ({
}
)
: null}
{isPlusEnabled &&
connectionOption.supported_actions.length > 1 && (
<Field
id="enabled_actions"
name="enabled_actions"
validate={(value: string[]) => {
let error;
if (!value || value.length === 0) {
error = "At least one request type must be selected";
{isPlusEnabled && (
<Field
id="enabled_actions"
name="enabled_actions"
validate={(value: string[]) => {
let error;
if (!value || value.length === 0) {
error = "At least one request type must be selected";
}
return error;
}}
>
{({
field,
form,
}: {
field: FieldInputProps<string>;
form: any;
}) => (
<FormControl
data-testid="enabled-actions"
display="flex"
isInvalid={
form.touched.enabled_actions &&
form.errors.enabled_actions
}
return error;
}}
>
{({
field,
form,
}: {
field: FieldInputProps<string>;
form: any;
}) => (
<FormControl
data-testid="enabled-actions"
display="flex"
isInvalid={
form.touched.enabled_actions &&
form.errors.enabled_actions
}
isRequired
isRequired
>
{/* Known as enabled_actions throughout the front-end and back-end but it's displayed to the user as "Request types" */}
{getFormLabel("enabled_actions", "Request types")}
<VStack align="flex-start" w="inherit">
<Box width="100%">
<SelectInput
options={connectionOption.supported_actions.map(
(action) => ({
label: _.upperFirst(action),
value: action,
})
)}
fieldName={field.name}
size="sm"
isMulti
isDisabled={
connectionOption.supported_actions.length === 1
}
/>
</Box>
<FormErrorMessage>
{props.errors.enabled_actions}
</FormErrorMessage>
</VStack>
<Tooltip
aria-label="The request types that are supported for this integration."
hasArrow
label="The request types that are supported for this integration."
placement="right-start"
openDelay={500}
>
{/* Known as enabled_actions throughout the front-end and back-end but it's displayed to the user as "Request types" */}
{getFormLabel("enabled_actions", "Request types")}
<VStack align="flex-start" w="inherit">
<Box width="100%">
<SelectInput
options={connectionOption.supported_actions.map(
(action) => ({
label: action,
value: action,
})
)}
fieldName={field.name}
size="sm"
isMulti
/>
</Box>
<FormErrorMessage>
{props.errors.enabled_actions}
</FormErrorMessage>
</VStack>
<Tooltip
aria-label="The request types that are supported for this integration."
hasArrow
label="The request types that are supported for this integration."
placement="right-start"
openDelay={500}
>
<Flex alignItems="center" h="32px">
<CircleHelpIcon
marginLeft="8px"
_hover={{ cursor: "pointer" }}
/>
</Flex>
</Tooltip>
</FormControl>
)}
</Field>
)}
<Flex alignItems="center" h="32px">
<CircleHelpIcon
marginLeft="8px"
_hover={{ cursor: "pointer" }}
/>
</Flex>
</Tooltip>
</FormControl>
)}
</Field>
)}
{SystemType.DATABASE === connectionOption.type &&
!isCreatingConnectionConfig ? (
<DatasetConfigField
Expand Down

0 comments on commit da09d2a

Please sign in to comment.