-
Notifications
You must be signed in to change notification settings - Fork 231
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Build hook editor on build configuration page #680
Conversation
@MarkDeMaria I spoke to @jwforres, and we decided that it's better to have a ui-select with only the valid options:
This prevents users from selecting an invalid combination. |
5446f9c
to
d9e3dd6
Compare
d9e3dd6
to
72362c3
Compare
As discussed, now uses UI-Select with each possible combination. Selecting save will overwrite the postCommit data with what is being shown on the page. For example, if saving on the Script+Args page while Commands has data, Commands will be wiped in favor of Script+Args, but Commands will still be accessible prior to saving if user switches back to the Commands drop-down. Added bonus: Page will auto-select a dropdown option based on what is saved in Post Commit. One problem that needs addressing is that the edit-command directive needs to be able to replace the phrase "No Command set" with "No Argument set." See screenshots below. |
ed07a16
to
269c025
Compare
Can you add "Learn more" link to this topic? https://docs.openshift.org/latest/dev_guide/builds.html#build-hooks |
"Arguments to Default Image Entry Point", | ||
"Shell Script with Arguments", | ||
"Command with Arguments" | ||
]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer if we had a label and internal ID for each of these. I'd rather not do string comparisons on long labels, and it will make translation harder down the road.
$scope.buildHookSelection.type = "Command"; | ||
} else { | ||
$scope.buildHookSelection.type = "Shell Script"; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think something like this would be easier to follow:
var postCommit = _.get($scope, 'buildConfig.spec.postCommit', {});
if (_.size(postCommit.args) && _.size(postCommit.command)) {
$scope.buildHookSelection.type = "Command with Arguments";
return;
}
if (postCommit.script && _.size(postCommit.args)) {
$scope.buildHookSelection.type = "Shell Script with Arguments";
return;
}
// etc...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need an option for no post commit hooks? How do I unset the value?
var getInitialBuildHookSelection = function() { | ||
if (($scope.buildConfig.spec.postCommit.args || []).length) { | ||
if (($scope.buildConfig.spec.postCommit.command || []).length) { | ||
$scope.buildHookSelection.type = "Command with Arguments";sdas |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Random trailing chars
<h3 class="with-divider">Build Hooks | ||
<span class="help action-inline"> | ||
<a href> | ||
<i class="pficon pficon-help" data-toggle="tooltip" aria-hidden="true" data-original-title="Build hooks allow behavior to be injected into the build process."></i> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Build hooks let you run commands at the end of the build to verify the image."
<h4>Hook Types</h4> | ||
<ui-select required | ||
ng-model="buildHookSelection.type" | ||
title="Choose a Build Hook type to edit"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Choose a type of build hook
<h4>Command</h4> | ||
<edit-command | ||
args="buildConfig.spec.postCommit.command" | ||
isRequired="true"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure setting isRequired="true"
is correct since this is inside an ng-show
block, not an ng-if
. If I don't have a command and switch types, can I submit the form?
ui-ace="{ | ||
mode: 'yaml', | ||
theme: 'eclipse', | ||
onLoad: aceLoaded, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
aceLoaded
is not defined in the controller, remove onLoad
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like Line 112 & Line 293 both have onLoad: aceLoaded as well. Want me remove them too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it shouldn't be there unless there is a controller aceLoaded
method. (I don't think there is.)
ui-ace="{ | ||
mode: 'yaml', | ||
theme: 'eclipse', | ||
onLoad: aceLoaded, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
aceLoaded
is not defined in the controller, remove onLoad
showPrintMargin: false | ||
} | ||
}" | ||
ng-model="buildConfig.spec.postCommit.script" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All of these fields should use updatedBuildConfig
in the model. You shouldn't mutate the original build config.
|
||
|
||
<div class="section" ng-if="view.advancedOptions"> | ||
<div ng-if="!(updatedBuildConfig | isJenkinsPipelineStrategy)" class="section"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe make this div and its parent one div
<div ng-if="view.advancedOptions && !(updatedBuildConfig | isJenkinsPipelineStrategy)" class="section">
71b96b9
to
675b326
Compare
675b326
to
60bd1bd
Compare
60bd1bd
to
8a3f330
Compare
i think sentence case would look / read better in the dropdown "Shell
script with arguments"
…On Fri, Dec 16, 2016 at 2:29 PM, Mark DeMaria ***@***.***> wrote:
@spadgett <https://github.com/spadgett> @jwforres
<https://github.com/jwforres>
Build Hook Checkbox unselected
[image: image]
<https://cloud.githubusercontent.com/assets/19572090/21275667/e99ed41a-c39b-11e6-8c4c-7dfc9f227d5f.png>
Build Hook Checkbox selected
[image: image]
<https://cloud.githubusercontent.com/assets/19572090/21275699/19928586-c39c-11e6-9166-62da9cea31a7.png>
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#680 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABZk7YYp_4d5APiwcERdV4UEgM6kcQ03ks5rIua1gaJpZM4KXa-k>
.
|
Can do. Do you want sentence-case for all drop-down entries? |
@@ -51,6 +51,7 @@ window.OPENSHIFT_CONSTANTS = { | |||
"builds": "architecture/core_concepts/builds_and_image_streams.html#builds", | |||
"image-streams": "architecture/core_concepts/builds_and_image_streams.html#image-streams", | |||
"storage": "architecture/additional_concepts/storage.html", | |||
"build-hooks": "https://docs.openshift.org/latest/dev_guide/builds.html#build-hooks", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make it a relative URL.
"dev_guide/builds.html#build-hooks"
}, { | ||
"id": "commandArgs", | ||
"label": "Command with Arguments" | ||
}]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Per @jwforres let's make these all sentence case
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: the quotes around id
and label
aren't needed.
}]; | ||
|
||
$scope.buildHookSelection = { | ||
"type": {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The quotes are type
aren't needed.
var getInitialBuildHookSelection = function() { | ||
$scope.view.hasHooks = (_.size($scope.buildConfig.spec.postCommit.args) || | ||
_.size($scope.buildConfig.spec.postCommit.command) || | ||
$scope.buildConfig.spec.postCommit.script) ? true : false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think the postCommit
property is guaranteed to be in the JSON. Using _.get
guards against a runtime error.
var hasArgs = !_.isEmpty(_.get($scope, 'buildConfig.spec.postCommit.args'));
var hasCommand = !_.isEmpty(_.get($scope, 'buildConfig.spec.postCommit.command'));
var hasScript = !!_.get($scope, 'buildConfig.spec.postCommit.command');
$scope.view.hasHooks = hasArgs || hasCommand || hasScript;
Then you can use the local vars below without checking size again.
$scope.buildHookSelection.type.id = "command"; | ||
} | ||
|
||
$scope.buildHookSelection.type.label = _.find($scope.buildHookTypes, {'id': $scope.buildHookSelection.type.id}).label; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't need to set this. You can use {{$select.selected.label}}
in the ui-select
markup.
$scope.buildHookSelection.type.label = _.find($scope.buildHookTypes, {'id': $scope.buildHookSelection.type.id}).label; | ||
}; | ||
|
||
var clearIncompatibleBuildHookFields = function(selectedBuildHookID) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd delete the incompatible fields instead of setting them to empty values.
@@ -414,6 +487,7 @@ angular.module('openshiftConsole') | |||
|
|||
$scope.save = function() { | |||
$scope.disableInputs = true; | |||
clearIncompatibleBuildHookFields($scope.buildHookSelection.type.id); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd check $scope.buildHookSelection.type.id
directly in the clearIncompatibleBuildHookFields
instead of passing it in.
<div ng-if="view.advancedOptions && !(updatedBuildConfig | isJenkinsPipelineStrategy)" class="section"> | ||
<h3 class="with-divider">Build Hooks | ||
<span class="help action-inline"> | ||
<a href="{{'build-hooks' | helpLink}}" aria-hidden="true" target="_blank"><span class="learn-more-inline">Learn more <i class="fa fa-external-link"></i></span></a> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We've changed the "Learn More" links to use an uppercase M
.
<h4>Script</h4> | ||
<div | ||
ui-ace="{ | ||
mode: 'sh', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to add mode-sh.js
to ace-builds
in bower.json.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comments
Need to update |
e0407ed
to
231ccb6
Compare
I think it's small enough to add this PR. I'd make the label an optional attribute I can pass into the directive. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You have a change in dist.java
that shouldn't be there. We'll have to fix that before we merge.
Note this needs to be in by the end of tomorrow (Wed Jan 18) to make feature cutoff for 1.5. We can make the edit-command
directive changes a follow-on if necessary.
Thanks @MarkDeMaria
$scope.buildHookSelection.type = _.find($scope.buildHookTypes, { id: 'script' }); | ||
} else { | ||
$scope.buildHookSelection.type = _.find($scope.buildHookTypes, { id: 'command' }); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: I'd assign the id to a var and the only do the _.find in one place. That avoids repeating the same code.
var id;
if (hasArgs && hasCommand) {
id = 'commandArgs';
} else if ...
$scope.buildHookSelection.type = _.find($scope.buildHookTypes, { id: id });
$scope.updatedBuildConfig.spec.postCommit.command = []; | ||
$scope.updatedBuildConfig.spec.postCommit.args = []; | ||
$scope.updatedBuildConfig.spec.postCommit.script = ""; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What you have here is fine, although I might handle the simple case first and return early. It makes the code a little easier to understand because it avoids a big if
block.
var clearIncompatibleBuildHookFields = function() {
if (!$scope.view.hasHooks) {
$scope.updatedBuildConfig.spec.postCommit.command = [];
$scope.updatedBuildConfig.spec.postCommit.args = [];
$scope.updatedBuildConfig.spec.postCommit.script = "";
return;
}
switch ($scope.buildHookSelection.type.id) {
// ...
}
};
Probably should delete the keys for !hasHooks
case as well instead of setting them to empty values.
231ccb6
to
b2fa06b
Compare
-Single-select tag for Command, Script, and Args, Command+Args, Script+Args -Whatever option is currently-selected upon hitting 'Save' will overwrite anything else. For example, if post commit has a command in it, and you hit save on the Args page, the command will be deleted and the args saved. -Checkbox shows/hides the build hook editor. Leaving it unchcked and selecting "Save" with anything saved in the post commit section of the YAML will be deleted, as the user has indicated they do not wish to have any build hooks -Alterations to edit-command directive to allow for a 'type' arg to be passed through. Will replace relevant wording. For example, 'argument.' If no type provided, defaults to 'command.'
b2fa06b
to
a968944
Compare
<!-- Single-line entry --> | ||
<span ng-show="!multiline" class="input-group"> | ||
<input type="text" | ||
ng-model="nextArg" | ||
name="nextArg" | ||
ng-attr-id="{{id}}-add-arg" | ||
on-enter="addArg()" | ||
placeholder="Add argument" | ||
placeholder="Add {{type || 'command'}}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changing the default will affect other places where this is used, where it should be "Add argument"
Drag and drop command arguments to reorder them. | ||
</div> | ||
<div ng-if="type"> | ||
Enter the arguments that will be appended to the container's command. Drag and drop arguments to reorder them. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This text is not necessarily always correct when the type is set. We should add a description scope value if we need to say something specific like this.
I'm going to go ahead and merge so that we make DCUT. The remaining comments are fairly minor, and we can fix them in a follow up PR. @jwforres FYI [merge] |
Evaluated for origin web console merge up to a968944 |
Origin Web Console Merge Results: SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pull_requests_origin_web_console/932/) (Base Commit: f3d64d5) |
-Multi-select tag for Command, Script, and Args
-Warning states:
--On page load, if both Command and Script are both present, forms are disabled and user told to use YAML
--If either Command or Script present, and user tries to add the type not present, Save button is disabled and has-error info-block informs user of error and told to use YAML
All Selected

Script & Command present at page load. Form disabled and notification present

Page loaded with either script or command. Entered the other. Save button disabled and message shown to user.
