From 9fb431aab74bac8933f9077a0e6bc0ece3cb6da1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nuno=20G=C3=B3is?= Date: Wed, 2 Nov 2022 08:11:35 +0000 Subject: [PATCH] fix: limit total of PATs a user can have (#2301) * fix: limit total of PATs a user can have * increase PAT limit to 10 * Update src/lib/services/pat-service.ts Co-authored-by: Simon Hornby * disable button on the front-end when PAT limit is reached * import from server instead of repeating ourselves Co-authored-by: Simon Hornby --- .../PersonalAPITokensTab.tsx | 2 ++ frontend/tsconfig.json | 15 ++++---- src/lib/db/pat-store.ts | 9 +++++ src/lib/services/pat-service.ts | 8 +++++ src/lib/types/stores/pat-store.ts | 1 + src/lib/util/constants.ts | 2 ++ src/test/e2e/api/admin/user/pat.e2e.test.ts | 34 +++++++++++++++++++ src/test/fixtures/fake-pat-store.ts | 4 +++ 8 files changed, 66 insertions(+), 9 deletions(-) diff --git a/frontend/src/component/user/Profile/PersonalAPITokensTab/PersonalAPITokensTab.tsx b/frontend/src/component/user/Profile/PersonalAPITokensTab/PersonalAPITokensTab.tsx index 21f93a7268..83591d76b8 100644 --- a/frontend/src/component/user/Profile/PersonalAPITokensTab/PersonalAPITokensTab.tsx +++ b/frontend/src/component/user/Profile/PersonalAPITokensTab/PersonalAPITokensTab.tsx @@ -19,6 +19,7 @@ import { DateCell } from 'component/common/Table/cells/DateCell/DateCell'; import { HighlightCell } from 'component/common/Table/cells/HighlightCell/HighlightCell'; import { TextCell } from 'component/common/Table/cells/TextCell/TextCell'; import { SearchHighlightProvider } from 'component/common/Table/SearchHighlightContext/SearchHighlightContext'; +import { PAT_LIMIT } from '@server/util/constants'; import { usePersonalAPITokens } from 'hooks/api/getters/usePersonalAPITokens/usePersonalAPITokens'; import { useSearch } from 'hooks/useSearch'; import { @@ -250,6 +251,7 @@ export const PersonalAPITokensTab = ({ user }: IPersonalAPITokensTabProps) => {