forked from opensearch-project/OpenSearch-Dashboards
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Workspace] Copy selected/all saved objects (opensearch-project#6478)
* [Worksapce][UI] duplicate selected/all saved objects Signed-off-by: yubonluo <yubonluo@amazon.com> * fix test error Signed-off-by: yubonluo <yubonluo@amazon.com> * optimize code transfer memory Signed-off-by: yubonluo <yubonluo@amazon.com> * revert useless modify Signed-off-by: yubonluo <yubonluo@amazon.com> * optimize the code Signed-off-by: yubonluo <yubonluo@amazon.com> * add test id Signed-off-by: yubonluo <yubonluo@amazon.com> * Changeset file for PR opensearch-project#6478 created/updated * According the last mockup to optimize the code Signed-off-by: yubonluo <yubonluo@amazon.com> * Delete useless code Signed-off-by: yubonluo <yubonluo@amazon.com> * Optimize the code Signed-off-by: yubonluo <yubonluo@amazon.com> * optimize code Signed-off-by: yubonluo <yubonluo@amazon.com> * delete useless code Signed-off-by: yubonluo <yubonluo@amazon.com> * Optimize user experience Signed-off-by: yubonluo <yubonluo@amazon.com> * Solve the test snapshot error Signed-off-by: yubonluo <yubonluo@amazon.com> * modefy the ui text Signed-off-by: yubonluo <yubonluo@amazon.com> * support copy result flyout Signed-off-by: yubonluo <yubonluo@amazon.com> * optimize the code Signed-off-by: yubonluo <yubonluo@amazon.com> * optimize the code Signed-off-by: yubonluo <yubonluo@amazon.com> --------- Signed-off-by: yubonluo <yubonluo@amazon.com> Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
- Loading branch information
1 parent
5ee9b69
commit 9abde5c
Showing
33 changed files
with
3,156 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
feat: | ||
- [Workspace] Duplicate selected/all saved objects ([#6478](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6478)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
src/plugins/saved_objects_management/public/lib/duplicate_saved_objects.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* | ||
* 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', () => { | ||
const httpClient = httpServiceMock.createStartContract(); | ||
const objects = [ | ||
{ type: 'dashboard', id: '1' }, | ||
{ type: 'visualization', id: '2' }, | ||
]; | ||
const targetWorkspace = '1'; | ||
|
||
it('make http call with all parameter provided', async () => { | ||
const includeReferencesDeep = true; | ||
await duplicateSavedObjects(httpClient, objects, targetWorkspace, includeReferencesDeep); | ||
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, | ||
}, | ||
], | ||
} | ||
`); | ||
}); | ||
|
||
it('make http call without includeReferencesDeep parameter provided', async () => { | ||
await duplicateSavedObjects(httpClient, objects, 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\\"}", | ||
}, | ||
], | ||
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, | ||
}, | ||
], | ||
} | ||
`); | ||
}); | ||
}); |
21 changes: 21 additions & 0 deletions
21
src/plugins/saved_objects_management/public/lib/duplicate_saved_objects.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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[], | ||
targetWorkspace: string, | ||
includeReferencesDeep: boolean = true | ||
) { | ||
return await http.post('/api/workspaces/_duplicate_saved_objects', { | ||
body: JSON.stringify({ | ||
objects, | ||
includeReferencesDeep, | ||
targetWorkspace, | ||
}), | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.