Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: duplicate selected/all saved objects UI #305

Merged
merged 28 commits into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
783863b
Add copy saved objects among workspaces functionality (#53)
gaobinlong Jul 21, 2023
5e472e1
feat: duplicate selected objects (#113)
yuye-aws Aug 30, 2023
8536391
Saved objects page change (#123)
Hailong-am Sep 7, 2023
be72ad9
feat: duplicate all and single objects (#121)
yuye-aws Sep 11, 2023
251df79
feat: Duplicate dashboard visualize (#148)
yuye-aws Sep 20, 2023
2a00d66
delete useless code
yubonluo Mar 21, 2024
f7c18b4
refactor dupicate_model code and fix test error
yubonluo Mar 22, 2024
2be9d0c
add duplicate all/selected saved objects unit test
yubonluo Mar 26, 2024
3294e6c
Merge branch 'workspace-pr-integr' into pr-integr-duplicate
yubonluo Mar 26, 2024
49c6134
add util and copy unit test
yubonluo Mar 26, 2024
c127a79
Merge branch 'pr-integr-duplicate' of github.com:yubonluo/OpenSearch-…
yubonluo Mar 26, 2024
cf1a8ac
fix bug
yubonluo Mar 26, 2024
c3f0ce6
fix unit test error
yubonluo Mar 26, 2024
c0f62aa
add all unit test and fix code error
yubonluo Mar 28, 2024
4d5af83
revert useless modifications
yubonluo Mar 28, 2024
eddc611
add snapshot code
yubonluo Mar 28, 2024
8114a6f
delete useless code
yubonluo Mar 28, 2024
997d1b7
optimize code
yubonluo Apr 3, 2024
1cd26a3
split duplicate_modal
yubonluo Apr 7, 2024
334129a
optimize code
yubonluo Apr 7, 2024
6b382e6
Merge branch 'workspace-pr-integr' of github.com:ruanyl/OpenSearch-Da…
yubonluo Apr 7, 2024
c4ef126
fix unit test
yubonluo Apr 7, 2024
33bffaf
optimize code
yubonluo Apr 10, 2024
98bfa54
Merge branch 'workspace-pr-integr' of github.com:ruanyl/OpenSearch-Da…
yubonluo Apr 12, 2024
e62431f
Fixed the bug that can not duplicate all saved objects
yubonluo Apr 12, 2024
a44deab
Fixed the bug that can not duplicate all saved objects
yubonluo Apr 15, 2024
3c374f6
optimize code
yubonluo Apr 15, 2024
d873930
delete useless code
yubonluo Apr 15, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/plugins/saved_objects_management/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,17 @@ export {
ISavedObjectsManagementServiceRegistry,
SavedObjectsManagementServiceRegistryEntry,
} from './services';
export { ProcessedImportResponse, processImportResponse, FailedImport } from './lib';
export {
ProcessedImportResponse,
processImportResponse,
FailedImport,
duplicateSavedObjects,
getSavedObjectLabel,
} from './lib';
export { SavedObjectRelation, SavedObjectWithMetadata, SavedObjectMetadata } from './types';
export { SAVED_OBJECT_DELETE_TRIGGER, savedObjectDeleteTrigger } from './triggers';
export { SavedObjectDeleteContext } from './ui_actions_bootstrap';

export { SavedObjectsDuplicateModal, DuplicateMode } from './management_section';
export function plugin(initializerContext: PluginInitializerContext) {
return new SavedObjectsManagementPlugin();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

import { httpServiceMock } from '../../../../core/public/mocks';
import { duplicateSavedObjects } from './duplicate_saved_objects';

describe('copy saved objects', () => {
it('make http call with body provided', async () => {
const httpClient = httpServiceMock.createStartContract();
const objects = [
{ type: 'dashboard', id: '1' },
{ type: 'visualization', id: '2' },
];
const includeReferencesDeep = true;
const targetWorkspace = '1';
await duplicateSavedObjects(httpClient, objects, includeReferencesDeep, targetWorkspace);
expect(httpClient.post).toMatchInlineSnapshot(`
[MockFunction] {
"calls": Array [
Array [
"/api/saved_objects/_copy",
Object {
"body": "{\\"objects\\":[{\\"type\\":\\"dashboard\\",\\"id\\":\\"1\\"},{\\"type\\":\\"visualization\\",\\"id\\":\\"2\\"}],\\"includeReferencesDeep\\":true,\\"targetWorkspace\\":\\"1\\"}",
},
],
],
"results": Array [
Object {
"type": "return",
"value": undefined,
},
],
}
`);

await duplicateSavedObjects(httpClient, objects, undefined, targetWorkspace);
expect(httpClient.post).toMatchInlineSnapshot(`
[MockFunction] {
"calls": Array [
Array [
"/api/saved_objects/_copy",
Object {
"body": "{\\"objects\\":[{\\"type\\":\\"dashboard\\",\\"id\\":\\"1\\"},{\\"type\\":\\"visualization\\",\\"id\\":\\"2\\"}],\\"includeReferencesDeep\\":true,\\"targetWorkspace\\":\\"1\\"}",
},
],
Array [
"/api/saved_objects/_copy",
Object {
"body": "{\\"objects\\":[{\\"type\\":\\"dashboard\\",\\"id\\":\\"1\\"},{\\"type\\":\\"visualization\\",\\"id\\":\\"2\\"}],\\"includeReferencesDeep\\":true,\\"targetWorkspace\\":\\"1\\"}",
},
],
],
"results": Array [
Object {
"type": "return",
"value": undefined,
},
Object {
"type": "return",
"value": undefined,
},
],
}
`);
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

import { HttpStart } from 'src/core/public';

export async function duplicateSavedObjects(
http: HttpStart,
objects: any[],
includeReferencesDeep: boolean = true,
targetWorkspace: string
) {
return await http.post('/api/saved_objects/_copy', {
body: JSON.stringify({
objects,
includeReferencesDeep,
targetWorkspace,
}),
});
}
1 change: 1 addition & 0 deletions src/plugins/saved_objects_management/public/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,4 @@ export { extractExportDetails, SavedObjectsExportResultDetails } from './extract
export { createFieldList } from './create_field_list';
export { getAllowedTypes } from './get_allowed_types';
export { filterQuery } from './filter_query';
export { duplicateSavedObjects } from './duplicate_saved_objects';
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@
*/

export { mountManagementSection } from './mount_section';
export { SavedObjectsDuplicateModal, DuplicateMode } from './objects_table';
Loading
Loading