mirror of
https://github.com/elastic/kibana.git
synced 2025-06-27 10:40:07 -04:00
Fix: success message and scroll after adding panel from library (#220122)
Initially there was no success message for any type in the library and there was no scrolling to added panel. This change sets displaySuccessMessage to true for each plugin registered in the Add from Library flyout. It ensures that: - users see a success toast after adding a panel, - the newly added panel is automatically scrolled into view. Closes: #188775 --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
parent
e528a30fa8
commit
e7e8d2f13b
9 changed files with 71 additions and 44 deletions
|
@ -16,12 +16,15 @@ const APP_ICON = 'logoKibana';
|
|||
export const registerMyEmbeddableSavedObject = (embeddableSetup: EmbeddableSetup) =>
|
||||
embeddableSetup.registerAddFromLibraryType({
|
||||
onAdd: (container, savedObject) => {
|
||||
container.addNewPanel({
|
||||
panelType: MY_EMBEDDABLE_TYPE,
|
||||
serializedState: {
|
||||
rawState: savedObject.attributes,
|
||||
container.addNewPanel(
|
||||
{
|
||||
panelType: MY_EMBEDDABLE_TYPE,
|
||||
serializedState: {
|
||||
rawState: savedObject.attributes,
|
||||
},
|
||||
},
|
||||
});
|
||||
true // shows a toast and scrolls to panel
|
||||
);
|
||||
},
|
||||
savedObjectType: MY_SAVED_OBJECT_TYPE,
|
||||
savedObjectName: 'Some saved object',
|
||||
|
|
|
@ -65,14 +65,17 @@ export class LinksPlugin
|
|||
|
||||
plugins.embeddable.registerAddFromLibraryType({
|
||||
onAdd: async (container, savedObject) => {
|
||||
container.addNewPanel<LinksSerializedState>({
|
||||
panelType: CONTENT_ID,
|
||||
serializedState: {
|
||||
rawState: {
|
||||
savedObjectId: savedObject.id,
|
||||
container.addNewPanel<LinksSerializedState>(
|
||||
{
|
||||
panelType: CONTENT_ID,
|
||||
serializedState: {
|
||||
rawState: {
|
||||
savedObjectId: savedObject.id,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
true
|
||||
);
|
||||
},
|
||||
savedObjectType: CONTENT_ID,
|
||||
savedObjectName: APP_NAME,
|
||||
|
|
|
@ -398,13 +398,16 @@ export class DiscoverPlugin
|
|||
|
||||
plugins.embeddable.registerAddFromLibraryType<SavedSearchAttributes>({
|
||||
onAdd: async (container, savedObject) => {
|
||||
container.addNewPanel({
|
||||
panelType: SEARCH_EMBEDDABLE_TYPE,
|
||||
serializedState: {
|
||||
rawState: { savedObjectId: savedObject.id },
|
||||
references: savedObject.references,
|
||||
container.addNewPanel(
|
||||
{
|
||||
panelType: SEARCH_EMBEDDABLE_TYPE,
|
||||
serializedState: {
|
||||
rawState: { savedObjectId: savedObject.id },
|
||||
references: savedObject.references,
|
||||
},
|
||||
},
|
||||
});
|
||||
true
|
||||
);
|
||||
},
|
||||
savedObjectType: SavedSearchType,
|
||||
savedObjectName: i18n.translate('discover.savedSearch.savedObjectName', {
|
||||
|
|
|
@ -68,7 +68,6 @@ export const AddFromLibraryFlyout = ({
|
|||
);
|
||||
return;
|
||||
}
|
||||
|
||||
libraryType.onAdd(container, savedObject);
|
||||
runAddTelemetry(container, savedObject, libraryType.savedObjectMetaData);
|
||||
},
|
||||
|
|
|
@ -38,13 +38,21 @@ export interface EmbeddableSetup {
|
|||
/**
|
||||
* Register a saved object type with the "Add from library" flyout.
|
||||
*
|
||||
* `onAdd` receives the container and the saved object. You may pass a second boolean parameter
|
||||
* to `addNewPanel` to enable a success message and automatic scrolling.
|
||||
*
|
||||
* @example
|
||||
* registerAddFromLibraryType({
|
||||
* onAdd: (container, savedObject) => {
|
||||
* container.addNewPanel({
|
||||
* panelType: CONTENT_ID,
|
||||
* initialState: savedObject.attributes,
|
||||
* });
|
||||
* container.addNewPanel(
|
||||
* {
|
||||
* panelType: MY_EMBEDDABLE_TYPE,
|
||||
* serializedState: {
|
||||
* rawState: savedObject.attributes,
|
||||
* },
|
||||
* },
|
||||
* true // shows a toast and scrolls to panel
|
||||
* );
|
||||
* },
|
||||
* savedObjectType: MAP_SAVED_OBJECT_TYPE,
|
||||
* savedObjectName: i18n.translate('xpack.maps.mapSavedObjectLabel', {
|
||||
|
|
|
@ -407,15 +407,18 @@ export class VisualizationsPlugin
|
|||
});
|
||||
embeddable.registerAddFromLibraryType<VisualizationSavedObjectAttributes>({
|
||||
onAdd: async (container, savedObject) => {
|
||||
container.addNewPanel<VisualizeSavedObjectInputState>({
|
||||
panelType: VISUALIZE_EMBEDDABLE_TYPE,
|
||||
serializedState: {
|
||||
rawState: {
|
||||
savedObjectId: savedObject.id,
|
||||
container.addNewPanel<VisualizeSavedObjectInputState>(
|
||||
{
|
||||
panelType: VISUALIZE_EMBEDDABLE_TYPE,
|
||||
serializedState: {
|
||||
rawState: {
|
||||
savedObjectId: savedObject.id,
|
||||
},
|
||||
references: savedObject.references,
|
||||
},
|
||||
references: savedObject.references,
|
||||
},
|
||||
});
|
||||
true
|
||||
);
|
||||
},
|
||||
savedObjectType: VISUALIZE_EMBEDDABLE_TYPE,
|
||||
savedObjectName: i18n.translate('visualizations.visualizeSavedObjectName', {
|
||||
|
|
|
@ -17,11 +17,13 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
|
|||
const testSubjects = getService('testSubjects');
|
||||
const listingTable = getService('listingTable');
|
||||
|
||||
describe('Dashboard', () => {
|
||||
// https://github.com/elastic/kibana/issues/220515
|
||||
describe.skip('Dashboard', () => {
|
||||
const dashboardName = 'Dashboard Listing A11y';
|
||||
const clonedDashboardName = 'Dashboard Listing A11y (1)';
|
||||
|
||||
it('navitate to dashboard app', async () => {
|
||||
// https://github.com/elastic/kibana/issues/220515
|
||||
it.skip('navigate to dashboard app', async () => {
|
||||
await common.navigateToApp('dashboard');
|
||||
await a11y.testAppSnapshot();
|
||||
});
|
||||
|
|
|
@ -399,15 +399,18 @@ export class LensPlugin {
|
|||
// Let Dashboard know about the Lens panel type
|
||||
embeddable.registerAddFromLibraryType<LensSavedObjectAttributes>({
|
||||
onAdd: async (container, savedObject) => {
|
||||
container.addNewPanel({
|
||||
panelType: LENS_EMBEDDABLE_TYPE,
|
||||
serializedState: {
|
||||
rawState: {
|
||||
savedObjectId: savedObject.id,
|
||||
container.addNewPanel(
|
||||
{
|
||||
panelType: LENS_EMBEDDABLE_TYPE,
|
||||
serializedState: {
|
||||
rawState: {
|
||||
savedObjectId: savedObject.id,
|
||||
},
|
||||
references: savedObject.references,
|
||||
},
|
||||
references: savedObject.references,
|
||||
},
|
||||
});
|
||||
true
|
||||
);
|
||||
},
|
||||
savedObjectType: LENS_EMBEDDABLE_TYPE,
|
||||
savedObjectName: i18n.translate('xpack.lens.mapSavedObjectLabel', {
|
||||
|
|
|
@ -25,14 +25,17 @@ export function setupMapEmbeddable(embeddableSetup: EmbeddableSetup) {
|
|||
|
||||
embeddableSetup.registerAddFromLibraryType<MapAttributes>({
|
||||
onAdd: (container, savedObject) => {
|
||||
container.addNewPanel<MapSerializedState>({
|
||||
panelType: MAP_SAVED_OBJECT_TYPE,
|
||||
serializedState: {
|
||||
rawState: {
|
||||
savedObjectId: savedObject.id,
|
||||
container.addNewPanel<MapSerializedState>(
|
||||
{
|
||||
panelType: MAP_SAVED_OBJECT_TYPE,
|
||||
serializedState: {
|
||||
rawState: {
|
||||
savedObjectId: savedObject.id,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
true
|
||||
);
|
||||
},
|
||||
savedObjectType: MAP_SAVED_OBJECT_TYPE,
|
||||
savedObjectName: i18n.translate('xpack.maps.mapSavedObjectLabel', {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue