webpack/scenes/Subscriptions/components/SubscriptionsTable/SubscriptionsTable.js in katello-3.7.0.rc2 vs webpack/scenes/Subscriptions/components/SubscriptionsTable/SubscriptionsTable.js in katello-3.7.0
- old
+ new
@@ -1,11 +1,11 @@
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import { sprintf } from 'jed';
import { cloneDeep, findIndex, isEqual } from 'lodash';
-import { Table, Alert } from 'patternfly-react';
+import { Table } from 'patternfly-react';
import { LoadingState } from '../../../../move_to_pf/LoadingState';
import { Table as ForemanTable, TableBody as ForemanTableBody } from '../../../../move_to_foreman/components/common/table';
import ConfirmDialog from '../../../../move_to_foreman/components/common/ConfirmDialog';
import Dialog from '../../../../move_to_foreman/components/common/Dialog';
import { recordsValid } from '../../SubscriptionValidations';
@@ -23,35 +23,18 @@
title: __('Add Subscriptions'),
url: 'subscriptions/add',
},
};
-const ErrorAlerts = ({ errors }) => {
- const alerts = errors.filter(Boolean).map(e => (
- <Alert type={Alert.ALERT_TYPE_ERROR} key={e}>
- <span>{e}</span>
- </Alert>
- ));
-
- return (
- <div>
- {alerts}
- </div>
- );
-};
-ErrorAlerts.propTypes = {
- errors: PropTypes.arrayOf(PropTypes.string).isRequired,
-};
-
class SubscriptionsTable extends Component {
constructor(props) {
super(props);
this.state = {
rows: undefined,
subscriptions: undefined,
- groupdSubscriptions: undefined,
+ groupedSubscriptions: undefined,
updatedQuantity: {},
editing: false,
showUpdateConfirmDialog: false,
showCancelConfirmDialog: false,
showErrorDialog: false,
@@ -62,53 +45,53 @@
static getDerivedStateFromProps(nextProps, prevState) {
if (
nextProps.subscriptions !== undefined &&
!isEqual(nextProps.subscriptions, prevState.subscriptions)
) {
- const groupdSubscriptions = groupSubscriptionsByProductId(nextProps.subscriptions);
+ const groupedSubscriptions = groupSubscriptionsByProductId(nextProps.subscriptions);
const rows = buildTableRows(
- groupdSubscriptions,
+ groupedSubscriptions,
nextProps.subscriptions.availableQuantities,
prevState.updatedQuantity,
);
- return { rows, groupdSubscriptions, subscriptions: nextProps.subscriptions };
+ return { rows, groupedSubscriptions, subscriptions: nextProps.subscriptions };
}
return null;
}
toggleSubscriptionGroup(groupId) {
const { subscriptions } = this.props;
- const { groupdSubscriptions, updatedQuantity } = this.state;
- const { open } = groupdSubscriptions[groupId];
+ const { groupedSubscriptions, updatedQuantity } = this.state;
+ const { open } = groupedSubscriptions[groupId];
- groupdSubscriptions[groupId].open = !open;
+ groupedSubscriptions[groupId].open = !open;
const rows = buildTableRows(
- groupdSubscriptions,
+ groupedSubscriptions,
subscriptions.availableQuantities,
updatedQuantity,
);
- this.setState({ rows, groupdSubscriptions });
+ this.setState({ rows, groupedSubscriptions });
}
enableEditing(editingState) {
this.setState({
updatedQuantity: {},
editing: editingState,
});
}
updateRows(updatedQuantity) {
- const { groupdSubscriptions } = this.state;
+ const { groupedSubscriptions } = this.state;
const { subscriptions } = this.props;
const rows = buildTableRows(
- groupdSubscriptions,
+ groupedSubscriptions,
subscriptions.availableQuantities,
updatedQuantity,
);
this.setState({ rows, updatedQuantity });
}
@@ -156,19 +139,19 @@
return false;
}
render() {
const { subscriptions } = this.props;
- const { groupdSubscriptions } = this.state;
+ const { groupedSubscriptions } = this.state;
const groupingController = {
isCollapseable: ({ rowData }) =>
// it is the first subscription in the group
- rowData.id === groupdSubscriptions[rowData.product_id].subscriptions[0].id &&
+ rowData.id === groupedSubscriptions[rowData.product_id].subscriptions[0].id &&
// the group contains more then one subscription
- groupdSubscriptions[rowData.product_id].subscriptions.length > 1,
- isCollapsed: ({ rowData }) => !groupdSubscriptions[rowData.product_id].open,
+ groupedSubscriptions[rowData.product_id].subscriptions.length > 1,
+ isCollapsed: ({ rowData }) => !groupedSubscriptions[rowData.product_id].open,
toggle: ({ rowData }) => this.toggleSubscriptionGroup(rowData.product_id),
};
const inlineEditController = {
isEditing: ({ rowData }) => (this.state.editing && rowData.available >= 0),
@@ -256,15 +239,9 @@
groupingController,
);
return (
<LoadingState loading={subscriptions.loading} loadingText={__('Loading')}>
- <ErrorAlerts
- errors={[
- subscriptions.error,
- subscriptions.quantitiesError,
- ]}
- />
<ForemanTable
columns={columnsDefinition}
emptyState={emptyStateData}
bodyMessage={bodyMessage}
rows={this.state.rows}