Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing request type field #4414

Merged
merged 4 commits into from
Nov 10, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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