Feature: alert event toast color (#928)

This commit is contained in:
Arpit 2021-10-07 22:04:45 +05:30 committed by GitHub
parent 1ffe7442dc
commit f0cd921c06
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 48 additions and 10 deletions

View file

@ -24,6 +24,29 @@ export const EventManager = ({
return { name: action.name, value: action.id };
});
let alertTypes = [
{
name: 'Info',
id: 'info',
},
{
name: 'Success',
id: 'success',
},
{
name: 'Warning',
id: 'warning',
},
{
name: 'Danger',
id: 'error',
},
];
let alertOptions = alertTypes.map((alert) => {
return { name: alert.name, value: alert.id };
});
excludeEvents = excludeEvents || [];
/* Filter events based on excludesEvents ( a list of event ids to exclude ) */
@ -128,16 +151,31 @@ export const EventManager = ({
<div className="hr-text">Action options</div>
<div>
{event.actionId === 'show-alert' && (
<div className="row">
<div className="col-3 p-2">Message</div>
<div className="col-9">
<CodeHinter
currentState={currentState}
initialValue={event.message}
onChange={(value) => handlerChanged(index, 'message', value)}
/>
<>
<div className="row">
<div className="col-3 p-2">Message</div>
<div className="col-9">
<CodeHinter
currentState={currentState}
initialValue={event.message}
onChange={(value) => handlerChanged(index, 'message', value)}
/>
</div>
</div>
</div>
<div className="row mt-3">
<div className="col-3 p-2">Alert Type</div>
<div className="col-9">
<SelectSearch
options={alertOptions}
value={event.alertType}
search={false}
onChange={(value) => handlerChanged(index, 'alertType', value)}
filterOptions={fuzzySearch}
placeholder="Select.."
/>
</div>
</div>
</>
)}
{event.actionId === 'open-webpage' && (

View file

@ -125,7 +125,7 @@ function executeAction(_ref, event, mode) {
switch (event.actionId) {
case 'show-alert': {
const message = resolveReferences(event.message, _ref.state.currentState);
toast(message, { hideProgressBar: true });
toast(message, { hideProgressBar: true, type: event.alertType });
return new Promise(function (resolve, reject) {
resolve();
});