Skip to content

Commit

Permalink
feat: FE static checks
Browse files Browse the repository at this point in the history
  • Loading branch information
huglx committed Jul 11, 2024
1 parent 292669b commit d0b103a
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 59 deletions.
16 changes: 8 additions & 8 deletions e2e/cypress/common/apiCalls/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -353,14 +353,14 @@ export const getParsedEmailVerification = () =>
});

export const getParsedEmailVerificationByIndex = (index: number) =>
getAllEmails().then((r) => {
return {
verifyEmailLink: r[index].html.replace(/.*(http:\/\/[\w:/]*).*/gs, '$1'),
fromAddress: r[index].from.value[0].address,
toAddress: r[index].to.value[0].address,
text: r[index].text,
};
});
getAllEmails().then((r) => {
return {
verifyEmailLink: r[index].html.replace(/.*(http:\/\/[\w:/]*).*/gs, '$1'),
fromAddress: r[index].from.value[0].address,
toAddress: r[index].to.value[0].address,
text: r[index].text,
};
});

export const getParsedEmailInvitationLink = () =>
getAllEmails().then(
Expand Down
50 changes: 25 additions & 25 deletions e2e/cypress/e2e/security/signUp.cy.ts
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
import {HOST} from '../../common/constants';

Check failure on line 1 in e2e/cypress/e2e/security/signUp.cy.ts

View workflow job for this annotation

GitHub Actions / E2E Static Check 🪲

Replace `HOST` with `·HOST·`
import {
createProject,
deleteAllEmails,
deleteUserSql,
disableEmailVerification,
disableRegistration,
enableEmailVerification,
enableRegistration,
getParsedEmailVerification,
getParsedEmailVerificationByIndex,
getRecaptchaSiteKey,
getUser,
login,
logout,
releaseForcedDate,
setProperty,
setRecaptchaSecretKey,
setRecaptchaSiteKey,
v2apiFetch,
createProject,

Check failure on line 3 in e2e/cypress/e2e/security/signUp.cy.ts

View workflow job for this annotation

GitHub Actions / E2E Static Check 🪲

Delete `··`
deleteAllEmails,

Check failure on line 4 in e2e/cypress/e2e/security/signUp.cy.ts

View workflow job for this annotation

GitHub Actions / E2E Static Check 🪲

Replace `····` with `··`
deleteUserSql,

Check failure on line 5 in e2e/cypress/e2e/security/signUp.cy.ts

View workflow job for this annotation

GitHub Actions / E2E Static Check 🪲

Delete `··`
disableEmailVerification,

Check failure on line 6 in e2e/cypress/e2e/security/signUp.cy.ts

View workflow job for this annotation

GitHub Actions / E2E Static Check 🪲

Delete `··`
disableRegistration,

Check failure on line 7 in e2e/cypress/e2e/security/signUp.cy.ts

View workflow job for this annotation

GitHub Actions / E2E Static Check 🪲

Delete `··`
enableEmailVerification,

Check failure on line 8 in e2e/cypress/e2e/security/signUp.cy.ts

View workflow job for this annotation

GitHub Actions / E2E Static Check 🪲

Delete `··`
enableRegistration,
getParsedEmailVerification,
getParsedEmailVerificationByIndex,
getRecaptchaSiteKey,
getUser,
login,
logout,
releaseForcedDate,
setProperty,
setRecaptchaSecretKey,
setRecaptchaSiteKey,
v2apiFetch,
} from '../../common/apiCalls/common';
import {assertMessage, gcy} from '../../common/shared';
import {
checkAnonymousIdSet,
checkAnonymousIdUnset,
checkAnonymousUserIdentified,
fillAndSubmitSignUpForm,
loginWithFakeGithub,
signUpAfter,
visitSignUp,
checkAnonymousIdSet,
checkAnonymousIdUnset,
checkAnonymousUserIdentified,
fillAndSubmitSignUpForm,
loginWithFakeGithub,
signUpAfter,
visitSignUp,
} from '../../common/login';
import {ProjectDTO} from '../../../../webapp/src/service/response.types';
import {waitForGlobalLoading} from '../../common/loading';
Expand Down
3 changes: 2 additions & 1 deletion webapp/src/component/layout/TopBanner/Announcement.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ const StyledTitle = styled('div')`
display: flex;
gap: 12px;
align-items: center;
color: ${({ theme }) => theme.palette.tokens._components.noticeBar.importantColor};
color: ${({ theme }) =>
theme.palette.tokens._components.noticeBar.importantColor};
`;

const StyledWrappableContent = styled('div')`
Expand Down
47 changes: 28 additions & 19 deletions webapp/src/component/layout/TopBanner/TopBanner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import {useAnnouncement} from './useAnnouncement';
import {useIsEmailVerified} from 'tg.globalContext/helpers';
import {Close} from '@mui/icons-material';
import {useResizeObserver} from 'usehooks-ts';
import {Announcement} from "tg.component/layout/TopBanner/Announcement";
import {useTranslate} from "@tolgee/react";
import {tokenService} from "tg.service/TokenService";
import {Announcement} from 'tg.component/layout/TopBanner/Announcement';
import {useTranslate} from '@tolgee/react';
import {tokenService} from 'tg.service/TokenService';

const StyledContainer = styled('div')`
position: fixed;
Expand All @@ -24,8 +24,10 @@ const StyledContainer = styled('div')`
}
&.email-not-verified {
color: ${(props) => props.theme.palette.tokens._components.noticeBar.importantLink};
background: ${(props) => props.theme.palette.tokens._components.noticeBar.importantFill};
color: ${(props) =>
props.theme.palette.tokens._components.noticeBar.importantLink};
background: ${(props) =>
props.theme.palette.tokens._components.noticeBar.importantFill};
}
font-size: 15px;
font-weight: 700;
Expand Down Expand Up @@ -60,9 +62,14 @@ export function TopBanner() {
const isEmailVerified = useIsEmailVerified();
const announcement = bannerType && getAnnouncement(bannerType);
const showCloseButton = isEmailVerified;
const containerClassName = isEmailVerified ? 'email-verified' : 'email-not-verified';
const containerClassName = isEmailVerified
? 'email-verified'
: 'email-not-verified';
const theme = useTheme();
const mailImage = theme.palette.mode === 'dark' ? "/images/mailDark.svg" : "/images/mailLight.svg";
const mailImage =
theme.palette.mode === 'dark'
? '/images/mailDark.svg'
: '/images/mailLight.svg';
const { t } = useTranslate();

useResizeObserver({
Expand All @@ -83,20 +90,22 @@ export function TopBanner() {

return (
<StyledContainer
ref={bannerRef}
data-cy="top-banner"
className={containerClassName}
ref={bannerRef}
data-cy="top-banner"
className={containerClassName}
>
<div />
<StyledContent data-cy="top-banner-content">{
!isEmailVerified ? (
<Announcement
content={t('verify_email_announcement')}
title={t('verify_email_now_title')}
icon={<img src={mailImage} alt="Mail Icon" />}
/>
) : announcement
}</StyledContent>
<StyledContent data-cy="top-banner-content">
{!isEmailVerified ? (
<Announcement
content={t('verify_email_announcement')}
title={t('verify_email_now_title')}
icon={<img src={mailImage} alt="Mail Icon" />}
/>
) : (
announcement
)}
</StyledContent>
{showCloseButton && (
<StyledCloseButton
role="button"
Expand Down
1 change: 0 additions & 1 deletion webapp/src/component/layout/TopBanner/useAnnouncement.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ export function useAnnouncement() {
const isEmailVerified = useIsEmailVerified();
const theme = useTheme();
return function AnnouncementWrapper(value: AnnouncementDtoType) {

switch (value) {
case 'FEATURE_BATCH_OPERATIONS':
return (
Expand Down
8 changes: 5 additions & 3 deletions webapp/src/globalContext/useQuickStartGuideService.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ export const useQuickStartGuideService = (
const projectIdParam = match?.params[PARAMS.PROJECT_ID];
const projectId = isNaN(projectIdParam) ? undefined : projectIdParam;
const [floatingOpen, setFloatingOpen] = useState(false);
const isVerified = initialData.state?.userInfo?.emailAwaitingVerification === null ||
!initialData.state?.serverConfiguration.needsEmailVerification
const isVerified =
initialData.state?.userInfo?.emailAwaitingVerification === null ||
!initialData.state?.serverConfiguration.needsEmailVerification;
const organizationSlug = initialData.state?.preferredOrganization?.slug;
const isOwner =
initialData.state?.preferredOrganization?.currentUserRole === 'OWNER';
Expand All @@ -30,7 +31,8 @@ export const useQuickStartGuideService = (
path: { slug: organizationSlug! },
query: { size: 1, sort: ['id,desc'] },
options: {
enabled: projectId === undefined && Boolean(organizationSlug) && isVerified,
enabled:
projectId === undefined && Boolean(organizationSlug) && isVerified,
},
});

Expand Down
3 changes: 1 addition & 2 deletions webapp/src/service/http/handleApiError.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const handleApiError = (
r: Response,
resObject: any,
init: RequestInit | undefined,
options: RequestOptions,
options: RequestOptions
) => {
if (r.status >= 500) {
const message =
Expand All @@ -29,7 +29,6 @@ export const handleApiError = (
return;
}
if (r.status == 403) {

if (resObject?.code === 'email_not_verified') {
globalContext.actions?.redirectToUnverifiedView();
return;
Expand Down

0 comments on commit d0b103a

Please sign in to comment.