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

[Workspace] Copy selected/all saved objects #6478

Merged
merged 41 commits into from
Jul 23, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
41d33da
[Worksapce][UI] duplicate selected/all saved objects
yubonluo Apr 16, 2024
a47a1b1
fix test error
yubonluo Apr 16, 2024
ee52e95
solve code conflict
yubonluo Apr 17, 2024
549d24a
optimize code transfer memory
yubonluo Apr 18, 2024
3365cb7
slove code conflict
yubonluo Apr 18, 2024
3642738
revert useless modify
yubonluo Apr 18, 2024
2768c29
Merge branch 'main' into main-dupluicate
yubonluo Apr 19, 2024
635bbaf
optimize the code
yubonluo Apr 23, 2024
64f2bab
Merge branch 'main' of github.com:opensearch-project/OpenSearch-Dashb…
yubonluo Apr 23, 2024
4ca87d2
Merge branch 'main-dupluicate' of github.com:yubonluo/OpenSearch-Dash…
yubonluo Apr 23, 2024
df96cc1
add test id
yubonluo Apr 24, 2024
4cb5808
Changeset file for PR #6478 created/updated
opensearch-changeset-bot[bot] Apr 24, 2024
d74031f
Merge branch 'main' into main-dupluicate
yubonluo Apr 24, 2024
5ca2685
Merge branch 'main' into main-dupluicate
yubonluo Apr 25, 2024
e142d4b
Merge branch 'main' into main-dupluicate
yubonluo Apr 25, 2024
8cc3721
Merge branch 'main' into main-dupluicate
yubonluo Apr 25, 2024
5341387
Merge branch 'main' into main-dupluicate
yubonluo Apr 28, 2024
f1bdcba
Merge branch 'main' of github.com:opensearch-project/OpenSearch-Dashb…
yubonluo Apr 28, 2024
5a3c22a
Merge branch 'main' into main-dupluicate
yubonluo Apr 30, 2024
900a88c
Merge branch 'main' into main-dupluicate
yubonluo May 2, 2024
bdb4050
Merge branch 'main' of github.com:opensearch-project/OpenSearch-Dashb…
yubonluo May 8, 2024
119bf3e
According the last mockup to optimize the code
yubonluo May 8, 2024
d87264b
Merge branch 'main-dupluicate' of github.com:yubonluo/OpenSearch-Dash…
yubonluo May 8, 2024
c608121
Delete useless code
yubonluo May 8, 2024
164197e
Optimize the code
yubonluo May 10, 2024
d70125a
Merge branch 'main' of github.com:opensearch-project/OpenSearch-Dashb…
yubonluo May 10, 2024
94e0767
optimize code
yubonluo May 10, 2024
c5685e1
delete useless code
yubonluo May 10, 2024
93eab5c
resolve code conflicts
yubonluo May 13, 2024
5cf468f
Optimize user experience
yubonluo May 14, 2024
ce32e1d
Solve the code conflict
yubonluo Jun 4, 2024
f93c2a8
Solve the test snapshot error
yubonluo Jun 4, 2024
111c5a5
Merge branch 'main' of github.com:opensearch-project/OpenSearch-Dashb…
yubonluo Jun 4, 2024
483337e
modefy the ui text
yubonluo Jun 11, 2024
b618076
Merge branch 'main' of github.com:opensearch-project/OpenSearch-Dashb…
yubonluo Jun 11, 2024
68e9c87
support copy result flyout
yubonluo Jun 21, 2024
722b89d
Merge branch 'main' of github.com:opensearch-project/OpenSearch-Dashb…
yubonluo Jun 21, 2024
4a0a7a0
solve the code conflict
yubonluo Jul 19, 2024
83c93e4
optimize the code
yubonluo Jul 19, 2024
0ef48c3
solve the code conflict
yubonluo Jul 23, 2024
b850070
optimize the code
yubonluo Jul 23, 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- [Workspace] Add workspace list page ([#6182](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6182))
- [Workspace] Add API to duplicate saved objects among workspaces ([#6288](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6288))
- [Workspace] Add workspaces column to saved objects page ([#6225](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6225))
- [Workspace] Add UI to duplicate saved objects among workspaces ([#6478](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6478))
yubonluo marked this conversation as resolved.
Show resolved Hide resolved
- [Multiple Datasource] Enhanced data source selector with default datasource shows as first choice ([#6293](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6293))
- [Multiple Datasource] Add multi data source support to sample vega visualizations ([#6218](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6218))
- [Multiple Datasource] Fetch data source title for DataSourceView when only id is provided ([#6315](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6315)
Expand Down
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/workspaces/_duplicate_saved_objects",
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);
yubonluo marked this conversation as resolved.
Show resolved Hide resolved
expect(httpClient.post).toMatchInlineSnapshot(`
[MockFunction] {
"calls": Array [
Array [
"/api/workspaces/_duplicate_saved_objects",
Object {
"body": "{\\"objects\\":[{\\"type\\":\\"dashboard\\",\\"id\\":\\"1\\"},{\\"type\\":\\"visualization\\",\\"id\\":\\"2\\"}],\\"includeReferencesDeep\\":true,\\"targetWorkspace\\":\\"1\\"}",
},
],
Array [
"/api/workspaces/_duplicate_saved_objects",
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,
yubonluo marked this conversation as resolved.
Show resolved Hide resolved
targetWorkspace: string
) {
return await http.post('/api/workspaces/_duplicate_saved_objects', {
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