Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[JENKINS-34522] Expose the noun for a item as a task via AlternativeU…
…iTextProvider
  • Loading branch information
stephenc committed Mar 2, 2017
1 parent 03c58b9 commit fd82ced
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 6 deletions.
14 changes: 14 additions & 0 deletions core/src/main/java/hudson/model/AbstractItem.java
Expand Up @@ -133,6 +133,15 @@ public String getPronoun() {
return AlternativeUiTextProvider.get(PRONOUN, this, Messages.AbstractItem_Pronoun());
}

/**
* Gets the term used in the UI to represent the kind of {@link Queue.Task} associated with this kind of
* {@link Item}. Must start with a capital letter. Defaults to "Build".
* @since FIXME
*/
public String getTaskNoun() {
return AlternativeUiTextProvider.get(TASK_NOUN, this, Messages.AbstractItem_TaskNoun());
}

@Exported
/**
* @return The display name of this object, or if it is not set, the name
Expand Down Expand Up @@ -749,4 +758,9 @@ public static AbstractItem resolveForCLI(
*/
public static final Message<AbstractItem> PRONOUN = new Message<AbstractItem>();

/**
* Replaceable noun for describing the kind of task that this item represents. Defaults to "Build".
*/
public static final Message<AbstractItem> TASK_NOUN = new Message<>();

}
8 changes: 8 additions & 0 deletions core/src/main/java/hudson/views/BuildButtonColumn.java
Expand Up @@ -24,6 +24,7 @@
package hudson.views;

import hudson.Extension;
import hudson.model.AbstractItem;
import org.jenkinsci.Symbol;
import org.kohsuke.stapler.DataBoundConstructor;

Expand All @@ -32,6 +33,13 @@ public class BuildButtonColumn extends ListViewColumn {
public BuildButtonColumn() {
}

public String taskNoun(Object job) {
if (job instanceof AbstractItem) {
return ((AbstractItem) job).getTaskNoun();
}
return hudson.model.Messages.AbstractItem_TaskNoun();
}

@Extension(ordinal=DEFAULT_COLUMNS_ORDINAL_ACTIONS_START-1) @Symbol("buildButton")
public static class DescriptorImpl extends ListViewColumnDescriptor {
@Override
Expand Down
1 change: 1 addition & 0 deletions core/src/main/resources/hudson/model/Messages.properties
Expand Up @@ -31,6 +31,7 @@ AbstractBuild.KeptBecause=This build is kept because of {0}.
AbstractItem.NoSuchJobExists=No such job \u2018{0}\u2019 exists. Perhaps you meant \u2018{1}\u2019?
AbstractItem.NoSuchJobExistsWithoutSuggestion=No such job \u2018{0}\u2019 exists.
AbstractItem.Pronoun=Item
AbstractItem.TaskNoun=Build
AbstractProject.AssignedLabelString_NoMatch_DidYouMean=There\u2019s no agent/cloud that matches this assignment. Did you mean \u2018{1}\u2019 instead of \u2018{0}\u2019?
AbstractProject.NewBuildForWorkspace=Scheduling a new build to get a workspace.
AbstractProject.AwaitingBuildForWorkspace=Awaiting build to get a workspace.
Expand Down
Expand Up @@ -30,11 +30,11 @@ THE SOFTWARE.
<a href="${jobBaseUrl}${job.shortUrl}build?delay=0sec">
<j:choose>
<j:when test="${job.parameterized}">
<j:set var="title" value="${%Schedule_a_build_with_parameters(h.getRelativeDisplayNameFrom(job, itemGroup))}"/>
<j:set var="title" value="${%Schedule_a_task_with_parameters(h.getRelativeDisplayNameFrom(job, itemGroup),it.taskNoun(job))}"/>
<j:set var="onclick" value="${null}"/>
</j:when>
<j:otherwise>
<j:set var="title" value="${%Schedule_a_build(h.getRelativeDisplayNameFrom(job, itemGroup))}"/>
<j:set var="title" value="${%Schedule_a_task(h.getRelativeDisplayNameFrom(job, itemGroup),it.taskNoun(job))}"/>
<j:set var="onclick" value="return build_${id}(this)"/>
</j:otherwise>
</j:choose>
Expand All @@ -46,7 +46,7 @@ THE SOFTWARE.
<script>
function build_${id}(img) {
new Ajax.Request(img.parentNode.href);
hoverNotification('${%Build_scheduled}', img, -100);
hoverNotification('${%Task_scheduled(it.taskNoun(job))}', img, -100);
return false;
}
</script>
Expand Down
Expand Up @@ -20,6 +20,6 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.

Build_scheduled=Build scheduled
Schedule_a_build=Schedule a build for {0}
Schedule_a_build_with_parameters=Schedule a build with parameters for {0}
Task_scheduled={0} scheduled
Schedule_a_task=Schedule a {1} for {0}
Schedule_a_task_with_parameters=Schedule a {1} with parameters for {0}

0 comments on commit fd82ced

Please sign in to comment.