Skip to content

Commit

Permalink
optimize code
Browse files Browse the repository at this point in the history
Signed-off-by: yubonluo <yubonluo@amazon.com>
  • Loading branch information
yubonluo committed Apr 3, 2024
1 parent 8114a6f commit 997d1b7
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 22 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*
* Any modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*/

import { HttpStart } from 'src/core/public';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ export class SavedObjectsDuplicateModal extends React.Component<Props, State> {
if (duplicateMode === DuplicateMode.All) {
selectedObjects = selectedObjects.filter((item) => this.isSavedObjectTypeIncluded(item.type));
}
// If the target workspace is selected, all saved objects will be retained.
// If the target workspace is not selected, all saved objects will be retained.
// If the target workspace has been selected, filter out the saved objects that belongs to the workspace.
const includedSelectedObjects = selectedObjects.filter((item) =>
!!targetWorkspaceId && !!item.workspaces ? !item.workspaces.includes(targetWorkspaceId) : true
Expand Down Expand Up @@ -285,7 +285,10 @@ export class SavedObjectsDuplicateModal extends React.Component<Props, State> {
>
<>
<EuiText size="s" color="subdued">
{'Specify a workspace where the objects will be duplicated.'}
{i18n.translate(
'savedObjectsManagement.objectsTable.duplicateModal.targetWorkspaceNotice',
{ defaultMessage: 'Specify a workspace where the objects will be duplicated.' }
)}
</EuiText>
<EuiSpacer size="s" />
<EuiComboBox
Expand All @@ -312,9 +315,13 @@ export class SavedObjectsDuplicateModal extends React.Component<Props, State> {
>
<>
<EuiText size="s" color="subdued">
{
'We recommended duplicating related objects to ensure your duplicated objects will continue to function.'
}
{i18n.translate(
'savedObjectsManagement.objectsTable.duplicateModal.relatedObjectsNotice',
{
defaultMessage:
'We recommended duplicating related objects to ensure your duplicated objects will continue to function.',
}
)}
</EuiText>
<EuiSpacer size="s" />
<EuiCheckbox
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import React from 'react';
import { shallow } from 'enzyme';
import { Header } from './header';
import { any } from 'bluebird';

describe('Header', () => {
it('should render normally', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export interface TableProps {
items: SavedObjectWithMetadata[];
itemId: string | (() => string);
totalItemCount: number;
onQueryChange: (query: any, filterFields?: string[]) => void;
onQueryChange: (query: any, filterFields: string[]) => void;
onTableChange: (table: any) => void;
isSearching: boolean;
onShowRelationships: (object: SavedObjectWithMetadata) => void;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,11 +234,6 @@ describe('SavedObjectsTable', () => {
}));
});

afterEach(() => {
jest.clearAllMocks();
jest.resetModules();
});

it('should render normally', async () => {
const component = shallowRender({ perPageConfig: 15 });

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,7 @@ import {
SavedObjectsManagementNamespaceServiceStart,
} from '../../services';
import { Header, Table, Flyout, Relationships, SavedObjectsDuplicateModal } from './components';
import { DataPublicPluginStart } from '../../../../data/public';

import { DataPublicPluginStart } from '../../../../../plugins/data/public';
import { DuplicateMode } from './';

interface ExportAllOption {
Expand Down Expand Up @@ -657,7 +656,9 @@ export class SavedObjectsTable extends Component<SavedObjectsTableProps, SavedOb
return null;
}
const { applications } = this.props;
const newIndexPatternUrl = applications.getUrlForApp('indexPatterns');
const newIndexPatternUrl = applications.getUrlForApp('management', {
path: 'opensearch-dashboards/indexPatterns',
});

return (
<Flyout
Expand Down

0 comments on commit 997d1b7

Please sign in to comment.