-
Notifications
You must be signed in to change notification settings - Fork 7
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
base: main
Are you sure you want to change the base?
Conversation
…nd used it wherever necessary
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.
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} /> |
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 review and feedback @going-confetti . I have moved the component as desired. It is all coming from RuleEditor. |
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.
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" |
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.
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.
<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> |
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.
Displaying the EmptyMessage
component at the top of the parent is intentional, so this change isn't needed.
src/views/Generator/TestRuleContainer/TestRule/TestRuleSelector.tsx
Outdated
Show resolved
Hide resolved
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.
See my comment in RuleEditor.tsx
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.
See my comment in RuleEditor.tsx
<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} /> |
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.
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.
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 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"> |
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.
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
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.
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.
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"> |
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.
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
This is what it should look like:
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)
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 this was correct in my previous PR. Nevermind, reverted back.
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 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"> |
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.
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 can continue working on it
Added
TestRule
toRuleEditor
to display rule summary while editing rule.Changed minor CSS to the affected components.
Description
How to Test
Checklist
npm run lint
) and all checks pass.npm test
) and all tests pass.Screenshots (if appropriate):
Related PR(s)/Issue(s)
Resolves #606