Stories

Let's navigate to the 'stories' folder.

In the 'Story.js' file, add a new tab for Story permissions on line 15 like this:

<Tabs defaultActiveKey="details">
    <Tab eventKey="details" title="Details"><Dashboard story={story} setSelectedStory={setSelectedStory} setStories={setStories}/></Tab>
    <Tab eventKey="permissions" title="Permissions"><StoryPermissions story={story}/></Tab>
</Tabs>

In the Dashboard component, add new state variables and make use of the useAccess hook to see which permissions the user has for changing story elements:

.
.
.
const [estimateAccess, setEstimateAccess] = useState(false)
const [statusAccess, setStatusAccess] = useState(false)
const [assigneeAccess, setAssigneeAccess] = useState(false)
const {story, setSelectedStory, setStories} = props

useAccess(story.id, "EstimateStory", setEstimateAccess)
useAccess(story.id, "ChangeStoryStatus", setStatusAccess)
useAccess(story.id, "ChangeStoryAssignee", setAssigneeAccess)
.
.
.

Now, disable form controls if the user doesn't have the required permissions:

And add the StoryPermissions component to the same file:

In the 'Stories.js' file, wrap the CreateStory button on line 70 in an AccessGuard like this:

And disable the StoryButton element if the user doesn't have 'ReadStory' permission on the story:

That's it! You now have a fully permissioned app, congratulations!

Last updated