diff options
author | talig <talig@amdocs.com> | 2017-12-20 14:30:43 +0200 |
---|---|---|
committer | Vitaly Emporopulo <Vitaliy.Emporopulo@amdocs.com> | 2017-12-21 11:12:33 +0000 |
commit | 8e9c0653dd6c6862123c9609ae34e1206d86456e (patch) | |
tree | 5eeef00ec0677133baa439ca8d7ffd7aca4804b6 /openecomp-ui/src/nfvo-utils | |
parent | 785ebcc95de3e064e843bec04ba7a209d854fc7c (diff) |
Add collaboration feature
Issue-ID: SDC-767
Change-Id: I14fb4c1f54086ed03a56a7ff7fab9ecd40381795
Signed-off-by: talig <talig@amdocs.com>
Diffstat (limited to 'openecomp-ui/src/nfvo-utils')
-rw-r--r-- | openecomp-ui/src/nfvo-utils/Validator.js | 16 | ||||
-rw-r--r-- | openecomp-ui/src/nfvo-utils/WebSocketUtil.js | 56 | ||||
-rw-r--r-- | openecomp-ui/src/nfvo-utils/getValue.js | 8 | ||||
-rw-r--r-- | openecomp-ui/src/nfvo-utils/i18n/en.json | 262 | ||||
-rw-r--r-- | openecomp-ui/src/nfvo-utils/i18n/i18n.stories.js | 35 |
5 files changed, 367 insertions, 10 deletions
diff --git a/openecomp-ui/src/nfvo-utils/Validator.js b/openecomp-ui/src/nfvo-utils/Validator.js index 3f6a00e289..0cb1943d66 100644 --- a/openecomp-ui/src/nfvo-utils/Validator.js +++ b/openecomp-ui/src/nfvo-utils/Validator.js @@ -20,8 +20,8 @@ import i18n from 'nfvo-utils/i18n/i18n.js'; class Validator { static get globalValidationFunctions() { return { - required: value => { - return typeof value === 'string' ? value.replace(/\s+/g, '') !== '' : value !== ''; + required: value => { + return typeof value === 'string' ? value.replace(/\s+/g, '') !== '' : value !== ''; }, requiredChooseOption: value => value !== '', maxLength: (value, length) => ValidatorJS.isLength(value, {max: length}), @@ -77,13 +77,13 @@ class Validator { length: value.length, maxLength }), - minLength: (value, minLength) => i18n(`Field value should contain at least ${minLength} characters.`), - pattern: (value, pattern) => i18n(`Field value should match the pattern: ${pattern}.`), + minLength: (value, minLength) => i18n('Field value should contain at least {minLength} characters.', {minLength: minLength}), + pattern: (value, pattern) => i18n('Field value should match the pattern: {pattern}.', {pattern: pattern}), numeric: () => i18n('Field value should contain numbers only.'), - maximum: (value, maxValue) => i18n(`Field value should be less or equal to: ${maxValue}.`), - minimum: (value, minValue) => i18n(`Field value should be at least: ${minValue.toString()}.`), - maximumExclusive: (value, maxValue) => i18n(`Field value should be less than: ${maxValue}.`), - minimumExclusive: (value, minValue) => i18n(`Field value should be more than: ${minValue.toString()}.`), + maximum: (value, maxValue) => i18n('Field value should be less or equal to: {maxValue}.', {maxValue: maxValue}), + minimum: (value, minValue) => i18n('Field value should be at least: {minValue}.', {minValue: minValue.toString()}), + maximumExclusive: (value, maxValue) => i18n('Field value should be less than: {maxValue}.', {maxValue: maxValue}), + minimumExclusive: (value, minValue) => i18n('Field value should be more than: {minValue}.', {minValue: minValue.toString()}), alphanumeric: () => i18n('Field value should contain letters or digits only.'), alphanumericWithSpaces: () => i18n('Field value should contain letters, digits or spaces only.'), validateName: ()=> i18n('Field value should contain English letters, digits , spaces, underscores, dashes and dots only.'), diff --git a/openecomp-ui/src/nfvo-utils/WebSocketUtil.js b/openecomp-ui/src/nfvo-utils/WebSocketUtil.js new file mode 100644 index 0000000000..c9dd10f1af --- /dev/null +++ b/openecomp-ui/src/nfvo-utils/WebSocketUtil.js @@ -0,0 +1,56 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * Licensed 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 store from 'sdc-app/AppStore.js'; +import Configuration from 'sdc-app/config/Configuration.js'; +import {actionTypes} from 'sdc-app/onboarding/userNotifications/UserNotificationsConstants.js'; + + +export const websocketUrl = 'ws://' + window.location.hostname + ':' + Configuration.get('websocketPort') + + '/' + Configuration.get('websocketPath'); + +/*** + * Websocket is treated like a singleton. only need one for the application. + */ +var websocket; + + +export default { + + open(url, {lastScanned}) { + if (websocket === undefined || websocket.readyState === websocket.CLOSED) { + websocket = new WebSocket(`${url}?LAST_DELIVERED_EVENT_ID=${lastScanned}`); + websocket.onmessage = event => store.dispatch({ + type: actionTypes.NOTIFICATION, + data: JSON.parse(event.data) + }); + websocket.onclose = event => { + if(event.code && event.code === 1001) { // - Idle Timeout + const {lastScanned} = store.getState().notifications; + console.log('Reconnecting to Websocket'); + this.open(websocketUrl, {lastScanned}); + } + }; + websocket.onerror = event => console.log(event); + } + }, + + close() { + if (websocket !== undefined) { + websocket.close(); + } + } +}; diff --git a/openecomp-ui/src/nfvo-utils/getValue.js b/openecomp-ui/src/nfvo-utils/getValue.js index 101655bf31..5ab0c76d73 100644 --- a/openecomp-ui/src/nfvo-utils/getValue.js +++ b/openecomp-ui/src/nfvo-utils/getValue.js @@ -25,8 +25,14 @@ function getValueFromVariable(variable) { return variable ? variable : undefined; } +function getArrayData(variable) { + return variable.length ? variable : undefined; +} + let getValue = element => { - return typeof element === 'object' ? getValueFromObject(element) : getValueFromVariable(element); + return typeof element === 'object' ? + element instanceof Array ? getArrayData(element) : getValueFromObject(element) : + getValueFromVariable(element); }; export function getStrValue(choiceObject) { diff --git a/openecomp-ui/src/nfvo-utils/i18n/en.json b/openecomp-ui/src/nfvo-utils/i18n/en.json index 8ed638352c..9cfaf6a569 100644 --- a/openecomp-ui/src/nfvo-utils/i18n/en.json +++ b/openecomp-ui/src/nfvo-utils/i18n/en.json @@ -29,6 +29,8 @@ "OK": "OK", "Cancel": "Cancel", "Error": "Error", + "Share": "Share", + "Commit": "Commit", "This item is checkedin/submitted, Click Check Out to continue": "This item is checkedin/submitted, Click Check Out to continue", "Name": "Name", "Description": "Description", @@ -170,6 +172,7 @@ "Licenses": "Licenses", "Licensing Version": "Licensing Version", "License Agreement": "License Agreement", + "Manage Permissions": "Manage Permissions", "Select...": "Select...", "Availability": "Availability", "Use Availability Zones for High Availability": "Use Availability Zones for High Availability", @@ -326,5 +329,262 @@ "Persistent Storage/Volume Size (GB)": "Persistent Storage/Volume Size (GB)", "I/O Operations (per second)": "I/O Operations (per second)", "CPU Oversubscription Ratio": "CPU Oversubscription Ratio", - "Memory - RAM": "Memory - RAM" + "Memory - RAM": "Memory - RAM", + "Commit error": "Commit error", + "Item version was certified by Owner": "Item version was certified by Owner", + + "VendorSoftwareProduct": "VSP", + "VendorSoftwareProduct/category": "Category", + "VendorSoftwareProduct/description": "Description", + "VendorSoftwareProduct/licensingData" : "Licenses", + "VendorSoftwareProduct/licensingData/featureGroups" : "Feature Groups", + "VendorSoftwareProduct/licensingData/licenseAgreement" : "License Agreement", + "VendorSoftwareProduct/licensingVersion": "Licensing Version", + "VendorSoftwareProduct/name": "Name", + "VendorSoftwareProduct/isOldVersion": "Is Old Version", + "VendorSoftwareProduct/onboardingMethod": "Onboarding Method", + "VendorSoftwareProduct/subCategory": "Sub-Category", + "VendorSoftwareProduct/vendorId": "Vendor ID", + "VendorSoftwareProduct/vendorName": "Vendor", + "VendorSoftwareProduct/onboardingOrigin": "Onboarding Origin", + "VendorSoftwareProduct/networkPackageName": "Network Package Name", + + "EntitlementPool" : "Entitlement Pool", + "EntitlementPool/name" : "Name", + "EntitlementPool/description" : "Description", + "EntitlementPool/referencingFeatureGroups" : "Referencing Feature Groups", + "EntitlementPool/operationalScope" : "Operational Scope", + "EntitlementPool/thresholdValue" : "Threshold Value", + "EntitlementPool/thresholdUnits" : "Threshold Units", + "EntitlementPool/increments" : "Increments", + "EntitlementPool/startDate" : "Start Date", + "EntitlementPool/expiryDate" : "Expiry Date", + "EntitlementPool/limits" : "Limits", + + "Limit/aggregationFunction" : "Aggregation Function", + "Limit/description" : "Description", + "Limit/metric" : "Metric", + "Limit/name" : "Name", + "Limit/time" : "Time", + "Limit/type" : "Type", + "Limit/unit" : "Unit", + "Limit/value" : "Value", + + "FeatureGroup" : "Feature Group", + "FeatureGroup/name" : "Name", + "FeatureGroup/description" : "Description", + "FeatureGroup/partNumber" : "Part Number", + "FeatureGroup/entitlementPoolsIds" : "Entitlement Pools", + "FeatureGroup/licenseKeyGroupsIds" : "License Keys", + "FeatureGroup/referencingLicenseAgreements" : "Referencing License Agreements", + "FeatureGroup/manufacturerReferenceNumber" : "Manufacturer Reference #", + + "VendorLicenseModel" : "License Model", + "VendorLicenseModel/vendorName" : "Vendor", + "VendorLicenseModel/description" : "Description", + + "Component" : "Component", + "Component/name" : "Name", + "Component/description" : "Description", + "Component/displayName" : "Display Name", + "Component/nfcCode" : "NFC Code", + "Component/vfcCode" : "VFC Code", + "Component/nfcFunction" : "NFC Function", + + "ComponentDependencies" : "Component Dependencies", + + "ComponentQuestionnaire" : "Component Questionnaire", + "ComponentQuestionnaire/compute" : "Compute", + "ComponentQuestionnaire/storage/backup/backupStorageSize": "Backup Storage Size", + "ComponentQuestionnaire/storage/backup/backupSolution": "Backup Solution", + "ComponentQuestionnaire/compute/guestOS" : "Guest OS", + "ComponentQuestionnaire/compute/guestOS/bitSize" : "Bit Size", + "ComponentQuestionnaire/compute/guestOS/name" : "Name", + "ComponentQuestionnaire/compute/guestOS/tools" : "Tools", + "ComponentQuestionnaire/compute/numOfVMs" : "Number of VMs", + "ComponentQuestionnaire/compute/numOfVMs/maximum" : "Max", + "ComponentQuestionnaire/compute/numOfVMs/minimum" : "Min", + "ComponentQuestionnaire/general" : "General", + "ComponentQuestionnaire/general/disk" : "Disk", + "ComponentQuestionnaire/general/disk/bootDiskSizePerVM" : "Size of boot disk per VM(GB)", + "ComponentQuestionnaire/general/disk/ephemeralDiskSizePerVM" : "Size of ephemeral disk per VM (GB)", + "ComponentQuestionnaire/general/dnsConfiguration" : "DNS Configuration", + "ComponentQuestionnaire/general/hypervisor" : "Hypervisor Info", + "ComponentQuestionnaire/general/hypervisor/hypervisor" : "Hypervisor", + "ComponentQuestionnaire/general/hypervisor/drivers" : "Drivers", + "ComponentQuestionnaire/general/hypervisor/containerFeaturesDescription" : "Container Features Description", + "ComponentQuestionnaire/general/image" : "Image", + "ComponentQuestionnaire/general/image/providedBy" : "Provided By", + "ComponentQuestionnaire/general/recovery" : "Recovery", + "ComponentQuestionnaire/general/recovery/pointObjective" : "Point Objective (Minutes)", + "ComponentQuestionnaire/general/recovery/timeObjective" : "Time Objective (Minutes)", + "ComponentQuestionnaire/general/recovery/vmProcessFailuresHandling" : "VM Process Failure Handling", + "ComponentQuestionnaire/general/vmCloneUsage" : "VM Clone Usage", + "ComponentQuestionnaire/highAvailabilityAndLoadBalancing" : "High Availability and Load-Balancing", + "ComponentQuestionnaire/highAvailabilityAndLoadBalancing/architectureChoice": "Architecture Choice", + "ComponentQuestionnaire/highAvailabilityAndLoadBalancing/failureLoadDistribution": "Failure Load Distribution", + "ComponentQuestionnaire/highAvailabilityAndLoadBalancing/highAvailabilityMode" : "Mode", + "ComponentQuestionnaire/highAvailabilityAndLoadBalancing/horizontalScaling": "Horizontal Scaling", + "ComponentQuestionnaire/highAvailabilityAndLoadBalancing/isComponentMandatory" : "Is Component Mandatory", + "ComponentQuestionnaire/highAvailabilityAndLoadBalancing/loadDistributionMechanism": "Load Distribution Mechanism", + "ComponentQuestionnaire/highAvailabilityAndLoadBalancing/nkModelImplementation": "nkModel Implementation", + "ComponentQuestionnaire/highAvailabilityAndLoadBalancing/slaRequirements": "SLA Requirements", + "ComponentQuestionnaire/network" : "Network", + "ComponentQuestionnaire/network/networkCapacity" : "Capacity", + "ComponentQuestionnaire/network/networkCapacity/networkTransactionsPerSecond": "Network Transactions Per Second", + "ComponentQuestionnaire/network/networkCapacity/protocolWithHighestTrafficProfileAcrossAllNICs": "Protocol with Highest Traffic Profile Across All NICs", + "ComponentQuestionnaire/storage" : "Storage", + "ComponentQuestionnaire/storage/backup" : "Backup", + "ComponentQuestionnaire/storage/backup/backupNIC" : "NIC", + "ComponentQuestionnaire/storage/backup/backupType" : "Type", + "ComponentQuestionnaire/storage/logBackup" : "Log Backup", + "ComponentQuestionnaire/storage/logBackup/logBackupFrequency": "Log Backup Frequency", + "ComponentQuestionnaire/storage/logBackup/logFileLocation": "Log File Location", + "ComponentQuestionnaire/storage/logBackup/logRetentionPeriod": "Log Retention Period", + "ComponentQuestionnaire/storage/logBackup/sizeOfLogFiles": "Size of Log Files", + "ComponentQuestionnaire/storage/snapshotBackup" : "Snapshot", + "ComponentQuestionnaire/storage/snapshotBackup/snapshotFrequency" : "Frequency", + + "ComputeQuestionnaire" : "Compute Questionnaire", + "ComputeQuestionnaire/vmSizing" : "VM Sizing", + "ComputeQuestionnaire/vmSizing/numOfCPUs" : "Number of CPUs", + "ComputeQuestionnaire/vmSizing/fileSystemSizeGB" : "File System Size (GB)", + "ComputeQuestionnaire/vmSizing/persistentStorageVolumeSize" : "Persistent Storage/Volume Size (GB)", + "ComputeQuestionnaire/vmSizing/ioOperationsPerSec" : "I/O Operations (per second)", + "ComputeQuestionnaire/vmSizing/cpuOverSubscriptionRatio" : "CPU Oversubscription Ratio", + "ComputeQuestionnaire/vmSizing/memoryRAM" : "Memory - RAM", + + "Compute/name" : "name", + "Compute/description" : "description", + + "LicenseAgreement" : "License Agreements", + "LicenseAgreement/description" : "Description", + "LicenseAgreement/featureGroupsIds" : "Related Feature Groups", + "LicenseAgreement/licenseTerm" : "Term", + "LicenseAgreement/name" : "Name", + "LicenseAgreement/requirementsAndConstrains" : "Requirements and Constraints", + + "LicenseKeyGroup" : "License Key Group", + "LicenseKeyGroup/description" : "Description", + "LicenseKeyGroup/expiryDate" : "Expiry Date", + "LicenseKeyGroup/increments" : "Increments", + "LicenseKeyGroup/name" : "Name", + "LicenseKeyGroup/operationalScope" : "Operational Scope", + "LicenseKeyGroup/referencingFeatureGroups" : "Referencing Feature Group(s)", + "LicenseKeyGroup/startDate" : "Start Date", + "LicenseKeyGroup/thresholdUnits" : "Threshold Units", + "LicenseKeyGroup/thresholdValue" : "Threshold Value", + "LicenseKeyGroup/type" : "Type", + + "Nic" : "NIC", + "Nic/description" : "Description", + "Nic/name" : "Name", + "Nic/networkDescription" : "Network Description", + "Nic/networkName" : "Network Name", + "Nic/networkType" : "Network Type", + + "NicQuestionnaire" : "NIC Questionnaire", + "NicQuestionnaire/ipConfiguration" : "IP Configuration", + "NicQuestionnaire/ipConfiguration/ipv4Required" : "IPv4 Required", + "NicQuestionnaire/ipConfiguration/ipv6Required" : "IPv6 Required", + "NicQuestionnaire/network/networkDescription" : "Network Description", + "NicQuestionnaire/sizing" : "Sizing", + "NicQuestionnaire/sizing/acceptableJitter" : "Acceptable Jitter", + "NicQuestionnaire/sizing/acceptableJitter/mean" : "Mean", + "NicQuestionnaire/sizing/acceptableJitter/max" : "Max", + "NicQuestionnaire/sizing/acceptableJitter/variable" : "Var", + "NicQuestionnaire/sizing/acceptablePacketLoss" : "Allow Packet Loss", + "NicQuestionnaire/sizing/describeQualityOfService" : "Describe Quality of Service", + "NicQuestionnaire/sizing/flowLength" : "Flow Length", + "NicQuestionnaire/sizing/flowLength/packets" : "Packets", + "NicQuestionnaire/sizing/flowLength/packets/peak" : "Peak", + "NicQuestionnaire/sizing/flowLength/packets/avg" : "Avg.", + "NicQuestionnaire/sizing/flowLength/bytes" : "Bytes", + "NicQuestionnaire/sizing/flowLength/bytes/peak" : "Peak", + "NicQuestionnaire/sizing/flowLength/bytes/avg" : "Avg.", + "NicQuestionnaire/sizing/inflowTrafficPerSecond" : "Inflow Traffic per second", + "NicQuestionnaire/sizing/inflowTrafficPerSecond/packets" : "Packets", + "NicQuestionnaire/sizing/inflowTrafficPerSecond/bytes" : "Bytes", + "NicQuestionnaire/sizing/inflowTrafficPerSecond/packets/peak" : "Peak", + "NicQuestionnaire/sizing/inflowTrafficPerSecond/packets/avg" : "Avg.", + "NicQuestionnaire/sizing/inflowTrafficPerSecond/bytes/peak" : "Peak", + "NicQuestionnaire/sizing/inflowTrafficPerSecond/bytes/avg" : "Avg.", + "NicQuestionnaire/sizing/outflowTrafficPerSecond" : "Outflow Traffic", + "NicQuestionnaire/sizing/outflowTrafficPerSecond/packets" : "Packets", + "NicQuestionnaire/sizing/outflowTrafficPerSecond/bytes" : "Bytes", + "NicQuestionnaire/sizing/outflowTrafficPerSecond/packets/peak" : "Peak", + "NicQuestionnaire/sizing/outflowTrafficPerSecond/packets/avg" : "Avg.", + "NicQuestionnaire/sizing/outflowTrafficPerSecond/bytes/peak" : "Peak", + "NicQuestionnaire/sizing/outflowTrafficPerSecond/bytes/avg" : "Avg.", + "NicQuestionnaire/protocols" : "Protocols", + "NicQuestionnaire/protocols/protocols" : "Protocols", + "NicQuestionnaire/protocols/protocolWithHighestTrafficProfile" : "Protocol with Highest Traffic Profile across all NICs", + + "OrchestrationTemplateCandidate/modules": "modules", + "OrchestrationTemplateCandidate/modules/index": "module", + "OrchestrationTemplateCandidate/nested": "nested", + "OrchestrationTemplateCandidate/unassigned": "unassigned", + "OrchestrationTemplateCandidate/modules/index/env": "env", + "OrchestrationTemplateCandidate/modules/index/yaml": "yaml", + "OrchestrationTemplateCandidate/modules/index/isBase": "Is Base", + + + "Image/fileName" : "File Name", + "Image/description" : "Description", + + "ImageQuestionnaire" : "Image Questionnaire", + "ImageQuestionnaire/format" : "Format", + "ImageQuestionnaire/version" : "Version", + "ImageQuestionnaire/md5" : "md5", + + "SNMP_POLL" : "SNMP Poll", + "SNMP_POLL/File Name" : "File Name", + + "SNMP_TRAP" : "SNMP Trap", + "SNMP_TRAP/File Name": "File Name", + + "Process" : "Process", + "Process/name" : "Name", + "Process/description" : "Description", + "Process/type" : "Type", + "Process/artifactName" : "Artifact Name", + + "DeploymentFlavor" : "Deployment Flavor", + "DeploymentFlavor/model" : "Model", + "DeploymentFlavor/description" : "Description", + "DeploymentFlavor/featureGroupId" : "Related FG", + "DeploymentFlavor/componentComputeAssociations" : "Associated Computes", + "DeploymentFlavor/componentComputeAssociations/componentId" : "Component", + "DeploymentFlavor/componentComputeAssociations/computeFlavorId" : "Compute", + + "Network/name" : "Name", + "Network/dhcp" : "DHCP", + + "OrchestrationTemplateCandidate": "Candidate Network Package", + "OrchestrationTemplateCandidate/File Structure": "File Structure", + + "OrchestrationTemplate": "Orchestration Template", + "NetworkPackage": "Network Package", + "NetworkPackage/File": "File", + "Artifact": "Artifact", + + "ServiceModel": "Service Model", + "ServiceModel/Service Model Definition Entry": "Definition Entry", + + "Merge Required" : "Conflicts", + + "VSPQuestionnaire" : "VSP Questionnaire", + "VSPQuestionnaire/general" : "General", + "VSPQuestionnaire/general/affinityData" : "Affinity", + "VSPQuestionnaire/general/availability" : "Availability", + "VSPQuestionnaire/general/availability/useAvailabilityZonesForHighAvailability" : "Use Availability Zones", + "VSPQuestionnaire/general/regionsData" : "Regions", + "VSPQuestionnaire/general/regionsData/multiRegion" : "Is Multi-Region", + "VSPQuestionnaire/general/regionsData/regions" : "Selected Regions", + "VSPQuestionnaire/general/storageDataReplication" : "Storage Data Replication", + "VSPQuestionnaire/general/storageDataReplication/storageReplicationAcrossRegion" : "Storage Replication Across Regions", + "VSPQuestionnaire/general/storageDataReplication/storageReplicationSize" : "Storage Replication Size", + "VSPQuestionnaire/general/storageDataReplication/storageReplicationSource": "Storage Replication Source", + "VSPQuestionnaire/general/storageDataReplication/storageReplicationFrequency" : "Storage Replication Frequency", + "VSPQuestionnaire/general/storageDataReplication/storageReplicationDestination" : "Storage Replication Destination" } diff --git a/openecomp-ui/src/nfvo-utils/i18n/i18n.stories.js b/openecomp-ui/src/nfvo-utils/i18n/i18n.stories.js new file mode 100644 index 0000000000..816915b1c9 --- /dev/null +++ b/openecomp-ui/src/nfvo-utils/i18n/i18n.stories.js @@ -0,0 +1,35 @@ +import React from 'react'; +import {storiesOf, action} from '@kadira/storybook'; +import {text, number} from '@kadira/storybook-addon-knobs'; +import {withKnobs} from '@kadira/storybook-addon-knobs'; +import i18n from 'nfvo-utils/i18n/i18n.js'; +import i18nJson from 'nfvo-utils/i18n/en.json'; + +const stories = storiesOf('i18n', module); +stories.addDecorator(withKnobs); + + +i18nJson['added'] = 'this is my test'; +i18nJson['added with {param}'] = 'this is my test with {param}'; + +stories + .add('i18n tests', () => { + let keys = [ + 'I do not exist', + 'Delete', + 'OrchestrationTemplateCandidate/File Structure' + ]; + let translations = []; + let i=0; + translations.push(<div id={i++}>KEY: VALUE</div>) + keys.forEach((key) => { + translations.push((<div id={i++}>{key} : {i18n(key)} </div>)); + }); + var param = 'param'; + translations.push((<div id={i++}>added : {i18n('added')} </div>)); + translations.push((<div id={i++}><font color="red"><b>WRONG</b></font> - added with ${param} in translation : {i18n(`added with ${param}`)} </div>)); + translations.push((<div id={i++}><font color="green"><b>RIGHT</b></font> - added with ${param} and options object {JSON.stringify({param:param})}: {i18n('added with {param}', {param: param})} </div>)); + + return (<div>{translations}</div>); + }) +; |