mirror of
https://github.com/suitenumerique/docs.git
synced 2026-05-07 07:32:33 +02:00
Compare commits
1 Commits
feature/ov
...
endpoint-n
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7f69a641a2 |
11
.github/workflows/docker-hub.yml
vendored
11
.github/workflows/docker-hub.yml
vendored
@@ -59,14 +59,6 @@ jobs:
|
||||
-
|
||||
name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Checkout custom code repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
repository: 'AntoLC/docs-customized'
|
||||
ref: 'main'
|
||||
path: docs-custom
|
||||
|
||||
-
|
||||
name: Docker meta
|
||||
id: meta
|
||||
@@ -84,7 +76,7 @@ jobs:
|
||||
name: Run trivy scan
|
||||
uses: numerique-gouv/action-trivy-cache@main
|
||||
with:
|
||||
docker-build-args: '-f src/frontend/Dockerfile --target frontend-production --build-arg CUSTOM_CODE=docs-custom'
|
||||
docker-build-args: '-f src/frontend/Dockerfile --target frontend-production'
|
||||
docker-image-name: 'docker.io/lasuite/impress-frontend:${{ github.sha }}'
|
||||
-
|
||||
name: Build and push
|
||||
@@ -95,7 +87,6 @@ jobs:
|
||||
target: frontend-production
|
||||
build-args: |
|
||||
DOCKER_USER=${{ env.DOCKER_USER }}:-1000
|
||||
CUSTOM_CODE=docs-custom
|
||||
PUBLISH_AS_MIT=false
|
||||
push: ${{ github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'preview') }}
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
|
||||
@@ -10,7 +10,7 @@ and this project adheres to
|
||||
|
||||
- ♿(frontend) improve accessibility:
|
||||
- ♿(frontend) improve share modal button accessibility #1626
|
||||
|
||||
- ✨(frontend) add /new route for document creation #1641
|
||||
## [3.10.0] - 2025-11-18
|
||||
|
||||
### Added
|
||||
|
||||
@@ -47,15 +47,6 @@ ENV NEXT_PUBLIC_SW_DEACTIVATED=${SW_DEACTIVATED}
|
||||
ARG PUBLISH_AS_MIT
|
||||
ENV NEXT_PUBLIC_PUBLISH_AS_MIT=${PUBLISH_AS_MIT}
|
||||
|
||||
ARG CUSTOM_CODE
|
||||
COPY ./${CUSTOM_CODE} /tmp/custom_code
|
||||
RUN if [ -n "$CUSTOM_CODE" ] && [ -d "/tmp/custom_code" ] && [ "$(ls -A /tmp/custom_code)" ]; then \
|
||||
echo "Custom code provided. Replacing files from $CUSTOM_CODE..."; \
|
||||
cp -Rv /tmp/custom_code/${CUSTOM_CODE}/* .; \
|
||||
else \
|
||||
echo "No custom code provided. Skipping replacement..."; \
|
||||
fi
|
||||
|
||||
RUN yarn build
|
||||
|
||||
# ---- Front-end image ----
|
||||
|
||||
79
src/frontend/apps/impress/src/pages/new/index.tsx
Normal file
79
src/frontend/apps/impress/src/pages/new/index.tsx
Normal file
@@ -0,0 +1,79 @@
|
||||
import { useRouter } from 'next/router';
|
||||
import { useEffect, useState } from 'react';
|
||||
|
||||
import { Loading } from '@/components';
|
||||
import { gotoLogin, useAuth } from '@/features/auth';
|
||||
import { useCreateDoc } from '@/features/docs/doc-management';
|
||||
import { useSkeletonStore } from '@/features/skeletons';
|
||||
import { NextPageWithLayout } from '@/types/next';
|
||||
|
||||
const Page: NextPageWithLayout = () => {
|
||||
const router = useRouter();
|
||||
const { authenticated } = useAuth();
|
||||
const { setIsSkeletonVisible } = useSkeletonStore();
|
||||
const [isNavigating, setIsNavigating] = useState(false);
|
||||
const [hasCreated, setHasCreated] = useState(false);
|
||||
|
||||
const { mutate: createDoc, isPending: isDocCreating } = useCreateDoc({
|
||||
onSuccess: (doc) => {
|
||||
setIsNavigating(true);
|
||||
setHasCreated(true);
|
||||
// Wait for navigation to complete
|
||||
router
|
||||
.replace(`/docs/${doc.id}`)
|
||||
.then(() => {
|
||||
// The skeleton will be disabled by the [id] page once the data is loaded
|
||||
setIsNavigating(false);
|
||||
})
|
||||
.catch(() => {
|
||||
// In case of navigation error, disable the skeleton
|
||||
setIsSkeletonVisible(false);
|
||||
setIsNavigating(false);
|
||||
});
|
||||
},
|
||||
onError: () => {
|
||||
// If there's an error, disable the skeleton
|
||||
setIsSkeletonVisible(false);
|
||||
setIsNavigating(false);
|
||||
},
|
||||
});
|
||||
|
||||
/**
|
||||
* Redirect to login if user is not authenticated
|
||||
*/
|
||||
useEffect(() => {
|
||||
// If not authenticated, redirect to login
|
||||
if (!authenticated) {
|
||||
gotoLogin();
|
||||
return;
|
||||
}
|
||||
}, [authenticated]);
|
||||
|
||||
/**
|
||||
* Create a new document when the page is visited
|
||||
* Only create if user is authenticated
|
||||
*/
|
||||
useEffect(() => {
|
||||
// Don't create if not authenticated (will be redirected)
|
||||
if (!authenticated) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Create document only if authenticated and not already created
|
||||
if (!hasCreated && !isDocCreating && !isNavigating) {
|
||||
setIsSkeletonVisible(true);
|
||||
createDoc();
|
||||
}
|
||||
}, [
|
||||
authenticated,
|
||||
hasCreated,
|
||||
isDocCreating,
|
||||
isNavigating,
|
||||
createDoc,
|
||||
setIsSkeletonVisible,
|
||||
]);
|
||||
|
||||
return <Loading />;
|
||||
};
|
||||
|
||||
export default Page;
|
||||
Reference in New Issue
Block a user