From 6c69401b9e23711bdccaf3a9751a3e1ae66e6fe5 Mon Sep 17 00:00:00 2001 From: Nathan Reese Date: Mon, 16 Dec 2024 09:37:44 -0700 Subject: [PATCH] [dashboard] decouple UpdateDashboardMetaProps type from DashboardContainerInput type (#204255) Part of https://github.com/elastic/kibana/issues/204249 --------- Co-authored-by: Elastic Machine --- .../hooks/use_dashboard_listing_table.tsx | 4 ++-- .../lib/update_dashboard_meta.ts | 17 +++++++++++------ .../types.ts | 5 ++--- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/plugins/dashboard/public/dashboard_listing/hooks/use_dashboard_listing_table.tsx b/src/plugins/dashboard/public/dashboard_listing/hooks/use_dashboard_listing_table.tsx index e434fe19d7b26..e29f93f97c17e 100644 --- a/src/plugins/dashboard/public/dashboard_listing/hooks/use_dashboard_listing_table.tsx +++ b/src/plugins/dashboard/public/dashboard_listing/hooks/use_dashboard_listing_table.tsx @@ -16,7 +16,6 @@ import type { SavedObjectsFindOptionsReference } from '@kbn/core/public'; import { reportPerformanceMetricEvent } from '@kbn/ebt-tools'; import { ViewMode } from '@kbn/embeddable-plugin/public'; -import { DashboardContainerInput } from '../../../common'; import type { DashboardSearchOut } from '../../../server/content_management'; import { DASHBOARD_CONTENT_ID, @@ -35,6 +34,7 @@ import { import { confirmCreateWithUnsaved } from '../confirm_overlays'; import { DashboardListingEmptyPrompt } from '../dashboard_listing_empty_prompt'; import { DashboardSavedObjectUserContent } from '../types'; +import { UpdateDashboardMetaProps } from '../../services/dashboard_content_management_service/lib/update_dashboard_meta'; type GetDetailViewLink = TableListViewTableProps['getDetailViewLink']; @@ -130,7 +130,7 @@ export const useDashboardListingTable = ({ }, [dashboardBackupService, goToDashboard, useSessionStorageIntegration]); const updateItemMeta = useCallback( - async (props: Pick) => { + async (props: UpdateDashboardMetaProps) => { await dashboardContentManagementService.updateDashboardMeta(props); setUnsavedDashboardIds(dashboardBackupService.getDashboardIdsWithUnsavedChanges()); diff --git a/src/plugins/dashboard/public/services/dashboard_content_management_service/lib/update_dashboard_meta.ts b/src/plugins/dashboard/public/services/dashboard_content_management_service/lib/update_dashboard_meta.ts index 90f31cfdc05c6..60f61b64caeec 100644 --- a/src/plugins/dashboard/public/services/dashboard_content_management_service/lib/update_dashboard_meta.ts +++ b/src/plugins/dashboard/public/services/dashboard_content_management_service/lib/update_dashboard_meta.ts @@ -7,16 +7,21 @@ * License v3.0 only", or the "Server Side Public License, v 1". */ -import { DashboardContainerInput } from '../../../../common'; import { DASHBOARD_CONTENT_ID } from '../../../dashboard_constants'; -import type { DashboardUpdateIn, DashboardUpdateOut } from '../../../../server/content_management'; +import type { + DashboardAttributes, + DashboardUpdateIn, + DashboardUpdateOut, +} from '../../../../server/content_management'; import { findDashboardsByIds } from './find_dashboards'; import { contentManagementService, savedObjectsTaggingService } from '../../kibana_services'; -type UpdateDashboardMetaProps = Pick< - DashboardContainerInput, - 'id' | 'title' | 'description' | 'tags' ->; +export interface UpdateDashboardMetaProps { + id: DashboardUpdateIn['id']; + title: DashboardAttributes['title']; + description?: DashboardAttributes['description']; + tags: string[]; +} export const updateDashboardMeta = async ({ id, diff --git a/src/plugins/dashboard/public/services/dashboard_content_management_service/types.ts b/src/plugins/dashboard/public/services/dashboard_content_management_service/types.ts index 1922ed3e30dac..3c0c37afc0cd6 100644 --- a/src/plugins/dashboard/public/services/dashboard_content_management_service/types.ts +++ b/src/plugins/dashboard/public/services/dashboard_content_management_service/types.ts @@ -21,6 +21,7 @@ import { SearchDashboardsResponse, } from './lib/find_dashboards'; import { DashboardState } from '../../dashboard_api/types'; +import { UpdateDashboardMetaProps } from './lib/update_dashboard_meta'; export interface DashboardContentManagementService { findDashboards: FindDashboardsService; @@ -28,9 +29,7 @@ export interface DashboardContentManagementService { loadDashboardState: (props: { id?: string }) => Promise; saveDashboardState: (props: SaveDashboardProps) => Promise; checkForDuplicateDashboardTitle: (meta: DashboardDuplicateTitleCheckProps) => Promise; - updateDashboardMeta: ( - props: Pick - ) => Promise; + updateDashboardMeta: (props: UpdateDashboardMetaProps) => Promise; } /**