Skip to content

Commit

Permalink
[Time to Visualize] Enable by Default (#88390)
Browse files Browse the repository at this point in the history
* Enable Time to Visualize by Default
  • Loading branch information
ThomThomson authored Jan 18, 2021
1 parent 32bd5ce commit af7a577
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 36 deletions.
2 changes: 1 addition & 1 deletion src/plugins/dashboard/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<typeof configSchema>;
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,11 @@ export function SavedObjectSaveModalDashboard(props: DashboardSaveModalProps) {
}
hasChildLabel={false}
>
<EuiPanel color="subdued" hasShadow={false}>
<EuiPanel color="subdued" hasShadow={false} data-test-subj="add-to-dashboard-options">
<div>
<EuiRadio
checked={dashboardOption === 'existing'}
id="existing"
id="existing-dashboard-option"
name="dashboard-option"
label={i18n.translate(
'presentationUtil.saveModalDashboard.existingDashboardOptionLabel',
Expand All @@ -129,7 +129,7 @@ export function SavedObjectSaveModalDashboard(props: DashboardSaveModalProps) {

<EuiRadio
checked={dashboardOption === 'new'}
id="new"
id="new-dashboard-option"
name="dashboard-option"
label={i18n.translate(
'presentationUtil.saveModalDashboard.newDashboardOptionLabel',
Expand All @@ -145,7 +145,7 @@ export function SavedObjectSaveModalDashboard(props: DashboardSaveModalProps) {

<EuiRadio
checked={dashboardOption === null}
id="library"
id="add-to-library-option"
name="dashboard-option"
label={i18n.translate('presentationUtil.saveModalDashboard.libraryOptionLabel', {
defaultMessage: 'No dashboard, but add to library',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ export const useSavedVisInstance = (
? stateTransferService.getAppNameFromId(originatingApp)
: undefined;
const redirectToOrigin = originatingApp ? () => navigateToApp(originatingApp) : undefined;
const byValueCreateMode = dashboard.dashboardFeatureFlagConfig.allowByValueEmbeddables;
const byValueCreateMode =
Boolean(originatingApp) && dashboard.dashboardFeatureFlagConfig.allowByValueEmbeddables;

if (savedVis.id) {
chrome.setBreadcrumbs(
Expand Down
66 changes: 52 additions & 14 deletions test/functional/page_objects/visualize_page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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');
Expand All @@ -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}`
Expand Down
28 changes: 14 additions & 14 deletions x-pack/test/functional/page_objects/lens_page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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, {
/**
Expand Down Expand Up @@ -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, () =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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`);
Expand Down

0 comments on commit af7a577

Please sign in to comment.