Skip to content

Commit

Permalink
resolve conflict
Browse files Browse the repository at this point in the history
Signed-off-by: yuye-aws <[email protected]>
  • Loading branch information
yuye-aws committed Sep 18, 2023
1 parent e7dbc08 commit f509edc
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import { Dashboard } from '../../dashboard';
import { SavedObjectWithMetadata } from '../../../../saved_objects_management/common';
import {
duplicateSavedObjects,
DuplicateState,
getWorkspacesWithWritePermission,
SavedObjectsDuplicateModal,
} from '../../../../saved_objects_management/public';
Expand Down Expand Up @@ -229,11 +230,13 @@ export const getNavActions = (
});
};

const dashboardSavedObjects = [(savedDashboard || {}) as SavedObjectWithMetadata];
const dashboardSavedObject = (savedDashboard || {}) as SavedObjectWithMetadata;
dashboardSavedObject.meta = { title: savedDashboard.title };

const duplicateModal = (
<SavedObjectsDuplicateModal
selectedSavedObjects={dashboardSavedObjects}
duplicateState={DuplicateState.Single}
selectedSavedObjects={[dashboardSavedObject]}
workspaces={workspaces}
getDuplicateWorkspaces={getDuplicateWorkspaces}
onDuplicate={onDuplicate}
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/saved_objects_management/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export {
duplicateSavedObjects,
getWorkspacesWithWritePermission,
} from './lib';
export { SavedObjectsDuplicateModal } from './management_section';
export { SavedObjectsDuplicateModal, DuplicateState } from './management_section';
export { SavedObjectRelation, SavedObjectWithMetadata, SavedObjectMetadata } from './types';
export { SAVED_OBJECT_DELETE_TRIGGER, savedObjectDeleteTrigger } from './triggers';
export { SavedObjectDeleteContext } from './ui_actions_bootstrap';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@
*/

export { mountManagementSection } from './mount_section';
export { SavedObjectsDuplicateModal } from './objects_table';
export { SavedObjectsDuplicateModal, DuplicateState } from './objects_table';
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,10 @@ export class SavedObjectsDuplicateModal extends React.Component<Props, State> {
key={savedObjectType}
label={
<FormattedMessage
id={'savedObjectsManagement.objectsTable.duplicateModal.savedObjectType.' + savedObjectType}
id={
'savedObjectsManagement.objectsTable.duplicateModal.savedObjectType.' +
savedObjectType
}
defaultMessage={
capitalizeFirstLetter(savedObjectType) + ` (${savedObjectTypeCount.toString()})`
}
Expand Down Expand Up @@ -263,7 +266,7 @@ export class SavedObjectsDuplicateModal extends React.Component<Props, State> {
const confirmMessageForAllObjects = `Duplicate (${includedSelectedObjects.length})`;
const confirmMessageForSingleOrSelectedObjects = 'Duplicate';
const confirmMessage =
duplicateState === DuplicateState.All
duplicateState === DuplicateState.All
? confirmMessageForAllObjects
: confirmMessageForSingleOrSelectedObjects;
const warningMessageForOnlyOneSavedObject = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ export class Table extends PureComponent<TableProps, TableState> {
type: 'icon',
icon: 'copyClipboard',
isPrimary: true,
onClick: (object: SavedObjectWithMetadata<unknown>) => onCopySingle(object),
onClick: (object: SavedObjectWithMetadata<unknown>) => onDuplicateSingle(object),
'data-test-subj': 'savedObjectsTableAction-duplicate',
},
]
Expand Down Expand Up @@ -449,7 +449,7 @@ export class Table extends PureComponent<TableProps, TableState> {
<EuiButtonIcon
key="copySO"
iconType="copyClipboard"
onClick={onCopySelected}
onClick={onDuplicateSelected}
isDisabled={selectedSavedObjects.length === 0}
data-test-subj="savedObjectsManagementCopy"
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ import {
import { Header, Table, Flyout, Relationships } from './components';
import { DataPublicPluginStart } from '../../../../data/public';
import { SavedObjectsDuplicateModal } from './components';
import { PUBLIC_WORKSPACE_ID, MANAGEMENT_WORKSPACE_ID } from '../../../../../core/public';
import { PUBLIC_WORKSPACE_ID } from '../../../../../core/public';

export enum DuplicateState {
Single = 'single',
Expand Down Expand Up @@ -533,20 +533,31 @@ export class SavedObjectsTable extends Component<SavedObjectsTableProps, SavedOb
const objectsToDuplicate = savedObjects.map((obj) => ({ id: obj.id, type: obj.type }));
let result;
try {
result = await duplicateSavedObjects(http, objectsToDuplicate, includeReferencesDeep, targetWorkspace);
result = await duplicateSavedObjects(
http,
objectsToDuplicate,
includeReferencesDeep,
targetWorkspace
);
if (result.success) {
notifications.toasts.addSuccess({
title: i18n.translate('savedObjectsManagement.objectsTable.duplicate.successNotification', {
defaultMessage:
'Duplicate ' + savedObjects.length.toString() + ' saved objects successfully',
}),
title: i18n.translate(
'savedObjectsManagement.objectsTable.duplicate.successNotification',
{
defaultMessage:
'Duplicate ' + savedObjects.length.toString() + ' saved objects successfully',
}
),
});
} else {
const failedCount = savedObjects.length - result.successCount;
notifications.toasts.addSuccess({
title: i18n.translate('savedObjectsManagement.objectsTable.duplicate.dangerNotification', {
defaultMessage: 'Unable to duplicate ' + failedCount.toString() + ' saved objects',
}),
title: i18n.translate(
'savedObjectsManagement.objectsTable.duplicate.dangerNotification',
{
defaultMessage: 'Unable to duplicate ' + failedCount.toString() + ' saved objects',
}
),
});
}
} catch (e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,23 +30,21 @@

import React from 'react';
import { i18n } from '@osd/i18n';

import { TopNavMenuData } from 'src/plugins/navigation/public';
import { AppMountParameters, WorkspaceAttribute } from 'opensearch-dashboards/public';
import { VISUALIZE_EMBEDDABLE_TYPE, VisualizeInput } from '../../../../visualizations/public';
import {
showSaveModal,
showDuplicateModal,
OnSaveProps,
SavedObjectSaveModalOrigin,
SavedObjectSaveOpts,
OnSaveProps,
showDuplicateModal,
showSaveModal,
} from '../../../../saved_objects/public';
import { unhashUrl } from '../../../../opensearch_dashboards_utils/public';

import {
VisualizeServices,
VisualizeAppStateContainer,
VisualizeEditorVisInstance,
VisualizeServices,
} from '../types';
import { VisualizeConstants } from '../visualize_constants';
import { getEditBreadcrumbs } from './breadcrumbs';
Expand All @@ -56,6 +54,7 @@ import {
getWorkspacesWithWritePermission,
SavedObjectsDuplicateModal,
SavedObjectWithMetadata,
DuplicateState,
} from '../../../../saved_objects_management/public/';

interface TopNavConfigParams {
Expand Down Expand Up @@ -338,11 +337,13 @@ export const getTopNavConfig = (
});
};

const visualizationSavedObjects = [(savedVis || {}) as SavedObjectWithMetadata];
const visualizationSavedObject = (savedVis || {}) as SavedObjectWithMetadata;
visualizationSavedObject.meta = { title: savedVis?.title }; // meta is missing in savedVis

const duplicateModal = (
<SavedObjectsDuplicateModal
selectedSavedObjects={visualizationSavedObjects}
duplicateState={DuplicateState.Single}
selectedSavedObjects={[visualizationSavedObject]}
workspaces={workspaces}
getDuplicateWorkspaces={getDuplicateWorkspaces}
onDuplicate={onDuplicate}
Expand Down

0 comments on commit f509edc

Please sign in to comment.