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

[React] Settings interface #5679

Merged
merged 43 commits into from
Oct 16, 2023

Conversation

SchrodingersGat
Copy link
Member

@SchrodingersGat SchrodingersGat commented Oct 9, 2023

Implementing a settings interface for the new UI

TODO

  • Integrate features from P-UI: Admin UI #5326
  • Implement boolean settings
  • Implement number settings
  • Implement string settings
  • Implement choice settings
  • Implement related model settings
  • Global settings
  • User settings
  • Plugin settings
  • Implement global settings context (zustand, not context)
  • Implement user roles context (zustand)
  • split settings list into groups by sub categories
  • use state manager instead of useContext
  • Change useInstance hook to use proper API URLs - not raw strings
  • Change form props to use proper API URLs - not raw strings

@SchrodingersGat SchrodingersGat added the Platform UI Related to the React based User Interface label Oct 9, 2023
@SchrodingersGat SchrodingersGat added this to the 0.13.0 milestone Oct 9, 2023
@netlify
Copy link

netlify bot commented Oct 9, 2023

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

Name Link
🔨 Latest commit 3c73b10
🔍 Latest deploy log https://app.netlify.com/sites/inventree-web-pui-preview/deploys/652d41d57e99110008333184
😎 Deploy Preview https://deploy-preview-5679--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: 70 (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.

- Allows list of settings to be drilled down through props
- Also provides a way of reloading the settings list
- No longer case sensitive
- Still some work to be done here
- Need to pass the base URL down through useContext
- Required some adjustment to existing forms interface
- Display units for setting (if available)
- Rename fieldType to field_type
- React does not like snakeCase props
src/frontend/src/components/nav/MainMenu.tsx Outdated Show resolved Hide resolved
src/frontend/src/components/nav/MainMenu.tsx Outdated Show resolved Hide resolved
src/frontend/src/hooks/UseInstance.tsx Outdated Show resolved Hide resolved
@SchrodingersGat SchrodingersGat mentioned this pull request Oct 11, 2023
@SchrodingersGat
Copy link
Member Author

@matmair let me go back and have a proper review of #5326 :)

@SchrodingersGat SchrodingersGat marked this pull request as draft October 11, 2023 02:48
…ttings

# Conflicts:
#	InvenTree/InvenTree/api_version.py
#	InvenTree/InvenTree/serializers.py
#	src/frontend/src/components/forms/ApiForm.tsx
#	src/frontend/src/components/forms/fields/ApiFormField.tsx
#	src/frontend/src/components/nav/MainMenu.tsx
#	src/frontend/src/functions/forms.tsx
#	src/frontend/src/hooks/UseInstance.tsx
#	src/frontend/src/pages/build/BuildDetail.tsx
#	src/frontend/src/pages/part/CategoryDetail.tsx
#	src/frontend/src/pages/part/PartDetail.tsx
#	src/frontend/src/pages/stock/LocationDetail.tsx
#	src/frontend/src/pages/stock/StockDetail.tsx
#	src/frontend/src/states/ApiState.tsx
#	src/frontend/src/states/states.tsx
…ttings

# Conflicts:
#	src/frontend/src/components/nav/MainMenu.tsx
- Replace with global state manager
- Does not currently refresh properly
…ttings

# Conflicts:
#	src/frontend/src/components/nav/PanelGroup.tsx
#	src/frontend/src/functions/forms.tsx
- Integrated many improvements from current master
- Now integrates nicely with userSettingsState and globalSettingsState
@SchrodingersGat SchrodingersGat marked this pull request as ready for review October 16, 2023 13:16
Copy link
Member

@matmair matmair left a comment

Choose a reason for hiding this comment

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

This is a good start for building out all required management options via the API; Great work

Comment on lines +53 to +77
openModalApiForm({
name: 'setting-edit',
url: settingsState.endpoint,
pk: setting.key,
method: 'PATCH',
title: t`Edit Setting`,
ignorePermissionCheck: true,
fields: {
value: {
value: setting?.value ?? '',
field_type: field_type,
choices: setting?.choices || [],
label: setting?.name,
description: setting?.description
}
},
onFormSuccess() {
showNotification({
title: t`Setting updated`,
message: t`${setting?.name} updated successfully`,
color: 'green'
});
settingsState.fetchSettings();
}
});
Copy link
Member

Choose a reason for hiding this comment

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

Comment: I played with inline editing - which gave a really snappy feel. Maybe that can be done in a follow up PR

Copy link
Contributor

Choose a reason for hiding this comment

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

I really like the idea, a modal requires way more clicks which is bad ux

Copy link
Member Author

Choose a reason for hiding this comment

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

The main drivers for a modal here is that the modal framework is already in place which handles API transactions, error handling, etc

I'd happily review an inline editor solution - potentially the forms components I have already implemented could be reused. The only requirement would be that we add provision for an in-line error message which is displayed when the value is marked as invalid by the server.

@SchrodingersGat
Copy link
Member Author

@matmair I am going to merge this in now as I think it is sufficiently advanced that we can leverage it. Thanks for your good points and improvements, I think it is pretty clean now!

Note that this does not address all the points in #5326 - perhaps the task-list over there can be moved to a new issue so we can continue to tick off the other items?

@SchrodingersGat SchrodingersGat merged commit 8bc750b into inventree:master Oct 16, 2023
19 checks passed
@SchrodingersGat SchrodingersGat deleted the react-settings branch October 16, 2023 23:28
@matmair matmair mentioned this pull request Oct 30, 2023
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Platform UI Related to the React based User Interface
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants