Repository navigation
feat(app): create an SLO from a search, and duplicate an SLO #3807
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
alex-fedotyev
wants to merge
1
commit into
alex/HDX-3001-slo-19-app-preview
from
alex/HDX-3001-slo-20-app-from-search
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| import Link from 'next/link'; | ||
| import type { Filter } from '@hyperdx/common-utils/dist/types'; | ||
| import { Button, Tooltip } from '@mantine/core'; | ||
| import { IconTargetArrow } from '@tabler/icons-react'; | ||
|
|
||
| import { | ||
| encodeJsonUrlParamValue, | ||
| encodeUrlParamValue, | ||
| } from '@/utils/urlParamEncoding'; | ||
|
|
||
| /** | ||
| * Opens the SLO builder with the current search as the eligible events. The | ||
| * query and filters are copied, so later edits to the search leave the SLO | ||
| * alone. | ||
| */ | ||
| export function CreateSloButton({ | ||
| source, | ||
| where, | ||
| whereLanguage, | ||
| filters, | ||
| savedSearchName, | ||
| }: { | ||
| source?: string | null; | ||
| where?: string | null; | ||
| whereLanguage?: string | null; | ||
| filters?: Filter[] | null; | ||
| savedSearchName?: string | null; | ||
| }) { | ||
| if (!source) return null; | ||
| const params = new URLSearchParams({ | ||
| source: encodeUrlParamValue(source), | ||
| where: encodeUrlParamValue(where ?? ''), | ||
| whereLanguage: encodeUrlParamValue(whereLanguage ?? 'lucene'), | ||
| filters: encodeJsonUrlParamValue(filters ?? []), | ||
| }); | ||
| if (savedSearchName) params.set('name', encodeUrlParamValue(savedSearchName)); | ||
| return ( | ||
| <Tooltip label="Create an SLO from this search" withArrow openDelay={300}> | ||
| <Button | ||
| component={Link} | ||
| href={`/slos/new?${params.toString()}`} | ||
| variant="secondary" | ||
| size="xs" | ||
| leftSection={<IconTargetArrow size={14} />} | ||
| style={{ flexShrink: 0 }} | ||
| data-testid="create-slo-button" | ||
| > | ||
| SLO | ||
| </Button> | ||
| </Tooltip> | ||
| ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
🟡 P2 — The preview for an SLO started from Search never runs, and a validation error shows instead
sloFormValuesFromSearchuses the defaultavailabilitytemplate withgood: ''.SloIndicatorSchema's superRefine (packages/common-utils/src/slo.ts:215) rejects that, sotrigger(PREVIEW_FIELDS)always resolves false. The user lands on a 'A good-event condition is required' error and no preview. The fix: validate only the eligible fields here, or skip validation ofindicator.good(or build the preview from the eligible counts alone). Then add a test that drives this path, because the current unit test only checks the form values.Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond