diff options
author | 2018-11-04 15:10:26 +0200 | |
---|---|---|
committer | 2018-11-04 15:10:32 +0200 | |
commit | b1b510be3d78daa8a37c4e058fa573a99ea62f2c (patch) | |
tree | e7a40fc272d0931bdde99f6741ca8d67de354762 /workflow-designer-ui/src/main | |
parent | ed8d3bede945e842a2716802272bdf9b24997e27 (diff) |
cache search result workflow
Issue-ID: SDC-1889
Change-Id: I4a29b9954d3ce50ea9745e8aa8996f46f12501f1
Signed-off-by: Yarin Dekel <yarind@amdocs.com>
Diffstat (limited to 'workflow-designer-ui/src/main')
6 files changed, 23 insertions, 49 deletions
diff --git a/workflow-designer-ui/src/main/frontend/src/features/catalog/Catalog.js b/workflow-designer-ui/src/main/frontend/src/features/catalog/Catalog.js index a7ddd147..867aeebd 100644 --- a/workflow-designer-ui/src/main/frontend/src/features/catalog/Catalog.js +++ b/workflow-designer-ui/src/main/frontend/src/features/catalog/Catalog.js @@ -19,7 +19,6 @@ import { connect } from 'react-redux'; import CatalogView from 'features/catalog/CatalogView'; import { fetchWorkflow, - resetWorkflow, searchChangedAction } from 'features/catalog/catalogActions'; @@ -28,13 +27,13 @@ import { NEW_WORKFLOW_MODAL } from 'shared/modal/modalWrapperComponents'; import { clearWorkflowAction } from 'features/workflow/workflowConstants'; const mapStateToProps = state => ({ - catalog: state.catalog + catalog: state.catalog, + searchNameFilter: state.searchNameFilter }); const mapDispatchToProps = dispatch => ({ handleFetchWorkflow: (sort, offset, searchNameFilter) => dispatch(fetchWorkflow(sort, offset, searchNameFilter)), - handleResetWorkflow: () => dispatch(resetWorkflow()), clearWorkflow: () => dispatch(clearWorkflowAction), showNewWorkflowModal: () => dispatch( diff --git a/workflow-designer-ui/src/main/frontend/src/features/catalog/CatalogView.jsx b/workflow-designer-ui/src/main/frontend/src/features/catalog/CatalogView.jsx index 4fdcc786..3f002523 100644 --- a/workflow-designer-ui/src/main/frontend/src/features/catalog/CatalogView.jsx +++ b/workflow-designer-ui/src/main/frontend/src/features/catalog/CatalogView.jsx @@ -27,9 +27,6 @@ import { NAME, ASC, DESC } from 'features/catalog/catalogConstants'; class CatalogView extends Component { constructor(props) { super(props); - this.state = { - searchValue: '' - }; } componentDidMount() { @@ -38,34 +35,31 @@ class CatalogView extends Component { clearWorkflow(); } - componentWillUnmount() { - this.props.handleResetWorkflow(); - } - handleAlphabeticalOrderByClick = e => { e.preventDefault(); const { handleFetchWorkflow, - catalog: { sort } + catalog: { sort, searchNameFilter } } = this.props; const payload = { ...sort }; payload[NAME] = payload[NAME] === ASC ? DESC : ASC; - handleFetchWorkflow(payload, undefined, this.state.searchValue); + handleFetchWorkflow(payload, undefined, searchNameFilter); }; handleScroll = () => { const { catalog: { paging: { offset }, - sort + sort, + searchNameFilter }, handleFetchWorkflow } = this.props; - handleFetchWorkflow(sort, offset, this.state.searchValue); + handleFetchWorkflow(sort, offset, searchNameFilter); }; goToOverviewPage = id => { @@ -91,7 +85,8 @@ class CatalogView extends Component { const { sort, paging: { hasMore, total }, - items + items, + searchNameFilter } = catalog; const alphabeticalOrder = sort[NAME]; @@ -99,7 +94,7 @@ class CatalogView extends Component { <div className="wf-catalog"> <Header searchChange={this.searchChange} - searchValue={this.state.searchValue} + searchValue={searchNameFilter} /> <InfiniteScroll useWindow={false} @@ -132,7 +127,8 @@ CatalogView.propTypes = { handleFetchWorkflow: PropTypes.func, showNewWorkflowModal: PropTypes.func, clearWorkflow: PropTypes.func, - searchInputChanged: PropTypes.func + searchInputChanged: PropTypes.func, + searchNameFilter: PropTypes.string }; CatalogView.defaultProps = { diff --git a/workflow-designer-ui/src/main/frontend/src/features/catalog/__tests__/catalogActions-test.js b/workflow-designer-ui/src/main/frontend/src/features/catalog/__tests__/catalogActions-test.js index 43c38e0b..e37307f7 100644 --- a/workflow-designer-ui/src/main/frontend/src/features/catalog/__tests__/catalogActions-test.js +++ b/workflow-designer-ui/src/main/frontend/src/features/catalog/__tests__/catalogActions-test.js @@ -19,16 +19,11 @@ import { FETCH_WORKFLOW, UPDATE_WORKFLOW, - RESET_WORKFLOW, LIMIT, NAME, ASC } from 'features/catalog/catalogConstants'; -import { - fetchWorkflow, - updateWorkflow, - resetWorkflow -} from 'features/catalog/catalogActions'; +import { fetchWorkflow, updateWorkflow } from 'features/catalog/catalogActions'; describe('Catalog Actions', () => { it('should have `fetchWorkflow` action', () => { @@ -65,10 +60,4 @@ describe('Catalog Actions', () => { payload }); }); - - it('should have `resetWorkflow` action', () => { - expect(resetWorkflow()).toEqual({ - type: RESET_WORKFLOW - }); - }); }); diff --git a/workflow-designer-ui/src/main/frontend/src/features/catalog/__tests__/catalogReducer-test.js b/workflow-designer-ui/src/main/frontend/src/features/catalog/__tests__/catalogReducer-test.js index 5444bf94..b31aa2ea 100644 --- a/workflow-designer-ui/src/main/frontend/src/features/catalog/__tests__/catalogReducer-test.js +++ b/workflow-designer-ui/src/main/frontend/src/features/catalog/__tests__/catalogReducer-test.js @@ -18,7 +18,7 @@ import { NAME, ASC, DESC } from 'features/catalog/catalogConstants'; import catalogReducer, { initialState } from 'features/catalog/catalogReducer'; -import { updateWorkflow, resetWorkflow } from 'features/catalog/catalogActions'; +import { updateWorkflow } from 'features/catalog/catalogActions'; describe('Catalog Reducer', () => { const state = { @@ -107,10 +107,4 @@ describe('Catalog Reducer', () => { ); }); - it('should reset state', () => { - expect(catalogReducer({ ...state, sort }, resetWorkflow())).toEqual({ - ...initialState, - sort - }); - }); }); diff --git a/workflow-designer-ui/src/main/frontend/src/features/catalog/catalogActions.js b/workflow-designer-ui/src/main/frontend/src/features/catalog/catalogActions.js index 6262da0d..f2cb0435 100644 --- a/workflow-designer-ui/src/main/frontend/src/features/catalog/catalogActions.js +++ b/workflow-designer-ui/src/main/frontend/src/features/catalog/catalogActions.js @@ -24,11 +24,10 @@ import { } from 'features/catalog/catalogConstants'; export const { - [NAMESPACE]: { updateWorkflow, resetWorkflow } + [NAMESPACE]: { updateWorkflow } } = createActions({ [NAMESPACE]: { - UPDATE_WORKFLOW: undefined, - RESET_WORKFLOW: undefined + UPDATE_WORKFLOW: undefined } }); diff --git a/workflow-designer-ui/src/main/frontend/src/features/catalog/catalogReducer.js b/workflow-designer-ui/src/main/frontend/src/features/catalog/catalogReducer.js index 78d8e529..e5f887b6 100644 --- a/workflow-designer-ui/src/main/frontend/src/features/catalog/catalogReducer.js +++ b/workflow-designer-ui/src/main/frontend/src/features/catalog/catalogReducer.js @@ -14,12 +14,8 @@ * limitations under the License. */ -import { - NAME, - ASC, - UPDATE_WORKFLOW, - RESET_WORKFLOW -} from 'features/catalog/catalogConstants'; +import { NAME, ASC, UPDATE_WORKFLOW } from 'features/catalog/catalogConstants'; +import { SEARCH_CHANGED } from './catalogConstants'; export const initialState = { paging: { @@ -35,9 +31,6 @@ const catalogReducer = (state = initialState, action) => { const { type, payload } = action; switch (type) { - case RESET_WORKFLOW: - return { ...initialState, sort: state.sort }; - case UPDATE_WORKFLOW: return { ...state, @@ -47,7 +40,11 @@ const catalogReducer = (state = initialState, action) => { ? [...payload.items] : [...state.items, ...payload.items] }; - + case SEARCH_CHANGED: + return { + ...state, + searchNameFilter: action.payload.searchNameFilter + }; default: return state; } |