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][Feature] Import sample data to workspace #210

Conversation

wanglam
Copy link
Collaborator

@wanglam wanglam commented Oct 7, 2023

Description

Import sample data to specific workspace

Issues Resolved

Screenshot

Testing the changes

Check List

  • All tests pass
    • yarn test:jest
    • yarn test:jest_integration
    • yarn test:ftr
  • New functionality includes testing.
  • New functionality has been documented.
  • Update CHANGELOG.md
  • Commits are signed per the DCO using --signoff

wanglam and others added 2 commits October 7, 2023 15:37
Signed-off-by: Lin Wang <wonglam@amazon.com>
* refactor: simplify sample data saved object id prefix logic

Signed-off-by: Yulong Ruan <ruanyl@amazon.com>

* fix: align the prefix order of sample data install and uninstall

rename appendPrefix to addPrefix

Signed-off-by: Yulong Ruan <ruanyl@amazon.com>

---------

Signed-off-by: Yulong Ruan <ruanyl@amazon.com>
@wanglam wanglam changed the title Feat import sample data to workspace [Workspace][Feature] mport sample data to workspace Oct 7, 2023
@wanglam wanglam changed the title [Workspace][Feature] mport sample data to workspace [Workspace][Feature] Import sample data to workspace Oct 7, 2023
@codecov-commenter
Copy link

codecov-commenter commented Oct 7, 2023

Codecov Report

Merging #210 (28732c5) into workspace-pr-integr (c05b434) will increase coverage by 0.02%.
Report is 4 commits behind head on workspace-pr-integr.
The diff coverage is 83.05%.

@@                   Coverage Diff                   @@
##           workspace-pr-integr     #210      +/-   ##
=======================================================
+ Coverage                66.46%   66.49%   +0.02%     
=======================================================
  Files                     3408     3412       +4     
  Lines                    65222    65253      +31     
  Branches                 10457    10460       +3     
=======================================================
+ Hits                     43353    43390      +37     
+ Misses                   19265    19263       -2     
+ Partials                  2604     2600       -4     
Flag Coverage Δ
Linux_ 66.07% <83.05%> (+0.02%) ⬆️
_1 34.82% <ø> (+<0.01%) ⬆️
_2 ?
_3 44.49% <ø> (+<0.01%) ⬆️
_4 34.88% <83.05%> (+0.06%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
...blic/application/opensearch_dashboards_services.ts 20.00% <ø> (ø)
src/plugins/home/public/plugin.ts 38.09% <ø> (ø)
.../services/sample_data/data_sets/ecommerce/index.ts 85.71% <ø> (+10.71%) ⬆️
...er/services/sample_data/data_sets/flights/index.ts 100.00% <ø> (ø)
...erver/services/sample_data/data_sets/logs/index.ts 85.71% <ø> (+10.71%) ⬆️
...ns/home/server/services/sample_data/routes/list.ts 60.52% <100.00%> (+1.06%) ⬆️
...me/server/services/sample_data/routes/uninstall.ts 80.76% <100.00%> (+4.57%) ⬆️
...home/server/services/sample_data/routes/install.ts 65.75% <57.14%> (-1.42%) ⬇️
...home/server/services/sample_data/data_sets/util.ts 80.85% <84.44%> (+7.32%) ⬆️

... and 26 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@wanglam wanglam marked this pull request as ready for review October 8, 2023 02:07
@wanglam wanglam requested a review from ruanyl October 8, 2023 02:32
savedObjectList: SavedObject[],
workspaceId?: string
) => {
savedObjectList = cloneDeep(savedObjectList);
Copy link
Collaborator

@SuZhou-Joe SuZhou-Joe Oct 11, 2023

Choose a reason for hiding this comment

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

I am a little bit confused here, should we assign the copied object to a new variable?

Copy link
Collaborator Author

@wanglam wanglam Oct 11, 2023

Choose a reason for hiding this comment

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

There are too many attributes update work in overrideSavedObjectId. It's all based references, it will take huge effects if we want to use new variables.

Copy link
Owner

Choose a reason for hiding this comment

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

I guess @SuZhou-Joe want to say: shall we do const savedObjectListCopy = cloneDeep(savedObjectList);?

Comment on lines +88 to +93
if (workspaceId) {
savedObjectsList = getWorkspaceIntegratedSavedObjects(savedObjectsList, workspaceId);
}
if (dataSourceId) {
savedObjectsList = getDataSourceIntegratedSavedObjects(savedObjectsList, dataSourceId);
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we take the order of these two ifs into account?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, it will cause different id after condition switched.

savedObjectList: SavedObject[],
workspaceId?: string
) => {
savedObjectList = cloneDeep(savedObjectList);
Copy link
Owner

Choose a reason for hiding this comment

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

I guess @SuZhou-Joe want to say: shall we do const savedObjectListCopy = cloneDeep(savedObjectList);?

Signed-off-by: Lin Wang <wonglam@amazon.com>
@SuZhou-Joe
Copy link
Collaborator

Shall we add some integration_test for the functionality?

@wanglam wanglam merged commit 2c7aadf into ruanyl:workspace-pr-integr Oct 13, 2023
32 checks passed
wanglam added a commit that referenced this pull request Feb 26, 2024
* feat: import sample data saved objects to workspace

Signed-off-by: Lin Wang <wonglam@amazon.com>

* refactor: simplify sample data saved object id prefix logic (#1)

* refactor: simplify sample data saved object id prefix logic

Signed-off-by: Yulong Ruan <ruanyl@amazon.com>

* fix: align the prefix order of sample data install and uninstall

rename appendPrefix to addPrefix

Signed-off-by: Yulong Ruan <ruanyl@amazon.com>

---------

Signed-off-by: Yulong Ruan <ruanyl@amazon.com>

* refactor: assigned copied saved objects to new variables

Signed-off-by: Lin Wang <wonglam@amazon.com>

---------

Signed-off-by: Lin Wang <wonglam@amazon.com>
Signed-off-by: Yulong Ruan <ruanyl@amazon.com>
Co-authored-by: Yulong Ruan <ruanyu1@gmail.com>
SuZhou-Joe pushed a commit that referenced this pull request Mar 18, 2024
* feat: import sample data saved objects to workspace

Signed-off-by: Lin Wang <wonglam@amazon.com>

* refactor: simplify sample data saved object id prefix logic (#1)

* refactor: simplify sample data saved object id prefix logic

Signed-off-by: Yulong Ruan <ruanyl@amazon.com>

* fix: align the prefix order of sample data install and uninstall

rename appendPrefix to addPrefix

Signed-off-by: Yulong Ruan <ruanyl@amazon.com>

---------

Signed-off-by: Yulong Ruan <ruanyl@amazon.com>

* refactor: assigned copied saved objects to new variables

Signed-off-by: Lin Wang <wonglam@amazon.com>

---------

Signed-off-by: Lin Wang <wonglam@amazon.com>
Signed-off-by: Yulong Ruan <ruanyl@amazon.com>
Co-authored-by: Yulong Ruan <ruanyu1@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants