From ccff49ddf74f3ba2ca659e7391c58bcc4bee9d1b Mon Sep 17 00:00:00 2001 From: Devon Thomson Date: Mon, 18 Jan 2021 16:13:39 -0500 Subject: [PATCH] [Time to Visualize] Enable by Default (#88390) (#88626) * Enable Time to Visualize by Default --- src/plugins/dashboard/config.ts | 2 +- .../saved_object_save_modal_dashboard.tsx | 8 +-- .../utils/use/use_saved_vis_instance.ts | 3 +- .../functional/page_objects/visualize_page.ts | 66 +++++++++++++++---- .../test/functional/page_objects/lens_page.ts | 28 ++++---- .../functional/tests/visualize_integration.ts | 5 +- 6 files changed, 76 insertions(+), 36 deletions(-) diff --git a/src/plugins/dashboard/config.ts b/src/plugins/dashboard/config.ts index ff968a51679e0..da3f8a61306b8 100644 --- a/src/plugins/dashboard/config.ts +++ b/src/plugins/dashboard/config.ts @@ -20,7 +20,7 @@ import { schema, TypeOf } from '@kbn/config-schema'; export const configSchema = schema.object({ - allowByValueEmbeddables: schema.boolean({ defaultValue: false }), + allowByValueEmbeddables: schema.boolean({ defaultValue: true }), }); export type ConfigSchema = TypeOf; diff --git a/src/plugins/presentation_util/public/components/saved_object_save_modal_dashboard.tsx b/src/plugins/presentation_util/public/components/saved_object_save_modal_dashboard.tsx index aafa500002ae2..04700e9379840 100644 --- a/src/plugins/presentation_util/public/components/saved_object_save_modal_dashboard.tsx +++ b/src/plugins/presentation_util/public/components/saved_object_save_modal_dashboard.tsx @@ -99,11 +99,11 @@ export function SavedObjectSaveModalDashboard(props: DashboardSaveModalProps) { } hasChildLabel={false} > - +
navigateToApp(originatingApp) : undefined; - const byValueCreateMode = dashboard.dashboardFeatureFlagConfig.allowByValueEmbeddables; + const byValueCreateMode = + Boolean(originatingApp) && dashboard.dashboardFeatureFlagConfig.allowByValueEmbeddables; if (savedVis.id) { chrome.setBreadcrumbs( diff --git a/test/functional/page_objects/visualize_page.ts b/test/functional/page_objects/visualize_page.ts index d8329f492fe80..d5df15968f741 100644 --- a/test/functional/page_objects/visualize_page.ts +++ b/test/functional/page_objects/visualize_page.ts @@ -20,6 +20,18 @@ import { FtrProviderContext } from '../ftr_provider_context'; import { VisualizeConstants } from '../../../src/plugins/visualize/public/application/visualize_constants'; +interface VisualizeSaveModalArgs { + saveAsNew?: boolean; + redirectToOrigin?: boolean; + addToDashboard?: boolean; + dashboardId?: string; +} + +type DashboardPickerOption = + | 'add-to-library-option' + | 'existing-dashboard-option' + | 'new-dashboard-option'; + export function VisualizePageProvider({ getService, getPageObjects }: FtrProviderContext) { const testSubjects = getService('testSubjects'); const retry = getService('retry'); @@ -346,11 +358,27 @@ export function VisualizePageProvider({ getService, getPageObjects }: FtrProvide } } - public async saveVisualization( + public async saveVisualization(vizName: string, saveModalArgs: VisualizeSaveModalArgs = {}) { + await this.ensureSavePanelOpen(); + + await this.setSaveModalValues(vizName, saveModalArgs); + log.debug('Click Save Visualization button'); + + await testSubjects.click('confirmSaveSavedObjectButton'); + + // Confirm that the Visualization has actually been saved + await testSubjects.existOrFail('saveVisualizationSuccess'); + const message = await common.closeToast(); + await header.waitUntilLoadingHasFinished(); + await common.waitForSaveModalToClose(); + + return message; + } + + public async setSaveModalValues( vizName: string, - { saveAsNew = false, redirectToOrigin = false } = {} + { saveAsNew, redirectToOrigin, addToDashboard, dashboardId }: VisualizeSaveModalArgs = {} ) { - await this.ensureSavePanelOpen(); await testSubjects.setValue('savedObjectTitle', vizName); const saveAsNewCheckboxExists = await testSubjects.exists('saveAsNewCheckbox'); @@ -366,24 +394,34 @@ export function VisualizePageProvider({ getService, getPageObjects }: FtrProvide log.debug('redirect to origin checkbox exists. Setting its state to', state); await testSubjects.setEuiSwitch('returnToOriginModeSwitch', state); } - log.debug('Click Save Visualization button'); - await testSubjects.click('confirmSaveSavedObjectButton'); - - // Confirm that the Visualization has actually been saved - await testSubjects.existOrFail('saveVisualizationSuccess'); - const message = await common.closeToast(); - await header.waitUntilLoadingHasFinished(); - await common.waitForSaveModalToClose(); + const dashboardSelectorExists = await testSubjects.exists('add-to-dashboard-options'); + if (dashboardSelectorExists) { + let option: DashboardPickerOption = 'add-to-library-option'; + if (addToDashboard) { + option = dashboardId ? 'existing-dashboard-option' : 'new-dashboard-option'; + } + log.debug('save modal dashboard selector, choosing option:', option); + const dashboardSelector = await testSubjects.find('add-to-dashboard-options'); + const label = await dashboardSelector.findByCssSelector(`label[for="${option}"]`); + await label.click(); - return message; + if (dashboardId) { + // TODO - selecting an existing dashboard + } + } } public async saveVisualizationExpectSuccess( vizName: string, - { saveAsNew = false, redirectToOrigin = false } = {} + { saveAsNew, redirectToOrigin, addToDashboard, dashboardId }: VisualizeSaveModalArgs = {} ) { - const saveMessage = await this.saveVisualization(vizName, { saveAsNew, redirectToOrigin }); + const saveMessage = await this.saveVisualization(vizName, { + saveAsNew, + redirectToOrigin, + addToDashboard, + dashboardId, + }); if (!saveMessage) { throw new Error( `Expected saveVisualization to respond with the saveMessage from the toast, got ${saveMessage}` diff --git a/x-pack/test/functional/page_objects/lens_page.ts b/x-pack/test/functional/page_objects/lens_page.ts index 13ff6a64f8936..04c660847bcee 100644 --- a/x-pack/test/functional/page_objects/lens_page.ts +++ b/x-pack/test/functional/page_objects/lens_page.ts @@ -16,7 +16,7 @@ export function LensPageProvider({ getService, getPageObjects }: FtrProviderCont const find = getService('find'); const comboBox = getService('comboBox'); const browser = getService('browser'); - const PageObjects = getPageObjects(['header', 'timePicker', 'common']); + const PageObjects = getPageObjects(['header', 'timePicker', 'common', 'visualize']); return logWrapper('lensPage', log, { /** @@ -270,22 +270,22 @@ export function LensPageProvider({ getService, getPageObjects }: FtrProviderCont /** * Save the current Lens visualization. */ - async save(title: string, saveAsNew?: boolean, redirectToOrigin?: boolean) { + async save( + title: string, + saveAsNew?: boolean, + redirectToOrigin?: boolean, + addToDashboard?: boolean, + dashboardId?: string + ) { await PageObjects.header.waitUntilLoadingHasFinished(); await testSubjects.click('lnsApp_saveButton'); - await testSubjects.setValue('savedObjectTitle', title); - - const saveAsNewCheckboxExists = await testSubjects.exists('saveAsNewCheckbox'); - if (saveAsNewCheckboxExists) { - const state = saveAsNew ? 'check' : 'uncheck'; - await testSubjects.setEuiSwitch('saveAsNewCheckbox', state); - } - const redirectToOriginCheckboxExists = await testSubjects.exists('returnToOriginModeSwitch'); - if (redirectToOriginCheckboxExists) { - const state = redirectToOrigin ? 'check' : 'uncheck'; - await testSubjects.setEuiSwitch('returnToOriginModeSwitch', state); - } + await PageObjects.visualize.setSaveModalValues(title, { + saveAsNew, + redirectToOrigin, + addToDashboard, + dashboardId, + }); await testSubjects.click('confirmSaveSavedObjectButton'); await retry.waitForWithTimeout('Save modal to disappear', 1000, () => diff --git a/x-pack/test/saved_object_tagging/functional/tests/visualize_integration.ts b/x-pack/test/saved_object_tagging/functional/tests/visualize_integration.ts index 834c3083071df..e92ba226f3959 100644 --- a/x-pack/test/saved_object_tagging/functional/tests/visualize_integration.ts +++ b/x-pack/test/saved_object_tagging/functional/tests/visualize_integration.ts @@ -94,7 +94,8 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { await PageObjects.visEditor.clickGo(); await PageObjects.visualize.ensureSavePanelOpen(); - await testSubjects.setValue('savedObjectTitle', 'My new markdown viz'); + await PageObjects.visualize.setSaveModalValues('My new markdown viz'); + await selectSavedObjectTags('tag-1'); await testSubjects.click('confirmSaveSavedObjectButton'); @@ -118,7 +119,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { await PageObjects.visEditor.clickGo(); await PageObjects.visualize.ensureSavePanelOpen(); - await testSubjects.setValue('savedObjectTitle', 'vis-with-new-tag'); + await PageObjects.visualize.setSaveModalValues('vis-with-new-tag'); await testSubjects.click('savedObjectTagSelector'); await testSubjects.click(`tagSelectorOption-action__create`);