Skip to content

#feat16 : Added command graph (browser based). #45

Merged
gemanor merged 51 commits intopermitio:mainfrom
harshtech123:main
Mar 27, 2025
Merged

#feat16 : Added command graph (browser based). #45
gemanor merged 51 commits intopermitio:mainfrom
harshtech123:main

Conversation

@harshtech123
Copy link
Copy Markdown
Contributor

/claim #16
/closes #16

CLI is now able to read the whole resource instance, relationships, and role assignment from the Permit APIs and display them as a graph with the relationships.

added command graph that runs on

npx tsx ./source/cli.tsx graph

display a permit fga graph that is showing the graph of the Permit permissions in ReBAC.

opened in default browser
Screenshot 2024-12-08 134007

@harshtech123
Copy link
Copy Markdown
Contributor Author

implemented the fonts style and color as per permit color and fonts , plus followed the same way of zanzibar tuples as per our website. saved the "resource"/"role"/"user" repetitive text.
Screenshot 2024-12-27 202354

harshtech123 and others added 23 commits January 6, 2025 18:08
1 Users is now  in orange boxes
2 Resource instance in purple
3 Resource instances is  in the following naming convention resource_type#resource_id
4. Green lines is presenting the roles and the connection between a user and resource instance (the pill  shows the role assigned)
5 Green dashed lines added it show the implicit (derived) assignment of a user to a resource
6 Orange lines now presents relationships between resource instances (the pill describes the relationship)
added more detailed styling
Orange lines now presenting relationships between resource instances (the pill is describing the relationship)
every user is now displayed in the graph
 lines now use better styling
added pagination support for better fetching
added styles that render graph in configurable format
added support for layering
ensuring every node is appear only once
updates styles
advance algorithms for rendering and calculating positions
solved cross edges problem
Copy link
Copy Markdown
Collaborator

@gemanor gemanor left a comment

Choose a reason for hiding this comment

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

The code is generally great, but it also needs some refactoring. Left comments.


export const saveHTMLGraph = (graphData: GraphData) => {
const outputHTMLPath = resolve(process.cwd(), 'permit-graph.html');
const htmlTemplate = `
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please extract it to an external HTML file and import it to the component

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

@@ -0,0 +1,168 @@
// Define types
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The file name should be GraphData.ts or GraphDataGenerator.ts

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

changed , thank you!

@@ -0,0 +1,406 @@
import React, { useEffect, useState } from 'react';
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This file should get refactored with the following comments in mind:

  • File name should be GraphCommands.tsx or just Graph.tsx
  • No API calls should made from here, but from hooks. See the contributing guide for the right usage of hooks, AuthProvider, and useClient to do API calls (you'll maybe need to merge from the main for that)
  • Functions need to be more modular break to smaller, more maintainable functions

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

named as GraphCommands.tsx and now using useClient for making api calls, thank you!

Copy link
Copy Markdown
Collaborator

@gemanor gemanor left a comment

Choose a reason for hiding this comment

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

Great Job! Thanks for this.

@gemanor gemanor merged commit 6874f4a into permitio:main Mar 27, 2025
3 checks passed
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.

Display Permit's ReBAC Graph

2 participants