improving creating the package

Issue-ID: CCSDK-2298
Signed-off-by: ShaabanEltanany <shaaban.eltanany.ext@orange.com>
Change-Id: Id50c6d0ee1bf4336e1eba6a9491b15c778cec4e8
diff --git a/cds-ui/designer-client/src/app/modules/feature-modules/packages/configuration-dashboard/configuration-dashboard.component.ts b/cds-ui/designer-client/src/app/modules/feature-modules/packages/configuration-dashboard/configuration-dashboard.component.ts
index fbdfd00..dc5697f 100644
--- a/cds-ui/designer-client/src/app/modules/feature-modules/packages/configuration-dashboard/configuration-dashboard.component.ts
+++ b/cds-ui/designer-client/src/app/modules/feature-modules/packages/configuration-dashboard/configuration-dashboard.component.ts
@@ -284,7 +284,8 @@
 
     checkSkipTypesOfAction() {
         console.log(this.cbaPackage);
-        if (this.cbaPackage.templateTopology.node_templates && this.cbaPackage.templateTopology.workflows) {
+        if (this.cbaPackage.templateTopology && this.cbaPackage.templateTopology.node_templates
+            && this.cbaPackage.templateTopology.workflows) {
             this.goToDesignerMode(this.id);
         } else {
             this.dataTarget = '#exampleModalLong';
diff --git a/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/creationModes/DesignerCreationMode.ts b/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/creationModes/DesignerCreationMode.ts
index a9deb67..e2790d5 100644
--- a/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/creationModes/DesignerCreationMode.ts
+++ b/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/creationModes/DesignerCreationMode.ts
@@ -80,24 +80,25 @@
                 if (!key.includes(cbaPackage.metaData.name)) {
                     files.push({file: key});
                 } else {
-                    // it means this is entry definition
                     insideVlbDefinition = JSON.parse(valueOfFile);
                 }
             });
         }
         console.log(vlbDefinition);
-        vlbDefinition.imports = files;
-        if (insideVlbDefinition && insideVlbDefinition.topology_template) {
-            vlbDefinition.topology_template = insideVlbDefinition.topology_template;
-        }
         console.log(cbaPackage.definitions.dslDefinition.content);
-        if (cbaPackage.definitions.dslDefinition.content) {
+        if (cbaPackage.definitions && cbaPackage.definitions.dslDefinition &&
+            cbaPackage.definitions.dslDefinition.content) {
             vlbDefinition.dsl_definitions = JSON.parse(cbaPackage.definitions.dslDefinition.content);
         }
 
-        if (cbaPackage.templateTopology.content) {
+        vlbDefinition.imports = files;
+        if (insideVlbDefinition && insideVlbDefinition.topology_template) {
+            vlbDefinition.topology_template = insideVlbDefinition.topology_template;
+        } else if (cbaPackage.templateTopology && cbaPackage.templateTopology.content) {
             vlbDefinition.topology_template = JSON.parse(cbaPackage.templateTopology.content);
         }
+
+
         console.log(vlbDefinition);
 
         const value = packageCreationUtils.transformToJson(vlbDefinition);