Skip to content

Commit 70b85f1

Browse files
authored
[Bug]: Cannot manage secrets in UI as project admin #2960 (#2972)
1 parent 6baff8f commit 70b85f1

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

frontend/src/pages/Project/Secrets/index.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { useTranslation } from 'react-i18next';
33

44
import { Button, ButtonWithConfirmation, Header, ListEmptyMessage, Modal, Pagination, SpaceBetween, Table } from 'components';
55

6-
import { useCollection, useNotifications, usePermissionGuard } from 'hooks';
6+
import { useAppSelector, useCollection, useNotifications, usePermissionGuard } from 'hooks';
77
import { getServerError } from 'libs';
88
import {
99
useDeleteSecretsMutation,
@@ -13,6 +13,9 @@ import {
1313
} from 'services/secrets';
1414
import { GlobalUserRole, ProjectUserRole } from 'types';
1515

16+
import { selectUserData } from 'App/slice';
17+
18+
import { getProjectRoleByUserName } from '../utils';
1619
import { SecretForm } from './Form';
1720

1821
import { IProps, TFormValues } from './types';
@@ -21,13 +24,16 @@ import styles from './styles.module.scss';
2124

2225
export const ProjectSecrets: React.FC<IProps> = ({ project, loading }) => {
2326
const { t } = useTranslation();
27+
const userData = useAppSelector(selectUserData);
28+
const userName = userData?.username ?? '';
2429
const [initialFormValues, setInitialFormValues] = useState<TFormValues | undefined>();
2530
const projectName = project?.project_name ?? '';
2631
const [pushNotification] = useNotifications();
2732

2833
const [hasPermissionForSecretsManaging] = usePermissionGuard({
2934
allowedProjectRoles: [ProjectUserRole.ADMIN],
3035
allowedGlobalRoles: [GlobalUserRole.ADMIN],
36+
projectRole: project ? (getProjectRoleByUserName(project, userName) ?? undefined) : undefined,
3137
});
3238

3339
const { data, isLoading, isFetching } = useGetAllSecretsQuery(

0 commit comments

Comments
 (0)