Skip to content

Commit

Permalink
[dashboard] decouple UpdateDashboardMetaProps type from DashboardCont…
Browse files Browse the repository at this point in the history
…ainerInput type (elastic#204255)

Part of elastic#204249

---------

Co-authored-by: Elastic Machine <[email protected]>
  • Loading branch information
nreese and elasticmachine authored Dec 16, 2024
1 parent 984a059 commit 6c69401
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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<DashboardSavedObjectUserContent>['getDetailViewLink'];
Expand Down Expand Up @@ -130,7 +130,7 @@ export const useDashboardListingTable = ({
}, [dashboardBackupService, goToDashboard, useSessionStorageIntegration]);

const updateItemMeta = useCallback(
async (props: Pick<DashboardContainerInput, 'id' | 'title' | 'description' | 'tags'>) => {
async (props: UpdateDashboardMetaProps) => {
await dashboardContentManagementService.updateDashboardMeta(props);

setUnsavedDashboardIds(dashboardBackupService.getDashboardIdsWithUnsavedChanges());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,15 @@ import {
SearchDashboardsResponse,
} from './lib/find_dashboards';
import { DashboardState } from '../../dashboard_api/types';
import { UpdateDashboardMetaProps } from './lib/update_dashboard_meta';

export interface DashboardContentManagementService {
findDashboards: FindDashboardsService;
deleteDashboards: (ids: string[]) => Promise<void>;
loadDashboardState: (props: { id?: string }) => Promise<LoadDashboardReturn>;
saveDashboardState: (props: SaveDashboardProps) => Promise<SaveDashboardReturn>;
checkForDuplicateDashboardTitle: (meta: DashboardDuplicateTitleCheckProps) => Promise<boolean>;
updateDashboardMeta: (
props: Pick<DashboardContainerInput, 'id' | 'title' | 'description' | 'tags'>
) => Promise<void>;
updateDashboardMeta: (props: UpdateDashboardMetaProps) => Promise<void>;
}

/**
Expand Down

0 comments on commit 6c69401

Please sign in to comment.