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] Support feature quantities in workspace list page #6627

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

raintygao
Copy link
Contributor

@raintygao raintygao commented Apr 24, 2024

Description

Support feature selection quantities in workspace list page

Screenshot

image

Changelog

  • feat: [Workspace] Support feature quantities in workspace list 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

Comment on lines 27 to 29
const defaultProps = ({
workspaceConfigurableApps$: of(undefined),
} as unknown) as WorkspaceListProps;
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 defaultProps = ({
workspaceConfigurableApps$: of(undefined),
} as unknown) as WorkspaceListProps;
const workspaceConfigurableApps: PublicAppInfo[] = [];
const defaultProps: WorkspaceListProps = {
workspaceConfigurableApps$: new BehaviorSubject(workspaceConfigurableApps),
};

Can we do this? The cast as WorksapaceListProps is not necessary and safe here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The suggested change will also throw type error. I'm open to if we use type assertion in test case.

Copy link
Member

Choose a reason for hiding this comment

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

  1. It seems unnecessary, we can just mock an object that matches the WorkspaceListProps.
  2. WorkspaceListProps may have more field in the future and if we use type assertion, the type error will be swallowed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So do you mean if there is type error in test file we can ignore? Seems your suggested change will throw type error.

Copy link
Member

Choose a reason for hiding this comment

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

No, I mean we should not use type assertion here. Could you please try the latest version of the suggestions? It should work without type error as long as you import type PublicAppInfo.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, that's fine.

const [queryInput, setQueryInput] = useState<string>('');
const [pagination, setPagination] = useState({
pageIndex: 0,
pageSize: 5,
pageSizeOptions: [5, 10, 20],
});
const [deletedWorkspace, setDeletedWorkspace] = useState<WorkspaceAttribute | null>(null);
const configurableApps = useObservable(props.workspaceConfigurableApps$ ?? of(undefined));
Copy link
Member

Choose a reason for hiding this comment

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

curious why don't we use of([]) as default value.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a missed change, updated.

Copy link

codecov bot commented Apr 24, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 67.49%. Comparing base (460428c) to head (a89f35c).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6627      +/-   ##
==========================================
- Coverage   67.79%   67.49%   -0.30%     
==========================================
  Files        3413     2655     -758     
  Lines       66755    50623   -16132     
  Branches    10861     9170    -1691     
==========================================
- Hits        45254    34170   -11084     
+ Misses      18857    14206    -4651     
+ Partials     2644     2247     -397     
Flag Coverage Δ
Linux_1 ?
Linux_2 55.63% <ø> (ø)
Linux_3 45.26% <ø> (+0.01%) ⬆️
Linux_4 34.91% <ø> (ø)
Windows_1 ?
Windows_2 55.59% <ø> (ø)
Windows_3 ?
Windows_4 34.91% <ø> (ø)

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 changed the title feat: Support feature quantities in workspace list page [Workspace] Support feature quantities in workspace list page Apr 24, 2024
Copy link
Contributor

❌ Invalid Prefix For Manual Changeset Creation

Invalid description prefix. Found "feat". Only "skip" entry option is permitted for manual commit of changeset files.

If you were trying to skip the changelog entry, please use the "skip" entry option in the ##Changelog section of your PR description.

@github-actions github-actions bot added failed changeset and removed Skip-Changelog PRs that are too trivial to warrant a changelog or release notes entry labels Apr 24, 2024
@SuZhou-Joe
Copy link
Member

@raintygao https://github.com/apps/opensearch-changeset-bot could you please install the app into your forked repo? I think this PR deserves a changelog.

@raintygao raintygao closed this Apr 24, 2024
@raintygao raintygao reopened this Apr 24, 2024
Copy link
Contributor

❌ Invalid Prefix For Manual Changeset Creation

Invalid description prefix. Found "feat". Only "skip" entry option is permitted for manual commit of changeset files.

If you were trying to skip the changelog entry, please use the "skip" entry option in the ##Changelog section of your PR description.

const featureFilter = featureMatchesConfig(featuresConfig);
const selectedApplications = configurableApps.filter((app) => featureFilter(app));
return {
total: configurableApps.length,
Copy link
Contributor

Choose a reason for hiding this comment

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

The DEFAULT_SELECTED_FEATURES_IDS is not exists in configurable apps. Shall we add them to the total and selected list?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No. Here we need to make features consistent with create page.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think the featureConfig will includes these two feature ids, which means it may return {total: 0, selected: 2}. Do we need to filter out these two feature ids?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

SelectedFeatures are filtered from workspaceConfigurableApps, workspaceConfigurableApps will filter out default selected features.

@@ -106,6 +117,10 @@ export const WorkspaceList = () => {
name: 'Features',
isExpander: true,
hasActions: true,
render: (features: string[]) => {
const { total, selected } = getSelectedFeatureQuantities(features, configurableApps || []);
Copy link
Contributor

Choose a reason for hiding this comment

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

Shall we render "-" for configurableApps is undefined or empty? 0/0 may looks strange.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think so. Usually - represents null or missed data, 0/0 represent 0 features selected, I think that's how it should be.

workspaceConfigurableApps$?: BehaviorSubject<PublicAppInfo[]>;
}

const WORKSPACE_LIST_PAGE_DESCRIPTION = i18n.translate('workspace.list.description', {
defaultMessage:
'Workspace allow you to save and organize library items, such as index patterns, visualizations, dashboards, saved searches, and share them with other OpenSearch Dashboards users. You can control which features are visible in each workspace, and which users and groups have read and write access to the library items in the workspace.',
Copy link
Member

Choose a reason for hiding this comment

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

nit: is it A workspace allows or Workspaces allow

kavilla
kavilla previously approved these changes Apr 27, 2024
Copy link
Member

@kavilla kavilla left a comment

Choose a reason for hiding this comment

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

i think it would be cool to make the #/# a tool tip, and it displays the names of the selected apps

Signed-off-by: tygao <tygao@amazon.com>
Signed-off-by: tygao <tygao@amazon.com>
Signed-off-by: tygao <tygao@amazon.com>
@raintygao
Copy link
Contributor Author

i think it would be cool to make the #/# a tool tip, and it displays the names of the selected apps

Thanks for your suggestion. That's cool. I will discuss this with designer.

@raintygao
Copy link
Contributor Author

Hi @kavilla , could you help approve again? Seems your approval was dismissed because of my commit to update description.

@SuZhou-Joe SuZhou-Joe marked this pull request as draft June 5, 2024 02:10
@BionIT
Copy link
Collaborator

BionIT commented Jun 5, 2024

Hi @raintygao, is this PR targeting 2.15 or 2.16?

@raintygao
Copy link
Contributor Author

Hi @raintygao, is this PR targeting 2.15 or 2.16?

Hi @BionIT , there will be some new UX design updates in this part, we convert this PR to draft for now.

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.

None yet

5 participants