Loading modules/cloud_dashboard/cloud_dashboard/src/constant/form_template/aws_cloud/network_interface.ts 0 → 100644 +31 −0 Changes for modules/cloud_dashboard/cloud_dashboard/src/constant/form_template/aws_cloud/network_interface.ts: 31 added lines, 0 removed lines. Original line number Diff line number Diff line import EntityFormTemplate from 'model/EntityFormTemplate'; const AWS_CLOUD_NETWORK_INTERFACE_TEMPLATE: EntityFormTemplate[] = [ { cloudServiceProvider: 'aws_cloud', entityName: 'network_interface', actionType: 'create', entityRecords: [ { type: 'panel', panelName: 'Network interface', keyValueRecords: [ { type: 'default', labelName: 'Name', name: 'name', defaultValue: '' }, { type: 'default', labelName: 'Description', name: 'description', defaultValue: '' }, { type: 'select', labelName: 'Subnet', name: 'subnet_id', url: '/cloud_dashboard/aws_cloud/{cloud_context}/aws_cloud_network_interface/subnet_options', defaultValue: '' }, { type: 'multi-select', labelName: 'Security groups', name: 'security_groups', url: '/cloud_dashboard/aws_cloud/{cloud_context}/aws_cloud_network_interface/security_group_options/{subnet_id}', defaultValue: [] }, ] } ] }, ] export default AWS_CLOUD_NETWORK_INTERFACE_TEMPLATE; modules/cloud_dashboard/cloud_dashboard/src/constant/form_template/entity_form_template.ts +3 −1 Changes for modules/cloud_dashboard/cloud_dashboard/src/constant/form_template/entity_form_template.ts: 3 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -4,10 +4,11 @@ import AWS_CLOUD_IMAGE_TEMPLATE from 'constant/form_template/aws_cloud/image'; import AWS_CLOUD_INSTANCE_TEMPLATE from 'constant/form_template/aws_cloud/instance'; import AWS_CLOUD_INTERNET_GATEWAY_TEMPLATE from 'constant/form_template/aws_cloud/internet_gateway'; import AWS_CLOUD_KEY_PAIR_TEMPLATE from 'constant/form_template/aws_cloud/key_pair'; import AWS_CLOUD_NETWORK_INTERFACE_TEMPLATE from 'constant/form_template/aws_cloud/network_interface'; import AWS_CLOUD_SECURITY_GROUP_TEMPLATE from 'constant/form_template/aws_cloud/security_group'; import AWS_CLOUD_SUBNET_TEMPLATE from 'constant/form_template/aws_cloud/subnet'; import AWS_CLOUD_TRANSIT_GATEWAY_TEMPLATE from 'constant/form_template/aws_cloud/transit_gateway'; import AWS_CLOUD_VPC_TEMPLATE from 'constant/form_template/aws_cloud/vpc'; import AWS_CLOUD_SUBNET_TEMPLATE from 'constant/form_template/aws_cloud/subnet'; import K8S_DEPLOYMENT_TEMPLATE from 'constant/form_template/k8s/deployment'; import K8S_NAMESPACE_TEMPLATE from 'constant/form_template/k8s/namespace'; import K8S_OTHER_TEMPLATE from 'constant/form_template/k8s/other'; Loading @@ -27,6 +28,7 @@ const ENTITY_FORM_LIST = [ ...AWS_CLOUD_ELASTIC_IP_TEMPLATE, ...AWS_CLOUD_IMAGE_TEMPLATE, ...AWS_CLOUD_INSTANCE_TEMPLATE, ...AWS_CLOUD_NETWORK_INTERFACE_TEMPLATE, ...AWS_CLOUD_KEY_PAIR_TEMPLATE, ...AWS_CLOUD_SECURITY_GROUP_TEMPLATE, ...AWS_CLOUD_CARRIER_GATEWAY_TEMPLATE, Loading modules/cloud_dashboard/cloud_dashboard/src/molecules/EntityFormBlock.tsx +1 −0 Changes for modules/cloud_dashboard/cloud_dashboard/src/molecules/EntityFormBlock.tsx: 1 added line, 0 removed lines. Original line number Diff line number Diff line Loading @@ -120,6 +120,7 @@ const EntityFormBlock = ({ keyValueRecord, cloudContext, formData, setFormData } label={keyValueRecord.labelName} value={value} setValue={setValue} formData={formData} url={keyValueRecord.url} cloudContext={cloudContext} required={!!keyValueRecord.required} />; Loading modules/cloud_dashboard/cloud_dashboard/src/molecules/MultiSelectBlock.tsx +1 −1 Changes for modules/cloud_dashboard/cloud_dashboard/src/molecules/MultiSelectBlock.tsx: 1 added line, 1 removed line. Original line number Diff line number Diff line Loading @@ -25,7 +25,7 @@ const MultiSelectBlock = ({ }}> { recordList.map((d) => { return <option key={d.label} value={d.label}>{d.label}</option>; return <option key={d.value} value={d.value}>{d.label}</option>; }) } </Form.Select> Loading modules/cloud_dashboard/cloud_dashboard/src/molecules/UrlMultiSelectBlock.tsx +17 −2 Changes for modules/cloud_dashboard/cloud_dashboard/src/molecules/UrlMultiSelectBlock.tsx: 17 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -8,10 +8,11 @@ import { useParams } from 'react-router-dom'; * * @param */ const UrlMultiSelectBlock = ({ label, value, setValue, url, cloudContext, required }: { const UrlMultiSelectBlock = ({ label, value, setValue, formData, url, cloudContext, required }: { label: string, value: string[], setValue: (s: string[]) => void, formData: Record<string, any>, url: string, cloudContext: string, required: boolean, Loading @@ -29,14 +30,28 @@ const UrlMultiSelectBlock = ({ label, value, setValue, url, cloudContext, requir const [recordList, setRecordList] = useState<{ value: string, label: string, group?: string }[]>([]); useEffect(() => { // Replace the part of the URL that corresponds to the keyword. let replacedUrl = url .replace('{cloud_context}', cloudContext) .replace('{entity_id}', params.entityId); const result = replacedUrl.match(/\{[^{}]+\}/g); if (result !== null) { for (const pattern of result) { const key = pattern.substring(1, pattern.length - 1); replacedUrl = replacedUrl.replace(pattern, `${formData[key]}`); } } if (replacedUrl.endsWith('/')) { replacedUrl = replacedUrl.substring(0, replacedUrl.length - 1); } getJsonData<{ value: string, label: string, group?: string }[]>(replacedUrl).then((jsonData) => { setRecordList(jsonData); if (value.length !== 0) { setValue([]); } }) // eslint-disable-next-line react-hooks/exhaustive-deps }, [cloudContext]); }, [cloudContext, formData]); return <MultiSelectBlock label={label} Loading Loading
modules/cloud_dashboard/cloud_dashboard/src/constant/form_template/aws_cloud/network_interface.ts 0 → 100644 +31 −0 Changes for modules/cloud_dashboard/cloud_dashboard/src/constant/form_template/aws_cloud/network_interface.ts: 31 added lines, 0 removed lines. Original line number Diff line number Diff line import EntityFormTemplate from 'model/EntityFormTemplate'; const AWS_CLOUD_NETWORK_INTERFACE_TEMPLATE: EntityFormTemplate[] = [ { cloudServiceProvider: 'aws_cloud', entityName: 'network_interface', actionType: 'create', entityRecords: [ { type: 'panel', panelName: 'Network interface', keyValueRecords: [ { type: 'default', labelName: 'Name', name: 'name', defaultValue: '' }, { type: 'default', labelName: 'Description', name: 'description', defaultValue: '' }, { type: 'select', labelName: 'Subnet', name: 'subnet_id', url: '/cloud_dashboard/aws_cloud/{cloud_context}/aws_cloud_network_interface/subnet_options', defaultValue: '' }, { type: 'multi-select', labelName: 'Security groups', name: 'security_groups', url: '/cloud_dashboard/aws_cloud/{cloud_context}/aws_cloud_network_interface/security_group_options/{subnet_id}', defaultValue: [] }, ] } ] }, ] export default AWS_CLOUD_NETWORK_INTERFACE_TEMPLATE;
modules/cloud_dashboard/cloud_dashboard/src/constant/form_template/entity_form_template.ts +3 −1 Changes for modules/cloud_dashboard/cloud_dashboard/src/constant/form_template/entity_form_template.ts: 3 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -4,10 +4,11 @@ import AWS_CLOUD_IMAGE_TEMPLATE from 'constant/form_template/aws_cloud/image'; import AWS_CLOUD_INSTANCE_TEMPLATE from 'constant/form_template/aws_cloud/instance'; import AWS_CLOUD_INTERNET_GATEWAY_TEMPLATE from 'constant/form_template/aws_cloud/internet_gateway'; import AWS_CLOUD_KEY_PAIR_TEMPLATE from 'constant/form_template/aws_cloud/key_pair'; import AWS_CLOUD_NETWORK_INTERFACE_TEMPLATE from 'constant/form_template/aws_cloud/network_interface'; import AWS_CLOUD_SECURITY_GROUP_TEMPLATE from 'constant/form_template/aws_cloud/security_group'; import AWS_CLOUD_SUBNET_TEMPLATE from 'constant/form_template/aws_cloud/subnet'; import AWS_CLOUD_TRANSIT_GATEWAY_TEMPLATE from 'constant/form_template/aws_cloud/transit_gateway'; import AWS_CLOUD_VPC_TEMPLATE from 'constant/form_template/aws_cloud/vpc'; import AWS_CLOUD_SUBNET_TEMPLATE from 'constant/form_template/aws_cloud/subnet'; import K8S_DEPLOYMENT_TEMPLATE from 'constant/form_template/k8s/deployment'; import K8S_NAMESPACE_TEMPLATE from 'constant/form_template/k8s/namespace'; import K8S_OTHER_TEMPLATE from 'constant/form_template/k8s/other'; Loading @@ -27,6 +28,7 @@ const ENTITY_FORM_LIST = [ ...AWS_CLOUD_ELASTIC_IP_TEMPLATE, ...AWS_CLOUD_IMAGE_TEMPLATE, ...AWS_CLOUD_INSTANCE_TEMPLATE, ...AWS_CLOUD_NETWORK_INTERFACE_TEMPLATE, ...AWS_CLOUD_KEY_PAIR_TEMPLATE, ...AWS_CLOUD_SECURITY_GROUP_TEMPLATE, ...AWS_CLOUD_CARRIER_GATEWAY_TEMPLATE, Loading
modules/cloud_dashboard/cloud_dashboard/src/molecules/EntityFormBlock.tsx +1 −0 Changes for modules/cloud_dashboard/cloud_dashboard/src/molecules/EntityFormBlock.tsx: 1 added line, 0 removed lines. Original line number Diff line number Diff line Loading @@ -120,6 +120,7 @@ const EntityFormBlock = ({ keyValueRecord, cloudContext, formData, setFormData } label={keyValueRecord.labelName} value={value} setValue={setValue} formData={formData} url={keyValueRecord.url} cloudContext={cloudContext} required={!!keyValueRecord.required} />; Loading
modules/cloud_dashboard/cloud_dashboard/src/molecules/MultiSelectBlock.tsx +1 −1 Changes for modules/cloud_dashboard/cloud_dashboard/src/molecules/MultiSelectBlock.tsx: 1 added line, 1 removed line. Original line number Diff line number Diff line Loading @@ -25,7 +25,7 @@ const MultiSelectBlock = ({ }}> { recordList.map((d) => { return <option key={d.label} value={d.label}>{d.label}</option>; return <option key={d.value} value={d.value}>{d.label}</option>; }) } </Form.Select> Loading
modules/cloud_dashboard/cloud_dashboard/src/molecules/UrlMultiSelectBlock.tsx +17 −2 Changes for modules/cloud_dashboard/cloud_dashboard/src/molecules/UrlMultiSelectBlock.tsx: 17 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -8,10 +8,11 @@ import { useParams } from 'react-router-dom'; * * @param */ const UrlMultiSelectBlock = ({ label, value, setValue, url, cloudContext, required }: { const UrlMultiSelectBlock = ({ label, value, setValue, formData, url, cloudContext, required }: { label: string, value: string[], setValue: (s: string[]) => void, formData: Record<string, any>, url: string, cloudContext: string, required: boolean, Loading @@ -29,14 +30,28 @@ const UrlMultiSelectBlock = ({ label, value, setValue, url, cloudContext, requir const [recordList, setRecordList] = useState<{ value: string, label: string, group?: string }[]>([]); useEffect(() => { // Replace the part of the URL that corresponds to the keyword. let replacedUrl = url .replace('{cloud_context}', cloudContext) .replace('{entity_id}', params.entityId); const result = replacedUrl.match(/\{[^{}]+\}/g); if (result !== null) { for (const pattern of result) { const key = pattern.substring(1, pattern.length - 1); replacedUrl = replacedUrl.replace(pattern, `${formData[key]}`); } } if (replacedUrl.endsWith('/')) { replacedUrl = replacedUrl.substring(0, replacedUrl.length - 1); } getJsonData<{ value: string, label: string, group?: string }[]>(replacedUrl).then((jsonData) => { setRecordList(jsonData); if (value.length !== 0) { setValue([]); } }) // eslint-disable-next-line react-hooks/exhaustive-deps }, [cloudContext]); }, [cloudContext, formData]); return <MultiSelectBlock label={label} Loading