Make api name editable and add expiry (#6473)
Fixes #6302 --------- Co-authored-by: martmull <martmull@hotmail.fr>
This commit is contained in:
@ -6,6 +6,7 @@ import { OnboardingStatus, SubscriptionStatus } from '~/generated/graphql';
|
||||
import { useDefaultHomePagePath } from '~/hooks/useDefaultHomePagePath';
|
||||
import { useIsMatchingLocation } from '~/hooks/useIsMatchingLocation';
|
||||
import { usePageChangeEffectNavigateLocation } from '~/hooks/usePageChangeEffectNavigateLocation';
|
||||
import { UNTESTED_APP_PATHS } from '~/testing/constants/UntestedAppPaths';
|
||||
|
||||
jest.mock('@/onboarding/hooks/useOnboardingStatus');
|
||||
const setupMockOnboardingStatus = (
|
||||
@ -296,7 +297,7 @@ describe('usePageChangeEffectNavigateLocation', () => {
|
||||
SubscriptionStatus.Trialing,
|
||||
];
|
||||
expect(testCases.length).toEqual(
|
||||
Object.keys(AppPath).length *
|
||||
(Object.keys(AppPath).length - UNTESTED_APP_PATHS.length) *
|
||||
(Object.keys(OnboardingStatus).length +
|
||||
(Object.keys(SubscriptionStatus).length -
|
||||
untestedSubscriptionStatus.length)),
|
||||
|
||||
26
packages/twenty-front/src/hooks/useCleanRecoilState.ts
Normal file
26
packages/twenty-front/src/hooks/useCleanRecoilState.ts
Normal file
@ -0,0 +1,26 @@
|
||||
import { useIsMatchingLocation } from '~/hooks/useIsMatchingLocation';
|
||||
import { SettingsPath } from '@/types/SettingsPath';
|
||||
import { apiKeyTokenState } from '@/settings/developers/states/generatedApiKeyTokenState';
|
||||
import { useRecoilValue, useResetRecoilState } from 'recoil';
|
||||
import { AppPath } from '@/types/AppPath';
|
||||
import { isDefined } from '~/utils/isDefined';
|
||||
|
||||
export const useCleanRecoilState = () => {
|
||||
const isMatchingLocation = useIsMatchingLocation();
|
||||
const resetApiKeyToken = useResetRecoilState(apiKeyTokenState);
|
||||
const apiKeyToken = useRecoilValue(apiKeyTokenState);
|
||||
const cleanRecoilState = () => {
|
||||
if (
|
||||
!isMatchingLocation(
|
||||
`${AppPath.Settings}/${AppPath.Developers}/${SettingsPath.DevelopersApiKeyDetail}`,
|
||||
) &&
|
||||
isDefined(apiKeyToken)
|
||||
) {
|
||||
resetApiKeyToken();
|
||||
}
|
||||
};
|
||||
|
||||
return {
|
||||
cleanRecoilState,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user