forked from opensearch-project/OpenSearch-Dashboards
-
Notifications
You must be signed in to change notification settings - Fork 0
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
SuZhou-Joe
merged 28 commits into
ruanyl:workspace-pr-integr
from
yubonluo:pr-integr-duplicate
Apr 16, 2024
Merged
Changes from 13 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 5e472e1
feat: duplicate selected objects (#113)
yuye-aws 8536391
Saved objects page change (#123)
Hailong-am be72ad9
feat: duplicate all and single objects (#121)
yuye-aws 251df79
feat: Duplicate dashboard visualize (#148)
yuye-aws 2a00d66
delete useless code
yubonluo f7c18b4
refactor dupicate_model code and fix test error
yubonluo 2be9d0c
add duplicate all/selected saved objects unit test
yubonluo 3294e6c
Merge branch 'workspace-pr-integr' into pr-integr-duplicate
yubonluo 49c6134
add util and copy unit test
yubonluo c127a79
Merge branch 'pr-integr-duplicate' of github.com:yubonluo/OpenSearch-…
yubonluo cf1a8ac
fix bug
yubonluo c3f0ce6
fix unit test error
yubonluo c0f62aa
add all unit test and fix code error
yubonluo 4d5af83
revert useless modifications
yubonluo eddc611
add snapshot code
yubonluo 8114a6f
delete useless code
yubonluo 997d1b7
optimize code
yubonluo 1cd26a3
split duplicate_modal
yubonluo 334129a
optimize code
yubonluo 6b382e6
Merge branch 'workspace-pr-integr' of github.com:ruanyl/OpenSearch-Da…
yubonluo c4ef126
fix unit test
yubonluo 33bffaf
optimize code
yubonluo 98bfa54
Merge branch 'workspace-pr-integr' of github.com:ruanyl/OpenSearch-Da…
yubonluo e62431f
Fixed the bug that can not duplicate all saved objects
yubonluo a44deab
Fixed the bug that can not duplicate all saved objects
yubonluo 3c374f6
optimize code
yubonluo d873930
delete useless code
yubonluo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
40 changes: 40 additions & 0 deletions
40
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,40 @@ | ||
/* | ||
* 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, | ||
}, | ||
], | ||
} | ||
` | ||
); | ||
}); | ||
}); |
27 changes: 27 additions & 0 deletions
27
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,27 @@ | ||||||||||||||||||||||||||||||
/* | ||||||||||||||||||||||||||||||
* 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. | ||||||||||||||||||||||||||||||
*/ | ||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
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, | ||||||||||||||||||||||||||||||
}), | ||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||
} |
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
6 changes: 6 additions & 0 deletions
6
...t/public/management_section/objects_table/__snapshots__/saved_objects_table.test.tsx.snap
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code in copy.ts and copy.test.ts are old, please use the code in the
workspace-pr-integr
branch.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have reverted these codes