Skip to content

Commit

Permalink
fix: make importing workspace-specific objects as copy (opensearch-pr…
Browse files Browse the repository at this point in the history
…oject#62)

* setup workspace plugin project skeleton

Signed-off-by: Yulong Ruan <[email protected]>

* test: add unit tests

add license header

Signed-off-by: Yulong Ruan <[email protected]>

* workspace template init commit

Signed-off-by: Hailong Cui <[email protected]>

* refacter workspace template into hooks

Signed-off-by: Hailong Cui <[email protected]>

* refacter workspace template hooks

Signed-off-by: Hailong Cui <[email protected]>

* update coverImage comments

Signed-off-by: Hailong Cui <[email protected]>

* feature: add public/workspaces service

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: add interfaces for workspaces client

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: add interfaces for workspaces client

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: add interfaces for workspaces client

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: implement workspaces service

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: changes to client type interface

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: changes to client implement

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: implement more for workspaces service

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: implement more for workspaces service

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: implement more for workspaces service

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: add workspace creator page (#5)

* feat: add workspace creator page

Signed-off-by: Lin Wang <[email protected]>

* feat: integrate with application workspace template

Signed-off-by: Lin Wang <[email protected]>

* feat: add max-width and remove image wrapper if not exists

Signed-off-by: Lin Wang <[email protected]>

* feat: update filter condition to align with collapsible nav

Signed-off-by: Lin Wang <[email protected]>

---------

Signed-off-by: Lin Wang <[email protected]>

* Add validation when load page (#8)

* fix: validation & query

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: modify file name to reduce confusion

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: add landing logic to retrive workspace id

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: add worklist observable

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: add worklist observable

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: add worklist observable

Signed-off-by: SuZhoue-Joe <[email protected]>

* fix: type error

Signed-off-by: SuZhoue-Joe <[email protected]>

* fix: type error

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: make client more robust

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: use Subject

Signed-off-by: SuZhoue-Joe <[email protected]>

---------

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: use BehaviorObject and optimize code (#14)

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: integrate with workspace create API (#13)

* feat: integrate with workspace create API

Signed-off-by: Lin Wang <[email protected]>

* feat: update to i18n text for toast

Signed-off-by: Lin Wang <[email protected]>

---------

Signed-off-by: Lin Wang <[email protected]>

* Add currentWorkspace$ (#15)

* feat: add currentWorkspace$

Signed-off-by: SuZhoue-Joe <[email protected]>

* fix: type error

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: add emit on currentWorkspace$

Signed-off-by: SuZhoue-Joe <[email protected]>

---------

Signed-off-by: SuZhoue-Joe <[email protected]>

* register plugin with workspace template (#16)

Signed-off-by: Hailong Cui <[email protected]>

* workspace dropdown list (#9)

Add workspace dropdown list 

---------

Signed-off-by: zhichao-aws <[email protected]>
Signed-off-by: SuZhoue-Joe <[email protected]>
Signed-off-by: suzhou <[email protected]>
Co-authored-by: SuZhoue-Joe <[email protected]>

* init workspace menu stage 1 (#12)

* feat: init workspace menu stage 1

Signed-off-by: tygao <[email protected]>

* fix: remove port diff

Signed-off-by: tygao <[email protected]>

* feat: update menu logic

Signed-off-by: tygao <[email protected]>

---------

Signed-off-by: tygao <[email protected]>

* Fix template registration import error (#21)

* fix import error

Signed-off-by: Hailong Cui <[email protected]>

* fix osd bootstrap failure

Signed-off-by: Hailong Cui <[email protected]>

---------

Signed-off-by: Hailong Cui <[email protected]>

* Add workspace overview page (#19)

* feat: add workspace overview page

Signed-off-by: Lin Wang <[email protected]>

* refactor: move paths to common constants

Signed-off-by: Lin Wang <[email protected]>

* feat: add workspace overview item by custom nav in start phase

Signed-off-by: Lin Wang <[email protected]>

* refactor: change to currentWorkspace$ in workspace client

Signed-off-by: Lin Wang <[email protected]>

---------

Signed-off-by: Lin Wang <[email protected]>

* feat: navigate to workspace create page after button clicked (#23)

Signed-off-by: Lin Wang <[email protected]>

* fix failed test snapshots (#22)

fix failed test snapshots

temporary fix: fetch functional test from main branch

fixed git error which cannot find ref due to feature branch `workspace`
not exists on repo opensearch-dashboards-functional-test

Signed-off-by: Yulong Ruan <[email protected]>

---------

Signed-off-by: Yulong Ruan <[email protected]>

* change to currentWorkspace, wrap title using i18n (#20)

* change to currentWorkspace, wrap title using i18n

Signed-off-by: zhichao-aws <[email protected]>

* change import

Signed-off-by: zhichao-aws <[email protected]>

* directly return [] if currentWorkspace is null

Signed-off-by: zhichao-aws <[email protected]>

---------

Signed-off-by: zhichao-aws <[email protected]>

* add workspace switch (#17)

* feat: update workspace switch

Signed-off-by: tygao <[email protected]>

* fix: fix switch error

Signed-off-by: tygao <[email protected]>

* fix: fix prettier after merge

Signed-off-by: tygao <[email protected]>

* chore: remove extra code after merge

Signed-off-by: tygao <[email protected]>

---------

Signed-off-by: tygao <[email protected]>

* Add update workspace page (#25)

Signed-off-by: gaobinlong <[email protected]>

* Delete Workspace (#24)

* add delete workspace modal

Signed-off-by: yuye-aws <[email protected]>

* implement delete on workspace overview page

Signed-off-by: yuye-aws <[email protected]>

* fix export on delete workspace modal

Signed-off-by: yuye-aws <[email protected]>

* add try catch to handle errors for workspace delete

Signed-off-by: yuye-aws <[email protected]>

* move visibility control to workspace overview page exlusively

Signed-off-by: yuye-aws <[email protected]>

* remove unused import

Signed-off-by: yuye-aws <[email protected]>

---------

Signed-off-by: yuye-aws <[email protected]>

* feat: redirect to overview page after workspace switch (#26)

Signed-off-by: Lin Wang <[email protected]>

* update menu filter logic (#28)

* feat: update menu logic

Signed-off-by: tygao <[email protected]>

* fix: use navLinks to filter

Signed-off-by: tygao <[email protected]>

---------

Signed-off-by: tygao <[email protected]>

* feat: redirect to workspace overview page after created success (#29)

Signed-off-by: Lin Wang <[email protected]>

* [Feature] Complied saved_objects create/find (#18)

* temp: save

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: make create/find support workspaces

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: extract management code

Signed-off-by: SuZhoue-Joe <[email protected]>

* fix: type check

Signed-off-by: SuZhoue-Joe <[email protected]>

* fix: build error

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: enable workspaces on saved client server side

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: some optimization

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: extract management code

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: merge fix

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: optimize code

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: reuse common function

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: optimize code when create

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: remove useless test code

Signed-off-by: SuZhoue-Joe <[email protected]>

---------

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: redirect to workspace update page after workspace switch (#30)

* Move delete button to update page (#27)

* add delete workspace modal

Signed-off-by: yuye-aws <[email protected]>

* implement delete on workspace overview page

Signed-off-by: yuye-aws <[email protected]>

* fix export on delete workspace modal

Signed-off-by: yuye-aws <[email protected]>

* add try catch to handle errors for workspace delete

Signed-off-by: yuye-aws <[email protected]>

* move visibility control to workspace overview page exlusively

Signed-off-by: yuye-aws <[email protected]>

* remove unused import

Signed-off-by: yuye-aws <[email protected]>

* change workspace overview route to workspace update

Signed-off-by: yuye-aws <[email protected]>

* move delete button from workspace overview page to update page

Signed-off-by: yuye-aws <[email protected]>

* remove update button from workspace overview page

Signed-off-by: yuye-aws <[email protected]>

* recover router to workspace overview page

Signed-off-by: yuye-aws <[email protected]>

* change navigation url for workspace overview button on left side panel

Signed-off-by: yuye-aws <[email protected]>

---------

Signed-off-by: yuye-aws <[email protected]>

* fix: linting error

Signed-off-by: Yulong Ruan <[email protected]>

* remove duplicate EuiPage (#34)

* remove duplicate EuiPage

Signed-off-by: Hailong Cui <[email protected]>

* fix: remove duplicate workspace template

Signed-off-by: Hailong Cui <[email protected]>

---------

Signed-off-by: Hailong Cui <[email protected]>

* remove clear button, add the width of create button (#33)

Signed-off-by: zhichao-aws <[email protected]>

* rename OpenSearch Plugins to OpenSearch Features

this is a temporary fix just for demo, should be reverted later

Signed-off-by: Yulong Ruan <[email protected]>

* Add some logic check when overwrite a saved object (#32)

* feat: add some logic check when overwrite a saved object

Signed-off-by: SuZhoue-Joe <[email protected]>

* fix: type check

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: update

Signed-off-by: SuZhoue-Joe <[email protected]>

---------

Signed-off-by: SuZhoue-Joe <[email protected]>

* Add color, icon and defaultVISTheme for workspace (#36)

* feat: add color, icon and defaultVISTheme field for workspace saved object

Signed-off-by: Lin Wang <[email protected]>

* add new fields to workspace form

Signed-off-by: Lin Wang <[email protected]>

* feat: remove feature or group name hack

Signed-off-by: Lin Wang <[email protected]>

---------

Signed-off-by: Lin Wang <[email protected]>

* feat: add workspace list (#39)

Signed-off-by: tygao <[email protected]>

* Feature/menu change (#37)

* feat: register library menus

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: some update

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: optimize code

Signed-off-by: SuZhou-Joe <[email protected]>

* feat: optimize code

Signed-off-by: SuZhou-Joe <[email protected]>

---------

Signed-off-by: SuZhoue-Joe <[email protected]>
Signed-off-by: SuZhou-Joe <[email protected]>

* feat: different left menu and exit workspace (#38)

* Exit workspace from left menu

Signed-off-by: yuye-aws <[email protected]>

* Show exit workspace button with small window size

Signed-off-by: yuye-aws <[email protected]>

* Remove recently viewed and workspace overview on left menu

Signed-off-by: yuye-aws <[email protected]>

* Add buttons for outside, inside workspace case

Signed-off-by: yuye-aws <[email protected]>

* Implement home button and workspace over view button on left menu

Signed-off-by: yuye-aws <[email protected]>

* Implement workspace dropdown list in left menu

Signed-off-by: yuye-aws <[email protected]>

* Add props on recently accessed and custom nav link

Signed-off-by: yuye-aws <[email protected]>

* Add three props to mock props for collapsible nav: exitWorkspace, getWorkspaceUrl, workspaceList$

Signed-off-by: yuye-aws <[email protected]>

* Add three props to mock props for header: exitWorkspace, getWorkspaceUrl, workspaceList$

Signed-off-by: yuye-aws <[email protected]>

* Fix bugs for function createWorkspaceNavLink

Signed-off-by: yuye-aws <[email protected]>

* Remove unused constants

Signed-off-by: yuye-aws <[email protected]>

* Reuse method getWorkspaceUrl

Signed-off-by: yuye-aws <[email protected]>

* Remove recently accessed and custom nav props in test

Signed-off-by: yuye-aws <[email protected]>

* Revert "Remove recently accessed and custom nav props in test"

This reverts commit 7895e5c5dcde9e134f26b2d6a3df54a2d62e9274.

* Wrap title with i18n

Signed-off-by: yuye-aws <[email protected]>

* Add redirect for workspace app

Signed-off-by: yuye-aws <[email protected]>

* Enable users to go to workspace lists page via see more under workspaces in left menu

Signed-off-by: yuye-aws <[email protected]>

---------

Signed-off-by: yuye-aws <[email protected]>

* feat: make url stateful (#35)

* feat: make url stateful

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: optimize code

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: remove useless change

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: optimize url listener

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: make formatUrlWithWorkspaceId extensible

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: modify to related components

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: modify the async format to be sync function

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: modify the async format to be sync function

Signed-off-by: SuZhoue-Joe <[email protected]>

* fix: type check

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: use path to maintain workspace info

Signed-off-by: SuZhou-Joe <[email protected]>

* feat: optimize code

Signed-off-by: SuZhou-Joe <[email protected]>

* feat: optimize code

Signed-off-by: SuZhou-Joe <[email protected]>

* feat: optimize code

Signed-off-by: SuZhou-Joe <[email protected]>

* feat: optimize code

Signed-off-by: SuZhou-Joe <[email protected]>

* feat: optimize code

Signed-off-by: SuZhou-Joe <[email protected]>

* feat: optimize code

Signed-off-by: SuZhou-Joe <[email protected]>

---------

Signed-off-by: SuZhoue-Joe <[email protected]>
Signed-off-by: SuZhou-Joe <[email protected]>

* Fix build error and part of test error (#42)

* fix: fix build error and some ut

Signed-off-by: tygao <[email protected]>

* chore: remove saved object client test diff

Signed-off-by: tygao <[email protected]>

---------

Signed-off-by: tygao <[email protected]>

* feat: optimize code (#40)

Signed-off-by: SuZhou-Joe <[email protected]>

* fix: bootstrap error (#43)

Signed-off-by: SuZhou-Joe <[email protected]>

* feat: add workspace permission control interface (#41)

* feat: add workspace permission control interface

Signed-off-by: Lin Wang <[email protected]>

* feat: add request parameter for workspace permission control

Signed-off-by: Lin Wang <[email protected]>

---------

Signed-off-by: Lin Wang <[email protected]>

* allow user to turn on/off workspace from advance settings (#46)

return 404 if accessing a workspace path when workspace is disabled

---------

Signed-off-by: Yulong Ruan <[email protected]>

* fix: unit test failure (#50)

Signed-off-by: SuZhou-Joe <[email protected]>

* Add workspace column into saved objects table (#44)

* Add workspace column into saved management page

Signed-off-by: Hailong Cui <[email protected]>

* savedObjectsManagement as optional dependency

Signed-off-by: Hailong Cui <[email protected]>

* i18n for column title

Signed-off-by: Hailong Cui <[email protected]>

---------

Signed-off-by: Hailong Cui <[email protected]>

* fix missing mocks of workspacesSetup

Signed-off-by: Yulong Ruan <[email protected]>

* Integrate workspace service into saved object management (#31)

* setup workspace plugin project skeleton

Signed-off-by: Yulong Ruan <[email protected]>

* test: add unit tests

add license header

Signed-off-by: Yulong Ruan <[email protected]>

* workspace template init commit

Signed-off-by: Hailong Cui <[email protected]>

* refacter workspace template into hooks

Signed-off-by: Hailong Cui <[email protected]>

* refacter workspace template hooks

Signed-off-by: Hailong Cui <[email protected]>

* update coverImage comments

Signed-off-by: Hailong Cui <[email protected]>

* feature: add public/workspaces service

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: add interfaces for workspaces client

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: add interfaces for workspaces client

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: add interfaces for workspaces client

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: implement workspaces service

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: changes to client type interface

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: changes to client implement

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: implement more for workspaces service

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: implement more for workspaces service

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: implement more for workspaces service

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: add workspace creator page (#5)

* feat: add workspace creator page

Signed-off-by: Lin Wang <[email protected]>

* feat: integrate with application workspace template

Signed-off-by: Lin Wang <[email protected]>

* feat: add max-width and remove image wrapper if not exists

Signed-off-by: Lin Wang <[email protected]>

* feat: update filter condition to align with collapsible nav

Signed-off-by: Lin Wang <[email protected]>

---------

Signed-off-by: Lin Wang <[email protected]>

* Add validation when load page (#8)

* fix: validation & query

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: modify file name to reduce confusion

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: add landing logic to retrive workspace id

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: add worklist observable

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: add worklist observable

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: add worklist observable

Signed-off-by: SuZhoue-Joe <[email protected]>

* fix: type error

Signed-off-by: SuZhoue-Joe <[email protected]>

* fix: type error

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: make client more robust

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: use Subject

Signed-off-by: SuZhoue-Joe <[email protected]>

---------

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: use BehaviorObject and optimize code (#14)

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: integrate with workspace create API (#13)

* feat: integrate with workspace create API

Signed-off-by: Lin Wang <[email protected]>

* feat: update to i18n text for toast

Signed-off-by: Lin Wang <[email protected]>

---------

Signed-off-by: Lin Wang <[email protected]>

* Add currentWorkspace$ (#15)

* feat: add currentWorkspace$

Signed-off-by: SuZhoue-Joe <[email protected]>

* fix: type error

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: add emit on currentWorkspace$

Signed-off-by: SuZhoue-Joe <[email protected]>

---------

Signed-off-by: SuZhoue-Joe <[email protected]>

* register plugin with workspace template (#16)

Signed-off-by: Hailong Cui <[email protected]>

* workspace dropdown list (#9)

Add workspace dropdown list 

---------

Signed-off-by: zhichao-aws <[email protected]>
Signed-off-by: SuZhoue-Joe <[email protected]>
Signed-off-by: suzhou <[email protected]>
Co-authored-by: SuZhoue-Joe <[email protected]>

* init workspace menu stage 1 (#12)

* feat: init workspace menu stage 1

Signed-off-by: tygao <[email protected]>

* fix: remove port diff

Signed-off-by: tygao <[email protected]>

* feat: update menu logic

Signed-off-by: tygao <[email protected]>

---------

Signed-off-by: tygao <[email protected]>

* Fix template registration import error (#21)

* fix import error

Signed-off-by: Hailong Cui <[email protected]>

* fix osd bootstrap failure

Signed-off-by: Hailong Cui <[email protected]>

---------

Signed-off-by: Hailong Cui <[email protected]>

* Add workspace overview page (#19)

* feat: add workspace overview page

Signed-off-by: Lin Wang <[email protected]>

* refactor: move paths to common constants

Signed-off-by: Lin Wang <[email protected]>

* feat: add workspace overview item by custom nav in start phase

Signed-off-by: Lin Wang <[email protected]>

* refactor: change to currentWorkspace$ in workspace client

Signed-off-by: Lin Wang <[email protected]>

---------

Signed-off-by: Lin Wang <[email protected]>

* feat: navigate to workspace create page after button clicked (#23)

Signed-off-by: Lin Wang <[email protected]>

* fix failed test snapshots (#22)

fix failed test snapshots

temporary fix: fetch functional test from main branch

fixed git error which cannot find ref due to feature branch `workspace`
not exists on repo opensearch-dashboards-functional-test

Signed-off-by: Yulong Ruan <[email protected]>

---------

Signed-off-by: Yulong Ruan <[email protected]>

* change to currentWorkspace, wrap title using i18n (#20)

* change to currentWorkspace, wrap title using i18n

Signed-off-by: zhichao-aws <[email protected]>

* change import

Signed-off-by: zhichao-aws <[email protected]>

* directly return [] if currentWorkspace is null

Signed-off-by: zhichao-aws <[email protected]>

---------

Signed-off-by: zhichao-aws <[email protected]>

* add workspace switch (#17)

* feat: update workspace switch

Signed-off-by: tygao <[email protected]>

* fix: fix switch error

Signed-off-by: tygao <[email protected]>

* fix: fix prettier after merge

Signed-off-by: tygao <[email protected]>

* chore: remove extra code after merge

Signed-off-by: tygao <[email protected]>

---------

Signed-off-by: tygao <[email protected]>

* Add update workspace page (#25)

Signed-off-by: gaobinlong <[email protected]>

* Delete Workspace (#24)

* add delete workspace modal

Signed-off-by: yuye-aws <[email protected]>

* implement delete on workspace overview page

Signed-off-by: yuye-aws <[email protected]>

* fix export on delete workspace modal

Signed-off-by: yuye-aws <[email protected]>

* add try catch to handle errors for workspace delete

Signed-off-by: yuye-aws <[email protected]>

* move visibility control to workspace overview page exlusively

Signed-off-by: yuye-aws <[email protected]>

* remove unused import

Signed-off-by: yuye-aws <[email protected]>

---------

Signed-off-by: yuye-aws <[email protected]>

* feat: redirect to overview page after workspace switch (#26)

Signed-off-by: Lin Wang <[email protected]>

* update menu filter logic (#28)

* feat: update menu logic

Signed-off-by: tygao <[email protected]>

* fix: use navLinks to filter

Signed-off-by: tygao <[email protected]>

---------

Signed-off-by: tygao <[email protected]>

* feat: redirect to workspace overview page after created success (#29)

Signed-off-by: Lin Wang <[email protected]>

* [Feature] Complied saved_objects create/find (#18)

* temp: save

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: make create/find support workspaces

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: extract management code

Signed-off-by: SuZhoue-Joe <[email protected]>

* fix: type check

Signed-off-by: SuZhoue-Joe <[email protected]>

* fix: build error

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: enable workspaces on saved client server side

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: some optimization

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: extract management code

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: merge fix

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: optimize code

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: reuse common function

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: optimize code when create

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: remove useless test code

Signed-off-by: SuZhoue-Joe <[email protected]>

---------

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: redirect to workspace update page after workspace switch (#30)

* Move delete button to update page (#27)

* add delete workspace modal

Signed-off-by: yuye-aws <[email protected]>

* implement delete on workspace overview page

Signed-off-by: yuye-aws <[email protected]>

* fix export on delete workspace modal

Signed-off-by: yuye-aws <[email protected]>

* add try catch to handle errors for workspace delete

Signed-off-by: yuye-aws <[email protected]>

* move visibility control to workspace overview page exlusively

Signed-off-by: yuye-aws <[email protected]>

* remove unused import

Signed-off-by: yuye-aws <[email protected]>

* change workspace overview route to workspace update

Signed-off-by: yuye-aws <[email protected]>

* move delete button from workspace overview page to update page

Signed-off-by: yuye-aws <[email protected]>

* remove update button from workspace overview page

Signed-off-by: yuye-aws <[email protected]>

* recover router to workspace overview page

Signed-off-by: yuye-aws <[email protected]>

* change navigation url for workspace overview button on left side panel

Signed-off-by: yuye-aws <[email protected]>

---------

Signed-off-by: yuye-aws <[email protected]>

* fix: linting error

Signed-off-by: Yulong Ruan <[email protected]>

* remove duplicate EuiPage (#34)

* remove duplicate EuiPage

Signed-off-by: Hailong Cui <[email protected]>

* fix: remove duplicate workspace template

Signed-off-by: Hailong Cui <[email protected]>

---------

Signed-off-by: Hailong Cui <[email protected]>

* remove clear button, add the width of create button (#33)

Signed-off-by: zhichao-aws <[email protected]>

* rename OpenSearch Plugins to OpenSearch Features

this is a temporary fix just for demo, should be reverted later

Signed-off-by: Yulong Ruan <[email protected]>

* Add some logic check when overwrite a saved object (#32)

* feat: add some logic check when overwrite a saved object

Signed-off-by: SuZhoue-Joe <[email protected]>

* fix: type check

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: update

Signed-off-by: SuZhoue-Joe <[email protected]>

---------

Signed-off-by: SuZhoue-Joe <[email protected]>

* Add color, icon and defaultVISTheme for workspace (#36)

* feat: add color, icon and defaultVISTheme field for workspace saved object

Signed-off-by: Lin Wang <[email protected]>

* add new fields to workspace form

Signed-off-by: Lin Wang <[email protected]>

* feat: remove feature or group name hack

Signed-off-by: Lin Wang <[email protected]>

---------

Signed-off-by: Lin Wang <[email protected]>

* feat: add workspace list (#39)

Signed-off-by: tygao <[email protected]>

* Feature/menu change (#37)

* feat: register library menus

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: some update

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: optimize code

Signed-off-by: SuZhou-Joe <[email protected]>

* feat: optimize code

Signed-off-by: SuZhou-Joe <[email protected]>

---------

Signed-off-by: SuZhoue-Joe <[email protected]>
Signed-off-by: SuZhou-Joe <[email protected]>

* feat: different left menu and exit workspace (#38)

* Exit workspace from left menu

Signed-off-by: yuye-aws <[email protected]>

* Show exit workspace button with small window size

Signed-off-by: yuye-aws <[email protected]>

* Remove recently viewed and workspace overview on left menu

Signed-off-by: yuye-aws <[email protected]>

* Add buttons for outside, inside workspace case

Signed-off-by: yuye-aws <[email protected]>

* Implement home button and workspace over view button on left menu

Signed-off-by: yuye-aws <[email protected]>

* Implement workspace dropdown list in left menu

Signed-off-by: yuye-aws <[email protected]>

* Add props on recently accessed and custom nav link

Signed-off-by: yuye-aws <[email protected]>

* Add three props to mock props for collapsible nav: exitWorkspace, getWorkspaceUrl, workspaceList$

Signed-off-by: yuye-aws <[email protected]>

* Add three props to mock props for header: exitWorkspace, getWorkspaceUrl, workspaceList$

Signed-off-by: yuye-aws <[email protected]>

* Fix bugs for function createWorkspaceNavLink

Signed-off-by: yuye-aws <[email protected]>

* Remove unused constants

Signed-off-by: yuye-aws <[email protected]>

* Reuse method getWorkspaceUrl

Signed-off-by: yuye-aws <[email protected]>

* Remove recently accessed and custom nav props in test

Signed-off-by: yuye-aws <[email protected]>

* Revert "Remove recently accessed and custom nav props in test"

This reverts commit 7895e5c5dcde9e134f26b2d6a3df54a2d62e9274.

* Wrap title with i18n

Signed-off-by: yuye-aws <[email protected]>

* Add redirect for workspace app

Signed-off-by: yuye-aws <[email protected]>

* Enable users to go to workspace lists page via see more under workspaces in left menu

Signed-off-by: yuye-aws <[email protected]>

---------

Signed-off-by: yuye-aws <[email protected]>

* feat: make url stateful (#35)

* feat: make url stateful

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: optimize code

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: remove useless change

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: optimize url listener

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: make formatUrlWithWorkspaceId extensible

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: modify to related components

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: modify the async format to be sync function

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: modify the async format to be sync function

Signed-off-by: SuZhoue-Joe <[email protected]>

* fix: type check

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: use path to maintain workspace info

Signed-off-by: SuZhou-Joe <[email protected]>

* feat: optimize code

Signed-off-by: SuZhou-Joe <[email protected]>

* feat: optimize code

Signed-off-by: SuZhou-Joe <[email protected]>

* feat: optimize code

Signed-off-by: SuZhou-Joe <[email protected]>

* feat: optimize code

Signed-off-by: SuZhou-Joe <[email protected]>

* feat: optimize code

Signed-off-by: SuZhou-Joe <[email protected]>

* feat: optimize code

Signed-off-by: SuZhou-Joe <[email protected]>

---------

Signed-off-by: SuZhoue-Joe <[email protected]>
Signed-off-by: SuZhou-Joe <[email protected]>

* Fix build error and part of test error (#42)

* fix: fix build error and some ut

Signed-off-by: tygao <[email protected]>

* chore: remove saved object client test diff

Signed-off-by: tygao <[email protected]>

---------

Signed-off-by: tygao <[email protected]>

* feat: optimize code (#40)

Signed-off-by: SuZhou-Joe <[email protected]>

* fix: bootstrap error (#43)

Signed-off-by: SuZhou-Joe <[email protected]>

* feat: add workspace permission control interface (#41)

* feat: add workspace permission control interface

Signed-off-by: Lin Wang <[email protected]>

* feat: add request parameter for workspace permission control

Signed-off-by: Lin Wang <[email protected]>

---------

Signed-off-by: Lin Wang <[email protected]>

* temp: save

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: make create/find support workspaces

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: extract management code

Signed-off-by: SuZhoue-Joe <[email protected]>

* fix: type check

Signed-off-by: SuZhoue-Joe <[email protected]>

* fix: build error

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: enable workspaces on saved client server side

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: extract management code

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: merge fix

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: optimize code

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: remove useless test code

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: integrate with saved object management page

Signed-off-by: SuZhoue-Joe <[email protected]>

* Revert "feat: extract management code"

This reverts commit 9c765d23aeae8bb76ab35a897e4abef9cc9da860.

* Revert "feat: extract management code"

This reverts commit 526c28e01b2a6b80e4f8ee7170b740f5c452b97c.

* fix: type check

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: update

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: optimize code

Signed-off-by: SuZhou-Joe <[email protected]>

* feat: optimize code

Signed-off-by: SuZhou-Joe <[email protected]>

* feat: remove useless import

Signed-off-by: SuZhou-Joe <[email protected]>

* feat: remove useless import

Signed-off-by: SuZhou-Joe <[email protected]>

* feat: remove useless import

Signed-off-by: SuZhou-Joe <[email protected]>

* feat: refractor workspacesServiceMock

Signed-off-by: SuZhou-Joe <[email protected]>

* feat: make all test pass

Signed-off-by: SuZhou-Joe <[email protected]>

---------

Signed-off-by: Yulong Ruan <[email protected]>
Signed-off-by: Hailong Cui <[email protected]>
Signed-off-by: SuZhoue-Joe <[email protected]>
Signed-off-by: Lin Wang <[email protected]>
Signed-off-by: zhichao-aws <[email protected]>
Signed-off-by: suzhou <[email protected]>
Signed-off-by: tygao <[email protected]>
Signed-off-by: gaobinlong <[email protected]>
Signed-off-by: yuye-aws <[email protected]>
Signed-off-by: SuZhou-Joe <[email protected]>
Co-authored-by: Yulong Ruan <[email protected]>
Co-authored-by: Hailong Cui <[email protected]>
Co-authored-by: Lin Wang <[email protected]>
Co-authored-by: zhichao-aws <[email protected]>
Co-authored-by: raintygao <[email protected]>
Co-authored-by: gaobinlong <[email protected]>
Co-authored-by: Yuye Zhu <[email protected]>

* Feature: hide workspace from saved objects management page. (#45)

* setup workspace plugin project skeleton

Signed-off-by: Yulong Ruan <[email protected]>

* test: add unit tests

add license header

Signed-off-by: Yulong Ruan <[email protected]>

* workspace template init commit

Signed-off-by: Hailong Cui <[email protected]>

* refacter workspace template into hooks

Signed-off-by: Hailong Cui <[email protected]>

* refacter workspace template hooks

Signed-off-by: Hailong Cui <[email protected]>

* update coverImage comments

Signed-off-by: Hailong Cui <[email protected]>

* feature: add public/workspaces service

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: add interfaces for workspaces client

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: add interfaces for workspaces client

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: add interfaces for workspaces client

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: implement workspaces service

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: changes to client type interface

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: changes to client implement

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: implement more for workspaces service

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: implement more for workspaces service

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: implement more for workspaces service

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: add workspace creator page (#5)

* feat: add workspace creator page

Signed-off-by: Lin Wang <[email protected]>

* feat: integrate with application workspace template

Signed-off-by: Lin Wang <[email protected]>

* feat: add max-width and remove image wrapper if not exists

Signed-off-by: Lin Wang <[email protected]>

* feat: update filter condition to align with collapsible nav

Signed-off-by: Lin Wang <[email protected]>

---------

Signed-off-by: Lin Wang <[email protected]>

* Add validation when load page (#8)

* fix: validation & query

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: modify file name to reduce confusion

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: add landing logic to retrive workspace id

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: add worklist observable

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: add worklist observable

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: add worklist observable

Signed-off-by: SuZhoue-Joe <[email protected]>

* fix: type error

Signed-off-by: SuZhoue-Joe <[email protected]>

* fix: type error

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: make client more robust

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: use Subject

Signed-off-by: SuZhoue-Joe <[email protected]>

---------

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: use BehaviorObject and optimize code (#14)

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: integrate with workspace create API (#13)

* feat: integrate with workspace create API

Signed-off-by: Lin Wang <[email protected]>

* feat: update to i18n text for toast

Signed-off-by: Lin Wang <[email protected]>

---------

Signed-off-by: Lin Wang <[email protected]>

* Add currentWorkspace$ (#15)

* feat: add currentWorkspace$

Signed-off-by: SuZhoue-Joe <[email protected]>

* fix: type error

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: add emit on currentWorkspace$

Signed-off-by: SuZhoue-Joe <[email protected]>

---------

Signed-off-by: SuZhoue-Joe <[email protected]>

* register plugin with workspace template (#16)

Signed-off-by: Hailong Cui <[email protected]>

* workspace dropdown list (#9)

Add workspace dropdown list 

---------

Signed-off-by: zhichao-aws <[email protected]>
Signed-off-by: SuZhoue-Joe <[email protected]>
Signed-off-by: suzhou <[email protected]>
Co-authored-by: SuZhoue-Joe <[email protected]>

* init workspace menu stage 1 (#12)

* feat: init workspace menu stage 1

Signed-off-by: tygao <[email protected]>

* fix: remove port diff

Signed-off-by: tygao <[email protected]>

* feat: update menu logic

Signed-off-by: tygao <[email protected]>

---------

Signed-off-by: tygao <[email protected]>

* Fix template registration import error (#21)

* fix import error

Signed-off-by: Hailong Cui <[email protected]>

* fix osd bootstrap failure

Signed-off-by: Hailong Cui <[email protected]>

---------

Signed-off-by: Hailong Cui <[email protected]>

* Add workspace overview page (#19)

* feat: add workspace overview page

Signed-off-by: Lin Wang <[email protected]>

* refactor: move paths to common constants

Signed-off-by: Lin Wang <[email protected]>

* feat: add workspace overview item by custom nav in start phase

Signed-off-by: Lin Wang <[email protected]>

* refactor: change to currentWorkspace$ in workspace client

Signed-off-by: Lin Wang <[email protected]>

---------

Signed-off-by: Lin Wang <[email protected]>

* feat: navigate to workspace create page after button clicked (#23)

Signed-off-by: Lin Wang <[email protected]>

* fix failed test snapshots (#22)

fix failed test snapshots

temporary fix: fetch functional test from main branch

fixed git error which cannot find ref due to feature branch `workspace`
not exists on repo opensearch-dashboards-functional-test

Signed-off-by: Yulong Ruan <[email protected]>

---------

Signed-off-by: Yulong Ruan <[email protected]>

* change to currentWorkspace, wrap title using i18n (#20)

* change to currentWorkspace, wrap title using i18n

Signed-off-by: zhichao-aws <[email protected]>

* change import

Signed-off-by: zhichao-aws <[email protected]>

* directly return [] if currentWorkspace is null

Signed-off-by: zhichao-aws <[email protected]>

---------

Signed-off-by: zhichao-aws <[email protected]>

* add workspace switch (#17)

* feat: update workspace switch

Signed-off-by: tygao <[email protected]>

* fix: fix switch error

Signed-off-by: tygao <[email protected]>

* fix: fix prettier after merge

Signed-off-by: tygao <[email protected]>

* chore: remove extra code after merge

Signed-off-by: tygao <[email protected]>

---------

Signed-off-by: tygao <[email protected]>

* Add update workspace page (#25)

Signed-off-by: gaobinlong <[email protected]>

* Delete Workspace (#24)

* add delete workspace modal

Signed-off-by: yuye-aws <[email protected]>

* implement delete on workspace overview page

Signed-off-by: yuye-aws <[email protected]>

* fix export on delete workspace modal

Signed-off-by: yuye-aws <[email protected]>

* add try catch to handle errors for workspace delete

Signed-off-by: yuye-aws <[email protected]>

* move visibility control to workspace overview page exlusively

Signed-off-by: yuye-aws <[email protected]>

* remove unused import

Signed-off-by: yuye-aws <[email protected]>

---------

Signed-off-by: yuye-aws <[email protected]>

* feat: redirect to overview page after workspace switch (#26)

Signed-off-by: Lin Wang <[email protected]>

* update menu filter logic (#28)

* feat: update menu logic

Signed-off-by: tygao <[email protected]>

* fix: use navLinks to filter

Signed-off-by: tygao <[email protected]>

---------

Signed-off-by: tygao <[email protected]>

* feat: redirect to workspace overview page after created success (#29)

Signed-off-by: Lin Wang <[email protected]>

* [Feature] Complied saved_objects create/find (#18)

* temp: save

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: make create/find support workspaces

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: extract management code

Signed-off-by: SuZhoue-Joe <[email protected]>

* fix: type check

Signed-off-by: SuZhoue-Joe <[email protected]>

* fix: build error

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: enable workspaces on saved client server side

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: some optimization

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: extract management code

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: merge fix

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: optimize code

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: reuse common function

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: optimize code when create

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: remove useless test code

Signed-off-by: SuZhoue-Joe <[email protected]>

---------

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: redirect to workspace update page after workspace switch (#30)

* Move delete button to update page (#27)

* add delete workspace modal

Signed-off-by: yuye-aws <[email protected]>

* implement delete on workspace overview page

Signed-off-by: yuye-aws <[email protected]>

* fix export on delete workspace modal

Signed-off-by: yuye-aws <[email protected]>

* add try catch to handle errors for workspace delete

Signed-off-by: yuye-aws <[email protected]>

* move visibility control to workspace overview page exlusively

Signed-off-by: yuye-aws <[email protected]>

* remove unused import

Signed-off-by: yuye-aws <[email protected]>

* change workspace overview route to workspace update

Signed-off-by: yuye-aws <[email protected]>

* move delete button from workspace overview page to update page

Signed-off-by: yuye-aws <[email protected]>

* remove update button from workspace overview page

Signed-off-by: yuye-aws <[email protected]>

* recover router to workspace overview page

Signed-off-by: yuye-aws <[email protected]>

* change navigation url for workspace overview button on left side panel

Signed-off-by: yuye-aws <[email protected]>

---------

Signed-off-by: yuye-aws <[email protected]>

* fix: linting error

Signed-off-by: Yulong Ruan <[email protected]>

* remove duplicate EuiPage (#34)

* remove duplicate EuiPage

Signed-off-by: Hailong Cui <[email protected]>

* fix: remove duplicate workspace template

Signed-off-by: Hailong Cui <[email protected]>

---------

Signed-off-by: Hailong Cui <[email protected]>

* remove clear button, add the width of create button (#33)

Signed-off-by: zhichao-aws <[email protected]>

* rename OpenSearch Plugins to OpenSearch Features

this is a temporary fix just for demo, should be reverted later

Signed-off-by: Yulong Ruan <[email protected]>

* Add some logic check when overwrite a saved object (#32)

* feat: add some logic check when overwrite a saved object

Signed-off-by: SuZhoue-Joe <[email protected]>

* fix: type check

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: update

Signed-off-by: SuZhoue-Joe <[email protected]>

---------

Signed-off-by: SuZhoue-Joe <[email protected]>

* Add color, icon and defaultVISTheme for workspace (#36)

* feat: add color, icon and defaultVISTheme field for workspace saved object

Signed-off-by: Lin Wang <[email protected]>

* add new fields to workspace form

Signed-off-by: Lin Wang <[email protected]>

* feat: remove feature or group name hack

Signed-off-by: Lin Wang <[email protected]>

---------

Signed-off-by: Lin Wang <[email protected]>

* feat: add workspace list (#39)

Signed-off-by: tygao <[email protected]>

* Feature/menu change (#37)

* feat: register library menus

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: some update

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: optimize code

Signed-off-by: SuZhou-Joe <[email protected]>

* feat: optimize code

Signed-off-by: SuZhou-Joe <[email protected]>

---------

Signed-off-by: SuZhoue-Joe <[email protected]>
Signed-off-by: SuZhou-Joe <[email protected]>

* feat: different left menu and exit workspace (#38)

* Exit workspace from left menu

Signed-off-by: yuye-aws <[email protected]>

* Show exit workspace button with small window size

Signed-off-by: yuye-aws <[email protected]>

* Remove recently viewed and workspace overview on left menu

Signed-off-by: yuye-aws <[email protected]>

* Add buttons for outside, inside workspace case

Signed-off-by: yuye-aws <[email protected]>

* Implement home button and workspace over view button on left menu

Signed-off-by: yuye-aws <[email protected]>

* Implement workspace dropdown list in left menu

Signed-off-by: yuye-aws <[email protected]>

* Add props on recently accessed and custom nav link

Signed-off-by: yuye-aws <[email protected]>

* Add three props to mock props for collapsible nav: exitWorkspace, getWorkspaceUrl, workspaceList$

Signed-off-by: yuye-aws <[email protected]>

* Add three props to mock props for header: exitWorkspace, getWorkspaceUrl, workspaceList$

Signed-off-by: yuye-aws <[email protected]>

* Fix bugs for function createWorkspaceNavLink

Signed-off-by: yuye-aws <[email protected]>

* Remove unused constants

Signed-off-by: yuye-aws <[email protected]>

* Reuse method getWorkspaceUrl

Signed-off-by: yuye-aws <[email protected]>

* Remove recently accessed and custom nav props in test

Signed-off-by: yuye-aws <[email protected]>

* Revert "Remove recently accessed and custom nav props in test"

This reverts commit 7895e5c5dcde9e134f26b2d6a3df54a2d62e9274.

* Wrap title with i18n

Signed-off-by: yuye-aws <[email protected]>

* Add redirect for workspace app

Signed-off-by: yuye-aws <[email protected]>

* Enable users to go to workspace lists page via see more under workspaces in left menu

Signed-off-by: yuye-aws <[email protected]>

---------

Signed-off-by: yuye-aws <[email protected]>

* feat: make url stateful (#35)

* feat: make url stateful

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: optimize code

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: remove useless change

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: optimize url listener

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: make formatUrlWithWorkspaceId extensible

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: modify to related components

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: modify the async format to be sync function

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: modify the async format to be sync function

Signed-off-by: SuZhoue-Joe <[email protected]>

* fix: type check

Signed-off-by: SuZhoue-Joe <[email protected]>

* feat: use path to maintain workspace info

Signed-off-by: SuZhou-Joe <[email protected]>

* feat: optimize code

Signed-off-by: SuZhou-Joe <[email protected]>

* feat: optimize code

Signed-off-by: SuZhou-Joe <[email protected]>

* feat: optimize code

Signed-off-by: SuZhou-Joe <[email protected]>

* feat: optimize code

Signed-off-by: SuZhou-Joe <[email protected]>

* feat: optimize code

Signed-off-by: SuZhou-Joe <[email protected]>

* feat: optimize code

Signed-off-by: SuZhou-Joe <[email protected]>

---------

Signed-off-by: SuZhoue-Joe <[email protected]>
Signed-off-by: SuZhou-Joe <[email protected]>

* Fix build error and part of test error (#42)

* fix: fix build error and some ut

Signed-off-by: tygao <[email protected]>

* chore: remove saved object client test diff

Signed-off-by: tygao <[email protected]>

---------

Signed-off-by: tygao <[email protected]>

* feat: optimize code (#40)

Signed-off-by: SuZhou-Joe <[email protected]>

* fix: bootstrap error (#43)

Signed-off-by: SuZhou-Joe <[email protected]>

* feat: add workspace permission control interface (#41)

* feat: add workspace permission control interface

Signed-off-by: Lin Wang <[email protected]>

* feat: add request parameter for workspace permission control

Signed-off-by: Lin Wang <[email protected]>

---------

Signed-off-by: Lin Wang <[email protected]>

* allow user to turn on/off workspace from advance settings (#46)

return 404 if accessing a workspace path when workspace is disabled

---------

Signed-off-by: Yulong Ruan <[email protected]>

* fix: unit test failure (#50)

Signed-off-by: SuZhou-Joe <[email protected]>

* Add workspace column into saved objects table (#44)

* Add workspace column into saved management page

Signed-off-by: Hailong Cui <[email protected]>

* savedObjectsManagement as optional dependency

Signed-off-by: Hailong Cui <[email protected]>

* i18n for column title

Signed-off-by: Hailong Cui <[email protected]>

---------

Signed-off-by: Hailong Cui <[email protected]>

* feat: make edit url clickable

Signed-off-by: SuZhou-Joe <[email protected]>

* feat: add ui capability path

Signed-off-by: SuZhou-Joe <[email protected]>

* feat: add ui capability path

Signed-off-by: SuZhou-Joe <[email protected]>

* fet: remove useless jump code

Signed-off-by: SuZhou-Joe <[email protected]>

* feat: hide workspace from saved objects management page

Signed-off-by: SuZhou-Joe <[email protected]>

* feat: hide workspace from saved objects management page

Signed-off-by: SuZhou-Joe <[email protected]>

---------

Signed-off-by: Yulong Ruan <[email protected]>
Signed-off-by: Hailong Cui <[email protected]>
Signed-off-by: SuZhoue-Joe <[email protected]>
Signed-off-by: Lin Wang <[email protected]>
Signed-off-by: zhichao-aws <[email protected]>
Signed-off-by: suzhou <[email protected]>
Signed-off-by: tygao <[email protected]>
Signed-off-by: gaobinlong <[email protected]>
Signed-off-by: yuye-aws <[email protected]>
Signed-off-by: SuZhou-Joe <[email protected]>
Co-authored-by: Yulong Ruan <[email protected]>
Co-authored-by: Hailong Cui <[email protected]>
Co-authored-by: Lin Wang <[email protected]>
Co-authored-by: zhichao-aws <[email protected]>
Co-authored-by: raintygao <[email protected]>
Co-authored-by: gaobinlong <[email protected]>
Co-authored-by: Yuye Zhu <[email protected]>

* Add copy saved objects among workspaces functionality (#53)

* Add copy saved objects among workspaces functionality

Signed-off-by: gaobinlong <[email protected]>

Signed-off-by: gaobinlong <[email protected]>

* Fix bug

Signed-off-by: gaobinlong <[email protected]>

* Fix bug

Signed-off-by: gaobinlong <[email protected]>

---------

Signed-off-by: gaobinlong <[email protected]>

* add workspace saved objects client wrapper (#51)

* add workspace savedd objects client wrapper

Signed-off-by: Lin Wang <[email protected]>

* feat: add more methods to saved objects client wrapper

Signed-off-by: Lin Wang <[email protected]>

* feat: add findWithWorkspacePermissionControl in workspace saved objects client wrapper

Signed-off-by: Lin Wang <[email protected]>

* feat: throw 451 instead of interval error

Signed-off-by: Lin Wang <[email protected]>

* chore: fix workspace client init method type error

Signed-off-by: Lin Wang <[email protected]>

* feat: fix workspaces attribute type error in client wrapper

Signed-off-by: Lin Wang <[email protected]>

---------

Signed-off-by: Lin Wang <[email protected]>

* Refactor navigation links from left menu hard code to workspace plugin register (#55)

* feature: add public/workspaces service

Signed-off-by: SuZhoue-Joe <[email protected]>

* Exit workspace from left menu

Signed-off-by: yuye-aws <[email protected]>

* Show exit workspace button with small window size

Signed-off-by: yuye-aws <[email protected]>

* Remove recently viewed and workspace overview on left menu

Signed-off-by: yuye-aws <[email protected]>

* Add buttons for outside, inside workspace case

Signed-off-by: yuye-aws <[email protected]>

* Implement home button and workspace over view button on left menu

Signed-off-by: yuye-aws <[email protected]>

* Implement workspace dropdown list in left menu

Signed-off-by: yuye-aws <[email protected]>

* Add props on recently accessed and custom nav link

Signed-off-by: yuye-aws <[email protected]>

* Reuse method getWorkspaceUrl

Signed-off-by: yuye-aws <[email protected]>

* Remove recently accessed and custom nav props in test

Signed-off-by: yuye-aws <[email protected]>

* Revert "Remove recently accessed and custom nav props in test"

This reverts commit 7895e5c5dcde9e134f26b2d6a3df54a2d62e9274.

* Wrap title with i18n

Signed-off-by: yuye-aws <[email protected]>

* Add redirect for workspace app

Signed-off-by: yuye-aws <[email protected]>

* Enable users to go to workspace lists page via see more under workspaces in left menu

Signed-off-by: yuye-aws <[email protected]>

* Fix build error and part of test error (#42)

* fix: fix build error and some ut

Signed-off-by: tygao <[email protected]>

* chore: remove saved object client test diff

Signed-off-by: tygao <[email protected]>

---------

Signed-off-by: tygao <[email protected]>

* Comment Alerts and Favorites in left menu

Signed-off-by: yuye-aws <[email protected]>

* Recover recently viewed items in left menu

Signed-off-by: yuye-aws <[email protected]>

* Move exit workspace from left menu to update page

Signed-off-by: yuye-aws <[email protected]>

* Remove unused import

Signed-off-by: yuye-aws <[email protected]>

* Add workspace category info

Signed-off-by: yuye-aws <[email protected]>

* Remove workspace nav link

Signed-off-by: yuye-aws <[email protected]>

* Remove unused import

Signed-off-by: yuye-aws <[email protected]>

* Add FilteredNavLinks props to chrome service mock

Signed-off-by: yuye-aws <[email protected]>

* Remove workspace related constans from chrome

Signed-off-by: yuye-aws <[email protected]>

* Remove workspace related props from chrome and core

Signed-off-by: yuye-aws <[email protected]>

* Remove workspace related props from header

Signed-off-by: yuye-aws <[email protected]>

* Shorten import path for workspace updater

Signed-off-by: yuye-aws <[email protected]>

* Add euiIconType for workspace left menu category

Signed-off-by: yuye-aws <[email protected]>

* Remove workspace related props for collapsible nav

Signed-off-by: yuye-aws <[email protected]>

* Remove workspace related props for collapsible nav

Signed-off-by: yuye-aws <[email protected]>

* Implement navigation for delete and exit workspace

Signed-off-by: yuye-aws <[email protected]>

* Navigate external links through url change

Signed-off-by: yuye-aws <[email protected]>

* Implement filteredNavLinks and sort ChromeNavLinks in nav link service

Signed-off-by: yuye-aws <[email protected]>

* Add workspace list, see more, admin and overview into chromenavlinks

Signed-off-by: yuye-aws <[email protected]>

* fix: unit test failure (#50)

Signed-off-by: SuZhou-Joe <[email protected]>

* Fix osd bootstrap error

Signed-off-by: yuye-aws <[email protected]>

* Check workspace enabled for left menu

Signed-off-by: yuye-aws <[email protected]>

* Add home nav link to left menu when outside workspace

Signed-off-by: yuye-aws <[email protected]>

* Fix unit test for collapsible nav

Signed-off-by: yuye-aws <[email protected]>

* Fix unit test for header

Signed-off-by: yuye-aws <[email protected]>

* Fix unit test for collapsible nav

Signed-off-by: yuye-aws <[email protected]>

* Fix unit test for collapsible nav

Signed-off-by: yuye-aws <[email protected]>

* Update snapshot for unit tests

Signed-off-by: yuye-aws <[email protected]>

* fix osd bootstrap error

Signed-off-by: yuye-aws <[email protected]>

* fix combinelatest import error

Signed-off-by: yuye-aws <[email protected]>

* update snapshot for unit tests

Signed-off-by: yuye-aws <[email protected]>

* variable rename

Signed-off-by: yuye-aws <[email protected]>

* move custom nav link to mock props

Signed-off-by: yuye-aws <[email protected]>

* move default filtered nav link to core

Signed-off-by: yuye-aws <[email protected]>

* change navigation method in workspace updater

Signed-off-by: yuye-aws <[email protected]>

* Update src/plugins/workspace/public/components/workspace_updater/workspace_updater.tsx

Co-authored-by: SuZhou-Joe <[email protected]>

* revert some unncessary changes

Signed-off-by: yuye-aws <[email protected]>

* fix navigation url bug

Signed-off-by: yuye-aws <[email protected]>

* move default filtered nav link value setting from core to workspace plugin

Signed-off-by: yuye-aws <[email protected]>

* move filter nav link to a new function

Signed-off-by: yuye-aws <[email protected]>

* process filter nav links when workspace is disabled

Signed-off-by: yuye-aws <[email protected]>

* change navigation method

Signed-off-by: yuye-aws <[email protected]>

---------

Signed-off-by: SuZhoue-Joe <[email protected]>
Signed-off-by: yuye-aws <[email protected]>
Signed-off-by: tygao <[email protected]>
Signed-off-by: SuZhou-Joe <[email protected]>
Co-authored-by: SuZhoue-Joe <[email protected]>
Co-authored-by: raintygao <[email protected]>

* fix: osd bootstrap error (#57)

* fix osd bootstrap error

Signed-off-by: yuye-aws <[email protected]>

* fix build plugins error

Signed-off-by: yuye-aws <[email protected]>

---------

Signed-off-by: yuye-aws <[email protected]>

* feat: filter out ADMIN application and add feature dependency logic (#49)

* feat: filter out ADMIN application and add feature dependency logic

Signed-off-by: Lin Wang <[email protected]>

* feat: separate feature utils function

Signed-off-by: Lin Wang <[email protected]>

* feat: rename isFeatureDependBySelectedFeatures, separate generateFeatureDependencyMap and add annotation

Signed-off-by: Lin Wang <[email protected]>

---------

Signed-off-by: Lin Wang <[email protected]>

* feat: do not register app when feature flag is off (#56)

* feat: do not register app when feature flag is off

Signed-off-by: SuZhou-Joe <[email protected]>

* feat: comply with the category name

Signed-off-by: SuZhou-Joe <[email protected]>

* feat: opt according to PR

Signed-off-by: SuZhou-Joe <[email protected]>

* feat: optimize the comment

Signed-off-by: SuZhou-Joe <[email protected]>

---------

Signed-off-by: SuZhou-Joe <[email protected]>

* Sort category and non-category nav link according to order in left menu (#60)

* change order for home

Signed-off-by: yuye-aws <[email protected]>

* Sort category and non-category navlink types in left menu

Signed-off-by: yuye-aws <[email protected]>

* change order for overview when inside workspace

Signed-off-by: yuye-aws <[email protected]>

* assign sorted unknowns to another variable

Signed-off-by: yuye-aws <[email protected]>

* change annotation

Signed-off-by: yuye-aws <[email protected]>

* refactor function getMergedNavLinks in left menu

Signed-off-by: yuye-aws <[email protected]>

* fix zero order bug

Signed-off-by: yuye-aws <[email protected]>

* add annotation

Signed-off-by: yuye-aws <[email protected]>

---------

Signed-off-by: yuye-aws <[email protected]>

* Refactor: Assign default value for filtered nav links (#64)

* remove default filtered nav link value set

Signed-off-by: yuye-aws <[email protected]>

* default value for nav link

Signed-off-by: yuye-aws <[email protected]>

* refactor currentworkspace logic

Signed-off-by: yuye-aws <[email protected]>

---------

Signed-off-by: yuye-aws <[email protected]>

* Permission control service for saved objects (#63)

* feat: move permission control to saved objects directory

Signed-off-by: SuZhou-Joe <[email protected]>

* feat: use bulkGetObjects and fix unit test

Signed-off-by: SuZhou-Joe <[email protected]>

* feat: add http routes for validate & list

Signed-off-by: SuZhou-Joe <[email protected]>

* feat: move permissionModes to common place

Signed-off-by: SuZhou-Joe <[email protected]>

* feat: rename routes

Signed-off-by: SuZhou-Joe <[email protected]>

* feat: some side effects

Signed-off-by: SuZhou-Joe <[email protected]>

* feat: some side effects

Signed-off-by: SuZhou-Joe <[email protected]>

---------

Signed-off-by: SuZhou-Joe <[email protected]>

* fix: make importing workspace-specific objects as copy

Signed-off-by: SuZhou-Joe <[email protected]>

* feat: make unit test pass

Signed-off-by: SuZhou-Joe <[email protected]>

* feat: revert the workspace change

Signed-off-by: SuZhou-Joe <[email protected]>

* feat: make import support multiple workspaces

Signed-off-by: SuZhou-Joe <[email protected]>

* feat: change logic

Signed-off-by: SuZhou-Joe <suzhou@am…
  • Loading branch information
8 people committed Aug 31, 2023
1 parent 8dc25d6 commit 0d47d87
Show file tree
Hide file tree
Showing 18 changed files with 383 additions and 178 deletions.

Large diffs are not rendered by default.

10 changes: 1 addition & 9 deletions src/core/public/chrome/ui/header/collapsible_nav.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,6 @@ describe('CollapsibleNav', () => {
});

it('remembers collapsible section state', () => {
/**
* TODO skip for workspace refractor, will revert once refractor the left menu part
*/
return;
const navLinks = [
mockLink({ category: opensearchDashboards }),
mockLink({ category: observability }),
Expand All @@ -172,7 +168,7 @@ describe('CollapsibleNav', () => {
recentlyAccessed$={new BehaviorSubject(recentNavLinks)}
/>
);
expectShownNavLinksCount(component, 0);
expectShownNavLinksCount(component, 3);
clickGroup(component, 'opensearchDashboards');
clickGroup(component, 'recentlyViewed');
expectShownNavLinksCount(component, 1);
Expand All @@ -183,10 +179,6 @@ describe('CollapsibleNav', () => {
});

it('closes the nav after clicking a link', () => {
/**
* TODO skip for workspace refractor, will revert once refractor the left menu part
*/
return;
const onClose = sinon.spy();
const navLinks = [
mockLink({ category: opensearchDashboards }),
Expand Down
3 changes: 3 additions & 0 deletions src/core/public/workspace/workspaces_service.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ import { WorkspaceAttribute } from '..';
const currentWorkspaceId$ = new BehaviorSubject<string>('');
const workspaceList$ = new BehaviorSubject<WorkspaceAttribute[]>([]);
const currentWorkspace$ = new BehaviorSubject<WorkspaceAttribute | null>(null);
const hasFetchedWorkspaceList$ = new BehaviorSubject<boolean>(false);
const workspaceEnabled$ = new BehaviorSubject<boolean>(false);

const createWorkspacesSetupContractMock = () => ({
currentWorkspaceId$,
workspaceList$,
currentWorkspace$,
hasFetchedWorkspaceList$,
workspaceEnabled$,
registerWorkspaceMenuRender: jest.fn(),
});
Expand All @@ -23,6 +25,7 @@ const createWorkspacesStartContractMock = () => ({
currentWorkspaceId$,
workspaceList$,
currentWorkspace$,
hasFetchedWorkspaceList$,
workspaceEnabled$,
renderWorkspaceMenu: jest.fn(),
});
Expand Down
5 changes: 5 additions & 0 deletions src/core/public/workspace/workspaces_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export interface WorkspaceObservables {
currentWorkspace$: BehaviorSubject<WorkspaceAttribute | null>;
workspaceList$: BehaviorSubject<WorkspaceAttribute[]>;
workspaceEnabled$: BehaviorSubject<boolean>;
hasFetchedWorkspaceList$: BehaviorSubject<boolean>;
}

/**
Expand All @@ -40,6 +41,7 @@ export class WorkspaceService implements CoreService<WorkspaceSetup, WorkspaceSt
private currentWorkspaceId$ = new BehaviorSubject<string>('');
private workspaceList$ = new BehaviorSubject<WorkspaceAttribute[]>([]);
private currentWorkspace$ = new BehaviorSubject<WorkspaceAttribute | null>(null);
private hasFetchedWorkspaceList$ = new BehaviorSubject<boolean>(false);
private workspaceEnabled$ = new BehaviorSubject<boolean>(false);
private _renderWorkspaceMenu: WorkspaceMenuRenderFn | null = null;

Expand All @@ -48,6 +50,7 @@ export class WorkspaceService implements CoreService<WorkspaceSetup, WorkspaceSt
currentWorkspaceId$: this.currentWorkspaceId$,
currentWorkspace$: this.currentWorkspace$,
workspaceList$: this.workspaceList$,
hasFetchedWorkspaceList$: this.hasFetchedWorkspaceList$,
workspaceEnabled$: this.workspaceEnabled$,
registerWorkspaceMenuRender: (render: WorkspaceMenuRenderFn) =>
(this._renderWorkspaceMenu = render),
Expand All @@ -65,6 +68,7 @@ export class WorkspaceService implements CoreService<WorkspaceSetup, WorkspaceSt
currentWorkspaceId$: this.currentWorkspaceId$,
currentWorkspace$: this.currentWorkspace$,
workspaceList$: this.workspaceList$,
hasFetchedWorkspaceList$: this.hasFetchedWorkspaceList$,
workspaceEnabled$: this.workspaceEnabled$,
};
return {
Expand All @@ -87,6 +91,7 @@ export class WorkspaceService implements CoreService<WorkspaceSetup, WorkspaceSt
this.currentWorkspaceId$.unsubscribe();
this.workspaceList$.unsubscribe();
this.workspaceEnabled$.unsubscribe();
this.hasFetchedWorkspaceList$.unsubscribe();
this._renderWorkspaceMenu = null;
}
}
3 changes: 3 additions & 0 deletions src/core/server/saved_objects/import/check_conflicts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ interface CheckConflictsParams {
ignoreRegularConflicts?: boolean;
retries?: SavedObjectsImportRetry[];
createNewCopies?: boolean;
workspaces?: string[];
}

const isUnresolvableConflict = (error: SavedObjectError) =>
Expand All @@ -56,6 +57,7 @@ export async function checkConflicts({
ignoreRegularConflicts,
retries = [],
createNewCopies,
workspaces,
}: CheckConflictsParams) {
const filteredObjects: Array<SavedObject<{ title?: string }>> = [];
const errors: SavedObjectsImportError[] = [];
Expand All @@ -77,6 +79,7 @@ export async function checkConflicts({
});
const checkConflictsResult = await savedObjectsClient.checkConflicts(objectsToCheck, {
namespace,
workspaces,
});
const errorMap = checkConflictsResult.errors.reduce(
(acc, { type, id, error }) => acc.set(`${type}:${id}`, error),
Expand Down
9 changes: 8 additions & 1 deletion src/core/server/saved_objects/import/import_saved_objects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import { validateReferences } from './validate_references';
import { checkOriginConflicts } from './check_origin_conflicts';
import { createSavedObjects } from './create_saved_objects';
import { checkConflicts } from './check_conflicts';
import { regenerateIds } from './regenerate_ids';
import { regenerateIds, regenerateIdsWithReference } from './regenerate_ids';

/**
* Import saved objects from given stream. See the {@link SavedObjectsImportOptions | options} for more
Expand Down Expand Up @@ -81,12 +81,19 @@ export async function importSavedObjectsFromStream({
if (createNewCopies) {
importIdMap = regenerateIds(collectSavedObjectsResult.collectedObjects);
} else {
importIdMap = await regenerateIdsWithReference({
savedObjects: collectSavedObjectsResult.collectedObjects,
savedObjectsClient,
workspaces,
objectLimit,
});
// Check single-namespace objects for conflicts in this namespace, and check multi-namespace objects for conflicts across all namespaces
const checkConflictsParams = {
objects: collectSavedObjectsResult.collectedObjects,
savedObjectsClient,
namespace,
ignoreRegularConflicts: overwrite,
workspaces,
};
const checkConflictsResult = await checkConflicts(checkConflictsParams);
errorAccumulator = [...errorAccumulator, ...checkConflictsResult.errors];
Expand Down
39 changes: 38 additions & 1 deletion src/core/server/saved_objects/import/regenerate_ids.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
*/

import { v4 as uuidv4 } from 'uuid';
import { SavedObject } from '../types';
import { SavedObject, SavedObjectsClientContract } from '../types';
import { SavedObjectsUtils } from '../service';

/**
* Takes an array of saved objects and returns an importIdMap of randomly-generated new IDs.
Expand All @@ -42,3 +43,39 @@ export const regenerateIds = (objects: SavedObject[]) => {
}, new Map<string, { id: string; omitOriginId?: boolean }>());
return importIdMap;
};

export const regenerateIdsWithReference = async (props: {
savedObjects: SavedObject[];
savedObjectsClient: SavedObjectsClientContract;
workspaces?: string[];
objectLimit: number;
}): Promise<Map<string, { id?: string; omitOriginId?: boolean }>> => {
const { savedObjects, savedObjectsClient, workspaces } = props;
if (!workspaces || !workspaces.length) {
return savedObjects.reduce((acc, object) => {
return acc.set(`${object.type}:${object.id}`, { id: object.id, omitOriginId: false });
}, new Map<string, { id: string; omitOriginId?: boolean }>());
}

const bulkGetResult = await savedObjectsClient.bulkGet(
savedObjects.map((item) => ({ type: item.type, id: item.id }))
);

return bulkGetResult.saved_objects.reduce((acc, object) => {
if (object.error?.statusCode === 404) {
acc.set(`${object.type}:${object.id}`, { id: object.id, omitOriginId: true });
return acc;
}

const filteredWorkspaces = SavedObjectsUtils.filterWorkspacesAccordingToBaseWorkspaces(
workspaces,
object.workspaces
);
if (filteredWorkspaces.length) {
acc.set(`${object.type}:${object.id}`, { id: uuidv4(), omitOriginId: true });
} else {
acc.set(`${object.type}:${object.id}`, { id: object.id, omitOriginId: false });
}
return acc;
}, new Map<string, { id: string; omitOriginId?: boolean }>());
};
110 changes: 84 additions & 26 deletions src/core/server/saved_objects/service/lib/repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -378,15 +378,28 @@ export class SavedObjectsRepository {

const method = object.id && overwrite ? 'index' : 'create';
const requiresNamespacesCheck = object.id && this._registry.isMultiNamespace(object.type);
/**
* Only when importing an object to a target workspace should we check if the object is workspace-specific.
*/
const requiresWorkspaceCheck = object.id;

if (object.id == null) object.id = uuid.v1();

let opensearchRequestIndexPayload = {};

if (requiresNamespacesCheck || requiresWorkspaceCheck) {
opensearchRequestIndexPayload = {
opensearchRequestIndex: bulkGetRequestIndexCounter,
};
bulkGetRequestIndexCounter++;
}

return {
tag: 'Right' as 'Right',
value: {
method,
object,
...(requiresNamespacesCheck && { opensearchRequestIndex: bulkGetRequestIndexCounter++ }),
...opensearchRequestIndexPayload,
},
};
});
Expand All @@ -397,7 +410,7 @@ export class SavedObjectsRepository {
.map(({ value: { object: { type, id } } }) => ({
_id: this._serializer.generateRawId(namespace, type, id),
_index: this.getIndexForType(type),
_source: ['type', 'namespaces'],
_source: ['type', 'namespaces', 'workspaces'],
}));
const bulkGetResponse = bulkGetDocs.length
? await this.client.mget(
Expand Down Expand Up @@ -426,15 +439,8 @@ export class SavedObjectsRepository {
method,
} = expectedBulkGetResult.value;
let savedObjectWorkspaces: string[] | undefined;
if (expectedBulkGetResult.value.method === 'create') {
if (options.workspaces) {
savedObjectWorkspaces = Array.from(new Set([...(options.workspaces || [])]));
}
} else if (object.workspaces) {
savedObjectWorkspaces = Array.from(
new Set([...object.workspaces, ...(options.workspaces || [])])
);
}
let finalMethod = method;
let finalObjectId = object.id;
if (opensearchRequestIndex !== undefined) {
const indexFound = bulkGetResponse?.statusCode !== 404;
const actualResult = indexFound
Expand Down Expand Up @@ -471,12 +477,57 @@ export class SavedObjectsRepository {
versionProperties = getExpectedVersionProperties(version);
}

if (expectedBulkGetResult.value.method === 'create') {
savedObjectWorkspaces = options.workspaces;
} else {
const changeToCreate = () => {
finalMethod = 'create';
finalObjectId = object.id;
savedObjectWorkspaces = options.workspaces;
versionProperties = {};
};
/**
* When overwrite, need to check if the object is workspace-specific
* if so, copy object to target workspace instead of refering it.
*/
const rawId = this._serializer.generateRawId(namespace, object.type, object.id);
const findObject =
bulkGetResponse?.statusCode !== 404
? bulkGetResponse?.body.docs?.find((item) => item._id === rawId)
: null;
if (findObject && findObject.found) {
const transformedObject = this._serializer.rawToSavedObject(
findObject as SavedObjectsRawDoc
) as SavedObject;
const filteredWorkspaces = SavedObjectsUtils.filterWorkspacesAccordingToBaseWorkspaces(
options.workspaces,
transformedObject.workspaces
);
/**
* We need to create a new object when the object
* is about to import into workspaces it is not belong to
*/
if (filteredWorkspaces.length) {
/**
* Create a new object but only belong to the set of (target workspaces - original workspace)
*/
changeToCreate();
finalObjectId = uuid.v1();
savedObjectWorkspaces = filteredWorkspaces;
} else {
savedObjectWorkspaces = transformedObject.workspaces;
}
} else {
savedObjectWorkspaces = options.workspaces;
}
}

const expectedResult = {
opensearchRequestIndex: bulkRequestIndexCounter++,
requestedId: object.id,
requestedId: finalObjectId,
rawMigratedDoc: this._serializer.savedObjectToRaw(
this._migrator.migrateDocument({
id: object.id,
id: finalObjectId,
type: object.type,
attributes: object.attributes,
migrationVersion: object.migrationVersion,
Expand All @@ -492,7 +543,7 @@ export class SavedObjectsRepository {

bulkCreateParams.push(
{
[method]: {
[finalMethod]: {
_id: expectedResult.rawMigratedDoc._id,
_index: this.getIndexForType(object.type),
...(overwrite && versionProperties),
Expand Down Expand Up @@ -583,7 +634,7 @@ export class SavedObjectsRepository {
const bulkGetDocs = expectedBulkGetResults.filter(isRight).map(({ value: { type, id } }) => ({
_id: this._serializer.generateRawId(namespace, type, id),
_index: this.getIndexForType(type),
_source: ['type', 'namespaces'],
_source: ['type', 'namespaces', 'workspaces'],
}));
const bulkGetResponse = bulkGetDocs.length
? await this.client.mget(
Expand All @@ -606,17 +657,24 @@ export class SavedObjectsRepository {
const { type, id, opensearchRequestIndex } = expectedResult.value;
const doc = bulkGetResponse?.body.docs[opensearchRequestIndex];
if (doc?.found) {
errors.push({
id,
type,
error: {
...errorContent(SavedObjectsErrorHelpers.createConflictError(type, id)),
// @ts-expect-error MultiGetHit._source is optional
...(!this.rawDocExistsInNamespace(doc!, namespace) && {
metadata: { isNotOverwritable: true },
}),
},
});
const transformedObject = this._serializer.rawToSavedObject(doc as SavedObjectsRawDoc);
const filteredWorkspaces = SavedObjectsUtils.filterWorkspacesAccordingToBaseWorkspaces(
options.workspaces,
transformedObject.workspaces
);
if (!filteredWorkspaces.length) {
errors.push({
id,
type,
error: {
...errorContent(SavedObjectsErrorHelpers.createConflictError(type, id)),
// @ts-expect-error MultiGetHit._source is optional
...(!this.rawDocExistsInNamespace(doc!, namespace) && {
metadata: { isNotOverwritable: true },
}),
},
});
}
}
});

Expand Down
7 changes: 7 additions & 0 deletions src/core/server/saved_objects/service/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,11 @@ export class SavedObjectsUtils {
total: 0,
saved_objects: [],
});

public static filterWorkspacesAccordingToBaseWorkspaces(
targetWorkspaces?: string[],
baseWorkspaces?: string[]
): string[] {
return targetWorkspaces?.filter((item) => !baseWorkspaces?.includes(item)) || [];
}
}

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

Loading

0 comments on commit 0d47d87

Please sign in to comment.