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] Refactor new home page #8467

Open
wants to merge 15 commits into
base: main
Choose a base branch
from

Conversation

yubonluo
Copy link
Contributor

@yubonluo yubonluo commented Oct 3, 2024

Description

Refactor new home page.
The new home page will show use case card, workspace list, use case information flyout, create workspace button for OSD admin, view workspace button, tools button, setting button and user information.

  1. For the order of workspace list, it should show recently visited first, then other workspaces alphabetically.
  2. Clicking the information icon will show the use case information
  3. Clicking the create button will preselect the use case in the workspace create page;
  4. Clicking the view all button will preselect the use case in the workspace list page;

Issues Resolved

Screenshot

2024-10-03.15.23.43.mp4

Dark mode

image

Testing the changes

opensearchDashboards.dashboardAdmin.users: ["admin"]
workspace.enabled: true 
opensearch.hosts: ["https://localhost:9200"]
opensearch.username: "admin"
opensearch.password: "myStrongPassword!" 
opensearch.ssl.verificationMode: none
savedObjects.permission.enabled: true

uiSettings:
   overrides:
     "home:useNewHomePage": true

Changelog

  • refactor: [Workspace] Refactor new home page.

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

Copy link

codecov bot commented Oct 3, 2024

Codecov Report

Attention: Patch coverage is 80.48780% with 16 lines in your changes missing coverage. Please review.

Project coverage is 60.93%. Comparing base (49cca7b) to head (dfad00f).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
...components/workspace_initial/workspace_initial.tsx 79.06% 6 Missing and 3 partials ⚠️
...ents/workspace_initial/workspace_use_case_card.tsx 80.95% 2 Missing and 2 partials ⚠️
src/plugins/home/public/plugin.ts 0.00% 2 Missing ⚠️
src/plugins/workspace/public/plugin.ts 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8467      +/-   ##
==========================================
- Coverage   60.95%   60.93%   -0.03%     
==========================================
  Files        3758     3759       +1     
  Lines       89326    89349      +23     
  Branches    13974    13981       +7     
==========================================
- Hits        54453    54446       -7     
- Misses      31481    31501      +20     
- Partials     3392     3402      +10     
Flag Coverage Δ
Linux_1 28.93% <80.48%> (+<0.01%) ⬆️
Linux_2 56.30% <ø> (-0.06%) ⬇️
Linux_3 37.77% <0.00%> (-0.01%) ⬇️
Linux_4 29.94% <0.00%> (-0.02%) ⬇️
Windows_1 28.94% <80.48%> (+<0.01%) ⬆️
Windows_2 56.25% <ø> (-0.06%) ⬇️
Windows_3 37.78% <0.00%> (-0.01%) ⬇️
Windows_4 29.94% <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.

Signed-off-by: yubonluo <[email protected]>
Signed-off-by: yubonluo <[email protected]>
Signed-off-by: yubonluo <[email protected]>
@@ -166,6 +166,9 @@ export class HomePublicPlugin
navLinkStatus: AppNavLinkStatus.hidden,
mount: async (params: AppMountParameters) => {
const [coreStart, { navigation }] = await core.getStartServices();
if (!!coreStart.application.capabilities.workspaces?.enabled) {
coreStart.application.navigateToApp('workspace_initial');
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
coreStart.application.navigateToApp('workspace_initial');
coreStart.application.navigateToApp('workspace_initial');
return ;

What about we return early here to avoid unnecessary code execution below.

const isDashboardAdmin = !!application.capabilities.dashboards?.isDashboardAdmin;
const availableUseCases = registeredUseCases$
.getValue()
.filter((item) => !item.systematic || item.id === 'all');
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
.filter((item) => !item.systematic || item.id === 'all');
.filter((item) => !item.systematic || item.id === ALL_USE_CASE_ID);

Nit: we have the id from core I remember.

</EuiPageBody>
{isUseCaseFlyoutVisible && (
<WorkspaceUseCaseFlyout
Copy link
Member

Choose a reason for hiding this comment

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

image

The features inside the flyout do not looks correct to me.

Comment on lines +82 to +84
setSettingMount(items.at(2));
setDevToolsMount(items.at(3));
setUserAccountMount(items.at(-1));
Copy link
Member

Choose a reason for hiding this comment

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

Can we use id to match instead picking from fixed index?

Comment on lines +101 to +103
userAccountMount.mount(mountUserAccountRef.current);
devToolsMount.mount(mountDevToolsRef.current);
settingMount.mount(mountSettingRef.current);
Copy link
Member

Choose a reason for hiding this comment

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

We should mount the menu in individual if else. The code won't work if security plugin is not installed.

.filter((item) => !item.systematic || item.id === 'all');
const workspaceList = workspaces.workspaceList$.getValue();
const [isUseCaseFlyoutVisible, setIsUseCaseFlyoutVisible] = useState(false);
const [defaultUseCaseId, setDefaultUseCaseId] = useState(availableUseCases[0].id);
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
const [defaultUseCaseId, setDefaultUseCaseId] = useState(availableUseCases[0].id);
const [defaultExpandedUseCaseId, setDefaultExpandedUseCaseId] = useState(availableUseCases[0].id);

Nit: defaultUseCaseId seems a little bit confusing.

Comment on lines +76 to +78
const [userAccountMount, setUserAccountMount] = useState<ChromeNavControl | undefined>(undefined);
const [settingMount, setSettingMount] = useState<ChromeNavControl | undefined>(undefined);
const [devToolsMount, setDevToolsMount] = useState<ChromeNavControl | undefined>(undefined);
Copy link
Member

Choose a reason for hiding this comment

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

What about we just use const items = useObservable(chrome.navControls.getLeftBottom$()); and cherry-pick the needed icon to render? the useState seems overwhelming here.

<EuiIcon type="reporter" size="s" color="primary" />
&nbsp;
<EuiLink
href="https://docs.aws.amazon.com/opensearch-service/latest/developerguide/what-is.html"
Copy link
Member

Choose a reason for hiding this comment

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

Should it be the doc link related to workspace?

@@ -0,0 +1,80 @@
/* stylelint-disable */
.observability {
Copy link
Member

Choose a reason for hiding this comment

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

The className may match unexpected elements, can we add some prefix?

/* stylelint-disable */
.observability {
background-color: hsla(30deg, 24%, 96%, 100%);
background-image:
Copy link
Member

Choose a reason for hiding this comment

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

Can we move the customized gradient to a file like gradient_variables.scss? So that we only apply the stylelint-disable rule in that file.

Comment on lines +67 to +80
.createWorkspaceTextBorder {
border: 1px dashed;
border-radius: 8px;
max-height: 160px;
width: 210px;
padding: 10px;
border-color: $ouiColorDarkShade;
}

.fixedLeftBottomIcon {
position: fixed;
bottom: 12px;
left: 12px;
}
Copy link
Member

Choose a reason for hiding this comment

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

Same here, please use a unified prefix for the class.

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.

2 participants