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

feat: Edit correlation rule #30

Merged
merged 8 commits into from
Jul 15, 2024
Merged

Conversation

going-confetti
Copy link
Collaborator

@going-confetti going-confetti commented Jul 12, 2024

image

src/hooks/useGeneratorStore/useGeneratorStore.ts Outdated Show resolved Hide resolved
Comment on lines +43 to +53
<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>
Copy link
Collaborator Author

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.)

src/views/Generator/GeneratorDrawer/GeneratorDrawer.tsx Outdated Show resolved Hide resolved
Comment on lines +34 to +36
// value is always a string in Radix Select
const handleFromChange = (value: string) => {
const type = allowedTypes[value as Selector['from']].includes(selector.type)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is really annoying

Copy link
Member

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 🫠

Comment on lines 19 to 24
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)',
}}
Copy link
Collaborator Author

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

Comment on lines +15 to +16
selectRule(ruleId)
navigate(`/generator/rule/${ruleId}`)
Copy link
Collaborator Author

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

Copy link
Member

@Llandy3d Llandy3d left a 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(),
Copy link
Member

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 🤔

Copy link
Collaborator Author

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.

Copy link
Member

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

Comment on lines 142 to 169
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',
},
}
Copy link
Member

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 ? 🤔

Copy link
Collaborator Author

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)

Comment on lines +34 to +36
// value is always a string in Radix Select
const handleFromChange = (value: string) => {
const type = allowedTypes[value as Selector['from']].includes(selector.type)
Copy link
Member

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 🫠

Copy link
Collaborator

@e-fisher e-fisher left a comment

Choose a reason for hiding this comment

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

Noticed this warning in the console, might not be a problem later on when we add some form library to handle validation.

LGTM! 🚀

CleanShot 2024-07-15 at 14 57 04@2x

@going-confetti going-confetti merged commit c7080f3 into main Jul 15, 2024
1 check passed
@going-confetti going-confetti deleted the feat/correlation-rule-editing branch July 15, 2024 12:24
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.

3 participants