e2corporation commented on code in PR #3371: URL: https://github.com/apache/incubator-devlake/pull/3371#discussion_r992513032
########## config-ui/src/hooks/data-scope/useTransformationsManager.jsx: ########## @@ -0,0 +1,237 @@ +/* + * 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 { useCallback, useState } from 'react' +import { Providers } from '@/data/Providers' +import useDataScopesManager from '@/hooks/useDataScopesManager' +import TransformationSettings from '@/models/TransformationSettings' +import { isEqual } from 'lodash' + +// TODO separate to each plugin +const getDefaultTransformations = (provider) => { + let transforms = {} + switch (provider) { + case Providers.GITHUB: + transforms = { + prType: '', + prComponent: '', + prBodyClosePattern: '', + issueSeverity: '', + issueComponent: '', + issuePriority: '', + issueTypeRequirement: '', + issueTypeBug: '', + issueTypeIncident: '', + refdiff: null, + productionPattern: '', + deploymentPattern: '' + // stagingPattern: '', + // testingPattern: '' + } + break + case Providers.JIRA: + transforms = { + epicKeyField: '', + typeMappings: {}, + storyPointField: '', + remotelinkCommitShaPattern: '', + bugTags: [], + incidentTags: [], + requirementTags: [], + // @todo: verify if jira utilizes deploy tag(s)? + productionPattern: '', + deploymentPattern: '' + // stagingPattern: '', + // testingPattern: '' + } + break + case Providers.JENKINS: + transforms = { + productionPattern: '', + deploymentPattern: '' + // stagingPattern: '', + // testingPattern: '' + } + break + case Providers.GITLAB: + transforms = { + productionPattern: '', + deploymentPattern: '' + // stagingPattern: '', + // testingPattern: '' + } + break + case Providers.TAPD: + // @todo: complete tapd transforms #2673 + transforms = { + issueTypeRequirement: '', + issueTypeBug: '', + issueTypeIncident: '', + productionPattern: '', + deploymentPattern: '' + // stagingPattern: '', + // testingPattern: '' + } + break + } + return transforms +} + +// manage transformations in one place +const useTransformationsManager = () => { + const [transformations, setTransformations] = useState({}) + + const generateKey = ( + connectionProvider, + connectionId, + projectNameOrBoard + ) => { + let key = `not-distinguish` Review Comment: Ok, as a grammatical suggestion `not-distinguished` in past tense may read a bit better. -- 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]
