From 54315850fe5d73af1c374b788c2eabaf5b3d1fa6 Mon Sep 17 00:00:00 2001 From: Kyle Johnson Date: Tue, 28 Jan 2025 16:04:20 +0000 Subject: [PATCH] fix: integrations page permission (#5042) --- .../web/components/pages/IntegrationsPage.tsx | 69 +++++++++---------- 1 file changed, 31 insertions(+), 38 deletions(-) diff --git a/frontend/web/components/pages/IntegrationsPage.tsx b/frontend/web/components/pages/IntegrationsPage.tsx index 62f08e105d82..d420f5624101 100644 --- a/frontend/web/components/pages/IntegrationsPage.tsx +++ b/frontend/web/components/pages/IntegrationsPage.tsx @@ -1,29 +1,34 @@ import React, { FC, useEffect } from 'react' import IntegrationList from 'components/IntegrationList' -import Permission from 'common/providers/Permission' +import { useHasPermission } from 'common/providers/Permission' import Constants from 'common/constants' import PageTitle from 'components/PageTitle' import InfoMessage from 'components/InfoMessage' import { Link } from 'react-router-dom' import Utils from 'common/utils/utils' -import { Project } from 'common/types/responses' import AccountStore from 'common/stores/account-store' -import ProjectProvider from 'common/providers/ProjectProvider' import API from 'project/api' -type ProjectSettingsPageType = { +import { useGetProjectQuery } from 'common/services/useProject' + +type IntegrationsPageType = { match: { params: { projectId: string } } } -const ProjectSettingsPage: FC = ({ match }) => { +const IntegrationsPage: FC = ({ match }) => { useEffect(() => { API.trackPage(Constants.pages.INTEGRATIONS) }, []) const integrations = Object.keys(Utils.getIntegrationData()) - + const { isLoading: permissionsLoading, permission } = useHasPermission({ + id: match.params.projectId, + level: 'project', + permission: 'ADMIN', + }) + const { data: project } = useGetProjectQuery({ id: match.params.projectId }) return (
@@ -45,40 +50,28 @@ const ProjectSettingsPage: FC = ({ match }) => { )} - - {({ isLoading, permission }) => - isLoading ? ( - - ) : ( -
- - {({ project }: { project: Project }) => ( -
- {permission ? ( -
- {project && project.environments && ( - - )} -
- ) : ( -
{Constants.projectPermissions('Admin')}
- )} -
+ {permissionsLoading ? ( + + ) : ( +
+
+ {permission ? ( +
+ {project && ( + )} - -
- ) - } - +
+ ) : ( +
{Constants.projectPermissions('Admin')}
+ )} +
+
+ )}
) } -export default ProjectSettingsPage +export default IntegrationsPage