ljmotta commented on code in PR #2341: URL: https://github.com/apache/incubator-kie-tools/pull/2341#discussion_r1608240604
########## packages/dmn-editor/src/normalization/autoGenerateDrd.ts: ########## @@ -0,0 +1,205 @@ +/* + * 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 { generateUuid } from "@kie-tools/boxed-expression-component/dist/api"; +import { ExternalDmnsIndex, ExternalModelsIndex, ExternalPmmlsIndex } from "../DmnEditor"; +import { computeDiagramData } from "../store/computed/computeDiagramData"; +import { State } from "../store/Store"; +import { MIN_NODE_SIZES } from "../diagram/nodes/DefaultSizes"; +import { getNodeTypeFromDmnObject } from "../diagram/maths/DmnMaths"; +import { DMN15__tDefinitions } from "@kie-tools/dmn-marshaller/dist/schemas/dmn-1_5/ts-gen/types"; +import { DmnLatestModel } from "@kie-tools/dmn-marshaller"; +import { parseXmlHref } from "../xml/xmlHrefs"; +import { computeIndexedDrd } from "../store/computed/computeIndexes"; +import { getDefaultDrdName } from "../mutations/addOrGetDrd"; +import { addShape } from "../mutations/addShape"; +import { addEdge } from "../mutations/addEdge"; +import { EdgeType, NodeType } from "../diagram/connections/graphStructure"; +import { PositionalNodeHandleId } from "../diagram/connections/PositionalNodeHandles"; + +export async function autoGenerateDrd(args: { + model: State["dmn"]["model"]; + diagram: State["diagram"]; + externalModelsByNamespace: ExternalModelsIndex | undefined; + externalModelTypesByNamespace: { + dmns: ExternalDmnsIndex; + pmmls: ExternalPmmlsIndex; + }; +}) { + // Create DRD + args.model.definitions["dmndi:DMNDI"] = { + ...args.model.definitions["dmndi:DMNDI"], + "dmndi:DMNDiagram": [ + { + "@_id": generateUuid(), + "@_name": getDefaultDrdName({ drdIndex: 0 }), + "@_useAlternativeInputDataShape": false, Review Comment: The modal will popup as soon as the user open the DMN model (e.g. first time opening the Editor). As `false` is the default value for any new model, I've harded code this value. The user still can change this option on the DRD dropdown. -- 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]
