-
Notifications
You must be signed in to change notification settings - Fork 919
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* [Worksapce][UI] duplicate selected/all saved objects * fix test error * optimize code transfer memory * revert useless modify * optimize the code * add test id * Changeset file for PR #6478 created/updated * According the last mockup to optimize the code * Delete useless code * Optimize the code * optimize code * delete useless code * Optimize user experience * Solve the test snapshot error * modefy the ui text * support copy result flyout * optimize the code * optimize the code --------- (cherry picked from commit 9abde5c) Signed-off-by: yubonluo <[email protected]> Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
- Loading branch information
1 parent
d660ff0
commit 2bc4669
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.