Skip to content

Commit

Permalink
Remove idName
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed Sep 12, 2021
1 parent ea7ee42 commit de3f105
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 19 deletions.
4 changes: 0 additions & 4 deletions src/combination/dimensions.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ export const DIMENSIONS = [
propName: 'task',
// Name used in output and error messages
messageName: 'task',
// Property name for the identifier
idName: 'id',
// Property name for the title
titleName: 'taskTitle',
// Whether dimension was created by users or by plugins
Expand All @@ -24,14 +22,12 @@ export const DIMENSIONS = [
{
propName: 'runner',
messageName: 'runner',
idName: 'id',
titleName: 'runnerTitle',
createdByUser: false,
},
{
propName: 'system',
messageName: 'system',
idName: 'id',
titleName: 'systemTitle',
createdByUser: true,
},
Expand Down
9 changes: 3 additions & 6 deletions src/combination/ids.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,15 @@ const isNotDuplicate = function ({ dimension, id }, index, combinationIds) {
}

// Retrieve each dimension's id of a given combination
export const getCombinationIds = function (combination) {
export const getCombinationIds = function ({ dimensions }) {
return DIMENSIONS.map((dimension) => ({
dimension,
id: combination.dimensions[dimension.propName][dimension.idName],
id: dimensions[dimension.propName].id,
}))
}

export const getDimensionId = function (propName, { dimensions }) {
const { idName } = DIMENSIONS.find(
(dimension) => dimension.propName === propName,
)
return dimensions[propName][idName]
return dimensions[propName].id
}

export const getDimensionTitle = function (propName, { dimensions }) {
Expand Down
14 changes: 5 additions & 9 deletions src/report/normalize/titles_add.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,10 @@ const addCombinationTitles = function (combination, titles) {
const addCombinationTitle = function ({
combination,
combination: { dimensions },
dimension: { propName, idName, titleName },
dimension: { propName, titleName },
titles,
}) {
const dimension = addTitle(dimensions[propName], {
idName,
titleName,
titles,
})
const dimension = addTitle(dimensions[propName], { titleName, titles })
return {
...combination,
dimensions: { ...dimensions, [propName]: dimension },
Expand All @@ -42,7 +38,7 @@ const addCombinationTitle = function ({
export const addFooterTitles = function (footer, titles, showTitles) {
const titlesA = showTitles ? titles : {}
const systems = footer.systems.map((system) =>
addTitle(system, { idName: 'id', titleName: 'title', titles: titlesA }),
addTitle(system, { titleName: 'title', titles: titlesA }),
)
return { ...footer, systems }
}
Expand All @@ -63,8 +59,8 @@ export const addFooterTitles = function (footer, titles, showTitles) {
// - provides a single place for all identifiers, which is simpler
// - removes the need for runners to handle this
// We do this by adding a `title` property for every `id` property.
const addTitle = function (obj, { idName, titleName, titles }) {
const id = obj[idName]
const addTitle = function (obj, { titleName, titles }) {
const { id } = obj
const { [id]: title = id } = titles
return title === undefined ? obj : { ...obj, [titleName]: title }
}

0 comments on commit de3f105

Please sign in to comment.