Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed Sep 12, 2021
1 parent d2e6e2f commit 25abab5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 18 deletions.
19 changes: 4 additions & 15 deletions src/combination/dimensions.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,13 @@
// previews and `dev`
export const DIMENSIONS = [
{
// Name used internally or in error messages
dimension: 'task',
// Property name for the identifier
idName: 'taskId',
// Property name for the title
titleName: 'taskTitle',
// Whether dimension was created by users or by plugins
createdByUser: true,
},
{
Expand All @@ -28,18 +32,3 @@ export const DIMENSIONS = [
createdByUser: true,
},
]

// Dimensions created by users, not by plugins
const getUserDimensions = function () {
return new Set(DIMENSIONS.filter(isUserDimension).map(getDimensionName))
}

const isUserDimension = function ({ createdByUser }) {
return createdByUser
}

const getDimensionName = function ({ dimension }) {
return dimension
}

export const USER_DIMENSIONS = getUserDimensions()
7 changes: 4 additions & 3 deletions src/combination/user_ids.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { USER_DIMENSIONS } from './dimensions.js'
import { DIMENSIONS } from './dimensions.js'
import { getCombinationsIds } from './ids.js'
import { getInputIds } from './inputs.js'

Expand All @@ -9,8 +9,9 @@ export const getUserIds = function (combinations, inputs) {
return [...combinationsUserIds, ...nonCombinationsIds]
}

const isUserId = function ({ dimension }) {
return USER_DIMENSIONS.has(dimension)
const isUserId = function (idInfo) {
return DIMENSIONS.find(({ dimension }) => idInfo.dimension === dimension)
.createdByUser
}

// Identifiers that do not relate to dimensions/combinations
Expand Down

0 comments on commit 25abab5

Please sign in to comment.