import { i18n } from '@kbn/i18n' ; import type { OverlayStart } from 'kibana/public' ; import type { SavedObject } from '../../../../saved_objects/public' ; import { SAVE_DUPLICATE_REJECTED } from './constants' ; import { confirmModalPromise } from './confirm_modal_promise' ; export function displayDuplicateTitleConfirmModal ( savedObject , overlays ) { const confirmMessage = i18n . translate ( 'visualizations.confirmModal.saveDuplicateConfirmationMessage' , { defaultMessage : `A {name} with the title '{title}' already exists. Would you like to save anyway?` , values : { title : savedObject . title , name : savedObject . getDisplayName ( ) } , } ) ; const confirmButtonText = i18n . translate ( 'visualizations.confirmModal.saveDuplicateButtonLabel' , { defaultMessage : 'Save {name}' , values : { name : savedObject . getDisplayName ( ) } , } ) ; try { return confirmModalPromise ( confirmMessage , '' , confirmButtonText , overlays ) ; } catch { return Promise . reject ( new Error ( SAVE_DUPLICATE_REJECTED ) ) ; } }