aswathitv commented on code in PR #3607: URL: https://github.com/apache/incubator-kie-tools/pull/3607#discussion_r3319398681
########## packages/bpmn-editor-envelope/src/customTasks/RestServiceTaskPropertiesPanel.tsx: ########## @@ -0,0 +1,1126 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import * as React from "react"; +import { CustomTask } from "@kie-tools/bpmn-editor/dist/BpmnEditor"; +import { generateUuid } from "@kie-tools/xyflow-react-kie-diagram/dist/uuid/uuid"; +import { useBpmnEditorStoreApi } from "@kie-tools/bpmn-editor/dist/store/StoreContext"; +import { useKogitoEditorEnvelopeContext, ChannelType } from "@kie-tools-core/editor/dist/api"; +import { useBpmnEditorChannelType } from "../BpmnMultiplyingArchitectureEditorFactory"; +import { PropertiesPanelHeaderFormSection } from "@kie-tools/bpmn-editor/dist/propertiesPanel/singleNodeProperties/_PropertiesPanelHeaderFormSection"; +import { NameDocumentationAndId } from "@kie-tools/bpmn-editor/dist/propertiesPanel/nameDocumentationAndId/NameDocumentationAndId"; +import { Select, SelectList, SelectOption } from "@patternfly/react-core/dist/js/components/Select"; +import { MenuToggle, MenuToggleElement } from "@patternfly/react-core/dist/js/components/MenuToggle"; +import { + BidirectionalDataMappingFormSection, + useDataMapping, +} from "@kie-tools/bpmn-editor/dist/propertiesPanel/dataMapping/DataMappingFormSection"; +import { OnEntryAndExitScriptsFormSection } from "@kie-tools/bpmn-editor/dist/propertiesPanel/onEntryAndExitScripts/OnEntryAndExitScriptsFormSection"; +import { FormGroup, FormSection, ActionGroup, FormHelperText } from "@patternfly/react-core/dist/js/components/Form"; +import { TextInput } from "@patternfly/react-core/dist/js/components/TextInput"; +import { TextArea } from "@patternfly/react-core/dist/js/components/TextArea"; +import { InputGroup, InputGroupItem } from "@patternfly/react-core/dist/js/components/InputGroup"; +import { Button } from "@patternfly/react-core/dist/js/components/Button"; +import { Alert } from "@patternfly/react-core/dist/js/components/Alert"; +import { Checkbox } from "@patternfly/react-core/dist/js/components/Checkbox"; +import { HelperText, HelperTextItem } from "@patternfly/react-core/dist/js/components/HelperText"; +import { Grid, GridItem } from "@patternfly/react-core/dist/js/layouts/Grid"; +import { PlusCircleIcon } from "@patternfly/react-icons/dist/js/icons/plus-circle-icon"; +import { TimesIcon } from "@patternfly/react-icons/dist/js/icons/times-icon"; +import { bpmnEditorEnvelopeI18nDefaults, bpmnEditorEnvelopeI18nDictionaries } from "../i18n"; +import { I18n } from "@kie-tools-core/i18n/dist/core"; +import { DataMapping, setDataMappingForElement } from "@kie-tools/bpmn-editor/dist/mutations/_dataMapping"; +import { DEFAULT_DATA_TYPES } from "@kie-tools/bpmn-editor/dist/mutations/addOrGetItemDefinitions"; +import { BpmnEditorChannelApi } from "../BpmnEditorChannelApi"; +import { MessageBusClientApi } from "@kie-tools-core/envelope-bus/dist/api"; +import { + RestProperties, + REST_TASK_ICON, + REST_PROPERTIES_DATA_TYPES, + REST_PROPERTIES_KEYS, + HTTP_METHODS_OPTIONS, + AUTH_STRATEGIES_OPTIONS, + HttpMethod, + AuthStrategy, +} from "./RestServiceTaskConstants"; +import { ContentDataInput } from "./ContentDataInput"; +import "@kie-tools/bpmn-editor/dist/propertiesPanel/metadata/Metadata.css"; + +export type HeaderParameter = { + id: string; + name: string; + value: string; +}; + +export type QueryParameter = { + id: string; + name: string; + value: string; +}; + +export type ContentDataVariable = { + variableName: string; + variableValue: string | null; +}; + +export const RestServiceTaskPropertiesPanel: CustomTask["propertiesPanelComponent"] = ({ task }) => { + const i18n = new I18n(bpmnEditorEnvelopeI18nDefaults, bpmnEditorEnvelopeI18nDictionaries).getCurrent(); + const bpmnEditorStoreApi = useBpmnEditorStoreApi(); + const { inputDataMapping, outputDataMapping } = useDataMapping(task, () => {}); + const envelopeContext = useKogitoEditorEnvelopeContext(); + const channelApi = envelopeContext.channelApi as unknown as MessageBusClientApi<BpmnEditorChannelApi>; + + const [localUrl, setLocalUrl] = React.useState<string>(""); + const [localProtocol, setLocalProtocol] = React.useState<string>(""); + const [localHost, setLocalHost] = React.useState<string>(""); + const [localPort, setLocalPort] = React.useState<string>(""); + const [localRequestTimeout, setLocalRequestTimeout] = React.useState<string>(""); + const [localRestServiceCallTaskId, setLocalRestServiceCallTaskId] = React.useState<string>(""); + + const dataInputVariables = React.useMemo( + () => + inputDataMapping + ?.filter((data) => data.name && !(REST_PROPERTIES_KEYS as readonly string[]).includes(data.name)) + ?.map((v) => v?.name) + ?.filter((name): name is string => name !== undefined), + [inputDataMapping] + ); + + const channelType = useBpmnEditorChannelType(); + const isVSCode = React.useMemo( + () => channelType === ChannelType.VSCODE_DESKTOP || channelType === ChannelType.VSCODE_WEB, + [channelType] + ); + + const [testResult, setTestResult] = React.useState<{ status: number; data?: any } | null>(null); + const [testError, setTestError] = React.useState<string | null>(null); + const [isLoading, setIsLoading] = React.useState(false); + const [testToken, setTestToken] = React.useState<string>(""); + const [useCorsProxy, setUseCorsProxy] = React.useState<boolean>(false); + const [isMethodDropdownOpen, setIsMethodDropdownOpen] = React.useState(false); + const [isAuthStrategyDropdownOpen, setIsAuthStrategyDropdownOpen] = React.useState(false); + + const [headers, setHeaders] = React.useState<HeaderParameter[]>([]); + const [queryParams, setQueryParams] = React.useState<QueryParameter[]>([]); + const [contentDataVariables, setContentDataVariables] = React.useState<ContentDataVariable[]>([]); + const [contentDataValue, setContentDataValue] = React.useState<string>(""); + const headerIdMapRef = React.useRef<Map<string, string>>(new Map()); + const queryIdMapRef = React.useRef<Map<string, string>>(new Map()); + const entryStyle = { + padding: "4px", + margin: "8px", + width: "calc(100% - 2 * 4px - 2 * 8px)", + }; Review Comment: This is the same style used in Metadata.tsx and Import.tsx. Patternfly is not available -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
