Skip to content

Commit 76bce43

Browse files
committed
🩹(frontend) fine tuning 2.3.0
- improve medium button style when 2 lines - improve design on Firefox input title - manage title modal without doc title - improve redirect when 401
1 parent 5ac71bf commit 76bce43

File tree

8 files changed

+31
-23
lines changed

8 files changed

+31
-23
lines changed

src/frontend/apps/e2e/__tests__/app-impress/doc-header.spec.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,7 @@ test.describe('Doc Header', () => {
9999
).toBeVisible();
100100

101101
await expect(
102-
page.getByText(
103-
`Are you sure you want to delete the document "${randomDoc}"?`,
104-
),
102+
page.getByText(`Are you sure you want to delete this document ?`),
105103
).toBeVisible();
106104

107105
await page

src/frontend/apps/impress/src/cunningham/cunningham-style.css

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,8 @@ input:-webkit-autofill:focus {
365365
}
366366

367367
.c__button--medium {
368-
padding: 0.9rem var(--c--theme--spacings--s);
368+
height: auto;
369+
min-height: var(--c--components--button--medium-height);
369370
}
370371

371372
.c__button--small {
@@ -551,6 +552,8 @@ input:-webkit-autofill:focus {
551552

552553
.c__modal__close .c__button {
553554
padding: 0 !important;
555+
top: -0.65rem;
556+
right: -0.65rem;
554557
}
555558

556559
.c__modal--full .c__modal__content {

src/frontend/apps/impress/src/features/auth/components/Auth.tsx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { PropsWithChildren } from 'react';
55
import { Box } from '@/components';
66

77
import { useAuth } from '../hooks';
8+
import { getAuthUrl } from '../utils';
89

910
export const Auth = ({ children }: PropsWithChildren) => {
1011
const { isLoading, pathAllowed, isFetchedAfterMount, authenticated } =
@@ -19,6 +20,22 @@ export const Auth = ({ children }: PropsWithChildren) => {
1920
);
2021
}
2122

23+
/**
24+
* If the user is authenticated and wanted initially to access a document,
25+
* we redirect to the document page.
26+
*/
27+
if (authenticated) {
28+
const authUrl = getAuthUrl();
29+
if (authUrl) {
30+
void replace(authUrl);
31+
return (
32+
<Box $height="100vh" $width="100vw" $align="center" $justify="center">
33+
<Loader />
34+
</Box>
35+
);
36+
}
37+
}
38+
2239
/**
2340
* If the user is not authenticated and the path is not allowed, we redirect to the login page.
2441
*/

src/frontend/apps/impress/src/features/auth/hooks/useAuth.tsx

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@ import { useRouter } from 'next/router';
22
import { useEffect, useState } from 'react';
33

44
import { useAuthQuery } from '../api';
5-
import { getAuthUrl } from '../utils';
65

76
const regexpUrlsAuth = [/\/docs\/$/g, /\/docs$/g, /^\/$/g];
87

98
export const useAuth = () => {
109
const { data: user, ...authStates } = useAuthQuery();
11-
const { pathname, replace } = useRouter();
10+
const { pathname } = useRouter();
1211

1312
const [pathAllowed, setPathAllowed] = useState<boolean>(
1413
!regexpUrlsAuth.some((regexp) => !!pathname.match(regexp)),
@@ -18,18 +17,6 @@ export const useAuth = () => {
1817
setPathAllowed(!regexpUrlsAuth.some((regexp) => !!pathname.match(regexp)));
1918
}, [pathname]);
2019

21-
// Redirect to the path before login
22-
useEffect(() => {
23-
if (!user) {
24-
return;
25-
}
26-
27-
const authUrl = getAuthUrl();
28-
if (authUrl) {
29-
void replace(authUrl);
30-
}
31-
}, [user, replace]);
32-
3320
return {
3421
user,
3522
authenticated: !!user && authStates.isSuccess,
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export * from './api/types';
1+
export * from './api';
22
export * from './components';
33
export * from './hooks';
44
export * from './utils';

src/frontend/apps/impress/src/features/docs/doc-header/components/DocTitle.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,8 @@ const DocTitleInput = ({ doc }: DocTitleProps) => {
116116
handleTitleSubmit(event.target.textContent || '')
117117
}
118118
$color={colorsTokens()['greyscale-1000']}
119+
$minHeight="40px"
120+
$padding={{ right: 'big' }}
119121
$css={css`
120122
&[contenteditable='true']:empty:not(:focus):before {
121123
content: '${untitledDocument}';

src/frontend/apps/impress/src/features/docs/doc-management/components/ModalRemoveDoc.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,7 @@ export const ModalRemoveDoc = ({ onClose, doc }: ModalRemoveDocProps) => {
8787
<Box aria-label={t('Content modal to delete document')}>
8888
{!isError && (
8989
<Text $size="sm" $variation="600">
90-
{t('Are you sure you want to delete the document "{{title}}"?', {
91-
title: doc.title,
92-
})}
90+
{t('Are you sure you want to delete this document ?')}
9391
</Text>
9492
)}
9593

src/frontend/apps/impress/src/pages/docs/[id]/index.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { useRouter } from 'next/router';
55
import { useEffect, useState } from 'react';
66

77
import { Box, Text, TextErrors } from '@/components';
8-
import { setAuthUrl } from '@/features/auth';
8+
import { KEY_AUTH, setAuthUrl } from '@/features/auth';
99
import { DocEditor } from '@/features/docs/doc-editor';
1010
import {
1111
Doc,
@@ -110,6 +110,9 @@ const DocPage = ({ id }: DocProps) => {
110110
}
111111

112112
if (error.status === 401) {
113+
void queryClient.resetQueries({
114+
queryKey: [KEY_AUTH],
115+
});
113116
setAuthUrl();
114117
void replace(`/401`);
115118
return null;

0 commit comments

Comments
 (0)