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] Jump to non-workspace url when clicking home icon #316

Merged

Conversation

SuZhou-Joe
Copy link
Collaborator

@SuZhou-Joe SuZhou-Joe commented Apr 7, 2024

Description

Home page, which is supposed to be only visited without workspace, now is enabled to be accessed by clicking the home icon or enter the url manually in the browser.

This PR introduces a new field workspaceAccessibility inside App, which indicates the accessibility of the application based on workspace. This field can bring two benefits:

  1. When navigate between apps, plugins and core application are using the navigateToApp method. By using the workspaceAccessibility field, workspace is able to do the hard navigation in a central place.
  2. The workspaceAccessibility field can be used in workspace create page to filter applications that should not be visible inside workspace. For now we filter out home overview page and all the pages under management section by hard code, which is not elegant and not extensible.

Issues Resolved

opensearch-project#6362

Screenshot

20240407094009141

Testing the changes

Check List

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

@codecov-commenter
Copy link

codecov-commenter commented Apr 7, 2024

Codecov Report

Attention: Patch coverage is 0% with 11 lines in your changes are missing coverage. Please review.

Project coverage is 44.41%. Comparing base (0f34d69) to head (00682b2).
Report is 9 commits behind head on workspace-pr-integr.

Files Patch % Lines
...rc/core/public/application/application_service.tsx 0.00% 7 Missing ⚠️
src/core/public/chrome/nav_links/to_nav_link.ts 0.00% 3 Missing ⚠️
src/core/public/core_system.ts 0.00% 1 Missing ⚠️
Additional details and impacted files
@@                   Coverage Diff                   @@
##           workspace-pr-integr     #316      +/-   ##
=======================================================
+ Coverage                35.17%   44.41%   +9.24%     
=======================================================
  Files                     1885     2741     +856     
  Lines                    36421    54278   +17857     
  Branches                  6672     8543    +1871     
=======================================================
+ Hits                     12810    24109   +11299     
- Misses                   22761    28796    +6035     
- Partials                   850     1373     +523     
Flag Coverage Δ
_1 32.80% <0.00%> (?)
_4 35.15% <0.00%> (-0.02%) ⬇️

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@SuZhou-Joe SuZhou-Joe force-pushed the feature/home-icon-click branch 2 times, most recently from 0026219 to 5602f14 Compare April 7, 2024 07:33
@ruanyl
Copy link
Owner

ruanyl commented Apr 8, 2024

@SuZhou-Joe I'm getting "Not Found" page when server base path is enabled

@ruanyl
Copy link
Owner

ruanyl commented Apr 8, 2024

I can see the anchor of home logo is still /mzt/w/management/app/home
image

I think toNavLink function should also be updated

@SuZhou-Joe
Copy link
Collaborator Author

SuZhou-Joe commented Apr 8, 2024

@SuZhou-Joe I'm getting "Not Found" page when server base path is enabled

Sorry for the mistake. Fix for that.

@SuZhou-Joe
Copy link
Collaborator Author

SuZhou-Joe commented Apr 8, 2024

How do you like the idea of adding a new field visibility on App? If it makes sense, I will add more unit test for this PR to make it prepared for merge.

@wanglam @ruanyl @gaobinlong @Hailong-am @raintygao @xluo-aws

@SuZhou-Joe
Copy link
Collaborator Author

SuZhou-Joe commented Apr 8, 2024

I can see the anchor of home logo is still /mzt/w/management/app/home image

I think toNavLink function should also be updated

Sure, done for that. But actually the home icon's link is coming from another place and fix for that as well.

* Defaulting to `both`
* See {@link AppVisibility}
*/
visibility?: AppVisibility;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Since this property only be used for workspace. Shall we change to a boolean property, and renaming to something like workspaceVisible?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

There should be 3 states: both, homeOnly and workspaceOnly. I have some concern that regarding undefined as both would introduce some confusion.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Though actually a link should be either homeOnly or workspaceOnly, I am afraid we can not force plugins to change the registration by 2.14 .

Copy link
Collaborator

Choose a reason for hiding this comment

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

Just a little concerned about there are too many visibility related property (status, navLinkStatus, chromeless) in the interface. Or we can just renaming to workspaceLess, then we just mark home plugin to true.

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, agree on that there are too many similar property. So I think maybe we could extend the status field by adding inaccessible-in-workspace and inaccessible-in-home, what do you think?

Copy link
Owner

Choose a reason for hiding this comment

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

an app can only be accessed within a workspace

workspace update/overview page are two examples

I mean only two state is not enough, if using workspaceless which is boolean, it can only represent two state above.

Copy link
Collaborator

@wanglam wanglam Apr 9, 2024

Choose a reason for hiding this comment

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

Is it necessary to mark the application as "an app can only be accessed within a workspace"? It will a little bit confused when workspace not enabled. For these pages, I think we still need to be displayed when workspace is turn off.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I mean only two state is not enough

I see. do you think undefined/null, true, false will be three states and enough for our case? undefined/null same as current.

Copy link
Collaborator Author

@SuZhou-Joe SuZhou-Joe Apr 9, 2024

Choose a reason for hiding this comment

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

If we need to represent 3 states in a single field, an enum would be better instead of regarding undefined/null as a different state to false. This is a draft PR and we can adjust that.
What about:

  • workspaceAccessibility.withinWorkspace -> only accessible in workspace, should be filter out from home in the future when workspace enabled, which means user won't be enable to create visualizations and dashboards out of workspace.
  • workspaceAccessibility.outOfWorkspace -> only accessible out of workspace, can be used for pages like home/workspace list/workspace create page. Should be used in workspace-create/workspace-update pages to filter out inaccessible features.
  • undefined -> as current to keep backward capability.

Copy link
Owner

Choose a reason for hiding this comment

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

Is it necessary to mark the application as "an app can only be accessed within a workspace"? It will a little bit confused when workspace not enabled. For these pages, I think we still need to be displayed when workspace is turn off.

That's a good point. One way that I can think of is to check the workspace flag when plugin register the app, for example, via capabilities service. If workspace is turned off, plugin should not use this flag

@wanglam
Copy link
Collaborator

wanglam commented Apr 8, 2024

How do you like the idea of adding a new field visibility on App? If it makes sense, I will add more unit test for this PR to make it prepared for merge.

@wanglam @ruanyl @gaobinlong @Hailong-am @raintygao @xluo-aws

Shall we filter out features in workspace create and update page by the new field in this PR?

@SuZhou-Joe
Copy link
Collaborator Author

How do you like the idea of adding a new field visibility on App? If it makes sense, I will add more unit test for this PR to make it prepared for merge.
@wanglam @ruanyl @gaobinlong @Hailong-am @raintygao @xluo-aws

Shall we filter out features in workspace create and update page by the new field in this PR?

Will be raised in a following PR.

@Hailong-am
Copy link
Collaborator

do we need to add workspaceless flag to workspace create/list application?

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
@SuZhou-Joe SuZhou-Joe merged commit 2c0827c into ruanyl:workspace-pr-integr Apr 12, 2024
43 checks passed
ruanyl added a commit that referenced this pull request May 13, 2024
…rch-project#6427)

* [Workspace] Jump to non-workspace url when clicking home icon (#316)

* temp: save

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

* feat: complete the feature

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

* feat: remove useless code

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

* fix: bootstrap error

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

* fix: bootstrap error

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

* fix: page not found error

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

* fix: anchor href

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

* feat: update toNavLink to comply with workspace

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

* feat: change to workspaceless

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

* feat: change to workspaceless

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

* feat: change to workspaceless

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

* feat: register list and create page as workspaceless

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

* feat: optimize code

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

* feat: update to WorkspaceVisibility

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

* feat: add unit test

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

* feat: optimize the jump logic

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

* fix: unit test

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

* feat: make app inaccessible if workspaceAccessibility is No

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

---------

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

* refactor: using WorkspaceAvailability

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

* feat: change test name

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

* feat: update wording

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

* feat: update test

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

* feat: add unit test

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

* feat: remove CHANGELOG change

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

* Changeset file for PR opensearch-project#6427 created/updated

* Apply suggestions from code review

Co-authored-by: Yulong Ruan <ruanyu1@gmail.com>
Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

* Update src/plugins/workspace/public/utils.test.ts

Co-authored-by: Miki <amoo_miki@yahoo.com>
Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

* Lint src/plugins/workspace/public/utils.test.ts

Signed-off-by: Miki <amoo_miki@yahoo.com>

* Lint src/plugins/workspace/public/utils.test.ts

Signed-off-by: Miki <amoo_miki@yahoo.com>

* Lint src/plugins/workspace/public/utils.test.ts

Signed-off-by: Miki <amoo_miki@yahoo.com>

* fix: lint error

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

* fix: unit test

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

---------

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
Signed-off-by: Miki <amoo_miki@yahoo.com>
Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
Co-authored-by: Yulong Ruan <ruanyu1@gmail.com>
Co-authored-by: Miki <amoo_miki@yahoo.com>
ruanyl added a commit that referenced this pull request May 17, 2024
…rch-project#6427) (opensearch-project#6628)

* [Workspace] Jump to non-workspace url when clicking home icon (#316)

* temp: save



* feat: complete the feature



* feat: remove useless code



* fix: bootstrap error



* fix: bootstrap error



* fix: page not found error



* fix: anchor href



* feat: update toNavLink to comply with workspace



* feat: change to workspaceless



* feat: change to workspaceless



* feat: change to workspaceless



* feat: register list and create page as workspaceless



* feat: optimize code



* feat: update to WorkspaceVisibility



* feat: add unit test



* feat: optimize the jump logic



* fix: unit test



* feat: make app inaccessible if workspaceAccessibility is No



---------



* refactor: using WorkspaceAvailability



* feat: change test name



* feat: update wording



* feat: update test



* feat: add unit test



* feat: remove CHANGELOG change



* Changeset file for PR opensearch-project#6427 created/updated

* Apply suggestions from code review




* Update src/plugins/workspace/public/utils.test.ts




* Lint src/plugins/workspace/public/utils.test.ts



* Lint src/plugins/workspace/public/utils.test.ts



* Lint src/plugins/workspace/public/utils.test.ts



* fix: lint error



* fix: unit test



---------






(cherry picked from commit 104ee42)

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
Signed-off-by: Miki <amoo_miki@yahoo.com>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
Co-authored-by: Yulong Ruan <ruanyu1@gmail.com>
Co-authored-by: Miki <amoo_miki@yahoo.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.

8 participants