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 6 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
1,535 changes: 1,384 additions & 151 deletions src/core/public/chrome/ui/header/__snapshots__/header.test.tsx.snap

Large diffs are not rendered by default.

40 changes: 25 additions & 15 deletions src/core/server/saved_objects/routes/copy.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
/*
* Copyright OpenSearch Contributors
* 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
Copy link
Collaborator

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.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have reverted these codes

* GitHub history for details.
*/

import { schema } from '@osd/config-schema';
import { IRouter } from '../../http';
import { SavedObjectConfig } from '../saved_objects_config';
import { exportSavedObjectsToStream } from '../export';
import { validateObjects } from './utils';
import { importSavedObjectsFromStream } from '../import';

export const registerCopyRoute = (router: IRouter, config: SavedObjectConfig) => {
Expand All @@ -17,11 +24,14 @@ export const registerCopyRoute = (router: IRouter, config: SavedObjectConfig) =>
path: '/_copy',
validate: {
body: schema.object({
objects: schema.arrayOf(
schema.object({
type: schema.string(),
id: schema.string(),
})
objects: schema.maybe(
schema.arrayOf(
schema.object({
type: schema.string(),
id: schema.string(),
}),
{ maxSize: maxImportExportSize }
)
),
includeReferencesDeep: schema.boolean({ defaultValue: false }),
targetWorkspace: schema.string(),
Expand All @@ -37,15 +47,15 @@ export const registerCopyRoute = (router: IRouter, config: SavedObjectConfig) =>
.getImportableAndExportableTypes()
.map((t) => t.name);

const invalidObjects = objects.filter((obj) => !supportedTypes.includes(obj.type));
if (invalidObjects.length) {
return res.badRequest({
body: {
message: `Trying to copy object(s) with unsupported types: ${invalidObjects
.map((obj) => `${obj.type}:${obj.id}`)
.join(', ')}`,
},
});
if (objects) {
const validationError = validateObjects(objects, supportedTypes);
if (validationError) {
return res.badRequest({
body: {
message: validationError,
},
});
}
}

const objectsListStream = await exportSavedObjectsToStream({
Expand Down
2 changes: 1 addition & 1 deletion src/core/server/saved_objects/routes/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ export function registerRoutes({
registerLogLegacyImportRoute(router, logger);
registerExportRoute(router, config);
registerImportRoute(router, config);
registerResolveImportErrorsRoute(router, config);
registerCopyRoute(router, config);
registerResolveImportErrorsRoute(router, config);
SuZhou-Joe marked this conversation as resolved.
Show resolved Hide resolved

const internalRouter = http.createRouter('/internal/saved_objects/');

Expand Down
14 changes: 12 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,21 @@ 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 {
showDuplicateModal,
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,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.
*/
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/*
* 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.
*/
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

Copy link
Author

Choose a reason for hiding this comment

The 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,
}),
});
}
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 { showDuplicateModal, SavedObjectsDuplicateModal, DuplicateMode } from './objects_table';

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading