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';
22 import { WORKFLOW_STATUS } from 'features/workflow/workflowConstants';
24 import Header from 'features/catalog/views/Header';
25 import Main from 'features/catalog/views/Main';
26 import { NAME, ASC, DESC } from 'features/catalog/catalogConstants';
28 class CatalogView extends Component {
34 const { clearWorkflow } = this.props;
36 this.fetchWorkflows();
39 fetchWorkflows = () => {
41 catalog: { sort, status, searchNameFilter },
51 handleAlphabeticalOrderByClick = e => {
56 catalog: { sort, status, searchNameFilter }
63 payload[NAME] = payload[NAME] === ASC ? DESC : ASC;
70 handleStatusChange = value => {
84 handleScroll = () => {
102 goToOverviewPage = id => {
103 const { history } = this.props;
104 history.push('/workflow/' + id + '/overview');
107 searchChange = searchValue => {
108 this.setState({ searchValue: searchValue });
109 this.dispatchChange(searchValue);
112 dispatchChange = searchValue => {
113 const { searchInputChanged, catalog } = this.props;
116 searchNameFilter: searchValue
118 sessionStorage.setItem('searchNameFilter', searchValue);
122 const { catalog, showNewWorkflowModal } = this.props;
125 paging: { hasMore, total },
130 const alphabeticalOrder = sort[NAME];
133 <div className="wf-catalog">
136 statusChange={this.handleStatusChange}
137 searchChange={this.searchChange}
138 searchValue={searchNameFilter}
142 loadMore={this.handleScroll}
146 alphabeticalOrder={alphabeticalOrder}
147 onAlphabeticalOrderByClick={
148 this.handleAlphabeticalOrderByClick
150 <div className="main__content">
151 {status === WORKFLOW_STATUS.ACTIVE && (
152 <AddWorkflow onClick={showNewWorkflowModal} />
156 onWorkflowClick={this.goToOverviewPage}
166 CatalogView.propTypes = {
167 history: PropTypes.object,
168 catalog: PropTypes.object,
169 handleResetWorkflow: PropTypes.func,
170 handleFetchWorkflow: PropTypes.func,
171 showNewWorkflowModal: PropTypes.func,
172 clearWorkflow: PropTypes.func,
173 searchInputChanged: PropTypes.func,
174 searchNameFilter: PropTypes.string
177 CatalogView.defaultProps = {
178 showNewWorkflowModal: () => {},
179 clearWorkflow: () => {}
182 export default CatalogView;