improve: filter as a plugin (#4255)
This commit is contained in:
@@ -21,7 +21,8 @@ export default class Operations extends React.Component {
|
||||
layoutActions: PropTypes.object.isRequired,
|
||||
authActions: PropTypes.object.isRequired,
|
||||
authSelectors: PropTypes.object.isRequired,
|
||||
getConfigs: PropTypes.func.isRequired
|
||||
getConfigs: PropTypes.func.isRequired,
|
||||
fn: PropTypes.func.isRequired
|
||||
};
|
||||
|
||||
render() {
|
||||
@@ -30,7 +31,8 @@ export default class Operations extends React.Component {
|
||||
getComponent,
|
||||
layoutSelectors,
|
||||
layoutActions,
|
||||
getConfigs
|
||||
getConfigs,
|
||||
fn
|
||||
} = this.props
|
||||
|
||||
let taggedOps = specSelectors.taggedOperations()
|
||||
@@ -52,9 +54,7 @@ export default class Operations extends React.Component {
|
||||
|
||||
if (filter) {
|
||||
if (filter !== true) {
|
||||
taggedOps = taggedOps.filter((tagObj, tag) => {
|
||||
return tag.indexOf(filter) !== -1
|
||||
})
|
||||
taggedOps = fn.opsFilter(taggedOps, filter)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
9
src/core/plugins/filter/index.js
Normal file
9
src/core/plugins/filter/index.js
Normal file
@@ -0,0 +1,9 @@
|
||||
import opsFilter from "./opsFilter"
|
||||
|
||||
export default function() {
|
||||
return {
|
||||
fn: {
|
||||
opsFilter
|
||||
}
|
||||
}
|
||||
}
|
||||
3
src/core/plugins/filter/opsFilter.js
Normal file
3
src/core/plugins/filter/opsFilter.js
Normal file
@@ -0,0 +1,3 @@
|
||||
export default function(taggedOps, phrase) {
|
||||
return taggedOps.filter((tagObj, tag) => tag.indexOf(phrase) !== -1)
|
||||
}
|
||||
@@ -12,6 +12,7 @@ import SplitPaneModePlugin from "core/plugins/split-pane-mode"
|
||||
import downloadUrlPlugin from "core/plugins/download-url"
|
||||
import configsPlugin from "core/plugins/configs"
|
||||
import deepLinkingPlugin from "core/plugins/deep-linking"
|
||||
import filter from "core/plugins/filter"
|
||||
|
||||
import OperationContainer from "core/containers/OperationContainer"
|
||||
|
||||
@@ -152,6 +153,7 @@ export default function() {
|
||||
ast,
|
||||
SplitPaneModePlugin,
|
||||
downloadUrlPlugin,
|
||||
deepLinkingPlugin
|
||||
deepLinkingPlugin,
|
||||
filter
|
||||
]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user