Skip to content

feat: Display rule summary preview while editing a rule #607

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

fsd-niraj
Copy link

@fsd-niraj fsd-niraj commented Mar 27, 2025

Added TestRule to RuleEditor to display rule summary while editing rule.
Changed minor CSS to the affected components.

Description

How to Test

Checklist

  • I have performed a self-review of my code.
  • I have added tests for my changes.
  • I have run linter locally (npm run lint) and all checks pass.
  • I have run tests locally (npm test) and all tests pass.
  • I have commented on my code, particularly in hard-to-understand areas.

Screenshots (if appropriate):

Related PR(s)/Issue(s)

Resolves #606

@fsd-niraj fsd-niraj requested a review from a team as a code owner March 27, 2025 00:30
@CLAassistant
Copy link

CLAassistant commented Mar 27, 2025

CLA assistant check
All committers have signed the CLA.

@fsd-niraj fsd-niraj changed the title exported ParameterizationSelectorContent fu, pulled rules via props a… exported ParameterizationSelectorContent fn, pulled rules via props a… Mar 27, 2025
Copy link
Collaborator

@going-confetti going-confetti left a comment

Choose a reason for hiding this comment

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

Hi @fsd-niraj

Thank you for this contribution!

I believe a few things are missing in terms of functionality:

  • Support for all types of test rules (not just Parameterization)
  • Rule filter isn't shown

I left a couple of comments that should help you address these. Please let me know if you have any questions.

Additionally, we haven't added proper contribution guidelines yet, but we follow the Conventional Commits spec, so could you please rename you PR accordingly (I suggest feat: Display rule summary preview while editing a rule)?

return (
<>
<Text size="2" as="p" mb="2" color="gray">
Replace request data with variables or custom values.
<ParameterizationSelectorContent rule={rule} />
Copy link
Collaborator

Choose a reason for hiding this comment

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

We would like to have a preview for all existing types of test rules. Instead of updating each type of the rule rule editor, could you please move it to StickyPanelHeader in the RuleEditor component?

I'm not too sure about the alignment, but here's an example with the preview being on the right:
image

@fsd-niraj fsd-niraj changed the title exported ParameterizationSelectorContent fn, pulled rules via props a… feat: Display rule summary preview while editing a rule Mar 27, 2025
@fsd-niraj
Copy link
Author

fsd-niraj commented Mar 27, 2025

Thanks for the review and feedback @going-confetti .
Screenshot 2025-03-27 at 8 55 12 PM

I have moved the component as desired. It is all coming from RuleEditor.
I have also added small UI fixes on the same screen, let me know if those are accepted in the following PR.
I'm pushing it on the same branch.

Copy link
Collaborator

@going-confetti going-confetti left a comment

Choose a reason for hiding this comment

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

Thank you for the changes. This placement is correct.

I don't necessarily agree with the proposed UI fixes, as the positions of the New rule button and the empty message are intentional and changing them is out of scope of this PR.

I added a comment to your changes in RuleEditor.tsx - addressing it should make the PR smaller

px="6"
px="3"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not sure if this needs to be changed in this PR, as it is out of scope of the original issue.
The reason it's 6 is to align it with Rule type labels - we may reconsider this in future, but I don't think it's a bug.

Comment on lines 48 to 54
<Flex justify="center" align="center" m="auto">
<EmptyMessage
message="Configure your test logic by adding a new rule"
pb="2"
action={<NewRuleMenu variant="solid" size="2" color="orange" />}
/>
</Flex>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Displaying the EmptyMessage component at the top of the parent is intentional, so this change isn't needed.

Copy link
Collaborator

Choose a reason for hiding this comment

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

See my comment in RuleEditor.tsx

Copy link
Collaborator

Choose a reason for hiding this comment

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

See my comment in RuleEditor.tsx

Comment on lines 104 to 119
<Flex align="center" justify="between">
<Flex align="center" gap="3" width="100%">
<Heading size="2" weight="medium">
{capitalize(startCase(rule.type))}
</Heading>
<Button
onClick={handleClose}
variant="ghost"
size="1"
css={{ gap: 0 }}
>
<ChevronLeftIcon />
Back
</Button>
</Flex>
<TestRuleInlineContent rule={rule} />
Copy link
Collaborator

Choose a reason for hiding this comment

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

Instead of adding this extra Flex wrapper here, may I ask you to wrap only TestRuleInlineContent with a Flex? Aligning it to the right can be achieved by adding ml="auto".
This should remove the need for changes in TestRuleInlineContent.tsx and VerificationContent.tsx that may have side-effects in other places.

Copy link
Author

Choose a reason for hiding this comment

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

I get what you mean, I'll fix that in next PR.

@@ -39,43 +39,49 @@ export function TestRuleInlineContent({ rule }: TestRuleInlineContentProps) {
function CorrelationContent({ rule }: { rule: CorrelationRule }) {
return (
<>
<TestRuleFilter filter={rule.extractor.filter} />
<TestRuleSelector rule={rule} />
<Flex gap="2" align="center">
Copy link
Collaborator

Choose a reason for hiding this comment

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

These extra Flex wrappers are not needed here and could potentially have unwanted side-effects in TestRule.tsx where TestRuleInlineContent is also used.

You can revert changes to both this file and VerificationContent.tsx as long as TestRuleInlineContent has a proper wrapper in RuleEditor.tsx

Copy link
Author

Choose a reason for hiding this comment

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

Screenshot 2025-03-31 at 3 09 33 PM
If Flex is removed, the Correlation section is going to get affected like this.

Copy link
Collaborator

Choose a reason for hiding this comment

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

My suggestion is to basically have that Flex in RuleEditor. It will likely need flexGrow to be set to 1 to make sure it can take up the full available space if needed

@@ -100,7 +101,7 @@ export function RuleEditor({ rule }: RuleEditorProps) {
<ScrollArea scrollbars="vertical">
<FormProvider {...formMethods}>
<StickyPanelHeader>
<Flex align="center" gap="3">
<Flex align="center" gap="3" width="100%" ml="auto">
Copy link
Collaborator

Choose a reason for hiding this comment

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

The position itself was correct in the previous commit, these properties mean there's no place for TestRuleInlineContent on this "line", which results in a somewhat broken layout
image

This is what it should look like:
image

Check how TestRuleInlineContent is used in TestRule.tsx - if you wrap it with a Flex and put it inside theFlex on line 104, you should be able to achieve this (it will need some extra props to make sure it's aligned to the right)

Copy link
Author

Choose a reason for hiding this comment

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

I think this was correct in my previous PR. Nevermind, reverted back.

Copy link
Collaborator

@cristianoventura cristianoventura left a comment

Choose a reason for hiding this comment

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

Thanks for your contribution @fsd-niraj!

Functionality-wise, it looks good! Just a couple of UI fixes as already requested. Also, we need to ensure that the UI of the original list of rules is not affected, as I mentioned in my comment.

Verify <Strong>{rule.target}</Strong>{' '}
<OperatorLabel operator={rule.operator} /> <ValueLabel rule={rule} />
</Badge>
<Flex gap="2" align="center">
Copy link
Collaborator

@cristianoventura cristianoventura Apr 1, 2025

Choose a reason for hiding this comment

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

I noticed that the addition of this Flex wrapper made the original rules list truncate

image

Copy link
Author

Choose a reason for hiding this comment

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

I can continue working on it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Display rule summary preview while editing a rule
4 participants