-
Notifications
You must be signed in to change notification settings - Fork 2
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
feat: Edit correlation rule #30
Conversation
going-confetti
commented
Jul 12, 2024
•
edited
Loading
edited
<Routes> | ||
<Route path="/" element={<ScrollableContent />}> | ||
<Route path="rule/:id" element={<RuleForm />} /> | ||
<Route path="loadProfile" element={<LoadProfile />} /> | ||
<Route path="thresholds" element={<VariablesEditor />} /> | ||
<Route path="thinkTime" element={<ThinkTime />} /> | ||
<Route path="testData" element={<VariablesEditor />} /> | ||
<Route path="imports" element={<ImportSelector />} /> | ||
<Route path="requestFilters" element={<RequestFilters />} /> | ||
</Route> | ||
</Routes> |
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 router simplifies handling drawer content, especially since we may need to open some of the tabs from elsewhere (rule from the list of rules, request filters from the list of requests etc.)
// value is always a string in Radix Select | ||
const handleFromChange = (value: string) => { | ||
const type = allowedTypes[value as Selector['from']].includes(selector.type) |
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.
This is really annoying
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.
now I see why the typing issues 🫠
style={{ | ||
borderRadius: 'var(--radius-1)', | ||
backgroundColor: 'var(--gray-2)', | ||
border: '1px solid transparent', | ||
borderColor: isSelected ? 'var(--accent-5)' : 'transparent', | ||
backgroundColor: isSelected ? 'var(--accent-3)' : 'var(--gray-2)', | ||
}} |
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.
Looks like we should add emotion already
selectRule(ruleId) | ||
navigate(`/generator/rule/${ruleId}`) |
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 useGeneratorStore
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.
LGTM! 🚀
case 'correlation': | ||
return { | ||
type: 'correlation', | ||
id: self.crypto.randomUUID(), |
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.
regarding ids
do we want to use UUIDs or actually numbers starting from 0
🤔
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 ids don't need to be sequential, because the user can (or rather will be able to) rearrange rules as they want.
Will we store rule ids in the generator file or is it a runtime only thing? Right now, I can't think of a good reason to store ids, so UUIDs can definitely be an overkill.
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 agree, nothing comes up for storing IDs in the saved file
case 'parameterization': | ||
return { | ||
type: 'parameterization', | ||
id: self.crypto.randomUUID(), | ||
filter: { path: '' }, | ||
selector: { | ||
type: 'begin-end', | ||
from: 'body', | ||
begin: '', | ||
end: '', | ||
}, | ||
value: { type: 'variable', variableName: '' }, | ||
} | ||
case 'verification': | ||
return { | ||
type: 'verification', | ||
id: self.crypto.randomUUID(), | ||
filter: { path: '' }, | ||
selector: { | ||
type: 'begin-end', | ||
from: 'body', | ||
begin: '', | ||
end: '', | ||
}, | ||
value: { | ||
type: 'recordedValue', | ||
}, | ||
} |
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.
should we be hiding these since we don't yet support them ? 🤔
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.
They are disabled in the UI, but yeah, we should remove these options from there.
As for the code, cases for verification and parameterization were suggested by copilot and I left them here, because it was easier than resorting to hacks to make exhaustive
work (the objects are correct, maybe with the exception of an empty variableName, but we'll probably have a check for that anyway since the user can remove a test variable that is used in a rule)
// value is always a string in Radix Select | ||
const handleFromChange = (value: string) => { | ||
const type = allowedTypes[value as Selector['from']].includes(selector.type) |
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.
now I see why the typing issues 🫠
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.