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
commit 525021214c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 14 additions and 28 deletions

View File

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

View File

@ -18,7 +18,7 @@
<i class="fa fa-question-circle"></i>
</a>
<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">
<input
type="radio"

View File

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

View File

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

View File

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

View File

@ -1,8 +1,8 @@
export default ['workflowData', 'workflowResultsService', 'workflowDataOptions',
'jobLabels', 'workflowNodes', '$scope', 'ParseTypeChange',
'jobLabels', 'workflowNodes', '$scope',
'ParseVariableString', 'count', '$state', 'i18n', 'WorkflowChartService', '$filter',
'moment', function(workflowData, workflowResultsService,
workflowDataOptions, jobLabels, workflowNodes, $scope, ParseTypeChange,
workflowDataOptions, jobLabels, workflowNodes, $scope,
ParseVariableString, count, $state, i18n, WorkflowChartService, $filter,
moment) {
let nodeRef;
@ -167,7 +167,6 @@ export default ['workflowData', 'workflowResultsService', 'workflowDataOptions',
// set up a read only code mirror for 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.varsLabel = i18n._('Extra Variables');
$scope.varsName = 'extra_vars';

View File

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

View File

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