@patternfly/react-core#AlertVariant JavaScript Examples
The following examples show how to use
@patternfly/react-core#AlertVariant.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ibutsu-page.js From ibutsu-server with MIT License | 6 votes |
showNotification(type, title, message, action?, timeout?, key?) {
let notifications = this.state.notifications;
let alertKey = key || getDateString();
timeout = timeout !== undefined ? timeout : true
if (notifications.find(element => element.key === alertKey) !== undefined) {
return;
}
let notification = {
'key': alertKey,
'type': AlertVariant[type],
'title': title,
'message': message,
'action': action
};
notifications.push(notification);
this.setState({notifications}, () => {
if (timeout === true) {
setTimeout(() => {
let notifs = this.state.notifications.filter((n) => {
if (n.type === type && n.title === title && n.message === message) {
return false;
}
return true;
});
this.setState({notifications: notifs});
}, ALERT_TIMEOUT);
}
});
}
Example #2
Source File: app.jsx From cockpit-certificates with GNU Lesser General Public License v2.1 | 5 votes |
render() {
const { certmongerService, startErrorMessage, cas, certs, toExpireCerts, expiredCerts } = this.state;
if (expiredCerts > 0) {
page_status.set_own({
type: "error",
title: cockpit.format(cockpit.ngettext("$0 certificate has expired",
"$0 certificates have expired",
expiredCerts), expiredCerts),
details: []
});
} else if (toExpireCerts > 0) {
page_status.set_own({
type: "warning",
title: cockpit.format(cockpit.ngettext("$0 certificate expires soon",
"$0 certificates expire soon",
toExpireCerts), toExpireCerts),
details: []
});
}
const certificatesBody = (
<CertificateList cas={cas} certs={certs} addAlert={this.addAlert} appOnValueChanged={this.onValueChanged} />
);
const emptyStateBody = (
<EmptyState service={ certmongerService }
serviceName={ CERTMONGER_SERVICE_NAME }
errorMessage={ startErrorMessage }
updateService={ () => this.updateCertmongerService() } />
);
const body = () => {
if (!certmongerService || !certmongerService.exists || !certmongerService.state || certmongerService.state !== "running")
return emptyStateBody;
return certificatesBody;
};
return (
<Page>
<PageSection variant={PageSectionVariants.light}>
{ body() }
<AlertGroup isToast>
{this.state.alerts.map((danger, index) => (
<Alert isLiveRegion
variant={AlertVariant.danger}
title={danger.title}
actionClose={
<AlertActionCloseButton variantLabel="danger alert"
onClose={() => this.removeAlert(index)} />
}
key={index}>
{_("Error message: ") + danger.message}
</Alert>
))}
</AlertGroup>
</PageSection>
</Page>
);
}