2 * Copyright © 2018 European Support Limited
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http: //www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 import React, { Component } from 'react';
18 import PropTypes from 'prop-types';
19 import InfiniteScroll from 'shared/scroll/InfiniteScroll';
20 import Workflows from 'features/catalog/views/Workflows';
21 import AddWorkflow from 'features/catalog/views/AddWorkflow';
23 import Header from 'features/catalog/views/Header';
24 import Main from 'features/catalog/views/Main';
25 import { NAME, ASC, DESC } from 'features/catalog/catalogConstants';
27 class CatalogView extends Component {
36 const { clearWorkflow } = this.props;
41 componentWillUnmount() {
42 this.props.handleResetWorkflow();
45 handleAlphabeticalOrderByClick = e => {
53 const payload = { ...sort };
55 payload[NAME] = payload[NAME] === ASC ? DESC : ASC;
57 handleFetchWorkflow(payload);
60 handleScroll = () => {
69 handleFetchWorkflow(sort, offset);
72 goToOverviewPage = id => {
73 const { history } = this.props;
74 history.push('/workflow/' + id + '/overview');
77 searchChange = searchValue => {
78 const { searchInputChanged, catalog } = this.props;
79 this.setState({ searchValue: searchValue });
82 searchNameFilter: searchValue
87 const { catalog, showNewWorkflowModal } = this.props;
90 paging: { hasMore, total },
93 const alphabeticalOrder = sort[NAME];
96 <div className="wf-catalog">
98 searchChange={this.searchChange}
99 searchValue={this.state.searchValue}
103 loadMore={this.handleScroll}
107 alphabeticalOrder={alphabeticalOrder}
108 onAlphabeticalOrderByClick={
109 this.handleAlphabeticalOrderByClick
111 <div className="main__content">
112 <AddWorkflow onClick={showNewWorkflowModal} />
115 onWorkflowClick={this.goToOverviewPage}
125 CatalogView.propTypes = {
126 history: PropTypes.object,
127 catalog: PropTypes.object,
128 handleResetWorkflow: PropTypes.func,
129 handleFetchWorkflow: PropTypes.func,
130 showNewWorkflowModal: PropTypes.func,
131 clearWorkflow: PropTypes.func,
132 searchInputChanged: PropTypes.func
135 CatalogView.defaultProps = {
136 showNewWorkflowModal: () => {},
137 clearWorkflow: () => {}
140 export default CatalogView;