Skip to content

Conversation

vivek
Copy link
Collaborator

@vivek vivek commented May 12, 2017

Description

See JENKINS-44208.

Basically, idea is for plugins interested in customizing blueocean url mapping for given ModelObject, they can implement BlueOceanUrlMapper. If there is need to customize Open Blue Ocean menu item/action, then implement BlueOceanUrlAction and BlueOceanUrlActionFactory.

Submitter checklist

  • Link to JIRA ticket in description, if appropriate.
  • Change is code complete and matches issue description
  • Appropriate unit or acceptance tests or explanation to why this change has no tests
  • Reviewer's manual test instructions provided in PR description. See Reviewer's first task below.
  • Ran Acceptance Test Harness against PR changes.

Reviewer checklist

  • Run the changes and verified the change matches the issue description
  • Reviewed the code
  • Verified that the appropriate tests have been written or valid explanation given

vivek added 2 commits May 15, 2017 16:30
This is to provide fine grained control for other plugins to generate
url for given model object.
@vivek
Copy link
Collaborator Author

vivek commented May 15, 2017

@brody @i386 Ended up using 48x48, it looked better:

image

@i386
Copy link
Contributor

i386 commented May 15, 2017

Nice 👍

@vivek
Copy link
Collaborator Author

vivek commented May 16, 2017

@alvarolobato PTAL. I think I have everything you need.

  • Implement BlueOceanUrlMapper to control custom mapping of jenkins ModelObject to url
  • Implement BlueOceanUrlActionFactory and BlueOceanUrlAction to customize the view of action menu to open blueocean. You might need to implement it for the ModelObject not handled by default implementation.

@vivek vivek changed the title Web url builder extension JENKINS-44208 Web url builder extension May 16, 2017
Copy link
Member

@alvarolobato alvarolobato left a comment

Choose a reason for hiding this comment

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

Thanks @vivek . Looks good, just some minor comments.

public String getUrl(@Nonnull ModelObject modelObject) {
BlueOrganization organization = getOrganization(modelObject);
if(organization == null){ //no organization, best we can do is to land user on landing page
return getLandingPagePath();
Copy link
Member

Choose a reason for hiding this comment

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

Maybe better just return null and let the default behaviour return the landing page or another mapper handle it?

In any case this is ordinal -9999 so it would always be the last one.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@alvarolobato getLandingPagePath() is computed using BlueOceanUIProvider, so should be fine, anyways ordinal value is going to let other plugins override it.

Copy link
Member

Choose a reason for hiding this comment

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

You are right, I miss read the method.

* @author Vivek Pandey
*/
@Extension(ordinal = -9999)
public class BlueOceanUrlActionImpl implements BlueOceanUrlAction {
Copy link
Member

Choose a reason for hiding this comment

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

Same as above

* @author Vivek Pandey
*/
@Extension(ordinal = -9999)
public class BlueOceanUrlActionFactoryImpl extends BlueOceanUrlActionFactory {
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 this should be moved outside blueocean-pipeline-api-impl there's nothing specific to pipeline here anymore, and should be possible to use it without pipeline plugins

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Agreed, it used to depend on this plugin but with this PR, we can pretty much move it inside blueocean-rest-impl.


import javax.annotation.Nonnull;

import static io.jenkins.blueocean.BlueOceanUrlMapperImpl.getLandingPagePath;
Copy link
Member

Choose a reason for hiding this comment

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

This probably should need to be moved here, as we may not have the dependency with pipeline plugins

@alvarolobato
Copy link
Member

🐝

@vivek
Copy link
Collaborator Author

vivek commented May 16, 2017

@alvarolobato PTAL. I think I have answered your concerns.

There are ATH tests failing as #open-blueocean-in-context element is no more there. I will fix those tests after I figure how to test these action menu. Thats coming up next.

vivek added 3 commits May 17, 2017 16:31
- BlueOceanUrlAction is a RootAction so that `Open Blue Ocean` gets
  added reliably on Jenkins home page.
- Make sure, BlueOceanUrlAction is added only once to left menu
@vivek
Copy link
Collaborator Author

vivek commented May 18, 2017

@imeredith PTAL at ATH changes.

@vivek
Copy link
Collaborator Author

vivek commented May 18, 2017

@imeredith tests are failing with same error:

Timed out while waiting for element <body.page-head-removed> to be present for 20000 milliseconds.  - expected "found" but got: "not found"
    at Timeout._onTimeout (/Users/vivek/ws/blueocean/acceptance-tests/src/main/js/custom_commands/removePageHead.js:50:18)

Perhaps these changes expose this timing bug? @imeredith It will be great if you could try out this branch.

@imeredith
Copy link
Collaborator

@vivek .useXpath() sets all selectors in the future to be xpath. A css one is failing so im guessing your use of xpath caused this (noticed in changes). You can do .useCss() to fix that

@imeredith
Copy link
Collaborator

Also the stuff in addOpenBlueOceanLinkToFooter is just flaky in general. If you cant get a test to pass it, try restarting the ATH server. its a real PITA.

@vivek
Copy link
Collaborator Author

vivek commented May 19, 2017

@imeredith Ah, right. I reset selector to css. Lets see how this run goes. addOpenBlueOceanLinkToFooter is deleted because there is no need for this trick as that button on top is removed.

vivek added 2 commits May 19, 2017 09:55
Provides methods to open and check visibility of 'open blue ocean' link
@vivek
Copy link
Collaborator Author

vivek commented May 19, 2017

@imeredith I changed openBlueOcean.js from command to page object. This way there is one place to open blueocean page and check it's visibility. All looks good now. PTAL before I merge:)

http://127.0.0.1:50313
Copy link
Member

Choose a reason for hiding this comment

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

probably should be ignored

Copy link
Collaborator

Choose a reason for hiding this comment

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

It is in my latest stuff

@michaelneale
Copy link
Member

🐝 from me but need @imeredith to give this the nod - as it is a bit of a cross cutting change, but looks great!

@michaelneale michaelneale mentioned this pull request May 22, 2017
8 tasks
@imeredith
Copy link
Collaborator

Why a pageobject and not a command? For a start its not a page, but it exists on most of classic pages.

@vivek
Copy link
Collaborator Author

vivek commented May 22, 2017

@imeredith nightwatch page objects can be anything that appears on a page and tests want access to it, so it's fine for it to be page object without any side effect.

Other reasons listed below:

  • It exposes two methods, open() and visible(), if we go with command approach there will be two commands then. This makes it modular.
  • Fixes flakiness. From what I experienced, command objects trying to useXpath() doesn't work well even if it gets reset with useCss(). OTOH, page object element's locateStrategy works quite reliably.

@imeredith
Copy link
Collaborator

🐝

@vivek vivek merged commit 7faf481 into master May 22, 2017
@vivek vivek deleted the web-url-builder-extension branch May 22, 2017 23:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants