-
Notifications
You must be signed in to change notification settings - Fork 1
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
refactor(SceneByVariableRepeaterGrid): Pull out "groupBy" logic out of the class #109
Conversation
…egend for single series
@@ -36,15 +36,18 @@ interface SceneByVariableRepeaterGridState extends EmbeddedSceneState { | |||
variableName: string; | |||
items: GridItemData[]; | |||
headerActions: (item: GridItemData, items: GridItemData[]) => VizPanelState['headerActions']; | |||
mapOptionToItem: ( |
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.
Decoupling: this new option allows the consumers of the class to customize how they build the grid items data.
value: option.value as string, | ||
label: option.label, | ||
queryRunnerParams: { | ||
serviceName: option.value as string, |
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.
Way cleaner/more explicit than before
@@ -30,6 +30,18 @@ export class SceneExploreFavorites extends SceneObjectBase<SceneExploreFavorites | |||
body: new SceneByVariableRepeaterGrid({ | |||
key: 'favorites-grid', | |||
variableName: 'favorite', | |||
mapOptionToItem: (option) => { | |||
// see FavoritesDataSource.ts | |||
const { index, value, panelType, queryRunnerParams } = JSON.parse(option.value as string); |
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.
Same here
… objects instead of setting state
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.
Nice refactor, I couldn't find any regressions with it 👏
LGTM!
✨ Description
Related issue(s): is blocked by #108
This PR aims at making
SceneByVariableRepeaterGrid
more generic.We achieve this:
SceneLabelValuesGrid
class, responsible for rendering the panels grid after the user has selected a "groupBy" valueWe have a bit of duplicated code, but it's temporary. In the next PR, we'll start customizing
SceneLabelValuesGrid
so that the "Comparison" flow is easier to understand for the user (currently it's not obvious for users to understand how they can compare 2 label values).📖 Summary of the changes
See diff tab for specific comments
🧪 How to test?