Merge pull request #3182 from kialam/artifacts-code-mirror

Artifacts Code Mirror

Reviewed-by: https://github.com/softwarefactory-project-zuul[bot]
This commit is contained in:
softwarefactory-project-zuul[bot]
2019-02-07 16:46:20 +00:00
committed by GitHub
11 changed files with 79 additions and 22 deletions

View File

@@ -381,7 +381,7 @@
flex-wrap: wrap; flex-wrap: wrap;
} }
.JobResults-resultRow #cm-variables-container { .JobResults-resultRow div[id$='variables-container'] {
width: 100%; width: 100%;
} }

View File

@@ -572,8 +572,25 @@ function getExtraVarsDetails () {
const tooltip = strings.get('tooltips.EXTRA_VARS'); const tooltip = strings.get('tooltips.EXTRA_VARS');
const value = parse(extraVars); const value = parse(extraVars);
const disabled = true; const disabled = true;
const name = 'extra_vars';
return { label, tooltip, value, disabled }; return { label, tooltip, value, disabled, name };
}
function getArtifactsDetails (val) {
const artifacts = val || resource.model.get('artifacts');
if (!artifacts || artifacts === '{}') {
return null;
}
const label = strings.get('labels.ARTIFACTS');
const tooltip = strings.get('tooltips.ARTIFACTS');
const value = parse(artifacts);
const disabled = true;
const name = 'artifacts';
return { label, tooltip, value, disabled, name };
} }
function getLabelDetails () { function getLabelDetails () {
@@ -781,6 +798,7 @@ function JobDetailsController (
vm.jobTags = getJobTagDetails(); vm.jobTags = getJobTagDetails();
vm.skipTags = getSkipTagDetails(); vm.skipTags = getSkipTagDetails();
vm.extraVars = getExtraVarsDetails(); vm.extraVars = getExtraVarsDetails();
vm.artifacts = getArtifactsDetails();
vm.labels = getLabelDetails(); vm.labels = getLabelDetails();
vm.inventorySource = getInventorySourceDetails(); vm.inventorySource = getInventorySourceDetails();
vm.overwrite = getOverwriteDetails(); vm.overwrite = getOverwriteDetails();
@@ -805,6 +823,7 @@ function JobDetailsController (
scm, scm,
inventoryScm, inventoryScm,
environment, environment,
artifacts,
executionNode executionNode
}) => { }) => {
vm.started = getStartDetails(started); vm.started = getStartDetails(started);
@@ -812,6 +831,7 @@ function JobDetailsController (
vm.projectUpdate = getProjectUpdateDetails(scm.id); vm.projectUpdate = getProjectUpdateDetails(scm.id);
vm.projectStatus = getProjectStatusDetails(scm.status); vm.projectStatus = getProjectStatusDetails(scm.status);
vm.environment = getEnvironmentDetails(environment); vm.environment = getEnvironmentDetails(environment);
vm.artifacts = getArtifactsDetails(artifacts);
vm.executionNode = getExecutionNodeDetails(executionNode); vm.executionNode = getExecutionNodeDetails(executionNode);
vm.inventoryScm = getInventoryScmDetails(inventoryScm.id, inventoryScm.status); vm.inventoryScm = getInventoryScmDetails(inventoryScm.id, inventoryScm.status);
vm.status = getStatusDetails(status); vm.status = getStatusDetails(status);

View File

@@ -332,10 +332,22 @@
ng-if="vm.extraVars" ng-if="vm.extraVars"
variables="{{ vm.extraVars.value }}" variables="{{ vm.extraVars.value }}"
tooltip="{{ vm.extraVars.tooltip }}" tooltip="{{ vm.extraVars.tooltip }}"
label="{{ vm.extraVars.label}}" label="{{ vm.extraVars.label }}"
name="{{ vm.extraVars.name }}"
disabled="{{ vm.extraVars.disabled }}"> disabled="{{ vm.extraVars.disabled }}">
</at-code-mirror> </at-code-mirror>
<!-- ARTIFACTS DETAIL -->
<at-code-mirror
class="JobResults-resultRow"
ng-if="vm.artifacts"
variables="{{ vm.artifacts.value }}"
tooltip="{{ vm.artifacts.tooltip }}"
label="{{ vm.artifacts.label }}"
name="{{ vm.artifacts.name }}"
disabled="{{ vm.artifacts.disabled }}">
</at-code-mirror>
<!-- LABELS DETAIL --> <!-- LABELS DETAIL -->
<div class="JobResults-resultRow" ng-show="vm.labels"> <div class="JobResults-resultRow" ng-show="vm.labels">
<div class="JobResults-resultRow"> <div class="JobResults-resultRow">

View File

@@ -14,6 +14,7 @@ function OutputStrings (BaseString) {
}; };
ns.tooltips = { ns.tooltips = {
ARTIFACTS: t.s('Read-only view of artifacts added to the job template'),
CANCEL: t.s('Cancel'), CANCEL: t.s('Cancel'),
COLLAPSE_OUTPUT: t.s('Collapse Output'), COLLAPSE_OUTPUT: t.s('Collapse Output'),
DELETE: t.s('Delete'), DELETE: t.s('Delete'),
@@ -49,6 +50,7 @@ function OutputStrings (BaseString) {
}; };
ns.labels = { ns.labels = {
ARTIFACTS: t.s('Artifacts'),
CREDENTIAL: t.s('Credential'), CREDENTIAL: t.s('Credential'),
ENVIRONMENT: t.s('Environment'), ENVIRONMENT: t.s('Environment'),
EXECUTION_NODE: t.s('Execution Node'), EXECUTION_NODE: t.s('Execution Node'),

View File

@@ -40,6 +40,7 @@ function JobStatusService (moment, message) {
started: model.get('started'), started: model.get('started'),
finished: model.get('finished'), finished: model.get('finished'),
environment: model.get('custom_virtualenv'), environment: model.get('custom_virtualenv'),
artifacts: model.get('artifacts'),
scm: { scm: {
id: model.get('summary_fields.project_update.id'), id: model.get('summary_fields.project_update.id'),
status: model.get('summary_fields.project_update.status') status: model.get('summary_fields.project_update.status')
@@ -279,6 +280,12 @@ function JobStatusService (moment, message) {
this.state.environment = env; this.state.environment = env;
}; };
this.setArtifacts = val => {
if (!val) return;
this.state.artifacts = val;
};
this.setExecutionNode = node => { this.setExecutionNode = node => {
if (!node) return; if (!node) return;
@@ -327,6 +334,7 @@ function JobStatusService (moment, message) {
this.setStarted(model.get('started')); this.setStarted(model.get('started'));
this.setJobStatus(model.get('status')); this.setJobStatus(model.get('status'));
this.setEnvironment(model.get('custom_virtualenv')); this.setEnvironment(model.get('custom_virtualenv'));
this.setArtifacts(model.get('artifacts'));
this.setExecutionNode(model.get('execution_node')); this.setExecutionNode(model.get('execution_node'));
this.initHostStatusCounts({ model }); this.initHostStatusCounts({ model });

View File

@@ -1,9 +1,7 @@
const templateUrl = require('~components/code-mirror/code-mirror.partial.html'); const templateUrl = require('~components/code-mirror/code-mirror.partial.html');
const CodeMirrorID = 'codemirror-extra-vars';
const CodeMirrorModalID = '#CodeMirror-modal'; const CodeMirrorModalID = '#CodeMirror-modal';
const ParseVariable = 'parseType'; const ParseVariable = 'parseType';
const CodeMirrorVar = 'variables';
const ParseType = 'yaml'; const ParseType = 'yaml';
function atCodeMirrorController ( function atCodeMirrorController (
@@ -13,19 +11,20 @@ function atCodeMirrorController (
ParseVariableString ParseVariableString
) { ) {
const vm = this; const vm = this;
function init (vars) { const variables = `${$scope.name}_variables`;
function init (vars, name) {
if ($scope.disabled === 'true') { if ($scope.disabled === 'true') {
$scope.disabled = true; $scope.disabled = true;
} else if ($scope.disabled === 'false') { } else if ($scope.disabled === 'false') {
$scope.disabled = false; $scope.disabled = false;
} }
$scope.variables = ParseVariableString(_.cloneDeep(vars)); $scope[variables] = ParseVariableString(_.cloneDeep(vars));
$scope.parseType = ParseType; $scope.parseType = ParseType;
const options = { const options = {
scope: $scope, scope: $scope,
variable: CodeMirrorVar, variable: variables,
parse_variable: ParseVariable, parse_variable: ParseVariable,
field_id: CodeMirrorID, field_id: name,
readOnly: $scope.disabled readOnly: $scope.disabled
}; };
ParseTypeChange(options); ParseTypeChange(options);
@@ -42,6 +41,9 @@ function atCodeMirrorController (
vm.expanded = false; vm.expanded = false;
} }
vm.variables = variables;
vm.name = $scope.name;
vm.modalName = `${vm.name}_modal`;
vm.strings = strings; vm.strings = strings;
vm.expanded = false; vm.expanded = false;
vm.close = close; vm.close = close;
@@ -49,7 +51,9 @@ function atCodeMirrorController (
if ($scope.init) { if ($scope.init) {
$scope.init = init; $scope.init = init;
} }
init($scope.variables); angular.element(document).ready(() => {
init($scope.variables, $scope.name);
});
} }
atCodeMirrorController.$inject = [ atCodeMirrorController.$inject = [
@@ -74,6 +78,7 @@ function atCodeMirrorTextarea () {
tooltip: '@', tooltip: '@',
tooltipPlacement: '@', tooltipPlacement: '@',
variables: '@', variables: '@',
name: '@',
init: '=' init: '='
} }
}; };

View File

@@ -23,7 +23,7 @@
type="radio" type="radio"
value="yaml" value="yaml"
ng-model="parseType" ng-model="parseType"
ng-change="parseTypeChange('parseType', 'variables')" ng-change="parseTypeChange('parseType', vm.variables)"
class="ng-pristine ng-untouched ng-valid ng-not-empty"> class="ng-pristine ng-untouched ng-valid ng-not-empty">
{{ vm.strings.get('label.YAML')}} {{ vm.strings.get('label.YAML')}}
</label> </label>
@@ -32,7 +32,7 @@
type="radio" type="radio"
value="json" value="json"
ng-model="parseType" ng-model="parseType"
ng-change="parseTypeChange('parseType', 'variables')" ng-change="parseTypeChange('parseType', vm.variables)"
class="ng-pristine ng-untouched ng-valid ng-not-empty"> class="ng-pristine ng-untouched ng-valid ng-not-empty">
{{ vm.strings.get('label.JSON')}} {{ vm.strings.get('label.JSON')}}
</label> </label>
@@ -47,9 +47,10 @@
ng-model="variables" ng-model="variables"
name="variables" name="variables"
class="form-control Form-textArea" class="form-control Form-textArea"
id="codemirror-extra-vars"> id="{{ vm.name }}">
</textarea> </textarea>
<at-code-mirror-modal <at-code-mirror-modal
name="{{ vm.modalName }}"
ng-if="vm.expanded" ng-if="vm.expanded"
variables="{{ variables }}" variables="{{ variables }}"
tooltip="{{ tooltip || vm.strings.get('code_mirror.tooltip.TOOLTIP') }}" tooltip="{{ tooltip || vm.strings.get('code_mirror.tooltip.TOOLTIP') }}"

View File

@@ -1,9 +1,7 @@
const templateUrl = require('~components/code-mirror/modal/code-mirror-modal.partial.html'); const templateUrl = require('~components/code-mirror/modal/code-mirror-modal.partial.html');
const CodeMirrorModalID = '#CodeMirror-modal'; const CodeMirrorModalID = '#CodeMirror-modal';
const CodeMirrorID = 'codemirror-extra-vars-modal';
const ParseVariable = 'parseType'; const ParseVariable = 'parseType';
const CodeMirrorVar = 'extra_variables';
const ParseType = 'yaml'; const ParseType = 'yaml';
const ModalHeight = '#CodeMirror-modal .modal-dialog'; const ModalHeight = '#CodeMirror-modal .modal-dialog';
const ModalHeader = '.atCodeMirror-label'; const ModalHeader = '.atCodeMirror-label';
@@ -16,6 +14,7 @@ function atCodeMirrorModalController (
ParseVariableString ParseVariableString
) { ) {
const vm = this; const vm = this;
const variables = `${$scope.name}_variables`;
function resize () { function resize () {
if ($scope.disabled === 'true') { if ($scope.disabled === 'true') {
$scope.disabled = true; $scope.disabled = true;
@@ -29,24 +28,24 @@ function atCodeMirrorModalController (
} }
function toggle () { function toggle () {
$scope.parseTypeChange('parseType', 'extra_variables'); $scope.parseTypeChange('parseType', variables);
setTimeout(resize, 0); setTimeout(resize, 0);
} }
function init () { function init (vars, name) {
if ($scope.disabled === 'true') { if ($scope.disabled === 'true') {
$scope.disabled = true; $scope.disabled = true;
} else if ($scope.disabled === 'false') { } else if ($scope.disabled === 'false') {
$scope.disabled = false; $scope.disabled = false;
} }
$(CodeMirrorModalID).modal('show'); $(CodeMirrorModalID).modal('show');
$scope.extra_variables = ParseVariableString(_.cloneDeep($scope.variables)); $scope[variables] = ParseVariableString(_.cloneDeep(vars));
$scope.parseType = ParseType; $scope.parseType = ParseType;
const options = { const options = {
scope: $scope, scope: $scope,
variable: CodeMirrorVar, variable: variables,
parse_variable: ParseVariable, parse_variable: ParseVariable,
field_id: CodeMirrorID, field_id: name,
readOnly: $scope.disabled readOnly: $scope.disabled
}; };
ParseTypeChange(options); ParseTypeChange(options);
@@ -59,9 +58,16 @@ function atCodeMirrorModalController (
$(`${CodeMirrorModalID} .modal-dialog`).on('resize', resize); $(`${CodeMirrorModalID} .modal-dialog`).on('resize', resize);
} }
vm.variables = variables;
vm.name = $scope.name;
vm.strings = strings; vm.strings = strings;
vm.toggle = toggle; vm.toggle = toggle;
init(); if ($scope.init) {
$scope.init = init;
}
angular.element(document).ready(() => {
init($scope.variables, $scope.name);
});
} }
atCodeMirrorModalController.$inject = [ atCodeMirrorModalController.$inject = [
@@ -85,6 +91,7 @@ function atCodeMirrorModal () {
labelClass: '@', labelClass: '@',
tooltip: '@', tooltip: '@',
variables: '@', variables: '@',
name: '@',
closeFn: '&' closeFn: '&'
} }
}; };

View File

@@ -58,7 +58,7 @@
ng-model="extra_variables" ng-model="extra_variables"
name="extra_variables" name="extra_variables"
class="form-control Form-textArea" class="form-control Form-textArea"
id="codemirror-extra-vars-modal"> id="{{ vm.name }}">
</textarea> </textarea>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">

View File

@@ -169,6 +169,7 @@ export default ['workflowData', 'workflowResultsService', 'workflowDataOptions',
$scope.parseType = 'yaml'; $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';
// Click binding for the expand/collapse button on the standard out log // Click binding for the expand/collapse button on the standard out log
$scope.stdoutFullScreen = false; $scope.stdoutFullScreen = false;

View File

@@ -224,6 +224,7 @@
tooltip="{{ varsTooltip }}" tooltip="{{ varsTooltip }}"
label="{{ varsLabel }}" label="{{ varsLabel }}"
label-class="WorkflowResults-extraVarsLabel" label-class="WorkflowResults-extraVarsLabel"
name="{{ varsName }}"
disabled="disabled"> disabled="disabled">
</at-code-mirror> </at-code-mirror>