[ML] Job selector text take group selection into account (#31333) (#31490)

* job selector text: take group selection into account

* fix localization error
This commit is contained in:
Melissa Alvarez 2019-02-19 13:16:44 -05:00 committed by GitHub
parent b2e35aba9c
commit 9e2a2dad59
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 5 deletions

View file

@ -114,14 +114,26 @@ export function JobSelectServiceProvider($rootScope, globalState, i18n) {
} else {
// not all jobs have been selected
// add up how many jobs belong to groups and how many don't
const selectedGroupJobs = [];
const groupCounts = {};
let groupLessJobs = 0;
jobs.forEach(job => {
const splitJobs = jobs.map(job => {
const obj = splitJobId(job);
if (obj.group) {
groupCounts[obj.group] = (groupCounts[obj.group] || 0) + 1;
// keep track of selected jobs from group selection
selectedGroupJobs.push(obj.job);
}
return obj;
});
splitJobs.forEach(jobObj => {
if (jobObj.group) {
groupCounts[jobObj.group] = (groupCounts[jobObj.group] || 0) + 1;
} else {
groupLessJobs++;
// if job has already been included via group selection don't add as groupless job
if (selectedGroupJobs.includes(jobObj.job) === false) {
groupLessJobs++;
}
}
});
const wholeGroups = [];
@ -146,8 +158,10 @@ export function JobSelectServiceProvider($rootScope, globalState, i18n) {
if (wholeGroups.length > 1 || groupLessJobs > 0) {
const total = (wholeGroups.length - 1) + groupLessJobs;
txt = i18n('xpack.ml.jobSelect.wholeGroupDescription', {
defaultMessage: '{wholeGroup} and {total, plural, zero {# other} one {# other} other {# others}}',
defaultMessage: `{wholeGroup} (with {count, plural, zero {# job} one {# job} other {# jobs}}) and
{total, plural, zero {# other} one {# other} other {# others}}`,
values: {
count: groupCounts[wholeGroups[0]],
wholeGroup: wholeGroups[0],
total,
}

View file

@ -5117,7 +5117,6 @@
"xpack.ml.jobSelect.jobDescription": "{jobId} 和 {jobsAmount, plural, zero {# 个其他作业} one {# 个其他作业} other {# 个其他作业}}",
"xpack.ml.jobSelect.noJobsSelectedWarningMessage": "未选择作业,将自动选择第一个作业",
"xpack.ml.jobSelect.requestedJobsDoesNotExistWarningMessage": "已请求\n{invalidIdsLength, plural, one { 个作业 {invalidIds} 不存在} other { 个作业 {invalidIds} 不存在}}",
"xpack.ml.jobSelect.wholeGroupDescription": "{wholeGroup} 和 {total, plural, zero {# 个其他作业} one {# 个其他作业} other {# 个其他作业}}",
"xpack.ml.jobSelectButton.jobSelectionMenuButtonAriaLabel": "作业选择菜单",
"xpack.ml.jobSelectButton.jobSelectionMenuButtonTooltip": "已选择 {description}",
"xpack.ml.jobSelectButton.jobTitle": "作业",