Removes unnecessary fragment elements. Fixes vertical alignment on notif row item. Bind notification list functions to constructor

This commit is contained in:
mabashian 2019-01-23 14:13:51 -05:00
parent c97dfeb725
commit 6c19d6ae4e
3 changed files with 74 additions and 65 deletions

View File

@ -44,7 +44,7 @@ class NotificationListItem extends React.Component {
return (
<I18n>
{({ i18n }) => (
<li key={itemId} className="pf-c-data-list__item">
<li key={itemId} className="pf-c-data-list__item pf-u-flex-row pf-u-align-items-center">
<div className="pf-c-data-list__cell pf-u-flex-row">
<div className="pf-u-display-inline-flex">
<Link

View File

@ -49,6 +49,19 @@ class Notifications extends Component {
successTemplateIds: [],
errorTemplateIds: []
};
this.onSearch = this.onSearch.bind(this);
this.getQueryParams = this.getQueryParams.bind(this);
this.onSort = this.onSort.bind(this);
this.onSetPage = this.onSetPage.bind(this);
this.onSelectAll = this.onSelectAll.bind(this);
this.onSelect = this.onSelect.bind(this);
this.toggleError = this.toggleError.bind(this);
this.toggleSuccess = this.toggleSuccess.bind(this);
this.updateUrl = this.updateUrl.bind(this);
this.postToError = this.postToError.bind(this);
this.postToSuccess = this.postToSuccess.bind(this);
this.fetchNotifications = this.fetchNotifications.bind(this);
}
componentDidMount () {
@ -296,58 +309,56 @@ class Notifications extends Component {
</EmptyStateBody>
</EmptyState>
)}
<Fragment>
{(
typeof noInitialResults !== 'undefined'
&& !noInitialResults
&& !loading
&& !error
) && (
<Fragment>
<DataListToolbar
isAllSelected={selected.length === results.length}
sortedColumnKey={sortedColumnKey}
sortOrder={sortOrder}
columns={this.columns}
onSearch={this.onSearch}
onSort={this.onSort}
onSelectAll={this.onSelectAll}
/>
<I18n>
{({ i18n }) => (
<ul className="pf-c-data-list" aria-label={i18n._(t`Organizations List`)}>
{results.map(o => (
<NotificationListItem
key={o.id}
itemId={o.id}
name={o.name}
notificationType={o.notification_type}
detailUrl={`notifications/${o.id}`}
parentBreadcrumb={parentBreadcrumb}
isSelected={selected.includes(o.id)}
onSelect={() => this.onSelect(o.id)}
errorTurnedOn={errorTemplateIds.includes(o.id)}
toggleError={this.toggleError}
successTurnedOn={successTemplateIds.includes(o.id)}
toggleSuccess={this.toggleSuccess}
/>
))}
</ul>
)}
</I18n>
<Pagination
count={count}
page={page}
pageCount={pageCount}
page_size={page_size}
pageSizeOptions={this.pageSizeOptions}
onSetPage={this.onSetPage}
/>
</Fragment>
)}
{loading ? <div>loading...</div> : ''}
{error ? <div>error</div> : ''}
</Fragment>
{(
typeof noInitialResults !== 'undefined'
&& !noInitialResults
&& !loading
&& !error
) && (
<Fragment>
<DataListToolbar
isAllSelected={selected.length === results.length}
sortedColumnKey={sortedColumnKey}
sortOrder={sortOrder}
columns={this.columns}
onSearch={this.onSearch}
onSort={this.onSort}
onSelectAll={this.onSelectAll}
/>
<I18n>
{({ i18n }) => (
<ul className="pf-c-data-list" aria-label={i18n._(t`Organizations List`)}>
{results.map(o => (
<NotificationListItem
key={o.id}
itemId={o.id}
name={o.name}
notificationType={o.notification_type}
detailUrl={`notifications/${o.id}`}
parentBreadcrumb={parentBreadcrumb}
isSelected={selected.includes(o.id)}
onSelect={() => this.onSelect(o.id)}
errorTurnedOn={errorTemplateIds.includes(o.id)}
toggleError={this.toggleError}
successTurnedOn={successTemplateIds.includes(o.id)}
toggleSuccess={this.toggleSuccess}
/>
))}
</ul>
)}
</I18n>
<Pagination
count={count}
page={page}
pageCount={pageCount}
page_size={page_size}
pageSizeOptions={this.pageSizeOptions}
onSetPage={this.onSetPage}
/>
</Fragment>
)}
{loading ? <div>loading...</div> : ''}
{error ? <div>error</div> : ''}
</Fragment>
);
}

View File

@ -54,18 +54,16 @@ const OrganizationDetail = ({
switch (currentTab) {
case 'notifications':
relatedTemplate = (
<Fragment>
<NotificationsList
getNotifications={(id, reqParams) => api.getOrganizationNotifications(id, reqParams)}
getSuccess={(id, reqParams) => api.getOrganizationNotificationSuccess(id, reqParams)}
getError={(id, reqParams) => api.getOrganizationNotificationError(id, reqParams)}
postSuccess={(id, data) => api.createOrganizationNotificationSuccess(id, data)}
postError={(id, data) => api.createOrganizationNotificationError(id, data)}
match={match}
location={location}
history={history}
/>
</Fragment>
<NotificationsList
getNotifications={(id, reqParams) => api.getOrganizationNotifications(id, reqParams)}
getSuccess={(id, reqParams) => api.getOrganizationNotificationSuccess(id, reqParams)}
getError={(id, reqParams) => api.getOrganizationNotificationError(id, reqParams)}
postSuccess={(id, data) => api.createOrganizationNotificationSuccess(id, data)}
postError={(id, data) => api.createOrganizationNotificationError(id, data)}
match={match}
location={location}
history={history}
/>
);
break;
default: