-
Notifications
You must be signed in to change notification settings - Fork 8k
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
[SLO] Fix SLO plugin context #183966
[SLO] Fix SLO plugin context #183966
Conversation
🤖 GitHub commentsExpand to view the GitHub comments
Just comment with:
|
Pinging @elastic/obs-ux-management-team (Team:obs-ux-management) |
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.
Can we please add a functional e2e test for this?
const context = useContext(PluginContext); | ||
if (!context) { | ||
throw new Error('Plugin context value is missing!'); | ||
} |
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.
why is this removed?
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 pretty much reverted the changes that broke it. As discussed, I am actually refactoring it and I will bring this back
|
||
export const PluginContext = createContext<PluginContextValue | null>(null); | ||
export const PluginContext = createContext( | ||
{} as PluginContextValue | OverviewEmbeddableContextValue |
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.
shouldn't this always be PluginContextValue
?
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.
On a dashboard context it should be OverviewEmbeddableContextValue
otherwise PluginContextValue
. Let me push the refactored code. I disabled an eslint rule though to make it work, so I'd like your thoughts on this.
3e11ab2
to
a643cb3
Compare
a643cb3
to
105d664
Compare
const executionContextName = executionContext.get().name; | ||
|
||
const { observabilityRuleTypeRegistry } = | ||
// eslint-disable-next-line react-hooks/rules-of-hooks |
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.
@shahzad31 This solution works, but honestly I don't like I had to disable this eslint rule. Instead I am thinking to do the executionContext check in this file x-pack/plugins/observability_solution/slo/public/pages/slos/components/common/burn_rate_rule_flyout.tsx
and pass the context as a param in the useGetFilteredRuleTypes
function. What do you think?
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 will also need to change the way useGetFilteredRuleTypes
is called in one more place as well x-pack/plugins/observability_solution/slo/public/pages/slos/components/compact_view/slo_list_compact_view.tsx
.
@shahzad31 I refactored as per our discussion in this commit, where I created a new |
...gins/observability_solution/slo/public/embeddable/slo/common/overview_embeddable_context.tsx
Outdated
Show resolved
Hide resolved
685cdeb
to
c67063c
Compare
@@ -16,14 +16,8 @@ export interface PluginContextValue { | |||
isServerless?: boolean; | |||
appMountParameters?: AppMountParameters; | |||
observabilityRuleTypeRegistry: ObservabilityRuleTypeRegistry; | |||
ObservabilityPageTemplate: React.ComponentType<LazyObservabilityPageTemplateProps>; | |||
ObservabilityPageTemplate?: React.ComponentType<LazyObservabilityPageTemplateProps>; |
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.
@shahzad31 I don't know how to proceed with the ts error I got regarding ObservabilityPageTemplate
. Any ideas?
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.
SLO Oveview ebeddable group-by is now working !!
💚 Build Succeeded
Metrics [docs]Module Count
Async chunks
Canvas Sharable Runtime
Page load bundle
HistoryTo update your PR or re-run it, just comment with: cc @mgiota |
Fixes #183967
This PR reverts the changes introduced in this PR regarding SLO Plugin context.
Before
Notice how the embeddable breaks when user clicks on the group accordion in order to expand it.
broken.mov
After
This is the fixed version, where clicking on the group shows the respective SLOs
fixed.mov