-
Notifications
You must be signed in to change notification settings - Fork 11
Enable WithEvent to send an event to the AWS EventBridge #132
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
Enable WithEvent to send an event to the AWS EventBridge #132
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR @kishaningithub!
It should be possible to opt-out of this feature though. I think this setting is suitable to be included in the data source configuration page.
For doing so, it's necessary to:
- Add it to the Settings structure: https://github.com/grafana/redshift-datasource/blob/main/pkg/redshift/models/settings.go#L34 (and access it with
c.settings.WithEventwhere you are using it now). - In the frontend:
- Add it to the data source options: https://github.com/grafana/redshift-datasource/blob/main/src/types.ts#L49
- Add it to the config page: https://github.com/grafana/redshift-datasource/blob/main/src/ConfigEditor/ConfigEditor.tsx#L211. Something like:
import { InlineField, Switch } from '@grafana/ui';
...
<InlineField label="Send events to Amazon EventBridge" labelWidth={28}>
<Switch
value={props.options.jsonData.withEvent}
onChange={(e) =>
props.onOptionsChange({
...props.options,
jsonData: {
...props.options.jsonData,
withEvent: e.currentTarget.checked,
},
})
}
/>
</InlineField>
5275c85 to
97453b0
Compare
|
@andresmgot Have addressed your feedback. Thanks for the detailed feedback though :-) |
andresmgot
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work here @kishaningithub! Only a couple more of minor comments to go.
src/ConfigEditor/ConfigEditor.tsx
Outdated
| label={selectors.components.ConfigEditor.Database.input} | ||
| data-testid={selectors.components.ConfigEditor.Database.testID} | ||
| /> | ||
| <InlineField label="Send events to Amazon EventBridge" labelWidth={28}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you add style={{ alignItems: 'center' }} the switch will be vertically aligned
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the easiest a way to view how the UI will look like in local machine? I tried yarn dev and yarn watch but they seem to be focussed on unit tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I use yarn watch, that shouldn't run the tests. With more details, what I run in development is:
make runin the main grafana/grafana repositoryyarn startin grafana/grafanagrafana/grafana/data/plugins/redshift-datasourceis a symbolic link pointing to my Redshift dist folder (grafana/redshift-datasource/dist)yarn watchin grafana/redshift-datasource
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@andresmgot What do you think of adding the above steps to CONTRIBUTING.md? Would be useful for people who are new to grafana plugin development like me :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's a good point. Let me check if that's already written somewhere and if not I will add it there
| <Switch | ||
| value={props.options.jsonData.withEvent ?? false} | ||
| onChange={(e) => | ||
| props.onOptionsChange({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you add a simple test for this? If you go to ConfigEditor.test.tsx you can take inspiration from the test should allow user to enter a database. You will need to add a data-testid to this Switch to test it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@andresmgot I have added test for this, If you see the test currently fails because the onChange is not getting triggered. I am unable to find a reason for this. Need your help in getting this test case passing. Thanks in advance! :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's because how Switch is internally implemented, if you do fireEvent.click(withEventField); rather than fireEvent.change(withEventField, { target: { checked: true } }); it should work.
4457d95 to
c75745a
Compare
andresmgot
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the changes!
| <Switch | ||
| value={props.options.jsonData.withEvent ?? false} | ||
| onChange={(e) => | ||
| props.onOptionsChange({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's because how Switch is internally implemented, if you do fireEvent.click(withEventField); rather than fireEvent.change(withEventField, { target: { checked: true } }); it should work.
|
@andresmgot Have addressed your review comments.. Thanks for the detailed reviews :-) |
andresmgot
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great! Thanks for the changes.
Addresses https://github.com/grafana/redshift-datasource/discussions/131