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

[PUI] Dashboard refactor #8278

Merged
merged 110 commits into from
Nov 1, 2024

Conversation

SchrodingersGat
Copy link
Member

@SchrodingersGat SchrodingersGat commented Oct 12, 2024

This PR presents a major refactor of the "dashboard" feature in PUI, bringing it closer towards a release state.

We were already using react-grid-layout for the new dashboard - this PR moves the implementation forward, adding new features, refactoring, etc

Related Issues

Main Goals

  • Remove duplicate "home" / "dashboard" pages
  • Improve usability of dashboard
  • Add method of "adding" new widgets to the dashboard
  • Add method of "removing" widgets from the dashboard
  • Replicate all previous "home page" functions as "dashboard" items
  • Provide a library of "builtin" dashboard items
  • Save and restore separate layout "per user"
  • Allow plugins to register dashboard items
  • Cleanup global navigation menu (left-hand drawer)
  • Playwright tests
  • Consolidate UI plugin API settings
  • Single entrypoint for accessing UI features on backend
  • Add "news" widget as a dashboard item
  • Review existing (legacy CUI) frontpage items
  • Add unit tests for "dashboard" API endpoints
  • Update documentation

Screenshots

Description Image
Sample dashboard with builtin items, and items loaded via plugins image
Add new item image
Remove Items image
Adjust layout image

@SchrodingersGat SchrodingersGat added enhancement This is an suggested enhancement or new feature old user interface Issues with Old User interface plugin Plugin ecosystem refactor feature Platform UI Related to the React based User Interface labels Oct 12, 2024
@SchrodingersGat SchrodingersGat added this to the 0.17.0 milestone Oct 12, 2024
Copy link

netlify bot commented Oct 12, 2024

Deploy Preview for inventree-web-pui-preview ready!

Name Link
🔨 Latest commit a18d3f3
🔍 Latest deploy log https://app.netlify.com/sites/inventree-web-pui-preview/deploys/672546d6607865000846057e
😎 Deploy Preview https://deploy-preview-8278--inventree-web-pui-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 100 (no change from production)
Accessibility: 86 (no change from production)
Best Practices: 100 (no change from production)
SEO: 78 (no change from production)
PWA: -
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

codecov bot commented Oct 12, 2024

Codecov Report

Attention: Patch coverage is 80.82192% with 98 lines in your changes missing coverage. Please review.

Project coverage is 84.35%. Comparing base (c4031db) to head (a18d3f3).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
...nd/src/components/dashboard/widgets/NewsWidget.tsx 17.85% 23 Missing ⚠️
...InvenTree/plugin/base/integration/SettingsMixin.py 9.09% 10 Missing ⚠️
...rontend/src/components/plugins/RemoteComponent.tsx 62.96% 7 Missing and 3 partials ⚠️
...ts/dashboard/widgets/QueryCountDashboardWidget.tsx 70.37% 7 Missing and 1 partial ⚠️
...ntend/src/components/dashboard/DashboardLayout.tsx 92.70% 1 Missing and 6 partials ⚠️
src/backend/InvenTree/plugin/base/ui/api.py 62.50% 6 Missing ⚠️
src/frontend/src/hooks/UseDashboardItems.tsx 84.84% 4 Missing and 1 partial ⚠️
src/backend/InvenTree/plugin/base/ui/mixins.py 81.81% 4 Missing ⚠️
...mponents/editors/TemplateEditor/TemplateEditor.tsx 82.35% 2 Missing and 1 partial ⚠️
src/frontend/src/tables/settings/TemplateTable.tsx 25.00% 0 Missing and 3 partials ⚠️
... and 13 more
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #8278      +/-   ##
==========================================
- Coverage   84.51%   84.35%   -0.17%     
==========================================
  Files        1169     1170       +1     
  Lines       53208    53460     +252     
  Branches     1978     1996      +18     
==========================================
+ Hits        44969    45096     +127     
- Misses       7725     7847     +122     
- Partials      514      517       +3     
Flag Coverage Δ
backend 85.95% <83.70%> (-0.03%) ⬇️
pui 68.04% <79.78%> (-0.14%) ⬇️

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.

@SchrodingersGat SchrodingersGat merged commit 18e5b0d into inventree:master Nov 1, 2024
25 of 26 checks passed
@SchrodingersGat SchrodingersGat deleted the dashboard-refactor branch November 1, 2024 21:48
Comment on lines -38 to +39
responseOptions: {
key: string;
title: string;
icon: InvenTreeIconType;
};
responseOptions: PluginUIFeature;
Copy link
Contributor

@wolflu05 wolflu05 Nov 28, 2024

Choose a reason for hiding this comment

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

@SchrodingersGat sorry, I only had a chance now to review this properly.

The idea here was, that each different feature can respond with some different options (which are defined in the "options" dict key provided by the get_ui_features function on the plugin class). That's why I build a TS generic type. Where each feature gets its base things defined (feature_type, requestContext, responseOptions, ...). I already defined them for TemplateEditorUIFeature (and TemplatePreviewUIFeature) here. (Your dashboard things are missing) Then some generic type helpers can be used where needed to type things. This becomes pretty handy, when we publish the inventree-ui npm package. UI feature developers then can just do something like this and the types of all available contexts, also specific for that feature get inferred:

import { PluginUIGetFeatureType, TemplateEditorUIFeature } from '@inventree/ui';

export const getFeature: PluginUIGetFeatureType<TemplateEditorUIFeature> = (params) => {
  //
};

You now only changed the responseOptions for the template editor feature to some "generic" options (Same in the plugin definition. It's not really clear now what are custom options specific to that feature and what are mandatory things like source. From my two examples this may be not really clear, because they both contained the same options, but I was planning, that other features may need to have different options. E.g. not all features need a description or icon. How do you want to move forward with this now, especially with inventree 1.0?

Copy link
Member Author

Choose a reason for hiding this comment

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

@wolflu05 i"m happy to look at expanding the typing system as part our efforts towards 1.0 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement This is an suggested enhancement or new feature feature old user interface Issues with Old User interface Platform UI Related to the React based User Interface plugin Plugin ecosystem refactor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[PUI] Improve home page style [FR] Improved Dashboard System / Index Page Improvements
3 participants