Skip to content
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

Support for Gitlab and Bitbucket webhooks in the BC editor #1539

Merged
merged 1 commit into from
Jun 13, 2017

Conversation

jhadvig
Copy link
Member

@jhadvig jhadvig commented May 11, 2017

https://trello.com/c/yy3ACVjj

Adding support for view/add/remove GitLab and Bitbucket webhooks.
Screen:
screenshot at 2017-05-11 14-09-39

screenshot at 2017-05-11 14-38-43

Not really sure if we want to display them by default as the screenshot show, but also not sure if we want to hide them in some "Advanced webhooks settings" since we already have advance view in the BC editor.

@spadgett @jwforres thoughts ?

@jwforres
Copy link
Member

jwforres commented May 11, 2017 via email

@jwforres
Copy link
Member

@ncameronbritt

@ncameronbritt
Copy link

@jwforres Sound like you're suggesting something similar to the way we handle users/roles in Membership?

@ncameronbritt
Copy link

What about something like this:
screen shot 2017-05-12 at 8 27 37 am
screen shot 2017-05-12 at 8 27 52 am
screen shot 2017-05-12 at 8 28 02 am

@ncameronbritt
Copy link

Is having multiple (and multiple kinds of) webhooks something that users need?

@jwforres
Copy link
Member

jwforres commented May 12, 2017 via email

@jhadvig
Copy link
Member Author

jhadvig commented May 12, 2017

@jwforres @ncameronbritt so I was thinking that we could list only existing webhooks, but instead of having a link under each type for Add {{type}} Webhook we could have a selectbox to specify the webhook type with a Add btn at the end of the wwebhook list.
openshift web console

@jwforres
Copy link
Member

jwforres commented May 12, 2017 via email

@ncameronbritt
Copy link

ncameronbritt commented May 12, 2017

Here are a few sketches. The first example seems like what @jhadvig proposed. Seems slightly odd that we would have to add a header for a new type. And how would they order? What if you had more than one for a given type?

The others are riffs on using more of a table format. The main difference being how the "add" action would work. Here I'd imagine that adding one would just append another row in the table.
screen shot 2017-05-12 at 9 51 30 am

@jhadvig
Copy link
Member Author

jhadvig commented May 12, 2017

@ncameronbritt so I was thinking something between #1 and #4. Dont think its necessary to have an extra Add webhook header.

openshift web console-33

OR

openshift web console-3

so we align with the style which we already have.
@jwforres thoughts ?

@jhadvig
Copy link
Member Author

jhadvig commented May 12, 2017

personally I would go with the the second option from my last comment

@sspeiche
Copy link

I can't see the different between the two but it looks good to me.

@jhadvig
Copy link
Member Author

jhadvig commented May 12, 2017

@sspeiche its the Add button... one aligns with the Remove/Undostyle we have in the existing webhooks, and the other is different.

@ncameronbritt
Copy link

I think I like the second one better, @jhadvig.

I still wonder about having them in more of a list with the label to the left of the URL and appending the most recently added to the end of the list. I think that might make it easier to keep up with which one is which if, for example, you had two GitHub webhooks. But that might not be a realistic scenario.

@jhadvig
Copy link
Member Author

jhadvig commented May 15, 2017

@ncameronbritt well then we would have to think about the way how to display the Remove/Undo logic in the list. I would suggest do that as a followup if we need to and just add the addtional types and the selectbox with the Add link as was suggested. Thoughts ? :)

@ncameronbritt
Copy link

I'm ok with that.

@jhadvig
Copy link
Member Author

jhadvig commented May 16, 2017

PR updated. Added logic for adding webhooks into editWebhookTriggers.js. When used the add-webhook attribute has to be specified ot the edit-webhook-triggers directive.
Attaching screens:
openshift web console-1

openshift web console-2

@jwforres @ncameronbritt PTAL

@spadgett spadgett self-requested a review June 6, 2017 14:29
@spadgett spadgett self-assigned this Jun 6, 2017
Copy link
Member

@spadgett spadgett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @jhadvig. A few comments.

return null;
}
}
$scope.triggerMeta = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I'd do something like

$scope.createTriggerSelect = {
  selectedType: "",
  options: [{
    type: 'github',
    label: 'GitHub'
  },
  ... 
  ]
};

Then you don't need getWebhookType above. You can update ui-select-choices to make the label option.label

secret: ApplicationGenerator._generateSecret()
};
$scope.triggers.push(webhook);
$scope.form.$setDirty();
$scope.triggers[webhookType + "Webhooks"].push(webhook);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i feel think the edit-webhook-triggers should take in just the array for this type instead of the entire map. Then you push push onto the array and don't need to worry about adding + "Webhooks" to the name.

Copy link
Member Author

@jhadvig jhadvig Jun 8, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But we have to pass the entire map cause we dont know what kind of webhook will user choose. When he chooses GitHub and creates it, we have to add the new webhook to the githubWebhooks array, or bitbucketWebhooks if he chooses Bitbucket. For that case we need to pass the entire map, just for the creating webhook action. Other option would be to split the create and view action for the webhooks in the edit-webhook-triggers and have separate directives for them. Thoughts ?


.col-add-webhook {
padding-top: 5px;
padding-bottom: 10px;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: We've started to alphabetize styles in our less files

<div class="display-webhooks" ng-if="!addWebhook">
<h5>{{type}} webhooks
<span class="help action-inline">
<a href="" aria-hidden="true">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is aria-hidden then the sr-only span on the next line will be hidden from screen readers. I'd move it outside the a element.

</h5>
<div ng-repeat="trigger in triggers">
<div class="display-webhooks" ng-if="!addWebhook">
<h5>{{type}} webhooks
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{{type}} Webhooks

(capital W)

</div>
</div>
<div class="add-webhook" ng-if="addWebhook">
<h5>Add webhook</h5>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add Webhook

<div class="trigger-info">
<span class="trigger-url">
<copy-to-clipboard is-disabled="trigger.disabled" clipboard-text="bcName | webhookURL : trigger.data.type : trigger.data[(type === 'GitHub') ? 'github' : 'generic'].secret : projectName"></copy-to-clipboard>
<ui-select ng-model="triggerMeta.typeToCreate"
theme="bootstrap"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think theme="bootstrap" is needed

ng-if="triggers.gitlabWebhooks.length"
add-webhook="false"
type="GitLab"
type-info="A GitLab source repository must be configured to use the webhook to trigger a build when source is committed."
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"The GitLab source repository..."

ng-if="triggers.bitbucketWebhooks.length"
add-webhook="false"
type="Bitbucket"
type-info="A Bitbucket source repository must be configured to use the webhook to trigger a build when source is committed."
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"The Butbucket source repository...."

<span class="fa fa-repeat" aria-hidden="true" title="Undo"></span>
<span class="sr-only">Undo</span>
<a href="" class="action-icon" ng-click="addWebhookTrigger(triggerMeta.typeToCreate)" role="button">
<span class="fa fa-plus" aria-hidden="true" title="Add"></span>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should give the add buttons here and for mobile disabled styles when a type is not selected.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really sure what you mean... dont we want to have the same styling here as we have in the for displaying the WH ? Meaning for non-mobile we would have Add link and for mobile an icon, as displayed in #1539 (comment)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I haven't selected anything in dropdown, I can't click the add button yet. It should have disabled classes so it's grayed out, cursor: not-allowed, etc.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I see. It's strange to me that edit-webhooks only edits webhooks of one type, but there's an add control for ALL types inside the directive. edit-webhooks directive should either be one directive for all webhooks or add should be outside the directive. Given the way the code is structured, I think moving add outside the directive is easier.

@openshift-bot openshift-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jun 7, 2017
@jhadvig
Copy link
Member Author

jhadvig commented Jun 9, 2017

Comments addressed. @spadgett PTAL :)

@openshift-bot openshift-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jun 9, 2017
Copy link
Member

@spadgett spadgett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @jhadvig this looks a lot cleaner. Just a few small comments.

var webhook = {
disabled: false,
data: {
type: webhookLabel
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I see that this is the API type value. Sorry didn't realize. I suggest:

      options: [{
        type: 'GitHub',
        propterty: 'github'
      }, { ... }]

And then this function should take in parameter type.

type: webhookLabel
}
};
var webhookType = _.find($scope.createTriggerSelect.options, function(o) {return o.label === webhookLabel}).type
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing ;. You can use the shorthand here

var webhookType = _.find($scope.createTriggerSelect, { label: webhookLabel }).type;
...

or if you rename the properties as above, this would be

var property = _.find($scope.createTriggerSelect, { type: type }).property;

webhook.data[webhookType] = {
secret: ApplicationGenerator._generateSecret()
};
$scope.triggers[webhookType + "Webhooks"].push(webhook);
Copy link
Member

@spadgett spadgett Jun 12, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouldn't append "Webhooks" if we don't need to? Maybe just...?

$scope.triggers[webhookType].push(webhook)

Realize this affects the initialization code and the view some.

Copy link
Member

@spadgett spadgett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since my remaining comments are minor, I'm going to approve to make sure it's in for dev cut.

@spadgett
Copy link
Member

[merge]

@spadgett
Copy link
Member

Looks like test flake #1685

[merge]

@openshift-bot
Copy link

Evaluated for origin web console merge up to 0ce355d

@openshift-bot
Copy link

openshift-bot commented Jun 13, 2017

Origin Web Console Merge Results: SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pull_requests_origin_web_console/1519/) (Base Commit: 54262a2)

@openshift-bot openshift-bot merged commit 50bfbcc into openshift:master Jun 13, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants