Skip to content
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

Alerting: alert list state view #33020

Merged
merged 6 commits into from
Apr 16, 2021
Merged

Alerting: alert list state view #33020

merged 6 commits into from
Apr 16, 2021

Conversation

domasx2
Copy link
Contributor

@domasx2 domasx2 commented Apr 15, 2021

Nailed together a rule list view that shows rules by state.
Some types were rejiggled to make it work

state-view.mp4

What this PR does / why we need it:

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

@oanamangiurea
Copy link
Contributor

This looks soo good 👍 . Probably will have to do something with the big group names, but anyway awesome work!

@domasx2
Copy link
Contributor Author

domasx2 commented Apr 15, 2021

This looks soo good . Probably will have to do something with the big group names, but anyway awesome work!

🌞
Design calls for 16px, but theme has only 14px or 18px predefined... So I left it at h4 element's default 18px for the moment

Copy link
Contributor

@kylebrandt kylebrandt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I no longer get "An unexpected error happened" on my instance on this branch, so I like it 🥇 :-)


const styles = useStyles(getStyles);
const tableStyles = useStyles(getAlertTableStyles);

const [expandedKeys, setExpandedKeys] = useState<string[]>([]);

const [ruleToDelete, setRuleToDelete] = useState<RulerRuleDTO>();
const [ruleToDelete, setRuleToDelete] = useState<CombinedRule>();

const toggleExpandedState = (ruleKey: string) =>
setExpandedKeys(
expandedKeys.includes(ruleKey) ? expandedKeys.filter((key) => key !== ruleKey) : [...expandedKeys, ruleKey]
);

const deleteRule = () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question: why not just dispatch the deleteRuleAction on click instead of doing it on next render after we set the state? Probably me that is missing something.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

setting ruleToDelete triggers a confirmation modal to be shown, but does not disaptch the delete action.
delete action is dispatched once user clicks confirmation button on the modal

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, ok ok - got it! Makes sense now.

rules: [],
};
combinedGroup.rules = group.rules.map(
(rule): CombinedRule =>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I think this code should be split up into multiple smaller functions to improve readability and prevent nesting.

Copy link
Contributor Author

@domasx2 domasx2 Apr 15, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • break it up a little

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

broke it up into several hopefully well-named functions

Copy link
Contributor

@mckn mckn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left some small nits but overall I think it looks good! Great work moving this forward!

@domasx2
Copy link
Contributor Author

domasx2 commented Apr 15, 2021

Left some small nits but overall I think it looks good! Great work moving this forward!

Thanks!! I will fix the nits, but please approve so I can merge things and keep moving :)

Base automatically changed from domas/rule-edit-form-edit to master April 16, 2021 08:08
@domasx2 domasx2 requested a review from mckn April 16, 2021 08:24
Copy link
Contributor

@mckn mckn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@domasx2 domasx2 merged commit 19c6a02 into master Apr 16, 2021
@domasx2 domasx2 deleted the domas/rule-list-state-view branch April 16, 2021 09:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants