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;
39 handleAlphabeticalOrderByClick = e => {
44 catalog: { sort, status, searchNameFilter }
51 payload[NAME] = payload[NAME] === ASC ? DESC : ASC;
58 handleStatusChange = value => {
71 handleScroll = () => {
89 goToOverviewPage = id => {
90 const { history } = this.props;
91 history.push('/workflow/' + id + '/overview');
94 searchChange = searchValue => {
95 this.setState({ searchValue: searchValue });
96 this.dispatchChange(searchValue);
99 dispatchChange = searchValue => {
100 const { searchInputChanged, catalog } = this.props;
103 searchNameFilter: searchValue
105 sessionStorage.setItem('searchNameFilter', searchValue);
109 const { catalog, showNewWorkflowModal } = this.props;
112 paging: { hasMore, total },
117 const alphabeticalOrder = sort[NAME];
120 <div className="wf-catalog">
123 statusChange={this.handleStatusChange}
124 searchChange={this.searchChange}
125 searchValue={searchNameFilter}
129 loadMore={this.handleScroll}
133 alphabeticalOrder={alphabeticalOrder}
134 onAlphabeticalOrderByClick={
135 this.handleAlphabeticalOrderByClick
137 <div className="main__content">
138 {status === WORKFLOW_STATUS.ACTIVE && (
139 <AddWorkflow onClick={showNewWorkflowModal} />
143 onWorkflowClick={this.goToOverviewPage}
153 CatalogView.propTypes = {
154 history: PropTypes.object,
155 catalog: PropTypes.object,
156 handleResetWorkflow: PropTypes.func,
157 handleFetchWorkflow: PropTypes.func,
158 showNewWorkflowModal: PropTypes.func,
159 clearWorkflow: PropTypes.func,
160 searchInputChanged: PropTypes.func,
161 searchNameFilter: PropTypes.string
164 CatalogView.defaultProps = {
165 showNewWorkflowModal: () => {},
166 clearWorkflow: () => {}
169 export default CatalogView;