Debian Codegraph @

install/freeipa-webui/src/pages/Configuration/ConfigServerOptions.tsx

raw
1 import React from "react";
2 // PatternFly
3 import { Form, FormGroup, TextArea } from "@patternfly/react-core";
4 // Data types
5 import { Config, Metadata } from "src/utils/datatypes/globalDataTypes";
6 // Form
7 import IpaDropdownSearch from "src/components/Form/IpaDropdownSearch";
8
9 interface PropsToServerOptions {
10 config: Partial<Config>;
11 // eslint-disable-next-line @typescript-eslint/no-explicit-any
12 ipaObject: Record<string, any>;
13 // eslint-disable-next-line @typescript-eslint/no-explicit-any
14 recordOnChange: (ipaObject: Record<string, any>) => void;
15 metadata: Metadata;
16 }
17
18 const ConfigServerOptions = (props: PropsToServerOptions) => {
19 let options = props.config.pkinit_server_server
20 ? [...props.config.pkinit_server_server]
21 : [];
22
23 const handleSearch = (value: string) => {
24 options = options.filter(
25 (item) =>
26 item !== props.config.ca_renewal_master_server &&
27 item.indexOf(value) !== -1
28 );
29 };
30
31 return (
32 <Form className="pf-v6-u-mb-lg pf-v6-u-mt-lg" isHorizontal>
33 <FormGroup
34 label="IPA CA renewal master"
35 fieldId="ca_renewal_master_server"
36 >
37 <IpaDropdownSearch
38 dataCy="configuration-dropdown-renewal-master"
39 id="ca_renewal_master_server"
40 name="ca_renewal_master_server"
41 options={options}
42 ipaObject={props.ipaObject}
43 setIpaObject={props.recordOnChange}
44 objectName="config"
45 metadata={props.metadata}
46 onSearch={handleSearch}
47 />
48 </FormGroup>
49 <FormGroup
50 label="IPA masters capable of PKINIT"
51 fieldId="pkinit_server_server"
52 >
53 <TextArea
54 data-cy="configuration-textbox-pkinit-server"
55 id="pkinit_server_server"
56 name="pkinit_server_server"
57 aria-label="master capable of PKINIT"
58 value={
59 props.config.pkinit_server_server
60 ? props.config.pkinit_server_server.join(", ")
61 : ""
62 }
63 isDisabled
64 />
65 </FormGroup>
66 </Form>
67 );
68 };
69
70 export default ConfigServerOptions;