mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
* made save as stay in edit mode when not navigating to another dashboard. Removed extra history entires from save
This commit is contained in:
parent
54eb92f49a
commit
9593886862
8 changed files with 36 additions and 18 deletions
|
@ -139,6 +139,7 @@ export class DashboardStateManager {
|
|||
// setup initial state by merging defaults with state from url & panels storage
|
||||
// also run migration, as state in url could be of older version
|
||||
const initialUrlState = this.kbnUrlStateStorage.get<DashboardAppState>(STATE_STORAGE_KEY);
|
||||
|
||||
const initialState = migrateAppState(
|
||||
{
|
||||
...this.stateDefaults,
|
||||
|
@ -345,7 +346,7 @@ export class DashboardStateManager {
|
|||
/**
|
||||
* Resets the state back to the last saved version of the dashboard.
|
||||
*/
|
||||
public resetState(resetViewMode: boolean) {
|
||||
public resetState() {
|
||||
// In order to show the correct warning, we have to store the unsaved
|
||||
// title on the dashboard object. We should fix this at some point, but this is how all the other object
|
||||
// save panels work at the moment.
|
||||
|
@ -368,12 +369,8 @@ export class DashboardStateManager {
|
|||
this.stateDefaults.filters = [...this.getLastSavedFilterBars()];
|
||||
this.isDirty = false;
|
||||
|
||||
if (resetViewMode) {
|
||||
this.stateContainer.set(this.stateDefaults);
|
||||
} else {
|
||||
const currentViewMode = this.stateContainer.get().viewMode;
|
||||
this.stateContainer.set({ ...this.stateDefaults, viewMode: currentViewMode });
|
||||
}
|
||||
const currentViewMode = this.stateContainer.get().viewMode;
|
||||
this.stateContainer.set({ ...this.stateDefaults, viewMode: currentViewMode });
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -38,7 +38,6 @@ export function saveDashboard(
|
|||
// reset state only when save() was successful
|
||||
// e.g. save() could be interrupted if title is duplicated and not confirmed
|
||||
dashboardStateManager.lastSavedDashboardFilters = dashboardStateManager.getFilterState();
|
||||
dashboardStateManager.resetState(!saveOptions.stayInEditMode);
|
||||
}
|
||||
|
||||
return id;
|
||||
|
|
|
@ -19,7 +19,12 @@ import {
|
|||
openAddPanelFlyout,
|
||||
ViewMode,
|
||||
} from '../../services/embeddable';
|
||||
import { getSavedObjectFinder, SaveResult, showSaveModal } from '../../services/saved_objects';
|
||||
import {
|
||||
getSavedObjectFinder,
|
||||
SavedObjectSaveOpts,
|
||||
SaveResult,
|
||||
showSaveModal,
|
||||
} from '../../services/saved_objects';
|
||||
|
||||
import { NavAction } from '../../types';
|
||||
import { DashboardSavedObject } from '../..';
|
||||
|
@ -43,7 +48,6 @@ import { OverlayRef } from '../../../../../core/public';
|
|||
import { getNewDashboardTitle, unsavedChangesBadge } from '../../dashboard_strings';
|
||||
import { DASHBOARD_PANELS_UNSAVED_ID } from '../lib/dashboard_panel_storage';
|
||||
import { DashboardContainer } from '..';
|
||||
import { SavedDashboardSaveOpts } from '../lib/save_dashboard';
|
||||
|
||||
export interface DashboardTopNavState {
|
||||
chromeIsVisible: boolean;
|
||||
|
@ -176,7 +180,7 @@ export function DashboardTopNav({
|
|||
}
|
||||
|
||||
function discardChanges() {
|
||||
dashboardStateManager.resetState(true);
|
||||
dashboardStateManager.resetState();
|
||||
dashboardStateManager.clearUnsavedPanels();
|
||||
|
||||
// We need to do a hard reset of the timepicker. appState will not reload like
|
||||
|
@ -221,7 +225,8 @@ export function DashboardTopNav({
|
|||
* @resolved {String} - The id of the doc
|
||||
*/
|
||||
const save = useCallback(
|
||||
async (saveOptions: SavedDashboardSaveOpts) => {
|
||||
async (saveOptions: SavedObjectSaveOpts) => {
|
||||
setIsSaveInProgress(true);
|
||||
return saveDashboard(angular.toJson, timefilter, dashboardStateManager, saveOptions)
|
||||
.then(function (id) {
|
||||
if (id) {
|
||||
|
@ -235,8 +240,15 @@ export function DashboardTopNav({
|
|||
|
||||
dashboardPanelStorage.clearPanels(lastDashboardId);
|
||||
if (id !== lastDashboardId) {
|
||||
redirectTo({ destination: 'dashboard', id, useReplace: !lastDashboardId });
|
||||
redirectTo({
|
||||
id,
|
||||
// editMode: true,
|
||||
destination: 'dashboard',
|
||||
useReplace: true,
|
||||
});
|
||||
} else {
|
||||
setIsSaveInProgress(false);
|
||||
dashboardStateManager.resetState();
|
||||
chrome.docTitle.change(dashboardStateManager.savedDashboard.lastSavedTitle);
|
||||
}
|
||||
}
|
||||
|
@ -354,7 +366,7 @@ export function DashboardTopNav({
|
|||
}
|
||||
|
||||
setIsSaveInProgress(true);
|
||||
save({ stayInEditMode: true }).then((response: SaveResult) => {
|
||||
save({}).then((response: SaveResult) => {
|
||||
// If the save wasn't successful, put the original values back.
|
||||
if (!(response as { id: string }).id) {
|
||||
dashboardStateManager.setTitle(currentTitle);
|
||||
|
|
|
@ -36,7 +36,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
|
|||
});
|
||||
|
||||
it('available in view mode', async () => {
|
||||
await PageObjects.dashboard.saveDashboard('full screen test', { saveAsNew: true });
|
||||
await PageObjects.dashboard.saveDashboard('full screen test', {
|
||||
saveAsNew: true,
|
||||
exitFromEditMode: true,
|
||||
});
|
||||
const exists = await PageObjects.dashboard.fullScreenModeMenuItemExists();
|
||||
expect(exists).to.be(true);
|
||||
});
|
||||
|
|
|
@ -68,7 +68,6 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
|
|||
storeTimeWithDashboard: true,
|
||||
});
|
||||
|
||||
await PageObjects.dashboard.switchToEditMode();
|
||||
await PageObjects.timePicker.setAbsoluteRange(
|
||||
'Sep 19, 2013 @ 06:31:44.000',
|
||||
'Sep 19, 2013 @ 06:31:44.000'
|
||||
|
@ -210,7 +209,6 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
|
|||
it('when time changed is not stored with dashboard', async function () {
|
||||
await PageObjects.dashboard.gotoDashboardEditMode(dashboardName);
|
||||
await PageObjects.dashboard.saveDashboard(dashboardName, { storeTimeWithDashboard: false });
|
||||
await PageObjects.dashboard.switchToEditMode();
|
||||
await PageObjects.timePicker.setAbsoluteRange(
|
||||
'Oct 19, 2014 @ 06:31:44.000',
|
||||
'Dec 19, 2014 @ 06:31:44.000'
|
||||
|
|
|
@ -31,6 +31,7 @@ export function DashboardPageProvider({ getService, getPageObjects }: FtrProvide
|
|||
* @default true
|
||||
*/
|
||||
waitDialogIsClosed?: boolean;
|
||||
exitFromEditMode?: boolean;
|
||||
needsConfirm?: boolean;
|
||||
storeTimeWithDashboard?: boolean;
|
||||
saveAsNew?: boolean;
|
||||
|
@ -376,7 +377,7 @@ export function DashboardPageProvider({ getService, getPageObjects }: FtrProvide
|
|||
*/
|
||||
public async saveDashboard(
|
||||
dashboardName: string,
|
||||
saveOptions: SaveDashboardOptions = { waitDialogIsClosed: true }
|
||||
saveOptions: SaveDashboardOptions = { waitDialogIsClosed: true, exitFromEditMode: true }
|
||||
) {
|
||||
await retry.try(async () => {
|
||||
await this.enterDashboardTitleAndClickSave(dashboardName, saveOptions);
|
||||
|
@ -393,6 +394,12 @@ export function DashboardPageProvider({ getService, getPageObjects }: FtrProvide
|
|||
await PageObjects.header.waitUntilLoadingHasFinished();
|
||||
await PageObjects.common.waitForSaveModalToClose();
|
||||
|
||||
const isInViewMode = await testSubjects.exists('dashboardEditMode');
|
||||
if (saveOptions.exitFromEditMode && !isInViewMode) {
|
||||
await this.clickCancelOutOfEditMode();
|
||||
}
|
||||
await PageObjects.header.waitUntilLoadingHasFinished();
|
||||
|
||||
return message;
|
||||
}
|
||||
|
||||
|
|
|
@ -71,6 +71,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
|
|||
{
|
||||
saveAsNew: false,
|
||||
waitDialogIsClosed: true,
|
||||
exitFromEditMode: true,
|
||||
}
|
||||
);
|
||||
|
||||
|
|
|
@ -60,6 +60,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
|
|||
{
|
||||
saveAsNew: false,
|
||||
waitDialogIsClosed: true,
|
||||
exitFromEditMode: true,
|
||||
}
|
||||
);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue