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]Add "All use case" option to workspace form #7318

Merged
merged 8 commits into from
Jul 19, 2024

Conversation

wanglam
Copy link
Contributor

@wanglam wanglam commented Jul 19, 2024

Description

The use case of workspace can only be one specific use case or all use case. This PR mainly includes below changes:

  1. Modify multi use case selection to single and add "all use case" option
  2. Avoid application been set to Inaccessible when workspace using all use case and application in any use case
  3. Avoid nav group been hidden when workspace using all use case

Issues Resolved

#7319

Screenshot

image

Testing the changes

  • Check out branch and Run yarn osd boostrap
  • Add below config to the opensearch_dashboards.yml
workspace.enabled: true
uiSettings.overrides["home:useNewHomePage"]: true
  • Run yarn start --no-base-path and login with admin user
  • Go to workspace create page
  • Fill workspace unique name and select All use case
  • Click create workspace and it will jump to workspace detail page like below image
    image

(The "all use case" will be selected and the left navigation will changed to all style)

Changelog

  • feat: [Workspace]Add "All use case" option to workspace form

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

Signed-off-by: Lin Wang <[email protected]>
@wanglam wanglam changed the title [Workspace]Add all use case option [Workspace]Add all use case option to workspace form Jul 19, 2024
Copy link

codecov bot commented Jul 19, 2024

Codecov Report

Attention: Patch coverage is 95.00000% with 1 line in your changes missing coverage. Please review.

Project coverage is 67.53%. Comparing base (3bb4170) to head (35da0e0).

Files Patch % Lines
...rkspace/public/components/workspace_list/index.tsx 80.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7318      +/-   ##
==========================================
- Coverage   67.53%   67.53%   -0.01%     
==========================================
  Files        3504     3504              
  Lines       69412    69408       -4     
  Branches    11324    11325       +1     
==========================================
- Hits        46879    46872       -7     
- Misses      19773    19776       +3     
  Partials     2760     2760              
Flag Coverage Δ
Linux_1 33.15% <95.00%> (-0.01%) ⬇️
Linux_2 55.46% <ø> (ø)
Linux_3 43.05% <ø> (-0.01%) ⬇️
Linux_4 34.76% <ø> (ø)
Windows_1 33.17% <95.00%> (-0.01%) ⬇️
Windows_2 55.41% <ø> (ø)
Windows_3 43.06% <ø> (ø)
Windows_4 34.76% <ø> (-0.01%) ⬇️

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.

@wanglam wanglam changed the title [Workspace]Add all use case option to workspace form [Workspace]Add "All use case" option to workspace form Jul 19, 2024
Comment on lines 44 to 47
useCaseId === ALL_USE_CASE_ID
? useCases.reduce<string[]>((previous, { features }) => previous.concat(features ?? []), [])
: useCases.find(({ id }) => id === useCaseId)?.features ?? [];
return availableFeatures.includes(featureId);
Copy link
Contributor

Choose a reason for hiding this comment

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

if an app have not register to any use case, will it be visible/accesable in all use case?

Copy link
Member

Choose a reason for hiding this comment

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

It will.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Based current implementation, the all use case will match all features inside registered use cases. If an app not register to any use case, it still can be accessible if it match below conditions:

  1. workspaceAvailability is outsideWorkspace
  2. navLinkStatus equal hidden
  3. chromeless equal true

Copy link
Contributor

Choose a reason for hiding this comment

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

for example, security analytics plugin have not finished the nav change, based on above conditions, it will be inaccessible when workspace is all use case. will that be an issue?

@@ -122,6 +124,7 @@ export class WorkspacePlugin implements Plugin<{}, {}, WorkspacePluginSetupDeps>
if (
navGroup.type !== NavGroupType.SYSTEM &&
currentWorkspace.features &&
getFirstUseCaseOfFeatureConfigs(currentWorkspace.features) !== ALL_USE_CASE_ID &&
Copy link
Member

Choose a reason for hiding this comment

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

Would be nice to have a comment on this logic

ruanyl
ruanyl previously approved these changes Jul 19, 2024
import { WorkspaceUseCase as WorkspaceUseCaseObject } from '../../types';
import { WorkspaceFormErrors } from './types';
import './workspace_use_case.scss';

import './workspace_use_case.scss';
Copy link
Member

Choose a reason for hiding this comment

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

Duplicate I suppose?

Comment on lines 44 to 47
useCaseId === ALL_USE_CASE_ID
? useCases.reduce<string[]>((previous, { features }) => previous.concat(features ?? []), [])
: useCases.find(({ id }) => id === useCaseId)?.features ?? [];
return availableFeatures.includes(featureId);
Copy link
Member

Choose a reason for hiding this comment

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

It will.

return useCase.features.includes(featureId);
}
return false;
const availableFeatures =
Copy link
Member

Choose a reason for hiding this comment

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

I thought we will just bypass all the features in all use case. Why do we change that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you mean we don't need to check whether the application id exists in registered use cases? We add skip the feature verification logic outside for all use case workspace.

SuZhou-Joe
SuZhou-Joe previously approved these changes Jul 19, 2024
@wanglam wanglam dismissed stale reviews from SuZhou-Joe and ruanyl via ba5e167 July 19, 2024 09:59
@ruanyl ruanyl merged commit 5741fd7 into opensearch-project:main Jul 19, 2024
67 checks passed
@opensearch-trigger-bot
Copy link
Contributor

The backport to 2.x failed:

The process '/usr/bin/git' failed with exit code 128

To backport manually, run these commands in your terminal:

# Navigate to the root of your repository
cd $(git rev-parse --show-toplevel)
# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add ../.worktrees/OpenSearch-Dashboards/backport-2.x 2.x
# Navigate to the new working tree
pushd ../.worktrees/OpenSearch-Dashboards/backport-2.x
# Create a new branch
git switch --create backport/backport-7318-to-2.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 5741fd7c262f4ace7d63dbc18c9549f8d35a92f7
# Push it to GitHub
git push --set-upstream origin backport/backport-7318-to-2.x
# Go back to the original working tree
popd
# Delete the working tree
git worktree remove ../.worktrees/OpenSearch-Dashboards/backport-2.x

Then, create a pull request where the base branch is 2.x and the compare/head branch is backport/backport-7318-to-2.x.

opensearch-trigger-bot bot pushed a commit that referenced this pull request Jul 21, 2024
* Add all use case option

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

* Changeset file for PR #7318 created/updated

* Changeset file for PR #7318 created/updated

* Changeset file for PR #7318 created/updated

* Fix use case selection

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

* All use case can accessible any app and add comment

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

* Remove duplicate style import

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

---------

Signed-off-by: Lin Wang <[email protected]>
Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
(cherry picked from commit 5741fd7)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
ruanyl pushed a commit that referenced this pull request Jul 21, 2024
* Add all use case option



* Changeset file for PR #7318 created/updated

* Changeset file for PR #7318 created/updated

* Changeset file for PR #7318 created/updated

* Fix use case selection



* All use case can accessible any app and add comment



* Remove duplicate style import



---------



(cherry picked from commit 5741fd7)

Signed-off-by: Lin Wang <[email protected]>
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>
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.

5 participants