Add a "Try Blue Ocean UI" button in classic Jenkins

This commit is contained in:
tfennelly 2016-06-09 19:10:11 +01:00
parent 403458eadb
commit 91538bc8ab
7 changed files with 98 additions and 0 deletions

View File

@ -35,6 +35,17 @@ builder.bundle('src/main/js/blueocean.js')
.less('src/main/less/blueocean.less')
.generateNoImportsBundle();
//
// Create the "Try Blue Ocean" Javascript bundle.
// This .js bundle will be added to every classic Jenkins page
// via a PageDecorator. Using this as a way of enticing Jenkins
// users to move from classic Jenkins to Blue Ocean where possible.
//
builder.bundle('src/main/js/try.js')
.inDir('target/classes/io/jenkins/blueocean')
.withExternalModuleMapping('jquery-detached', 'core-assets/jquery-detached:jquery2') // Bundled in Jenkins 2.x
.less('src/main/less/try.less');
//
// Copy/link the JDL assests into the webapp dir, making them available at runtime.
//

View File

@ -20,6 +20,7 @@
"eslint-plugin-react": "^5.0.1",
"giti": "^1.0.6",
"gulp": "^3.9.1",
"jquery-detached": "^2.1.4-v4",
"ncp": "^2.0.0",
"zombie": "^4.2.1"
},

View File

@ -0,0 +1,38 @@
/*
* The MIT License
*
* Copyright (c) 2016, CloudBees, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package io.jenkins.blueocean;
import hudson.Extension;
import hudson.model.PageDecorator;
/**
* Stapler page decorator for decorating classic Jenkins pages with visual
* prompts to the user that will hopefully entice/remind them into giving
* Blue ocean a try.
*
* @author <a href="mailto:tom.fennelly@gmail.com">tom.fennelly@gmail.com</a>
*/
@Extension
public class TryBlueOceanPageDecorator extends PageDecorator {
}

View File

@ -0,0 +1,18 @@
var $ = require('jquery-detached').getJQuery();
var jsModules = require('@jenkins-cd/js-modules');
$(document).ready(function () {
var tryBlueOcean = $('<div class="try-blueocean header-callout">Try Blue Ocean UI ...</div>');
tryBlueOcean.click(function () {
// We could enhance this further by looking at the current
// URL and going to different places in the BO UI depending
// on where the user is in classic jenkins UI e.g. if they
// are currently in a job on classic UI, bring them to the
// same job in BO UI Vs just brining them to the root of
// BO UI i.e. make the button context sensitive.
window.location.replace(jsModules.getRootURL() + '/blue');
});
$('#page-head #header').append(tryBlueOcean);
});

View File

@ -0,0 +1,19 @@
@import "variables";
.try-blueocean.header-callout {
position: absolute;
padding: 5px 10px;
right: 50%;
height: 30px !important;
top: 5px;
color: #4a90e2;
border: 1px solid;
border-color: #4a90e2;
border-radius: 3px;
}
.try-blueocean.header-callout:hover {
cursor: pointer;
background-color: #4a90e2;
color: white;
}

View File

@ -1,3 +1,6 @@
//
// TODO: Gather variables and add here.
// How might we get these from the JDL? Maybe include the LESS files in the JDL distro?
//
@blueocean_blue: #4A90E2;

View File

@ -0,0 +1,8 @@
<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler">
<!--
The following Stapler adjunct adds the "Try Blue Ocean JavaScript bundle to
every page in "classic" Jenkins.
-->
<st:adjunct includes="io.jenkins.blueocean.try"/>
</j:jelly>