Merge pull request #3483 from keithjgrant/inventory-vars-popout

Inventory vars popout round 2 (codemirror)

Reviewed-by: https://github.com/softwarefactory-project-zuul[bot]
This commit is contained in:
softwarefactory-project-zuul[bot]
2019-03-22 20:27:13 +00:00
committed by GitHub
8 changed files with 14 additions and 28 deletions

View File

@@ -73,6 +73,9 @@ function atCodeMirrorController (
return true; return true;
} }
if (typeof str === 'undefined') {
return '---';
}
if (typeof str !== 'string') { if (typeof str !== 'string') {
const yamlStr = jsyaml.safeDump(str); const yamlStr = jsyaml.safeDump(str);
// jsyaml.safeDump doesn't process an empty object correctly // jsyaml.safeDump doesn't process an empty object correctly

View File

@@ -18,7 +18,7 @@
<i class="fa fa-question-circle"></i> <i class="fa fa-question-circle"></i>
</a> </a>
<div class="atCodeMirror-toggleContainer FormToggle-container"> <div class="atCodeMirror-toggleContainer FormToggle-container">
<div class="btn-group"> <div id="{{ name }}_parse_type" class="btn-group">
<label ng-class="{'btn-primary': parseType === 'yaml','Button-primary--hollow' : parseType === 'json'}" class="btn btn-xs"> <label ng-class="{'btn-primary': parseType === 'yaml','Button-primary--hollow' : parseType === 'json'}" class="btn btn-xs">
<input <input
type="radio" type="radio"

View File

@@ -5,8 +5,8 @@
*************************************************/ *************************************************/
export default export default
['$scope', '$state', '$stateParams', 'GenerateForm', 'ParseTypeChange', 'HostsService', 'host', '$rootScope', ['$scope', '$state', '$stateParams', 'GenerateForm', 'HostsService', 'host', '$rootScope',
function($scope, $state, $stateParams, GenerateForm, ParseTypeChange, HostsService, host, $rootScope){ function($scope, $state, $stateParams, GenerateForm, HostsService, host, $rootScope){
$scope.parseType = 'yaml'; $scope.parseType = 'yaml';
$scope.formCancel = function(){ $scope.formCancel = function(){
$state.go('^', null, {reload: true}); $state.go('^', null, {reload: true});

View File

@@ -4,26 +4,18 @@
* All Rights Reserved * All Rights Reserved
*************************************************/ *************************************************/
export default ['$state', '$stateParams', '$scope', 'RelatedHostsFormDefinition', 'ParseTypeChange', export default ['$state', '$stateParams', '$scope', 'RelatedHostsFormDefinition',
'GenerateForm', 'HostsService', 'GetBasePath', 'ToJSON', 'canAdd', 'GenerateForm', 'HostsService', 'GetBasePath', 'ToJSON', 'canAdd',
function($state, $stateParams, $scope, RelatedHostsFormDefinition, ParseTypeChange, function($state, $stateParams, $scope, RelatedHostsFormDefinition,
GenerateForm, HostsService, GetBasePath, ToJSON, canAdd) { GenerateForm, HostsService, GetBasePath, ToJSON, canAdd) {
init(); init();
function init() { function init() {
$scope.canAdd = canAdd; $scope.canAdd = canAdd;
$scope.parseType = 'yaml';
$scope.host = { enabled: true }; $scope.host = { enabled: true };
// apply form definition's default field values // apply form definition's default field values
GenerateForm.applyDefaults(RelatedHostsFormDefinition, $scope); GenerateForm.applyDefaults(RelatedHostsFormDefinition, $scope);
ParseTypeChange({
scope: $scope,
field_id: 'host_host_variables',
variable: 'host_variables',
parse_variable: 'parseType'
});
} }
$scope.formCancel = function() { $scope.formCancel = function() {
$state.go('^'); $state.go('^');

View File

@@ -30,14 +30,6 @@ function InventoriesAdd($scope, $location,
// apply form definition's default field values // apply form definition's default field values
GenerateForm.applyDefaults(form, $scope); GenerateForm.applyDefaults(form, $scope);
$scope.parseType = 'yaml';
ParseTypeChange({
scope: $scope,
variable: 'inventory_variables',
parse_variable: 'parseType',
field_id: 'inventory_inventory_variables'
});
} }
// Save // Save

View File

@@ -1,8 +1,8 @@
export default ['workflowData', 'workflowResultsService', 'workflowDataOptions', export default ['workflowData', 'workflowResultsService', 'workflowDataOptions',
'jobLabels', 'workflowNodes', '$scope', 'ParseTypeChange', 'jobLabels', 'workflowNodes', '$scope',
'ParseVariableString', 'count', '$state', 'i18n', 'WorkflowChartService', '$filter', 'ParseVariableString', 'count', '$state', 'i18n', 'WorkflowChartService', '$filter',
'moment', function(workflowData, workflowResultsService, 'moment', function(workflowData, workflowResultsService,
workflowDataOptions, jobLabels, workflowNodes, $scope, ParseTypeChange, workflowDataOptions, jobLabels, workflowNodes, $scope,
ParseVariableString, count, $state, i18n, WorkflowChartService, $filter, ParseVariableString, count, $state, i18n, WorkflowChartService, $filter,
moment) { moment) {
let nodeRef; let nodeRef;
@@ -167,7 +167,6 @@ export default ['workflowData', 'workflowResultsService', 'workflowDataOptions',
// set up a read only code mirror for extra vars // set up a read only code mirror for extra vars
$scope.variables = ParseVariableString($scope.workflow.extra_vars); $scope.variables = ParseVariableString($scope.workflow.extra_vars);
$scope.parseType = 'yaml';
$scope.varsTooltip= i18n._('Read only view of extra variables added to the workflow.'); $scope.varsTooltip= i18n._('Read only view of extra variables added to the workflow.');
$scope.varsLabel = i18n._('Extra Variables'); $scope.varsLabel = i18n._('Extra Variables');
$scope.varsName = 'extra_vars'; $scope.varsName = 'extra_vars';

View File

@@ -220,12 +220,12 @@
<!-- EXTRA VARIABLES DETAIL --> <!-- EXTRA VARIABLES DETAIL -->
<at-code-mirror <at-code-mirror
ng-if="variables" ng-if="variables"
variables="{{ variables }}" variables="variables"
tooltip="{{ varsTooltip }}" tooltip="{{ varsTooltip }}"
label="{{ varsLabel }}" label="{{ varsLabel }}"
label-class="WorkflowResults-extraVarsLabel" label-class="WorkflowResults-extraVarsLabel"
name="{{ varsName }}" name="{{ varsName }}"
disabled="disabled"> disabled="true">
</at-code-mirror> </at-code-mirror>
<!-- LABELS DETAIL --> <!-- LABELS DETAIL -->

View File

@@ -159,8 +159,8 @@ module.exports = {
client.click('div[class="CodeMirror-scroll"]'); client.click('div[class="CodeMirror-scroll"]');
client.sendKeys('.CodeMirror textarea', client.Keys.ENTER); client.sendKeys('.CodeMirror textarea', client.Keys.ENTER);
client.sendKeys('.CodeMirror textarea', 'ansible_connection: local'); client.sendKeys('.CodeMirror textarea', 'ansible_connection: local');
client.click('#host_host_variables_parse_type label[class$="hollow"]'); client.click('#host_variables_parse_type label[class$="hollow"]');
client.click('#host_host_variables_parse_type label[class$="hollow"]'); client.click('#host_variables_parse_type label[class$="hollow"]');
client.expect.element('#host_save_btn').enabled; client.expect.element('#host_save_btn').enabled;
client.click('#host_save_btn'); client.click('#host_save_btn');