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

[frontend] Added auto collapse and submenu icon switches to settings #6341

Merged
merged 2 commits into from Mar 30, 2024

Conversation

Bonsai8863
Copy link
Contributor

@Bonsai8863 Bonsai8863 commented Mar 13, 2024

Proposed changes

  • Add setting to toggle hiding of left nav submenu icons
  • Add setting to toggle auto collapse left nav submenus

Related issues

Checklist

  • I consider the submitted work as finished
  • I tested the code for its functionality
  • I wrote/updated test cases for the relevant uses case
  • I added/update the relevant documentation (either on github or on notion)
  • Where necessary I refactored code to improve the overall quality

Copy link

codecov bot commented Mar 14, 2024

Codecov Report

Attention: Patch coverage is 75.00000% with 2 lines in your changes are missing coverage. Please review.

Project coverage is 67.65%. Comparing base (9c6ebf9) to head (3d85864).

❗ Current head 3d85864 differs from pull request most recent head 44264e9. Consider uploading reports for the commit 44264e9 to get more accurate results

Files Patch % Lines
...pencti-platform/opencti-graphql/src/domain/user.js 50.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6341      +/-   ##
==========================================
- Coverage   67.69%   67.65%   -0.05%     
==========================================
  Files         532      532              
  Lines       65004    64997       -7     
  Branches     5445     5433      -12     
==========================================
- Hits        44006    43975      -31     
- Misses      20998    21022      +24     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@lndrtrbn
Copy link
Member

Hello, thank you for your contribution !

We love the idea of saving auto collapse and submenu icons as preferences. But there is an issue with the implementation because the Settings page is not a page accessible by all the users (admin page).

Below, the implementation we suggest to do so every user can set their preferences:

  • Move the toggle inputs in the Profile page instead of Settings (accessible from top right button > Profile),
  • Save the 2 preferences in database below "user profile" and fetch them through the "me" object while loading the app instead of using local storage as the user will lose the preferences if switching computer by using local storage,
  • Use the local storage to keep in browser memory the state of the left menu items so when refreshing the app the menu will keep the same state for each item (if it should be closed or opened).

@Bonsai8863
Copy link
Contributor Author

Hello, thank you for your contribution !

We love the idea of saving auto collapse and submenu icons as preferences. But there is an issue with the implementation because the Settings page is not a page accessible by all the users (admin page).

Below, the implementation we suggest to do so every user can set their preferences:

  • Move the toggle inputs in the Profile page instead of Settings (accessible from top right button > Profile),
  • Save the 2 preferences in database below "user profile" and fetch them through the "me" object while loading the app instead of using local storage as the user will lose the preferences if switching computer by using local storage,
  • Use the local storage to keep in browser memory the state of the left menu items so when refreshing the app the menu will keep the same state for each item (if it should be closed or opened).

@lndrtrbn Thanks for the feedback! All your points have been addressed in the latest push.

Copy link
Member

@lndrtrbn lndrtrbn left a comment

Choose a reason for hiding this comment

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

I have tested locally and it works fine 👍
I just make some small remarks that should be easily fixed.

I was also questioned myself about this behavior: if several person use the same computer and browser then the state of the left navigation saved in local storage will collide between those users and they will have inconsistencies when login. It could be fixed by using the id of the user in the key for local storage. But I don't know if it is a real issue that need to be tackled, I'll ask info in the team.

EDIT : this local storage collision won't be tackle here

@@ -2673,5 +2673,7 @@
"Strategic": "Stratégique",
"Link created": "Lien créé",
"Public dashboard": "Tableau de bord public",
"Show left navigation submenu icons": "Afficher les icônes du sous-menu de navigation de gauche",
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
"Show left navigation submenu icons": "Afficher les icônes du sous-menu de navigation de gauche",
"Show left navigation submenu icons": "Afficher les icônes des sous-menus de la navigation de gauche",

@@ -2673,5 +2673,7 @@
"Strategic": "Stratégique",
"Link created": "Lien créé",
"Public dashboard": "Tableau de bord public",
"Show left navigation submenu icons": "Afficher les icônes du sous-menu de navigation de gauche",
"Auto collapse submenus in left navigation": "Sous-menus à réduction automatique dans la navigation de gauche",
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
"Auto collapse submenus in left navigation": "Sous-menus à réduction automatique dans la navigation de gauche",
"Auto collapse submenus in left navigation": "Fermer automatiquement les sous-menus de la navigation de gauche",

@@ -220,25 +226,47 @@ const LeftBar = () => {
data: useRef(null),
settings: useRef(null),
};
const [selectedMenu, setSelectedMenu] = useState(null);
// console.log(localStorage.getItem('selectedMenu'));
Copy link
Member

Choose a reason for hiding this comment

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

Leftover of debug I guess

Comment on lines 178 to 180
menuToggleSubmenuIcons: {
marginRight: 15,
},
Copy link
Member

Choose a reason for hiding this comment

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

It seems this style is never used?

style: {
whiteSpace: 'wrap',
lineHeight: 1.2,
padding: '4px 0 4px 10px',
Copy link
Member

Choose a reason for hiding this comment

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

Is this padding property really useful? It doesn't seem to change much, the less custom css we have, the better

Comment on lines 519 to 520
R.assoc('submenu_show_icons', newUser.submenu_show_icons),
R.assoc('submenu_auto_collapse', newUser.submenu_auto_collapse),
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure we should add those lines as those properties are not present in the input to create a user. So it will be always undefined.

@richard-julien richard-julien merged commit ff91835 into OpenCTI-Platform:master Mar 30, 2024
1 of 2 checks passed
@richard-julien richard-julien deleted the left_nav_settings branch March 30, 2024 18:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community use to identify PR from community
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants