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 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';
26 import { NAME, ASC, DESC } from 'features/catalog/catalogConstants';
28 class CatalogView extends React.Component {
30 const { clearWorkflow } = this.props;
35 componentWillUnmount() {
36 this.props.handleResetWorkflow();
39 handleAlphabeticalOrderByClick = e => {
47 const payload = { ...sort };
49 payload[NAME] = payload[NAME] === ASC ? DESC : ASC;
51 handleFetchWorkflow(payload);
54 handleScroll = () => {
63 handleFetchWorkflow(sort, offset);
66 goToOverviewPage = id => {
67 const { history } = this.props;
68 history.push('/workflow/' + id + '/overview');
72 const { catalog, showNewWorkflowModal } = this.props;
75 paging: { hasMore, total },
78 const alphabeticalOrder = sort[NAME];
81 <div className="wf-catalog">
85 loadMore={this.handleScroll}
89 alphabeticalOrder={alphabeticalOrder}
90 onAlphabeticalOrderByClick={
91 this.handleAlphabeticalOrderByClick
93 <div className="main__content">
94 <AddWorkflow onClick={showNewWorkflowModal} />
97 onWorkflowClick={this.goToOverviewPage}
107 CatalogView.propTypes = {
108 history: PropTypes.object,
109 catalog: PropTypes.object,
110 handleResetWorkflow: PropTypes.func,
111 handleFetchWorkflow: PropTypes.func,
112 showNewWorkflowModal: PropTypes.func,
113 clearWorkflow: PropTypes.func
116 CatalogView.defaultProps = {
117 showNewWorkflowModal: () => {},
118 clearWorkflow: () => {}
121 export default CatalogView;