mirror of
https://github.com/ansible/awx.git
synced 2026-02-01 09:38:10 -03:30
More cleanup based on pr feedback. Adds org notif list page and tests
This commit is contained in:
@@ -10,31 +10,15 @@ import {
|
||||
} from '@patternfly/react-core';
|
||||
|
||||
class NotificationListItem extends React.Component {
|
||||
constructor (props) {
|
||||
super(props);
|
||||
this.errorToggleClick = this.errorToggleClick.bind(this);
|
||||
this.successToggleClick = this.successToggleClick.bind(this);
|
||||
}
|
||||
|
||||
errorToggleClick (flag) {
|
||||
const { itemId, toggleError } = this.props;
|
||||
toggleError(itemId, flag);
|
||||
}
|
||||
|
||||
successToggleClick (flag) {
|
||||
const { itemId, toggleSuccess } = this.props;
|
||||
toggleSuccess(itemId, flag);
|
||||
}
|
||||
|
||||
render () {
|
||||
const {
|
||||
itemId,
|
||||
name,
|
||||
notificationType,
|
||||
detailUrl,
|
||||
parentBreadcrumb,
|
||||
successTurnedOn,
|
||||
errorTurnedOn
|
||||
errorTurnedOn,
|
||||
toggleNotification
|
||||
} = this.props;
|
||||
|
||||
const capText = {
|
||||
@@ -49,8 +33,7 @@ class NotificationListItem extends React.Component {
|
||||
<div className="pf-u-display-inline-flex">
|
||||
<Link
|
||||
to={{
|
||||
pathname: detailUrl,
|
||||
state: { breadcrumb: [parentBreadcrumb, { name, url: detailUrl }] }
|
||||
pathname: detailUrl
|
||||
}}
|
||||
>
|
||||
<b>{name}</b>
|
||||
@@ -69,13 +52,13 @@ class NotificationListItem extends React.Component {
|
||||
<Switch
|
||||
label={i18n._(t`Successful`)}
|
||||
isChecked={successTurnedOn}
|
||||
onChange={() => this.successToggleClick(successTurnedOn)}
|
||||
onChange={() => toggleNotification(itemId, successTurnedOn, 'success')}
|
||||
aria-label={i18n._(t`Notification success toggle`)}
|
||||
/>
|
||||
<Switch
|
||||
label={i18n._(t`Failure`)}
|
||||
isChecked={errorTurnedOn}
|
||||
onChange={() => this.errorToggleClick(errorTurnedOn)}
|
||||
onChange={() => toggleNotification(itemId, errorTurnedOn, 'error')}
|
||||
aria-label={i18n._(t`Notification failure toggle`)}
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -56,8 +56,7 @@ class Notifications extends Component {
|
||||
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.toggleNotification = this.toggleNotification.bind(this);
|
||||
this.updateUrl = this.updateUrl.bind(this);
|
||||
this.postToError = this.postToError.bind(this);
|
||||
this.postToSuccess = this.postToSuccess.bind(this);
|
||||
@@ -131,12 +130,12 @@ class Notifications extends Component {
|
||||
}
|
||||
};
|
||||
|
||||
toggleError = (id, isCurrentlyOn) => {
|
||||
this.postToError(id, isCurrentlyOn);
|
||||
};
|
||||
|
||||
toggleSuccess = (id, isCurrentlyOn) => {
|
||||
this.postToSuccess(id, isCurrentlyOn);
|
||||
toggleNotification = (id, isCurrentlyOn, status) => {
|
||||
if (status === 'success') {
|
||||
this.postToSuccess(id, isCurrentlyOn);
|
||||
} else if (status === 'error') {
|
||||
this.postToError(id, isCurrentlyOn);
|
||||
}
|
||||
};
|
||||
|
||||
updateUrl (queryParams) {
|
||||
@@ -293,8 +292,6 @@ class Notifications extends Component {
|
||||
successTemplateIds,
|
||||
errorTemplateIds
|
||||
} = this.state;
|
||||
const { match } = this.props;
|
||||
const parentBreadcrumb = { name: i18nMark('Organizations'), url: match.url };
|
||||
|
||||
return (
|
||||
<Fragment>
|
||||
@@ -335,13 +332,11 @@ class Notifications extends Component {
|
||||
name={o.name}
|
||||
notificationType={o.notification_type}
|
||||
detailUrl={`notifications/${o.id}`}
|
||||
parentBreadcrumb={parentBreadcrumb}
|
||||
isSelected={selected.includes(o.id)}
|
||||
onSelect={() => this.onSelect(o.id)}
|
||||
toggleNotification={this.toggleNotification}
|
||||
errorTurnedOn={errorTemplateIds.includes(o.id)}
|
||||
toggleError={this.toggleError}
|
||||
successTurnedOn={successTemplateIds.includes(o.id)}
|
||||
toggleSuccess={this.toggleSuccess}
|
||||
/>
|
||||
))}
|
||||
</ul>
|
||||
|
||||
Reference in New Issue
Block a user