Replace ${project} in a foreach query (for project dashboards)

Bug: Issue 11592
Change-Id: I548064dd2ddaa556c2a2a27ca37bdea15fc339dd
This commit is contained in:
Paladox none
2019-09-25 15:41:36 +00:00
parent bfa2a6e897
commit abbd26df55
2 changed files with 4 additions and 6 deletions

View File

@@ -119,9 +119,8 @@
const suffix = response.foreach ? ' ' + response.foreach : ''; const suffix = response.foreach ? ' ' + response.foreach : '';
return { return {
name: section.name, name: section.name,
query: query: (section.query + suffix).replace(
section.query.replace( PROJECT_PLACEHOLDER_PATTERN, project),
PROJECT_PLACEHOLDER_PATTERN, project) + suffix,
}; };
}), }),
}; };

View File

@@ -225,7 +225,6 @@ limitations under the License.
test('dashboard with foreach', () => { test('dashboard with foreach', () => {
sandbox.stub(element.$.restAPI, 'getDashboard', () => Promise.resolve({ sandbox.stub(element.$.restAPI, 'getDashboard', () => Promise.resolve({
title: 'title', title: 'title',
// Note: ${project} should not be resolved in foreach!
foreach: 'foreach for ${project}', foreach: 'foreach for ${project}',
sections: [ sections: [
{name: 'section 1', query: 'query 1'}, {name: 'section 1', query: 'query 1'},
@@ -238,10 +237,10 @@ limitations under the License.
{ {
title: 'title', title: 'title',
sections: [ sections: [
{name: 'section 1', query: 'query 1 foreach for ${project}'}, {name: 'section 1', query: 'query 1 foreach for project'},
{ {
name: 'section 2', name: 'section 2',
query: 'project query 2 foreach for ${project}', query: 'project query 2 foreach for project',
}, },
], ],
}); });