Skip to content

Commit

Permalink
[dashboard] remove legacy embeddable client migrations (#203669)
Browse files Browse the repository at this point in the history
Part of #203250
  • Loading branch information
nreese authored Dec 10, 2024
1 parent 5acba96 commit d67681d
Show file tree
Hide file tree
Showing 14 changed files with 25 additions and 181 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ export function getDashboardApi({
timeRestore$: unifiedSearchManager.internalApi.timeRestore$,
});
const unsavedChangesManager = initializeUnsavedChangesManager({
anyMigrationRun: savedObjectResult?.anyMigrationRun ?? false,
creationOptions,
controlGroupApi$,
lastSavedState: omit(savedObjectResult?.dashboardInput, 'controlGroupInput') ?? {
Expand Down
1 change: 0 additions & 1 deletion src/plugins/dashboard/public/dashboard_api/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,6 @@ export type DashboardApi = CanExpandPanels &
getSettings: () => DashboardStateFromSettingsFlyout;
getDashboardPanelFromId: (id: string) => Promise<DashboardPanelState>;
hasOverlays$: PublishingSubject<boolean>;
hasRunMigrations$: PublishingSubject<boolean>;
hasUnsavedChanges$: PublishingSubject<boolean>;
highlightPanel: (panelRef: HTMLDivElement) => void;
highlightPanelId$: PublishingSubject<string | undefined>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import {
import { initializeViewModeManager } from './view_mode_manager';

export function initializeUnsavedChangesManager({
anyMigrationRun,
creationOptions,
controlGroupApi$,
lastSavedState,
Expand All @@ -33,7 +32,6 @@ export function initializeUnsavedChangesManager({
viewModeManager,
unifiedSearchManager,
}: {
anyMigrationRun: boolean;
creationOptions?: DashboardCreationOptions;
controlGroupApi$: PublishingSubject<ControlGroupApi | undefined>;
lastSavedState: DashboardState;
Expand All @@ -43,7 +41,6 @@ export function initializeUnsavedChangesManager({
viewModeManager: ReturnType<typeof initializeViewModeManager>;
unifiedSearchManager: ReturnType<typeof initializeUnifiedSearchManager>;
}) {
const hasRunMigrations$ = new BehaviorSubject(anyMigrationRun);
const hasUnsavedChanges$ = new BehaviorSubject(false);
const lastSavedState$ = new BehaviorSubject<DashboardState>(lastSavedState);
const saveNotification$ = new Subject<void>();
Expand Down Expand Up @@ -113,7 +110,6 @@ export function initializeUnsavedChangesManager({
unifiedSearchManager.internalApi.reset(lastSavedState$.value);
await controlGroupApi$.value?.asyncResetUnsavedChanges();
},
hasRunMigrations$,
hasUnsavedChanges$,
saveNotification$,
},
Expand All @@ -125,11 +121,6 @@ export function initializeUnsavedChangesManager({
getLastSavedState: () => lastSavedState$.value,
onSave: (savedState: DashboardState) => {
lastSavedState$.next(savedState);

// if we set the last saved input, it means we have saved this Dashboard - therefore clientside migrations have
// been serialized into the SO.
hasRunMigrations$.next(false);

saveNotification$.next();
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,6 @@ export const unsavedChangesBadgeStrings = {
defaultMessage:
' You have unsaved changes in this dashboard. To remove this label, save the dashboard.',
}),
getHasRunMigrationsText: () =>
i18n.translate('dashboard.hasRunMigrationsBadge', {
defaultMessage: 'Save recommended',
}),
getHasRunMigrationsToolTipContent: () =>
i18n.translate('dashboard.hasRunMigrationsBadgeToolTipContent', {
defaultMessage:
'One or more panels on this dashboard have been updated to a new version. Save the dashboard so it loads faster next time.',
}),
};

export const getCreateVisualizationButtonTitle = () =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,10 @@ export const useDashboardMenuItems = ({

const dashboardApi = useDashboardApi();

const [dashboardTitle, hasOverlays, hasRunMigrations, hasUnsavedChanges, lastSavedId, viewMode] =
const [dashboardTitle, hasOverlays, hasUnsavedChanges, lastSavedId, viewMode] =
useBatchedPublishingSubjects(
dashboardApi.panelTitle,
dashboardApi.hasOverlays$,
dashboardApi.hasRunMigrations$,
dashboardApi.hasUnsavedChanges$,
dashboardApi.savedObjectId,
dashboardApi.viewMode
Expand Down Expand Up @@ -161,7 +160,7 @@ export const useDashboardMenuItems = ({
emphasize: true,
isLoading: isSaveInProgress,
testId: 'dashboardQuickSaveMenuItem',
disableButton: disableTopNav || !(hasRunMigrations || hasUnsavedChanges),
disableButton: disableTopNav || !hasUnsavedChanges,
run: () => quickSaveDashboard(),
} as TopNavMenuData,

Expand Down Expand Up @@ -211,7 +210,6 @@ export const useDashboardMenuItems = ({
}, [
disableTopNav,
isSaveInProgress,
hasRunMigrations,
hasUnsavedChanges,
lastSavedId,
dashboardInteractiveSave,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ export function InternalDashboardTopNav({
allDataViews,
focusedPanelId,
fullScreenMode,
hasRunMigrations,
hasUnsavedChanges,
lastSavedId,
query,
Expand All @@ -97,7 +96,6 @@ export function InternalDashboardTopNav({
dashboardApi.dataViews,
dashboardApi.focusedPanelId$,
dashboardApi.fullScreenMode$,
dashboardApi.hasRunMigrations$,
dashboardApi.hasUnsavedChanges$,
dashboardApi.savedObjectId,
dashboardApi.query$,
Expand Down Expand Up @@ -267,19 +265,6 @@ export function InternalDashboardTopNav({
} as EuiToolTipProps,
});
}
if (hasRunMigrations && viewMode === 'edit') {
allBadges.push({
'data-test-subj': 'dashboardSaveRecommendedBadge',
badgeText: unsavedChangesBadgeStrings.getHasRunMigrationsText(),
title: '',
color: 'success',
iconType: 'save',
toolTipProps: {
content: unsavedChangesBadgeStrings.getHasRunMigrationsToolTipContent(),
position: 'bottom',
} as EuiToolTipProps,
});
}

const { showWriteControls } = getDashboardCapabilities();
if (showWriteControls && dashboardApi.isManaged) {
Expand Down Expand Up @@ -328,7 +313,7 @@ export function InternalDashboardTopNav({
});
}
return allBadges;
}, [hasUnsavedChanges, viewMode, hasRunMigrations, isPopoverOpen, dashboardApi, maybeRedirect]);
}, [hasUnsavedChanges, viewMode, isPopoverOpen, dashboardApi, maybeRedirect]);

return (
<div className="dashboardTopNav">
Expand Down
1 change: 0 additions & 1 deletion src/plugins/dashboard/public/mocks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ export function buildMockDashboardApi({
viewMode: initialState.viewMode as ViewMode,
id: savedObjectId ?? '123',
} as SavedDashboardInput,
anyMigrationRun: false,
references: [],
},
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import type {
LoadDashboardReturn,
} from '../types';
import { convertNumberToDashboardVersion } from './dashboard_versioning';
import { migrateDashboardInput } from './migrate_dashboard_input';

export function migrateLegacyQuery(query: Query | { [key: string]: any } | string): Query {
// Lucene was the only option before, so language-less queries are all lucene
Expand Down Expand Up @@ -171,34 +170,32 @@ export const loadDashboardState = async ({

const panelMap = convertPanelsArrayToPanelMap(panels ?? []);

const { dashboardInput, anyMigrationRun } = migrateDashboardInput({
...DEFAULT_DASHBOARD_INPUT,
...options,

id: embeddableId,
refreshInterval,
timeRestore,
description,
timeRange,
filters,
panels: panelMap,
query,
title,

viewMode: ViewMode.VIEW, // dashboards loaded from saved object default to view mode. If it was edited recently, the view mode from session storage will override this.
tags: savedObjectsTaggingService?.getTaggingApi()?.ui.getTagIdsFromReferences(references) ?? [],

controlGroupInput: attributes.controlGroupInput,

...(version && { version: convertNumberToDashboardVersion(version) }),
});

return {
managed,
references,
resolveMeta,
dashboardInput,
anyMigrationRun,
dashboardInput: {
...DEFAULT_DASHBOARD_INPUT,
...options,

id: embeddableId,
refreshInterval,
timeRestore,
description,
timeRange,
filters,
panels: panelMap,
query,
title,

viewMode: ViewMode.VIEW, // dashboards loaded from saved object default to view mode. If it was edited recently, the view mode from session storage will override this.
tags:
savedObjectsTaggingService?.getTaggingApi()?.ui.getTagIdsFromReferences(references) ?? [],

controlGroupInput: attributes.controlGroupInput,

...(version && { version: convertNumberToDashboardVersion(version) }),
},
dashboardFound: true,
dashboardId: savedObjectId,
};
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ export interface LoadDashboardReturn {
managed?: boolean;
resolveMeta?: DashboardResolveMeta;
dashboardInput: SavedDashboardInput;
anyMigrationRun?: boolean;

/**
* Raw references returned directly from the Dashboard saved object. These
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1466,8 +1466,6 @@
"dashboard.featureCatalogue.dashboardDescription": "Affichez et partagez une collection de visualisations et de recherches enregistrées.",
"dashboard.featureCatalogue.dashboardSubtitle": "Analysez des données à l’aide de tableaux de bord.",
"dashboard.featureCatalogue.dashboardTitle": "Dashboard",
"dashboard.hasRunMigrationsBadge": "Enregistrement recommandé",
"dashboard.hasRunMigrationsBadgeToolTipContent": "Un ou plusieurs panneaux de ce tableau de bord ont été mis à jour vers une nouvelle version. Enregistrez le tableau de bord pour qu'il charge plus rapidement la prochaine fois.",
"dashboard.labs.enableLabsDescription": "Cet indicateur détermine si l'utilisateur a accès au bouton Ateliers, moyen rapide d'activer et de désactiver les fonctionnalités de la version d'évaluation technique dans le tableau de bord.",
"dashboard.labs.enableUI": "Activer le bouton Ateliers dans le tableau de bord",
"dashboard.listing.createNewDashboard.combineDataViewFromKibanaAppDescription": "Analysez toutes vos données Elastic en un seul endroit, en créant un tableau de bord et en ajoutant des visualisations.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1466,8 +1466,6 @@
"dashboard.featureCatalogue.dashboardDescription": "ビジュアライゼーションと保存された検索のコレクションの表示と共有を行います。",
"dashboard.featureCatalogue.dashboardSubtitle": "ダッシュボードでデータを分析します。",
"dashboard.featureCatalogue.dashboardTitle": "ダッシュボード",
"dashboard.hasRunMigrationsBadge": "推奨を保存",
"dashboard.hasRunMigrationsBadgeToolTipContent": "このダッシュボードの1つ以上のパネルが新しいバージョンに更新されました。ダッシュボードを保存すると、次回の読み込みが速くなります。",
"dashboard.labs.enableLabsDescription": "このフラグはビューアーで[ラボ]ボタンを使用できるかどうかを決定します。ダッシュボードで実験的機能を有効および無効にするための簡単な方法です。",
"dashboard.labs.enableUI": "ダッシュボードで[ラボ]ボタンを有効にする",
"dashboard.listing.createNewDashboard.combineDataViewFromKibanaAppDescription": "ダッシュボードを作成し、ビジュアライゼーションを追加して、すべてのElasticデータを1つの場所で分析します。",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1479,8 +1479,6 @@
"dashboard.featureCatalogue.dashboardDescription": "显示和共享可视化和已保存搜索的集合。",
"dashboard.featureCatalogue.dashboardSubtitle": "在仪表板中分析数据。",
"dashboard.featureCatalogue.dashboardTitle": "仪表板",
"dashboard.hasRunMigrationsBadge": "保存推荐项",
"dashboard.hasRunMigrationsBadgeToolTipContent": "此仪表板上的一个或多个面板已更新到新版本。保存该仪表板以便下次更快加载。",
"dashboard.labs.enableLabsDescription": "此标志决定查看者是否有权访问用于在仪表板中快速启用和禁用技术预览功能的'实验'按钮。",
"dashboard.labs.enableUI": "在仪表板中启用实验按钮",
"dashboard.listing.createNewDashboard.combineDataViewFromKibanaAppDescription": "通过创建仪表板并添加可视化,在一个位置分析所有 Elastic 数据。",
Expand Down

0 comments on commit d67681d

Please sign in to comment.