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

Make branding overridable in signin/login page #8462

Merged
merged 2 commits into from
Sep 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions core/src/main/java/jenkins/model/SimplePageDecorator.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,25 @@
* <p>
* This class provides a few hooks to augment the HTML of the login page.
*
* <dl>
* <dt>simple-branding.jelly</dt>
* <dd>
* This view contributes to the branding section, usually located on the left side of the login/register pages.
* </dd>
* <dt>simple-footer.jelly</dt>
* <dd>
* This view contributes to the footer section, located below the login/register form.
* </dd>
* <dt>simple-head.jelly</dt>
* <dd>
* This view contributes to the head section.
* </dd>
* <dt>simple-header.jelly</dt>
* <dd>
* This view contributes to the header section just above the login/register form.
* </dd>
* </dl>
*
* @since 2.128
*/
public class SimplePageDecorator extends Descriptor<SimplePageDecorator> implements ExtensionPoint, Describable<SimplePageDecorator> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,16 @@ THE SOFTWARE.
<!-- mobile friendly layout -->
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<!-- css styling, will fallback to default implementation -->
<st:include it="${simpleDecorator}" page="simple-head.jelly" optional="true"/>
Copy link
Member

Choose a reason for hiding this comment

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

why remove these optionals?

Copy link
Member Author

Choose a reason for hiding this comment

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

Since the views are moved from DefaultSimplePageDecorator to SimplePageDecorator now, they can't be missing, so just clarifying that (although it doesn't change anything functionally)

Copy link
Member

@timja timja Sep 5, 2023

Choose a reason for hiding this comment

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

Copy link
Member Author

@Vlatombe Vlatombe Sep 5, 2023

Choose a reason for hiding this comment

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

Works fine as the default from SimplePageDecorator will be used if none is provided by the concrete implementation.

<st:include it="${simpleDecorator}" page="simple-head.jelly" />
<script src="${resURL}/jsbundles/pages/register.js" type="text/javascript" defer="true" />
</head>
<body class="app-sign-in-register">
<section class="app-sign-in-register__branding">
<div class="app-sign-in-register__branding__starburst"></div>
<img src="${imagesURL}/svgs/logo.svg" alt="${%logo}"/>
</section>
<st:include it="${simpleDecorator}" page="simple-branding.jelly" />
<main id="main-panel" class="app-sign-in-register__content">
<div class="app-sign-in-register__content-inner">
<h1>${%Register}</h1>

<st:include it="${simpleDecorator}" page="simple-header.jelly" optional="true" />
<st:include it="${simpleDecorator}" page="simple-header.jelly" />

<template id="i18n" data-strength-strong="${%Strong}"
data-strength-moderate="${%Moderate}"
Expand Down
9 changes: 3 additions & 6 deletions core/src/main/resources/jenkins/model/Jenkins/login.jelly
Original file line number Diff line number Diff line change
Expand Up @@ -59,23 +59,20 @@ THE SOFTWARE.
<!-- mobile friendly layout -->
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<!-- css styling, will fallback to default implementation -->
<st:include it="${simpleDecorator}" page="simple-head.jelly" optional="true"/>
<st:include it="${simpleDecorator}" page="simple-head.jelly" />
</head>
<body class="app-sign-in-register">
<j:choose>
<j:when test="${it.setupWizard.isUsingSecurityToken()}">
<st:include it="${it.setupWizard}" page="authenticate-security-token"/>
</j:when>
<j:otherwise>
<section class="app-sign-in-register__branding">
<div class="app-sign-in-register__branding__starburst"></div>
<img src="${imagesURL}/svgs/logo.svg" alt="${%logo}"/>
</section>
<st:include it="${simpleDecorator}" page="simple-branding.jelly" />
<main id="main-panel" class="app-sign-in-register__content">
<div class="app-sign-in-register__content-inner">
<h1>Sign in to Jenkins</h1>

<st:include it="${simpleDecorator}" page="simple-header.jelly" optional="true" />
<st:include it="${simpleDecorator}" page="simple-header.jelly" />

<form name="login" action="${it.securityRealm.authenticationGatewayUrl}"
method="post">
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<!--
The MIT License

Copyright (c) 2023, 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.
-->
<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core">
<section class="app-sign-in-register__branding">
<div class="app-sign-in-register__branding__starburst"></div>
<img src="${imagesURL}/svgs/logo.svg" alt="${%logo}"/>
</section>
</j:jelly>
Loading