This is an automated email from the ASF dual-hosted git repository. heneveld pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/brooklyn-ui.git
commit b3aef528eb8cb3de26d130336ab51cf2c610e001 Author: Alex Heneveld <[email protected]> AuthorDate: Wed Nov 9 16:23:43 2022 +0000 quick launch give good message on complex object; and no longer require location --- ui-modules/utils/quick-launch/quick-launch.html | 11 ++++++++- ui-modules/utils/quick-launch/quick-launch.js | 32 +++++++++++++++---------- 2 files changed, 30 insertions(+), 13 deletions(-) diff --git a/ui-modules/utils/quick-launch/quick-launch.html b/ui-modules/utils/quick-launch/quick-launch.html index c08465a9..d0ae5e78 100644 --- a/ui-modules/utils/quick-launch/quick-launch.html +++ b/ui-modules/utils/quick-launch/quick-launch.html @@ -55,6 +55,8 @@ typeahead-template-url="LocationTemplate.html" typeahead-min-length="0" /> <small class="help-block"> + <span>A location may not be required.</span> + <!-- no longer required, so error should never come back --> <span ng-if="deploy.location.$error.required && (deploy.$submitted || deploy.location.$touched)">You must select a location.</span> <span ng-if="!args.noCreateLocationLink">Alternatively, you can <a href="/brooklyn-ui-location-manager/#!/wizard">create a new location</a></span> </small> @@ -65,7 +67,7 @@ <section class="quick-launch-section quick-launch-configuration"> <h3 class="quick-launch-section-title">Configuration</h3> <div class="quick-launch-section-content"> - <div ng-repeat="(key,value) in entityToDeploy['brooklyn.config'] track by key" ng-switch="configMap[key].type"> + <div ng-repeat="(key,value) in entityToDeploy['brooklyn.config'] track by key" ng-switch="configMap[key].json ? 'json' : type"> <div class="checkbox" ng-class="{'has-error': deploy[key].$invalid && deploy[key].$touched}" ng-switch-when="java.lang.Boolean"> <label> <input type="checkbox" ng-model="entityToDeploy['brooklyn.config'][key]" ng-disabled="deploying" auto-focus="focus === key" /> @@ -95,6 +97,13 @@ <span ng-if="deploy[key].$error.required">You must enter a value</span> </small> </div> + <div class="form-group" ng-class="{'has-error': deploy[key].$invalid && deploy[key].$touched}" ng-switch-when="json"> + <label for="{{key}}">{{key}} <i ng-click="deleteConfigField(key)" class="fa fa-trash form-delete"></i></label> + <input type="text" id="{{key}}" name="{{key}}" class="form-control" ng-model="entityToDeployConfigJson[key]" ng-required="isRequired(configMap[key])" disabled auto-focus="focus === key" /> + <small class="help-block"> + <span>This complex value can only be edited in composer.</span> + </small> + </div> <div class="form-group" ng-class="{'has-error': deploy[key].$invalid && deploy[key].$touched}" ng-switch-default> <label for="{{key}}">{{key}} <i ng-click="deleteConfigField(key)" class="fa fa-trash form-delete"></i></label> <input type="text" id="{{key}}" name="{{key}}" class="form-control" ng-model="entityToDeploy['brooklyn.config'][key]" ng-required="isRequired(configMap[key])" ng-disabled="deploying" auto-focus="focus === key" /> diff --git a/ui-modules/utils/quick-launch/quick-launch.js b/ui-modules/utils/quick-launch/quick-launch.js index ef639631..8f2b7bad 100644 --- a/ui-modules/utils/quick-launch/quick-launch.js +++ b/ui-modules/utils/quick-launch/quick-launch.js @@ -62,13 +62,14 @@ export function quickLaunchDirective() { } return obj; } - quickLaunch.buildNewApp = () => ({ - name: $scope.model.name || $scope.app.displayName, - location: $scope.model.location || '<REPLACE>', - services: [ - removeNullConfig(angular.copy($scope.entityToDeploy)) - ], - }); + quickLaunch.buildNewApp = () => { + const result = { + name: $scope.model.name || $scope.app.displayName, + }; + if ($scope.model.location) result.location = $scope.model.location; + result.services = [removeNullConfig(angular.copy($scope.entityToDeploy))]; + return result; + }; quickLaunch.getOriginalPlanFormat = getOriginalPlanFormat; quickLaunch.planSender = (plan) => { @@ -141,6 +142,7 @@ export function quickLaunchDirective() { $scope.formEnabled = $scope.forceFormOnly || (parsedPlan!==null && !checkForLocationTags(parsedPlan)); $scope.yamlViewDisplayed = !$scope.formEnabled; + $scope.entityToDeployConfigJson = {}; $scope.entityToDeploy = { type: $scope.app.symbolicName + ($scope.app.version ? ':' + $scope.app.version : ''), [BROOKLYN_CONFIG]: {}, @@ -149,15 +151,21 @@ export function quickLaunchDirective() { $scope.configMap = $scope.app.config.reduce((result, config) => { result[config.name] = config; - let configValue = parseConfigValue((parsedPlan[BROOKLYN_CONFIG] || {})[config.name]); + let configValue = (parsedPlan[BROOKLYN_CONFIG] || {})[config.name]; if (typeof configValue == 'undefined' && parsedPlan.services.length==1) { - configValue = parseConfigValue((parsedPlan.services[0] && parsedPlan.services[0][BROOKLYN_CONFIG] || {})[config.name]); + configValue = (parsedPlan.services[0] && parsedPlan.services[0][BROOKLYN_CONFIG] || {})[config.name]; } if (typeof configValue !== 'undefined') { $scope.entityToDeploy[BROOKLYN_CONFIG][config.name] = configValue; } else if (config.pinned || (isRequired(config) && (typeof config.defaultValue !== 'undefined'))) { - $scope.entityToDeploy[BROOKLYN_CONFIG][config.name] = parseConfigValue(get(config, 'defaultValue', null)); + $scope.entityToDeploy[BROOKLYN_CONFIG][config.name] = get(config, 'defaultValue', null); + } + + let json = getJsonOfConfigValue($scope.entityToDeploy[BROOKLYN_CONFIG][config.name]); + if (json!=null) { + $scope.entityToDeployConfigJson[config.name] = json; + result[config.name].json = true; } return result; @@ -217,10 +225,10 @@ export function quickLaunchDirective() { } // serialize value if it happens to be a complex object - function parseConfigValue(item) { + function getJsonOfConfigValue(item) { return (typeof item === 'object' && !isEmpty(item)) ? JSON.stringify(item) - : item; + : null; } function deleteConfigField(key) {
