unkeyed / unkey

Open source API management platform
https://go.unkey.com
Other
2.76k stars 278 forks source link

Permission ordering should show shallow permissions first #1011

Open chronark opened 6 months ago

chronark commented 6 months ago

Preliminary Checks

Reproduction / Replay Link (Optional)

No response

Issue Summary

All non-nested permissions should show before nested permissions

CleanShot 2024-02-20 at 16 47 57@2x

Steps to Reproduce

  1. (for example) Went to ...
  2. Clicked on...
  3. ...

Expected behavior

The order should be:

Other information

No response

Screenshots

No response

Version info

- OS:
- Node:
- npm:
linear[bot] commented 6 months ago

ENG-584 Permission ordering should show shallow permissions first

AkshayBandi027 commented 6 months ago

hey @chronark,

I have made some changes to tree component. Added a function that maps over nestedPermissions then every checks every permission if it as any nested permission if it contain then pushes to bottom of array and if doesn't then pushes to top of array.

image

And then finally we map over the sortedNestedPermissions array and return recursivePermission component.

image

It works as Excepted!!

https://www.loom.com/share/87013f98356f467da5752b5b0abbf543?sid=92c83072-0a95-429a-bb77-0e08af5c23e9

Any feedback would be appericated!

chronark commented 6 months ago

Nice, thank you

can you still sort alphabetically within one depth? Right now they are out of order, it should be

kfahad5607 commented 1 month ago

Can this issue be assigned to me? I have fixed the sorting order.

Here is the sorter function:

image

Sorting the arrays using .sort before mapping:

image image

Permissions in proper order:

image image