Skip to content

Commit

Permalink
Change default namespace handling in YAML
Browse files Browse the repository at this point in the history
  • Loading branch information
ghareeb-falazi committed Jan 27, 2020
1 parent d6aeb12 commit dfaef76
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 13 deletions.
Expand Up @@ -55,7 +55,8 @@ export enum ServiceTemplateTemplateTypes {

export enum StartNamespaces {
LocalStorageEntry = 'defaultNamespace',
DefaultStartNamespace = 'http://www.example.org/tosca'
DefaultStartNamespace = 'http://www.example.org/tosca',
DefaultStartNamespaceYaml= 'example.org.tosca'
}

/**
Expand Down
Expand Up @@ -11,14 +11,15 @@
*
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
*******************************************************************************/
import {Component, ElementRef, forwardRef, Input, OnInit, ViewChild} from '@angular/core';
import {WineryNamespaceSelectorService} from './wineryNamespaceSelector.service';
import {WineryNotificationService} from '../wineryNotificationModule/wineryNotification.service';
import {ControlValueAccessor, NG_VALUE_ACCESSOR} from '@angular/forms';
import {NamespaceProperties} from '../model/namespaceProperties';
import {StartNamespaces, ToscaTypes} from '../model/enums';
import {isNullOrUndefined} from 'util';
import { Component, ElementRef, forwardRef, Input, OnInit, ViewChild } from '@angular/core';
import { WineryNamespaceSelectorService } from './wineryNamespaceSelector.service';
import { WineryNotificationService } from '../wineryNotificationModule/wineryNotification.service';
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';
import { NamespaceProperties } from '../model/namespaceProperties';
import { StartNamespaces, ToscaTypes } from '../model/enums';
import { isNullOrUndefined } from 'util';
import { HttpErrorResponse } from '@angular/common/http';
import { WineryRepositoryConfigurationService } from '../wineryFeatureToggleModule/WineryRepositoryConfiguration.service';

const noop = () => {
};
Expand Down Expand Up @@ -90,7 +91,9 @@ export class WineryNamespaceSelectorComponent implements OnInit, ControlValueAcc
private onTouchedCallback: () => void = noop;
private propagateChange: (_: any) => void = noop;

constructor(private service: WineryNamespaceSelectorService, private notify: WineryNotificationService) {
constructor(private service: WineryNamespaceSelectorService,
private notify: WineryNotificationService,
private configuration: WineryRepositoryConfigurationService) {
}

ngOnInit() {
Expand Down Expand Up @@ -160,13 +163,17 @@ export class WineryNamespaceSelectorComponent implements OnInit, ControlValueAcc
// endregion

private applyToscaTypeToNamespace(namespaceStart: string) {
return namespaceStart.endsWith('/') ? namespaceStart + this.toscaType :
namespaceStart + '/' + this.toscaType;
if (this.configuration.isYaml()) {
return namespaceStart.endsWith('.') ? namespaceStart + this.toscaType : namespaceStart + '.' + this.toscaType;
}

return namespaceStart.endsWith('/') ? namespaceStart + this.toscaType : namespaceStart + '/' + this.toscaType;
}

private getDefaultNamespace() {
const defaultNamespace = this.configuration.isYaml() ?
StartNamespaces.DefaultStartNamespaceYaml.toString() : StartNamespaces.DefaultStartNamespace.toString();
const storageValue = localStorage.getItem(StartNamespaces.LocalStorageEntry.toString());
this.initNamespaceString = isNullOrUndefined(storageValue) || storageValue.length === 0 ?
StartNamespaces.DefaultStartNamespace.toString() : storageValue;
this.initNamespaceString = isNullOrUndefined(storageValue) || storageValue.length === 0 ? defaultNamespace : storageValue;
}
}

0 comments on commit dfaef76

Please sign in to comment.