Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
show api access screen in projet settings (#3056)
Signed-off-by: andreas-unleash <andreas@getunleash.ai> <!-- Thanks for creating a PR! To make it easier for reviewers and everyone else to understand what your changes relate to, please add some relevant content to the headings below. Feel free to ignore or delete sections that you don't think are relevant. Thank you! ❤️ --> ## About the changes <!-- Describe the changes introduced. What are they and why are they being introduced? Feel free to also add screenshots or steps to view the changes if they're visual. --> <!-- Does it close an issue? Multiple? --> Closes # [1-612](https://linear.app/unleash/issue/1-612/first-iteration-of-project-token-management) <!-- (For internal contributors): Does it relate to an issue on public roadmap? --> <!-- Relates to [roadmap](https://github.com/orgs/Unleash/projects/10) item: # --> ### Important files <!-- PRs can contain a lot of changes, but not all changes are equally important. Where should a reviewer start looking to get an overview of the changes? Are any files particularly important? --> ## Discussion points <!-- Anything about the PR you'd like to discuss before it gets merged? Got any questions or doubts? --> --------- Signed-off-by: andreas-unleash <andreas@getunleash.ai>
- Loading branch information
1 parent
377e0e9
commit d14072f
Showing
6 changed files
with
88 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
frontend/src/component/project/Project/ProjectSettings/ProjectApiAccess.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { useContext } from 'react'; | ||
import { PageContent } from 'component/common/PageContent/PageContent'; | ||
import { Alert } from '@mui/material'; | ||
import { PageHeader } from 'component/common/PageHeader/PageHeader'; | ||
import AccessContext from 'contexts/AccessContext'; | ||
import { UPDATE_PROJECT } from 'component/providers/AccessProvider/permissions'; | ||
import { useRequiredPathParam } from 'hooks/useRequiredPathParam'; | ||
import { usePageTitle } from 'hooks/usePageTitle'; | ||
import { useProjectNameOrId } from 'hooks/api/getters/useProject/useProject'; | ||
import { ApiTokenTable } from '../../../admin/apiToken/ApiTokenTable/ApiTokenTable'; | ||
|
||
export const ProjectApiAccess = () => { | ||
const projectId = useRequiredPathParam('projectId'); | ||
const projectName = useProjectNameOrId(projectId); | ||
const { hasAccess } = useContext(AccessContext); | ||
|
||
usePageTitle(`Project api access – ${projectName}`); | ||
|
||
if (!hasAccess(UPDATE_PROJECT, projectId)) { | ||
return ( | ||
<PageContent header={<PageHeader title="Api access" />}> | ||
<Alert severity="error"> | ||
You need project owner or admin permissions to access this | ||
section. | ||
</Alert> | ||
</PageContent> | ||
); | ||
} | ||
|
||
return ( | ||
<div style={{ width: '100%', overflow: 'hidden' }}> | ||
<ApiTokenTable compact filterForProject={projectId} /> | ||
</div> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters