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 => {
56 payload[NAME] = payload[NAME] === ASC ? DESC : ASC;
57 handleFetchWorkflow(payload, undefined, this.state.searchValue);
60 handleScroll = () => {
68 handleFetchWorkflow(sort, offset, this.state.searchValue);
71 goToOverviewPage = id => {
72 const { history } = this.props;
73 history.push('/workflow/' + id + '/overview');
76 searchChange = searchValue => {
77 this.setState({ searchValue: searchValue });
78 this.dispatchChange(searchValue);
81 dispatchChange = searchValue => {
82 const { searchInputChanged, catalog } = this.props;
85 searchNameFilter: searchValue
90 const { catalog, showNewWorkflowModal } = this.props;
93 paging: { hasMore, total },
96 const alphabeticalOrder = sort[NAME];
99 <div className="wf-catalog">
101 searchChange={this.searchChange}
102 searchValue={this.state.searchValue}
106 loadMore={this.handleScroll}
110 alphabeticalOrder={alphabeticalOrder}
111 onAlphabeticalOrderByClick={
112 this.handleAlphabeticalOrderByClick
114 <div className="main__content">
115 <AddWorkflow onClick={showNewWorkflowModal} />
118 onWorkflowClick={this.goToOverviewPage}
128 CatalogView.propTypes = {
129 history: PropTypes.object,
130 catalog: PropTypes.object,
131 handleResetWorkflow: PropTypes.func,
132 handleFetchWorkflow: PropTypes.func,
133 showNewWorkflowModal: PropTypes.func,
134 clearWorkflow: PropTypes.func,
135 searchInputChanged: PropTypes.func
138 CatalogView.defaultProps = {
139 showNewWorkflowModal: () => {},
140 clearWorkflow: () => {}
143 export default CatalogView;