-
Notifications
You must be signed in to change notification settings - Fork 134
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make it possible to add action(s) to notifications #3999
Comments
Find UI design and notes here: https://www.figma.com/file/HOx9fsNedtkR2G0bCpHDX9/Resource-actions%2C-previewing-and-more?type=design&node-id=952%3A8873&t=gS0RAqPiep22C2ve-1
|
thanks @julioramosest - looks good! |
@olensmar Can I be assigned this issue?
Please correct me if i missed something. |
Hi @ayushgml , we can assign you this issue and I have some useful information. I've made a proof of concept for implementing these actions in the following draft PR: https://github.com/kubeshop/monokle/pull/4021/files You can use that as a starting point for implementing actions. Let us know if you need more help! |
Thank you @devcatalin for assigning and for the information. I will use it to start working on it! |
@devcatalin what types of actions can a button have? From the design i can infer 2 - Default action and cancel. Therefore I added a type:
Any more types it should be having? |
I don't think we need "cancel" explicitly since notifications already have an "X" button and they disappear after a few seconds. I'd like the actions to be easily configured so that's what I tried if you look at the code changes from here: I introduced a new type AlertButton = {
text: string;
action: AnyAction;
style?: React.CSSProperties;
}; Where the <div>
{buttons?.map(button => (
<Button
key={button.text}
style={button.style}
onClick={() => {
dispatch(button.action);
}}
>
{button.text}
</Button>
))}
</div> Then, there is an example of an alert with two buttons that are using two different redux actions: {
type: AlertEnum.Info,
title: 'test',
message: 'test',
buttons: [
{
text: 'Sync action',
action: testSyncAction(),
},
{
text: 'Async action',
action: triggerTestAsyncAction(),
},
],
} The only downside is that if we need to do some async logic from those buttons, which might be the case quite often, we have to dispatch a redux action and then use a redux listener to check if that action has been dispatched so that we can do an async effect. Example: export const testAsyncListener: AppListenerFn = listen => {
listen({
actionCreator: triggerTestAsyncAction,
effect: async (action, {getState, dispatch}) => {
console.log('doing some async action, with access to getState and dispatch');
},
});
}; I hope this helps! Let me know if you have more questions |
Thank you @devcatalin for the reference. It helped me a lot! This card doesn't goes away on it's own.
Also this card is a
I want to ask for the HandleShowMore type of card. @devcatalin |
We can render the custom buttons inside the |
Thanks @devcatalin ! |
Hey @olensmar @devcatalin !! I implemened the thunk logic and the action trigger and tried it by triggering an error while previewing, it works. See below: Now should I implement the same update Dependencies action for all Helm Errors or some particulars errors? And any other default actions except the Helm that I need to work on? I still have to style the buttons and card as present in the design. |
For certain notifications we might have a default action for the user - for example below we could show a user an action to "Update Dependencies" - would be easy to add as a callback..
The text was updated successfully, but these errors were encountered: