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
Dashboard: Add new visualization/row/library panel/pasted panel is now a dropdown menu #65361
Conversation
…to choose a library panel to create
You have successfully added a new CodeQL configuration |
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.
Great job @polibb 🥳 , the code it's easy to read and well organized, I gave it a try locally and it works as expected, both with and without the feature flag.
P.S., I left a small nit, and I think we need some unit tests for the new components (but if time is scarce, we could always add the tests in a different PR).
public/app/features/dashboard/components/AddPanelButton/AddPanelButton.tsx
Outdated
Show resolved
Hide resolved
public/app/features/dashboard/components/AddPanelButton/AddPanelButton.tsx
Outdated
Show resolved
Hide resolved
public/app/features/dashboard/components/AddPanelButton/AddPanelButton.tsx
Outdated
Show resolved
Hide resolved
offset={[0, 6]} | ||
onVisibleChange={setAddMenuOpen} | ||
> | ||
<Button |
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.
Did you figure out why ToolbarButton cannot be used here? Would love to understand that.
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.
no 🥸
public/app/features/dashboard/components/AddPanelButton/index.ts
Outdated
Show resolved
Hide resolved
dashboard.addPanel(newPanel); | ||
}; | ||
|
||
type PanelPluginInfo = { defaults: { gridPos: { w: number; h: number }; title: 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.
A very similar type is defined in AddPanelWidget. Can we re-use that one?
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.
the id
of PanelPluginInfo
in AddPanelWidget
is of type number
, whereas we are looking for a panel in panels here which are of type PanelPluginMeta
which has the id
of type string
. (I suppose that's why const pluginInfo
is set of type any
, but that's not possible anymore - betterer is failing if I recreate the same method.)
The id
is used as a holder for the panel's type
in this search for the copied panel and then later for the creation of the pasted panel, so it suits it to be a string 😄.
I think we'll delete this AddPanelWidget
alltogether when the feature flag emptyDashboardPage
is removed?
Tbh, as a whole I was confused by this method - it's creating an array, but only ever fills it with 1 value; I'm not sure if pluginCopy.sort = -1;
is necessary and why. The main reason I think any
was used is because the defaults
key is set onto the panelCopy
(pluginCopy.defaults = copiedPanel;
), but overall I think we can either return a tuple or this kind of an object of combined types which are just the panel type and a type that cares about defaults
.
<Menu> | ||
<Menu.Item | ||
key="add-visualisation" | ||
label="Visualization" |
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.
Not blocking the PR, but shouldn’t we localise these?
What is this feature?
Implement dropdown to add a new viz/library panel/row/pasted panel in the dashboard. Implemented in place of the current button in the top bar.
This PR:
Add
icon in dashboard's nav barpanel-add
icon to sizexl
and sets it to xl everywhere it was used until nowgetNewDashboardModelData
when initialising a dashboardWhy do we need this feature?
Because it is better UX.
Who is this feature for?
Everyone
Which issue(s) does this PR fix?:
Fixes #64592
Special notes for your reviewer:
Please check that: