Documentation
  • 👋Welcome to Cerberus
  • Overview
    • 💡What we do
    • ✨Our Features
  • Product Guides
    • 💡Core concepts
    • 🍎Creating an App
    • 📎Modeling your domain
    • 📄Creating policies
  • Tutorial
    • 🛠️Getting set up
      • 🌠Cloning project
      • 👷Setting up workspace
      • 🏃‍♂️Build and run app
    • 📏Creating static rules
      • Create an account
      • Add migrations
    • ✍️Implementation
      • Backend
        • Migrate existing data
        • Routes
        • Services
          • User
          • Project
          • Sprint
          • Story
      • Frontend
        • Settings
        • Projects
        • Sprints
        • Stories
  • APIs
    • 🎨REST API
    • 🖥️Websocket API
  • Migrations
    • 🐧Scripting language
    • 🏃‍♂️Running migrations
Powered by GitBook
On this page
  1. Tutorial
  2. Implementation
  3. Frontend

Projects

We'll make some changes to the files in the 'src/components/projects' folder.

In the 'Projects.js' file, change the column on line 75 to:

{
    selectedProject
        ? <Project project={selectedProject} setSelectedProject={setSelectedProject} setProjects={setProjects}/>
        : <AccessGuard resourceId={authCtx.user.accountId} action="CreateProject">
            <CreateProject setProjects={setProjects}/>
        </AccessGuard>
}

The CreateProject component is now behind an AccessGuard component that only displays it if the user has the 'CreateProject' permission on the account.

Also update the ProjectButton component to this:

function ProjectButton(props) {
    const [readAccess, setReadAccess] = useState(false)
    useAccess(props.project.id, "ReadProject", setReadAccess)

    return <>
        <ListGroupItem
            disabled={!readAccess}
            .
            .
            .

This will disable the ListGroupItem if the user doesn't have the 'ReadProject' permission on the project.

The above two components are all you need to build a responsive UI that changes according to user permissions.

In the 'Project.js' file, look for the ProjectDashboard component, and wrap the 'Delete Project' button in an AccessGuard like this:

<AccessGuard resourceId={project.id} action="DeleteProject">
    <Button variant="danger" onClick={handleDeleteClicked}>Delete Project</Button>
</AccessGuard>

Next, wrap the Permissions component in an AccessGuard like this:

<AccessGuard resourceId={project.id} action="ReadProjectPermissions">
    <Permissions resourceId={project.id} changeAction="ChangeProjectPermissions"/>
</AccessGuard>
PreviousSettingsNextSprints

Last updated 2 years ago

✍️