refactor: operations component (#7044)

This commit is contained in:
Mahtis Michel
2021-03-11 00:14:41 +01:00
committed by GitHub
parent 072362244a
commit 84358aeb78
3 changed files with 83 additions and 68 deletions

View File

@@ -1,6 +1,7 @@
import reducers from "./reducers"
import * as actions from "./actions"
import * as selectors from "./selectors"
import * as wrapSelectors from "./spec-extensions/wrap-selector"
export default function() {
return {
@@ -9,6 +10,9 @@ export default function() {
reducers,
actions,
selectors
},
spec: {
wrapSelectors
}
}
}

View File

@@ -0,0 +1,22 @@
export const taggedOperations = (oriSelector, system) => (state, ...args) => {
let taggedOps = oriSelector(state, ...args)
const { fn, layoutSelectors, getConfigs } = system.getSystem()
const configs = getConfigs()
const { maxDisplayedTags } = configs
// Filter, if requested
let filter = layoutSelectors.currentFilter()
if (filter) {
if (filter !== true && filter !== "true" && filter !== "false") {
taggedOps = fn.opsFilter(taggedOps, filter)
}
}
// Limit to [max] items, if specified
if (maxDisplayedTags && !isNaN(maxDisplayedTags) && maxDisplayedTags >= 0) {
taggedOps = taggedOps.slice(0, maxDisplayedTags)
}
return taggedOps
}